Turn the party or flying objects
SCRIPT_CHANGE_DIRECTION · opcode 0xe8 · 3 bytes
Script virtual machine · Opcode list · Script direction changes
Rotates the party, or the flying objects in the block that triggered the script, by a number of direction steps.
Encoding
Offsets count from the opcode byte. The byte at offset 1 is a
ScriptDirectionTarget.
| Offset | Type | Field | Meaning |
|---|---|---|---|
| 0 | u8 | opcode | 0xe8 |
| 1 | s8 | target | SCRIPT_DIRECTION_PARTY (0xf1) or SCRIPT_DIRECTION_MOVERS (0xf5). |
| 2 | s8 | adjustment | Signed value added to the direction before keeping its low two bits. |
Every selector, including unrecognized ones, occupies 3 bytes.
Example (constructed, not from a level): e8 f1 02 adds 2 to the party's
direction.
Behavior
new_direction = (direction + adjustment) & 3
- Party. The party's facing is rotated, a scene update is requested and the keyboard pick-up cycle restarts.
- Flying objects. The handler visits the ten moving records. Each active record in the block whose event started the current script is rotated the same way. Their position in the block does not change, and no redraw is requested.1
Edge cases and unknowns
- Directions are numbered clockwise from north
(
Direction), so a positive turn is to the right. - Unrecognized selectors are skipped without effect; whether they are valid is not established.
Observed use
The reference scripts use SCRIPT_DIRECTION_PARTY 9 times and
SCRIPT_DIRECTION_MOVERS 6 times.