Action2/Vehicles

From GRFSpecs
< Action2
Revision as of 03:01, 17 November 2005 by dmccoy (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Defining cargo IDs for vehicles

Action 2

Defining cargo IDs for vehicles.

-=Introduction=-

For features 0, 1, 2 and 3 (vehicles), action 2 is used to define cargo IDs.  Cargo IDs are a set of sprites that show one vehicle in various states of load for one particular type of cargo.

-=Format=-

For vehicles, the data looks as follows:

 -+<Sprite-number> * <Length> 02 <veh-type> <cargo-id> <num-loadtypes> <num-loadingtypes> <loadtypes...>+-

||Element|Size|Description

<Sprite-number>|dec|A sequential sprite number

<length>|dec|The total number of bytes used in this action

02|B|Defines action 02

<veh-type>|B|For what type of vehicle should the following sprites be used?

<cargo-id>|B|What cargo ID this action 2 defines

<num-loadtypes>|B|Number of different states while moving

<num-loadingtypes>|B|Number of different states while loading/unloading

<loadtypes>|W|Sets from the most recent action 1 to use for various states of loading.||

-=Filling in the terms=-

Sprite-number

This is just the number you are at.

Length

Count the number of bytes in this action.

veh-type

This sets the type of vehicle that you wish to change. Set it to

00 for trains

01 for road vehicles

02 for ships

03 for planes

cargo-id

This is the number that you give this set of sprites. You can choose any value between 00 and FF, and you can reuse them within a grf file at a later point (if being equal to an existing cargo ID, the existing one is overwritten and the new one is used).

num-loadtypes

This is the number of different graphics that the vehicle has while it's not loading or unloading, depending on the amount of cargo it carries.  For example, if it has two states, full or empty, this would be 02.  If it has three states, full, half full or empty, this would be 03.

num-loadingtypes

Same as num-loadtypes, except this is used while the vehicle is loading or unloading. For example if the vehicle is closed, it might only have one state when moving (i.e. num-loadtypes is 01), but show several load states when it is being loaded or unloaded and thus open.

Neither num-loadtypes nor num-loadingtypes may be zero, there must be at least one state for each.

loadtypes

The sprite sets to use for the states of load. Each entry is a WORD value in little endian format, and refers to the most recent action 1 sets. For example, action 1 sets 4, 5 and 7 would be encoded as -+04 00+-, -+05 00+- and -+07 00+-, respectively. Note the additional 00 which is needed because it must be a word value here.

The first entries of these are used when not loading. There have to be num-loadtypes of these.  After this follow the sets to use while loading/unloading, and there must be num-loadingtype of those.

Note that you can share action 1 sets between several action 2 entries.  For example, you might have a wagon that can hold coal or iron ore, and it would look the same if it's empty. Then the empty sprite set could be shared by the action 2 entries for iron ore and coal.

-=Notes=-

Do not skip an action 2 using action 9 (unless it skips the whole file). Action 2 must not be skipped by action 9 or the patch will most likely crash. Skip or modify action 3 instead. Skipping an action 2 with an action 7 has no effect.

If there is only one load type, it is shown for all loads

If there are two load types, the first is shown below 50%, the other above 50%

If there are three load types, they are shown above/below 33% and 66%

If there are four load types, they are shown above/below 25%, 50% and 75%

etc...

-=Example=-

Something to go here