Flying object routines
Routines · Data · Address index
Creating, launching, moving and ending flying objects, and their hit tests. The routines page explains how the entries are written.
0x2166a — Create a magic flying object
- Role: Arguments: caster, object type, block, position in the block and
direction. Takes the first free record of the
flying-object table and gives up silently when all ten are
used; writes record type 2, the block, position, direction, type and
attacker, the range, flags and shape from the
magic flight properties, and copies the second routine of
the type's spell definition into the record, where the hit test calls it (
0x27d4c). Sets the state-change flag. The spell routines of the projectile spells call it with the caster's launch positionDS:0xe440, set at0x225a2–0x225aefrom the caster's slot and the party's direction. - Comparative source: REF-SCUMM-013,
launchMagicObject. - Used by: Ranged attacks › Monster spells, Launch an object › Behavior, Launched object kinds, Scripted characters, flags and messages › Special events and sequences, Spell definition
0x1d44a — Launch an item
- Address:
0x1d44a(entry) - Role: Arguments: the launching character (−1 for a monster, a wall or
a script), the item, a block, a position, a direction and a weapon type.
Takes the first free record of the flying-object table
and returns 0, leaving the item alone, when all ten are used. Otherwise
inserts the item in the block's chain at the position plus 4,
with the block argument unchecked and the chain head formed as
DS:0xa366+ 10 × block (0x1d48a–0x1d494), writes an item record (type 1, launch word 1, block, position, direction, item, weapon type, launcher, flags 0, range 12), plays sound0x1afor weapon type 7 and0x0botherwise, and returns 1. Callers: the monster ranged action (0x1a4e9), the throw button, the keyboard throw, a thrown weapon, a launcher andSCRIPT_LAUNCH_OBJECT. - Comparative source: REF-SCUMM-021,
launchObject. - Used by: Ranged attacks › When a monster fires, On the floor and in the air › Throwing and launching items, Launched object kinds, Launch an object › Behavior, Sound effects, On the floor and in the air, Scripted characters, flags and messages, Item entry
0x27bc4 — Flying-object step
- Range:
0x27bc4–0x27cf7 - Anomaly:
ANOMALY-153: the block of a flight is never range-checked. An item launched from a block of 1,024 or more is unlinked from the chain head atDS:0xa366+ 10 × old block, in the variables after the block table (0x27c5f–0x27c6b, unlink call0x27c6c), and relinked there while the step stays in the block. A step refused at the first crossing returns 0 at0x27ca8–0x27cc0, so the mover ends the flight with the record's block still out of range. - Role: Arguments: a record, the new block and the new position.
Advances one flying object. For an item, the step is allowed while the
launch word (
+2) is set, or when the new block's face looking back along the direction has wall property bit0x01, or bit0x02and the item has a small shape (wall check at0x27bd0). The item then moves to the new block's chain at the new position plus 4, the record's block and position are updated and the range decreases. When the step fails, it sets the record gate to0x10and runs the record runner on that face. For a magic record (0x27cc2–0x27cd0), the step is allowed when the new block's face looking back has bit0x01, or when the new block is the record's block; the starting block's faces are not read. - Used by: On the floor and in the air › Throwing and launching items, Block events › Wall activation and the 0xffff mask, Block events › Who sends each event, Events that start scripts › Activating walls, Wall mapping flags › Projectiles, On the floor and in the air, Level 11: reference tables › Fireball plates, Delete items, Wall properties, Anomalies and bugs
0x27cf8 — Flying-object hit test
- Range:
0x27cf8–0x27dcd - Role: Called by the flying-object mover after a step into
a new block, and after a refused step for a magic object with flag
0x20. While the record's launch word (+2) is set, it returns at once unless the object is on the party's block with a negative launcher byte (+0xb), or on a block holding monsters with a launcher byte of 0 or more. A magic object (record type 2) then calls its own handler; otherwise each monster slot found at the target block and position is tried with0x1f8b8until one hit succeeds, or, when the block holds no monster and is the party's,0x1f7c9is called. - Comparative source: REF-SCUMM-014,
updateFlyingObjectHitTest. - Used by: Flying weapons › What a flying item hits, How the systems affect one another › Flying objects hit
0x27dce — End a flight
- Role: For an item record, keeps the two low bits of the item's
position_raw(0x27de5), so that it lies on the floor in the quarter it reached, dispatches block event 4 on the record's block (0x27df5) and queues environmental sound0x12. Clears the record in every case. Nothing in the flight routines frees or moves the item further. - Used by: Block events › Who sends each event, On the floor and in the air › Throwing and launching items, Sound effects, Level 10: reference tables › The timed field
0x28a31 — Test every flying object where it is
- Range:
0x28a31–0x28a87 - Role: For each of the ten flying-object records in
use, runs the hit test on the record's block and position
(
+4,+6), without moving the object, and ends the flight when it hits. Called at the end of every monster update (0x1a9bd) and of every party move (0x24fbf), so that a monster or the party that has just entered the block of an object in flight is hit at once. - Used by: How the systems affect one another › Flying objects hit
0x27e31 — Move all flying objects
- Role: For each of the ten flying-object records in
use: notes whether the range is already 0; reads the
half-block step of the direction and position, and on a
block change computes the next block with the
next-block routine, which keeps ten bits (
and ax,0x3ffat0x1e382), so an out-of-range flight lands in (old + step) mod 1,024, and clears the launch word; without a block change the block stays as it is (0x27ebb–0x27ebe). It then calls the step. After a refused step, a magic record with flag0x20gets a hit test; the flight then ends. After a step into a new block it dispatches block event0x10there, then runs the hit test; a hit ends the flight, as does the step made with the range at 0, so an item flies at most 13 half-blocks. Ends go through0x27dce. - Used by: On the floor and in the air › Throwing and launching items, Block events › Who sends each event, How the systems affect one another › Flying objects hit, Timed updates › The table of timed updates, On the floor and in the air, Level 12: reference tables › The sigil and the fireball ring, Level 11: reference tables › Fireball plates