Skip to main content

Move the party, monsters or items

SCRIPT_MOVE_PARTY_OR_OBJECT · opcode 0xfa · 6 to 12 bytes

Script virtual machine · Opcode list · Scripted movement

Teleports the party to a block, moves every monster of a block, or moves the items of a block, possibly to another level.

Encoding​

Offsets count from the opcode byte. Words are little-endian. The byte at offset 1 is a ScriptMoveTarget and decides what follows. Sizes include the opcode and the selector.

SelectorByteOperands after the selectorSize
SCRIPT_MOVE_PARTY0xe8source_raw: u16le, destination_block: u16le6 bytes
SCRIPT_MOVE_MONSTERS0xf3source_block: u16le, destination_block: u16le6 bytes
SCRIPT_MOVE_ITEMS_FILTERED0xe1item_type: s16le, then the item locations10–12 bytes
SCRIPT_MOVE_ITEMS0xf5The item locations; item_type is taken as −18–10 bytes
Any other value—Two words, read and ignored6 bytes

Item locations​

source_level_marker: u8
source_level: s8 only if source_level_marker != SCRIPT_MOVE_CURRENT_LEVEL
source_block: u16le
destination_level_marker: u8
destination_level: s8 only if destination_level_marker != SCRIPT_MOVE_CURRENT_LEVEL
destination_block: u16le

ScriptMoveLevelMarker defines SCRIPT_MOVE_CURRENT_LEVEL (0xeb): no level byte follows. Any other marker byte is followed by a level byte. The reference scripts always write SCRIPT_MOVE_EXPLICIT_LEVEL (0xe5) for an explicit level, but the handler does not test that value, so an editor should preserve the marker as found.1

The handler then compares the resulting level with the current level number, not with the marker: an explicit level equal to the current level behaves exactly like SCRIPT_MOVE_CURRENT_LEVEL.1

Example (constructed, not from a level): fa f5 eb ab 00 e5 03 ab 00 moves all items of block 171 on the current level to block 171 of level 3. Block 171 is position [11:05], with block = YY × 32 + XX.

Moving the party​

OperandMeaning
source_rawRead and never used; see the unused source word. Zero in all 441 reference instructions; preserve it.
destination_blockNew party block, passed unchanged to the party-move routine; no range or passability check.

The handler saves the state of the running script — run variable, current block, event mask, stop flag, selected character and return-stack depth — and calls the party-move routine, which the party's own steps and the level change after loading also use. That routine performs these steps in order:2

  1. Run the notice check of every monster slot.
  2. Store destination_block as the party's block, keeping the old block.
  3. Dispatch BLOCK_EVENT_PARTY_LEAVE for the old block.
  4. Increment a movement counter; when it exceeds 3, print a carriage return to the message area and reset the counter.
  5. Dispatch BLOCK_EVENT_PARTY_ENTER for destination_block.
  6. If the destination's first wall reference in LevelBlockRuntime is WALL_REFERENCE_CLEARED_ON_ENTRY, set all four of its wall references to zero. The original levels use this reference as an invisible barrier that keeps monsters out of a block until the party first enters it; see the cleared-on-entry reference in the levels.
  7. Visit the monster slots again, increment the step counter, restart the keyboard pick-up cycle, request a scene update, then test every flying object where it is, so that an object in flight in the destination block hits the party at once.

Each dispatch is a direct call: an eligible block script runs inside this instruction, before the next step. The event gating decides whether a script runs at all. Afterwards the handler restores the saved values. It restores the return-stack depth only if the level-loading flag is clear, and it clears the pacing flag that the step and turn commands set, so the redraw that follows does not wait the usual 4 ticks after the previous step (that role is inferred). The level-loading flag itself is not saved, and the run loop stops when it is set, so a nested script that loads a level also ends the outer run after this instruction (inferred from that control flow).2

The unused source word. The handler decodes the two words of a party move with the same code as those of a monster move: the first goes into the variable that the monster branch compares with each monster's block, the second becomes the destination. The party branch never reads that first variable, and the run loop only steps over the instruction, so the word's value does not change what the instruction does. Whatever it was meant for, an interpreter can skip it and an editor should keep it as found.1

Moving monsters​

OperandMeaning
source_blockSelects every monster slot whose block equals this value.
destination_blockNew block passed to the placement routine; −1 leaves the block unchanged.

The handler visits the 30 slots in index order, whatever their hit points or mode. Each matching monster goes through the placement routine described under monster movement events, which raises the exit and entry events and updates the block occupancy.3

Anomaly. The handler passes the slot's position byte as the new direction, so each moved monster's direction is overwritten with its position; the position itself is unchanged. A position of 4 then shows the monster with a frame of the wrong row.3

Living monsters sent to [00:00]. Positions are written [XX:YY], column then row, with block = YY × 32 + XX. The handler does not test hit points, so a living monster moved to block 0 stays alive there: it keeps its hit points, mode and flags, and [00:00] counts it as an occupant, as it counts dead monsters. Nothing else treats block 0 specially. The monster update skips a slot for missing hit points or petrification, never for its block, so this monster is still updated at every pass of its group, and a new monster can take its slot only as a living one: when all 30 slots are alive, the slot farthest from the party (Place a monster).

The only reference use is on level 16, which uses the level 15 map. There the script moves the monster of [28:02], which it has just placed in MONSTER_MODE_WAIT, to [00:00], then places a new monster in [28:02]. In that map, [00:00], its neighbours [01:00] and [00:01], and the blocks at the opposite edges ([31:00], [00:31], [31:31]) in case the block number wraps around, have only the solid wall references 1 and 2, without WALL_RUNTIME_MONSTER_PASSAGE. The moved monster therefore cannot leave [00:00], and the party can never stand next to it (inferred from these walls and the movement rules; not observed in play).3

Moving items​

OperandMeaning
item_typeMoves only items whose sign-extended type_raw equals this ItemType; −1 moves every item.
source_level, source_blockWhere items are taken from.
destination_level, destination_blockWhere items are put.

Because the type byte is sign-extended, an item whose type byte is 255 cannot be selected on its own: −1 already means “any type”. The effect depends on whether each level is the current one:4

Source levelDestination levelEffect
CurrentCurrentEach matching item is unlinked from the source block's chain and inserted at the head of the destination chain. Its position_raw is kept.
CurrentOtherEach matching item is unlinked; its level_raw and location_raw receive the destination level and block. A position_raw below 8 is reduced to its low two bits.
OtherAnyEvery one of the 600 item records whose level and block match the source receives the destination level and block. The type filter is not applied, no chain is updated, positions are kept.

Fields belong to ItemRuntime. For a current-level source, the handler searches the source chain from its head again after each move, so the moved items end up in reverse order at the head of the destination chain. The search includes items in positions 4–7, which other callers of the same search can exclude.4

When the source is the current level, the handler then examines the ten active moving records — the flying objects whose movement dispatches BLOCK_EVENT_FLYING_OBJECT. An active record in source_block is moved to destination_block if the destination is the current level, and deactivated otherwise. This pass ignores item_type.4

Items moved from another level to the current one. Such an item gets the destination's level and block but is not linked into the block's item chain. The view, picking up and the block item conditions find a block's items through that chain, so until the level is loaded again the item is not drawn, cannot be picked up and is not counted by the block item conditions. The next load of the level rebuilds every chain from the item records and links the item in its block, at its kept position. That load happens when the party comes back to the level, or when a saved game is loaded, since the save keeps the item records.4 No reference script does this: the two moves that name a source level name their own level, which counts as the current one.

Anomaly

ANOMALY-145 — If source and destination are the same block of the current level and a matching item exists, the instruction never ends: the search starts again from the head of the chain after each move and keeps finding the item just reinserted there. The game stops responding. Run in a processor emulator with one item in the block, the handler had not returned after 20,000,000 instructions, while the same move to another block returned. This is latent: all 64 reference moves that keep the same block number change level. A faithful reimplementation loops as well; one that must survive such a script can leave the items where they are, since no reference script reaches this case.4

Continuation​

Every path requests a scene update and continues with the next instruction. Called routines, including nested block scripts, can change the execution state; malformed input is not characterized.1

Observed use​

The 749 reachable instructions of the 16 reference INF files use SCRIPT_MOVE_PARTY 441 times (278 distinct destinations), SCRIPT_MOVE_ITEMS 280 times, SCRIPT_MOVE_ITEMS_FILTERED 17 times and SCRIPT_MOVE_MONSTERS 11 times. No other selector occurs.

  • Filtered moves use the item types 0, 18, 26, 28, 29, 30, 34, 37, 38, 46 and 47.
  • Item moves give an explicit source level twice and an explicit destination level 116 times; 11 of these 118 explicit levels name the script's own level.
  • One monster move has destination block 0, position [00:00], the block where the game also puts dead monsters.

Sources​

Footnotes​

  1. Handler for 0xfa and the scene-update flag. Comparative source: EoBInfProcessor::oeob_movePartyOrObject (script/script_eob.cpp, lines 359–470) in REF-SCUMM-012. Statistics come from decoding the scripts reachable in the 16 reference INF files. ↩ ↩2 ↩3 ↩4

  2. Move the party, the block event dispatcher, the level-loading flag and the step pacing flag. Comparative source: EoBCoreEngine::moveParty (engine/scene_eob.cpp, lines 751–776) in REF-SCUMM-012. ↩ ↩2

  3. Handler for 0xfa, monster branch, and the placement routine, which stores its direction argument in the slot's direction. The walls of [00:00] come from LEVEL15.MAZ, whose name the level 16 INF file gives; the monster update and Place a monster give the slot rules. ↩ ↩2 ↩3

  4. Handler for 0xfa, item branches; chain search, unlinking and insertion; the chain rebuild run by every level load; the item records and the moving records. Comparative source: EoBCoreEngine::countQueuedItems (engine/items_eob.cpp, lines 372–401) in REF-SCUMM-012. ↩ ↩2 ↩3 ↩4 ↩5