Difference between revisions of "Callback: Animation control"
From GRFSpecs
Jump to navigationJump to search (simplify the description for stuff that applies to almost all callbacks. esp. some descriptions were too restrictive to specific callbacks before) |
(ottd 15 additions) |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | == Animation control (1B/25/140/152/159) == |
+ | == Animation control (1B/1C/25/140/148/152/159) == |
+ | These callbacks are called, when an animation trigger happens. |
||
− | Called periodically, in a time interval specified in property 16 (houses) or when an animation trigger happens (industry tiles, stations, airport tiles and objects). Returns the number of the frame the animation should jump to, or one of the following special values: |
||
{| |- |
{| |- |
||
+ | !Callback!!Feature!!Mask property!!Trigger!!Variable 10!!Variable 18 |
||
⚫ | |||
|- |
|- |
||
+ | |1B||Houses |
||
⚫ | |||
+ | |[[Action0/Houses#House_callback_flags_.2814.2C1D.29|Property 14 bit 2]] |
||
+ | |[[Action0/Houses#Periodic_refresh_multiplier_.2816.29|Periodic, see property 16]] <ref>For multi-tile houses [[Action0/Houses#Extra_Flags_.2819.29|property 19 bit 2]] controls, whether the trigger is synchronised across all house tiles. See details there.</ref> |
||
+ | |{{ottdp| |2.5|ttdprev=beta 2}} Random bits <ref>Lower 16 bits are random per tile. Upper 16 bits are the same for all tiles, if [[Action0/Houses#Extra_Flags_.2819.29|property 19 bit 2]] is set.</ref> |
||
+ | |Reserved for future use |
||
|- |
|- |
||
+ | |1C||Houses |
||
⚫ | |||
+ | |[[Action0/Houses#House_callback_flags_.2814.2C1D.29|Property 14 bit 3]] |
||
+ | |[[VariationalAction2/Houses#Construction_stage_and_pseudo-random_values_.2840.29|Construction stage]] changes <ref>During normal gameplay called 4 times per tile. During map generation called 1 time.<br>{{ttdp|}} For the first call to happen, you also have to set [[Action0/Houses#Building_flags_.2809.29|property 9 bit 5]].</ref> |
||
+ | |{{ottdp|15|no}} Random bits |
||
+ | |{{ottdp|15|no}} First call <ref>Var 18 bit 0 is set, if the callback is called the first time for a new house. In-game the construction stage will be zero, at map generation and in scenario editor, it will be 3.<br>Other bits of var 18 are reserved, and must be masked.</ref> |
||
|- |
|- |
||
+ | |25||Industry tiles |
||
⚫ | |||
⚫ | |||
+ | |All triggers, see variable 18 |
||
+ | |{{ottdp| |2.5|ttdprev=beta 2}} Random bits <ref name="randombits">Lower 16 bits are random per tile. Upper 16 bits are the same for all tiles, if the trigger applies to multiple tiles.</ref> |
||
+ | |Trigger and more, see [[Action0/Industry_Tiles#Triggers_for_callback_25_.2811.29|property 11]] |
||
⚫ | |||
+ | |140||Stations, road stops |
||
+ | |[[Action0/Stations#Animation_triggers_.2818.29|Station property 18]], [[Action0/Road_Stops#Animation_triggers_.2810.29|road stop property 10]] |
||
+ | |All triggers, see variable 18 |
||
+ | |{{ottdp| |2.5|ttdprev=beta 2}} Random bits <ref name="randombits" /> |
||
⚫ | |||
+ | |- |
||
+ | |148||Houses |
||
+ | |[[Action0/Houses#Cargo_acceptance_watch_list_.2820.29|Property 1E]] |
||
+ | |Watched cargo accepted <ref>Due to implementation details, up to 250 game ticks can pass between the actual acceptance and triggering this callback.</ref> |
||
+ | |Reserved for future use |
||
+ | |See [[Action0/Houses#Cargo_acceptance_watch_list_.2820.29|property 1E]] |
||
+ | |- |
||
+ | |154||Airport tiles |
||
⚫ | |||
+ | |All triggers, see variable 18 |
||
+ | |Random bits <ref name="randombits15">{{ottdp|15|no}} Lower 16 bits are random per tile. Upper 16 bits are the same for all tiles, if the trigger applies to multiple tiles.</ref> |
||
+ | |Trigger and more, see [[Action0/Airport_Tiles#Animation_triggers_via_callback_152_.2811.29|property 11]] |
||
+ | |- |
||
+ | |159||Objects |
||
⚫ | |||
+ | |All triggers, see variable 18 |
||
+ | |Random bits <ref name="randombits15" /> |
||
+ | |Trigger and more, see [[Action0/Objects#Animation_triggers_.2813.29|property 13]] |
||
|} |
|} |
||
+ | <references /> |
||
+ | The return value has the format SSFF: |
||
− | * For multi-tile town buildings, [[Action0/Houses#Extra_Flags_.2819.29|property 19/bit 2]] modifies this callback slightly, see details there. |
||
+ | * FF: One of the following values: |
||
− | |||
⚫ | |||
− | * Except for CB 1B (houses), the low byte of variable 18 contains the reason (animation trigger) for the call. The other bits may contain additional information specific for the trigger/reason. |
||
⚫ | |||
⚫ | |||
− | ! Feature !! Callback !! Animation triggers |
||
|- |
|- |
||
+ | |00 - FC||Jump to this animation frame. |
||
− | | Houses || 1B || none |
||
|- |
|- |
||
⚫ | |||
⚫ | |||
|- |
|- |
||
⚫ | |||
⚫ | |||
|- |
|- |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
|} |
|} |
||
+ | * SS: Sound effect: If non-zero, the sound effect number to play at the tile. |
||
+ | Note: Every time the animation frame is changed the map tile will be refreshed, even if the selected graphics stay the same. Therefore using the animation frame as a timer should be avoided, and animation triggers should be preferred instead. |
||
− | * Except for CB 1B (houses), the callbacks are always used when defined, no bit in the action 0 property needs to be set to activate them. |
||
− | |||
− | * {{ottdp| |2.5|ttdprev=beta 2}} Since TTDPatch 2.5 beta 2, these callbacks get random bits in variable 10, to allow randomizing changes. |
||
− | |||
− | * For callback 1B (houses), the exact randomness depends on bit 2 of [[Action0/Houses#Extra_Flags_.2819.29|property 19]] (synchronized callback 1B). If the callback is synchronized, the high 16 bits will be the same for all tiles and the low 16 bits will be different for each tile. Otherwise, all 32 bits will be independent for each tile. |
||
− | |||
− | * For CB 25 (industry tiles), the randomness depends on the type of the event. For triggers that happen for the whole industry (triggers 2, 3 and 4), the high 16 bits will be the same for all tiles, while the low 16 bits will be different. For other triggers, all 32 bits are independent. |
||
− | |||
− | * For CB 140 (stations), the high 16 bits are the same for all tiles triggered, while the low 16 bits are different for each tile. |
||
− | * Like all animation callbacks, if the high byte of the result is nonzero, it will be interpreted as a sound effect number, and the corresponding sound effect will be played at the tile. |
||
[[Category:Callbacks]] |
[[Category:Callbacks]] |
Latest revision as of 14:24, 26 April 2025
Animation control (1B/1C/25/140/148/152/159)
These callbacks are called, when an animation trigger happens.
Callback | Feature | Mask property | Trigger | Variable 10 | Variable 18 |
---|---|---|---|---|---|
1B | Houses | Property 14 bit 2 | Periodic, see property 16 [1] | ![]() ![]() |
Reserved for future use |
1C | Houses | Property 14 bit 3 | Construction stage changes [3] | ![]() ![]() |
![]() ![]() |
25 | Industry tiles | Property 11 | All triggers, see variable 18 | ![]() ![]() |
Trigger and more, see property 11 |
140 | Stations, road stops | Station property 18, road stop property 10 | All triggers, see variable 18 | ![]() ![]() |
Trigger and more, see station property 18 |
148 | Houses | Property 1E | Watched cargo accepted [6] | Reserved for future use | See property 1E |
154 | Airport tiles | Property 11 | All triggers, see variable 18 | Random bits [7] | Trigger and more, see property 11 |
159 | Objects | Property 13 | All triggers, see variable 18 | Random bits [7] | Trigger and more, see property 13 |
- ↑ For multi-tile houses property 19 bit 2 controls, whether the trigger is synchronised across all house tiles. See details there.
- ↑ Lower 16 bits are random per tile. Upper 16 bits are the same for all tiles, if property 19 bit 2 is set.
- ↑ During normal gameplay called 4 times per tile. During map generation called 1 time.
For the first call to happen, you also have to set property 9 bit 5.
- ↑ Var 18 bit 0 is set, if the callback is called the first time for a new house. In-game the construction stage will be zero, at map generation and in scenario editor, it will be 3.
Other bits of var 18 are reserved, and must be masked. - ↑ 5.0 5.1 Lower 16 bits are random per tile. Upper 16 bits are the same for all tiles, if the trigger applies to multiple tiles.
- ↑ Due to implementation details, up to 250 game ticks can pass between the actual acceptance and triggering this callback.
- ↑ 7.0 7.1
15
Lower 16 bits are random per tile. Upper 16 bits are the same for all tiles, if the trigger applies to multiple tiles.
The return value has the format SSFF:
- FF: One of the following values:
Value Meaning 00 - FC Jump to this animation frame. FD leave the animation in its current state (do nothing) FE start animation with its current frame FF stop animation in its current frame
- SS: Sound effect: If non-zero, the sound effect number to play at the tile.
Note: Every time the animation frame is changed the map tile will be refreshed, even if the selected graphics stay the same. Therefore using the animation frame as a timer should be avoided, and animation triggers should be preferred instead.