|
TTDPatch Site |
VariationalAction2
Variational Action 2Defining a choice between several action 2 entriesTo support changes in graphics based on other factors than just the load states, you use a variational action 2. This provides a sophisticated way of deciding what graphics to use. A variational action 2 can be used like any other action 2, but it provides an additional step in-between: instead of defining the action 1 sets right away, it instead specifies a list of additional action 2 entry, one of which is used depending on the kind of variation that is defined. These action 2 entries that are referred can in turn be variational or random (to provide chains of decisions), or they can be the final element, that is a regular action 2 which contains definitions of action 1 sets, or a callback result. The data looks as follows: <Sprite-number> * <Length> 02 <feature> <set-id> <type> <variable> <varadjust> <nvar> (<set-id> <low-range> <high-range>){n} <default>
You repeat the sequence of <set-id> <low-range> <high-range> as often as <nvar> specifies. <low-range> and <high-range> have a size of B, W, or D, depending on <type>. See that entry for more information. Sprite-numberThis is just the number you are at.LengthCount the number of bytes in this action.featureThis sets the type of feature that you wish to change. Set it to:00 for trains 01 for road vehicles 02 for ships 03 for planes 04 for stations 05 for canals 06 for bridges 07 for houses 09 for industry tiles 0A for industries 0B for cargos 0E for signals 0F for objects 10 for railtypes Set-IDThis defines the number of this action 2. The ID can then be used as target in an action 3 or another variational/random action 2. typeThe access type specifies both the size of the variable access, and selects between general variables and the object's innate variables, or variables of a specific "related" object. Use 81/85/89 to decide upon a general variable, or a variable of the object in question. Use 82/86/8A to refer to the "related" object:
This number also tells what size the checked variable is: For 81/82, the lowest byte of the value is accessed For 85/86, the lowest word is accessed For 89/8A, the lowest doubleword is accessed. If the accessed variable is smaller than the size given here, the extra bits may contain junk, and should probably be <and-masked> out. On this page, the size B/W/D means the field is byte-sized for types 81 and 82, word-sized for types 85 and 86, and doubleword-sized for types 89 and 8A. VariableWhich variable to use for this decision. The following variables are always available:
The definition of variable 1B is slightly feature-dependent. For features that can be drawn transparently (stations, bridges, houses, industry tiles and objects) bit 4 is set if the current feature will be drawn normally, and clear if the current feature will be drawn transparently. For these purposes, airports are stations. For all other features, bit 4 is undefined. For all features, the 80+x variables are offsets into the corresponding structure in TTD's game data. The 40+x and 60+x variables are special variables that are computed on-the-fly, and aren't actually stored anywhere in memory, unless stated otherwise. Therefore they should be used as little as necessary so as not to slow down the game too much with the calculation of these variables (which can be called thousands of times per second, whenever any vehicle moves). When displaying a vehicle (etc.) in the purchase list, the game will show those variations based on external variables (dates etc.) correctly, but variations based on vehicle variables (variables 40+x, 60+x and 80+x) will always show the first (not the default) cargo-ID unless otherwise specified for the given variable. If you do a calculation, the first cargo-ID will be selected if any of the needed variables is inaccessible. The lists of 80+x variables on the following pages are not exhaustive; only the useful variables are listed there. For a full list check the definition of corresponding structures in TTD. Marcin Grzegorczyk has a pretty good list of the structure definitions on his savegame internals page.
varadjustAdjust variable to a more useful range. It has the following format: <shift-num> <and-mask> [<add-val> <divide-val>/<modulo-val>]
<shift-num> is a partial bit-mask; its bits have the following meanings:
Bits 6 and 7 may not both be set. If neither are set, this varadjust is a shift-and adjustment. Note that for the add and divide operations, both the variable and the divisor are taken to be signed numbers. This means that if the high bit is set, the number is taken to be negative, so you may need to mask out the most significant bit to do an unsigned division. nvarHere you set how many different ranges to check for. If the value of the variable, after the above manipulations, is not within one of these ranges, the default will be used. When displayed in the purchase window, the game will always show the first range if the variable is of the 40+x or 80+x type (because the variable is undefined since the vehicle doesn't exist yet).Since 2.0.1 alpha 57, nvar=0 is a special case. Instead of using ranges, nvar=0 means that the result of an advanced calculation (or, if no calculation is performed, the adjusted variable value itself) is returned as callback result, with bit 15 set. This is useful for those callbacks where many different return values are possible and it is easier to calculate them than list them in ranges. The default value must still be specified, and will be used in case the variable(s) used are not available. sets and rangesFor each of the ranges to check, you give the set-id as a WORD value (i.e. with a 00 following, e.g. set-id 5 becomes05 00, or - in case of a callback result - by setting the high bit, e.g. 05 80), followed by the low and high limits of this range. The first range that matches will be used.The various \b, \w, and \d escape sequences can be useful for <min-range> and <max-range>. See the discussion of escape sequences for further information. defaultThe set-id to use if none of the ranges matches.Something to go here Created by: system last modification: Tuesday 09 of February, 2010 [07:59:07 UTC] by planetmaker |
Login Search
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||