Event opcodes
Story events run on a small bytecode VM inside each NPC pack. Retail has 74 one-byte opcodes of fixed length, with operands relative to the pack's D-block; a HackerGC base adds a 75th.
How scripts run
Every NPC pack carries two kinds of event logic. Tier-1 triggers are proximity records: doors, flag setters and scene starts. Tier-2 is a bytecode VM that runs a script when you talk to an actor or a scene begins.

- Each opcode is one byte with a fixed length, so a script can be decoded without running it.
- Operands are u16 offsets from the pack's D-block, which also holds the text, names and objectives they point at.
- In a Tier-1 trigger group, only the first trigger whose flag is set is active.
- A script ends at
END(0x00) outside every block. A retail new game starts onchunk/326.

Blocks without offsets
Conditions don't store jump distances. When a test fails, the VM steps forward one instruction at a time, counting nested blocks, until it reaches the matching ELSE. You can insert code anywhere without fixing up a single offset. In the DSL you write if … { } else { }, and the assembler writes the markers.
0B 04 00 IF_FLAG 0x004 ; flag clear? jump to ELSE
0D BEGIN
01 4C 0D SAY D+0x0D4C
0E ELSE
23 0B 00 CUTSCENE 11
0F ENDIF
00 END
Opcode reference
Lengths include the opcode byte and come from the table at OVR02 0x801FC454. Mnemonics are the Structured view's names. The DSL writes them in lower case, with if_item_alt for 0x1D and block_begin, block_else and block_end for markers that don't pair up.
| Op | Len | Mnemonic | Effect |
|---|---|---|---|
| Flow and conditions | |||
00 | 1 | END | Script finished |
0A | 1 | IF_YES | Yes/No prompt; "No" runs the else branch |
0B | 3 | IF_FLAG | Flag clear → else |
0C | 5 | IF_RUBIES | Fewer rubies than n → else |
0D 0E 0F | 1 | BEGIN ELSE ENDIF | Block markers |
1D 1E | 3 | IF_ITEM | Item not in inventory → else (identical handlers) |
2F | 3 | GOTO | Jump to D+offset |
3A | 3 | CHOICE | Menu of options; the second → else |
| Dialogue | |||
01 02 03 | 3 | SAY SAY2 SAY3 | Show the line at D+offset; SAY2 keeps the window, SAY3 keeps the line shown |
1F | 3 | SPEAKER | Set the speaker name |
20 | 1 | NO_SPEAKER | Clear the speaker name |
44 | 3 | OBJECTIVE | Set the quest-log line, up to 103 bytes (139 sites) |
| Flags, items and rubies | |||
04 | 3 | SET | Set a flag; 0xFD clears scratch flags 0–63 (wipe_scratch) |
05 | 3 | CLEAR | Clear a flag |
16 | 3 | GIVE | Give an item silently |
28 | 5 | CHEST | Open a chest: flag, item (283 of 291 use no-op flag 0xF8) |
33 | 5 | ADD_RUBIES | Add rubies (i32) |
| World and game modes | |||
06 | 8 | INN | Rest, heal, offer a save, then warp |
07 | 3 | SHOP | Open shop 0–22 |
08 | 3 | BATTLE | Start a battle from a zone or story id 0x100–0x13F |
19 | 11 | WARP | Warp: facing, chunk, x, z, flags |
22 | 3 | BGM | Load a music track |
23 | 3 | CUTSCENE | Run canned cutscene task 0–15 |
| Actors and camera | |||
10 | 3 | ANIM | Set this actor's animation |
11 | 1 | FACE_KNIGHT | Actor turns to face the Knight |
1C | 3 | WALK | Walk the Knight along the walk data at D+offset |
27 | 2 | WAIT | Wait n frames |
14 | 7 | CAM_EASE | Ease the camera to three angles (blocking) |
26 | 2 | CAM_ACTOR | Point the camera at an actor |
| HackerGC base only | |||
4A | 6 | EXT | ext sub a b; sub 0 runs new overlay new/a with argument b |
The other 40 retail opcodes cover fades, camera variants, helper actors, party healing and a few no-ops. Select an instruction in the Structured view to see its encoding and how many retail sites use it. Right-click a row and choose Insert after → Other instruction… for the opcodes the guided form can write.
Operand types
All multi-byte operands are little-endian. References into the pack are D-relative, so moving text means repointing every operand that names it. Living Tool does that each time it lays a pack out again.
| Kind | Encoding | Used by |
|---|---|---|
| Text ref | u16 offset from the D-block | 01–03 1F 3A 3B 44 |
| Code ref | u16 D-offset on an instruction boundary | 2E 2F |
| Walk ref | u16 D-offset of walk data | 1C 34 |
| Flag | u16, 0–511 on retail; up to 0x29F on a HackerGC base | 04 05 0B 2D 28 |
| Item | u16: below 500 an item, 1000+ a Living Toy, 3000 nothing | 16 1D 1E 28 |
| Chunk | u16 0–523, or a new area the project has (1328–2499) | 06 13 19 45 |
| Actor | u8 slot, below 87 | 24 25 26 36 37 48 |
Worked example
The wake-up scene on chunk/326 is actor 3 in npc/7: 30 instructions, 84 bytes. If you've already been woken, it plays a short line. Otherwise it runs the morning cutscene, sets the first objective and warps you outside. Here it is as the DSL prints it.
if flag(0x004) {
say @0x0D4C // "I guess it was just / an illusion..."
set 0x081
if flag(0x002) {
wipe_scratch // flags 0–63 cleared
set 0x002
} else {
wipe_scratch // flags 0–63 cleared
}
clear 0x0FC
} else {
cutscene 11 // Knight walks waypoints
say @0x1BCC // "Good morning! / Wake up, wake up!"
cutscene 12 // commit the typed name
say2 @0x0D74 // "$A, wake up! / Wake up you sleepy / head!"
anim 1
anim 2
say2 @0x0DA0 // "Come on $A, / it's almost noon! / Rise and shine!"
say @0x0DD0 // "I've never seen / anyone get up / so slowly! …"
anim 3
anim 0
set 0x00E
clear 0x0FF
clear 0x0FC
objective @0x1CC0 // "The Mayor was looking / for you. We better …"
warp facing:0 chunk/78 x:-32 z:-880 flags:0x0201
}
