Wait
SCRIPT_DELAY · opcode 0xe5 · 3 bytes
Script virtual machine · Opcode list · Sound and delay
Waits for a while before the script continues with the next instruction.
Encoding
Offsets count from the opcode byte. Words are little-endian.
| Offset | Type | Field | Meaning |
|---|---|---|---|
| 0 | u8 | opcode | 0xe5 |
| 1 | s16le | duration_raw | Signed number of ticks to wait. |
Behavior
The handler sign-extends duration_raw to 32 bits, adds it to the current
value of the game's free-running counter
and loops until that counter is no longer below the sum (unsigned
comparison). A tick lasts about 55 ms, so the wait lasts duration_raw × 55
ms.1
The loop is the whole wait: the game loop does not run, so monsters, flying objects and the other timed updates stand still. The shared counter of the game keeps advancing, unless it is paused, and the updates whose deadlines pass during the wait each run once afterwards.
Edge cases and unknowns
- The handler adds a signed value. With a negative value, the wait ends at once, unless the free-running counter is still below the value's magnitude, in the first half hour after the game starts, when the unsigned sum wraps and the wait would not end in practice. No reference script uses a negative value.
Observed use
The reference scripts contain 251 instructions of this kind, waiting from 1 to 100 ticks, about 0.05 to 5.5 seconds; 5 and 6 are the most frequent values.