Launch an object
SCRIPT_LAUNCH_OBJECT · opcode 0xe9 · 8 bytes
Script virtual machine · Opcode list · Scripted object launch
Throws an item or launches a magic flying object, such as a fireball, from a block in a given direction, with no character behind it.
Encoding
Offsets count from the opcode byte. Words are little-endian.
| Offset | Type | Field | Meaning |
|---|---|---|---|
| 0 | u8 | opcode | 0xe9 |
| 1 | u8 | kind | SCRIPT_LAUNCH_MAGIC (0xdf) or any other value, such as SCRIPT_LAUNCH_ITEM (0xec), from ScriptLaunchKind. |
| 2 | u16le | object_raw | Magic object type, or template item to copy. Only the low byte is read, sign-extended; the high byte is skipped. |
| 4 | u16le | block | Block the object starts from. |
| 6 | s8 | direction | Direction of travel. |
| 7 | s8 | direction_offset | 0 or 1: which of the two starting positions, in the half of the block behind the direction of travel. |
Example (level 12): e9 df 02 00 ca 02 02 01 launches a fireball from block
714, [10:22], travelling south, from its second starting position.
Behavior
Both paths start the object in block at a position read from a table by
direction and direction_offset: for each direction, the two quarters of
the half of the block behind the direction of travel (north: south-west and
south-east), offset 0 being the left one and 1 the right one. The object
travels in direction, launched by no character.1
Magic. With kind equal to SCRIPT_LAUNCH_MAGIC, the low byte of
object_raw is a magic object type, a row of the
magic flight properties: types 0 to 7 are
the party's projectile spells — Magic Missile, Melf's Acid Arrow,
Fireball, Hold Person, Lightning Bolt, Ice Storm, Hold Monster,
Flame Strike — and types 8 to 13 the special monster spells. The object
is created and flies, and hits, exactly as a
monster spell: a spell's damage
uses the caster level of no caster, 5 on levels 1 to 6 and 9 from level 7
on. Nothing happens when the ten flying objects are all in use.2
Item. Any other kind copies the template item object_raw and
launches the copy as a thrown item,
with the item's type as the weapon type; when no flight is free, the copy
is freed again. When no copy can be made, nothing happens.1
Edge cases and unknowns
- The handler ignores the high byte of
object_raw. An editor should preserve that byte. - Neither
directionnordirection_offsetis checked: the position is entry 2 × direction + offset of the eight-byte table, and larger values read the bytes that follow it. The magic type is not checked either: types from 14 on read other data as flight properties, including the routine called on a hit (inferred: a crash for most values). blockis not checked either; see the anomaly.
Observed use
The reference scripts contain 43 instructions of this kind. All 41 magic launches use type 2, Fireball: 4 on level 2, 1 on level 6, 1 on level 7, 2 on level 8, 2 on level 9, 23 on level 11 and 8 on level 12. A scripted fireball therefore deals 1d6 × 5 on levels 2 and 6, and 1d6 × 9 on the others (projectiles). The two item launches, on level 6, both throw a copy of template 49, a dart.