The trigger record
Triggers are stored in the map's TRIG section, one 2400-byte record per trigger, in the
order of the list. Mission briefings are in MBRF, in the same record with a different
set of actions.
A trigger#
| Bytes | Holds |
|---|---|
| 0–319 | 16 conditions, 20 bytes each |
| 320–2367 | 64 actions, 32 bytes each |
| 2368–2371 | the trigger's flags |
| 2372–2398 | 27 bytes, one per player or group: non-zero where the trigger runs for it |
| 2399 | used by the game while the trigger runs; 0 in a saved map |
The trigger's flags:
| Bit | Meaning |
|---|---|
| 0x04 | Preserved: the same as a Preserve Trigger action |
| 0x08 | Disabled, or finished: the trigger never runs. Editors set it to disable a trigger, and the game sets it on a trigger that has run and is not preserved |
| 0x02 | Each time the trigger's actions run, the player counts as having won without winning: every other player still in the game with no result is defeated, and the player's game goes on. A Defeat or Draw in the same trigger never takes effect. Some editors call it "ignore Defeat and Draw", which is not what it does |
| 0x01 | The trigger is part way through its actions; byte 2399 says which is next |
| 0x10 | Esc is skipping the trigger's Waits, transmissions and text |
| 0x20 | The trigger paused the game, and unpauses it when it finishes |
| 0x40 | Esc may not skip the trigger (Disable Debug Mode) |
The game sets 0x01, 0x10, 0x20 and 0x40 itself while the trigger runs, and StarEdit saves them as 0. A file that sets them is still obeyed: with 0x01 set, the first pass skips the conditions and starts at the action byte 2399 names.
The list of conditions ends at the first slot whose type is 0, and so does the list of actions.
A condition#
| Bytes | Holds |
|---|---|
| 0–3 | Location number, counted from 1; 0 for none. |
| 4–7 | Player or group. |
| 8–11 | Amount compared against. |
| 12–13 | Unit type. |
| 14 | Comparison, or the switch state for Switch. |
| 15 | Which condition this is. |
| 16 | Resource type, score type or switch number, depending on the condition. |
| 17 | Flags: 0x02 disabled; the others are editor and game bookkeeping. |
| 18–19 | Unused by ordinary triggers; some EUD tools store a mask here. |
All numbers are little-endian. An unused condition slot is all zeros.
An action#
| Bytes | Holds |
|---|---|
| 0–3 | Location number, counted from 1; 0 for none. The source location where there are two. |
| 4–7 | String-table entry of the text. |
| 8–11 | String-table entry of the sound file's name. |
| 12–15 | A time: milliseconds, or seconds for Set Countdown Timer. |
| 16–19 | Player or group; the first player where there are two. |
| 20–23 | Second player, destination location, amount, properties slot or AI script, depending on the action. |
| 24–25 | Unit type, or the score, resource or alliance type. |
| 26 | Which action this is. |
| 27 | Unit count, modifier, switch action, order or state, depending on the action. |
| 28 | Flags: 0x02 disabled, 0x04 always display; the others are editor and game bookkeeping. |
| 29 | Unused. |
| 30–31 | Unused by ordinary triggers; some EUD tools store a mask here. |
All numbers are little-endian. An unused action slot is all zeros.