Skip to main content

Block events

BlockEventMask · 16-bit word passed to the block event dispatcher

Events that start scripts · Block state flags · The engine in ten minutes

Level scripts run in response to events on a block: the party steps in, an item is dropped, a monster arrives, a timer expires. Each event has a mask value, which the game passes to the block's script; the script reads it back with SCRIPT_EXPR_EVENT_MASK to know why it runs. Whether a block receives an event at all depends on its block state flags; see event gating.1

All ten values that the reference scripts compare with the event mask are in this list.

typedef enum BlockEventMask {
BLOCK_EVENT_PARTY_ENTER = 0x0001, /* The party has been moved into the block. */
BLOCK_EVENT_PARTY_LEAVE = 0x0002, /* The party is leaving the block. */
BLOCK_EVENT_ITEM_PLACED = 0x0004, /* An item has been put into the block, or a flight ended there. */
BLOCK_EVENT_ITEM_REMOVED = 0x0008, /* An item has been taken out of the block. */
BLOCK_EVENT_FLYING_OBJECT = 0x0010, /* A flying object entered the block or struck one of its special walls. */
BLOCK_EVENT_STEP_COUNT = 0x0020, /* The party's step counter passed the sublevel's threshold ([00:00]). */
BLOCK_EVENT_WALL_DECORATION = 0x0040, /* The player activated a wall of the block in front of the party. */
BLOCK_EVENT_TIMER = 0x0080, /* A level script timer has expired. */
BLOCK_EVENT_ITEM_USED = 0x0100, /* A character used an item; sent to the block in front of the party. */
BLOCK_EVENT_MONSTER_ENTER = 0x0200, /* A monster has been placed in the block. */
BLOCK_EVENT_MONSTER_EXIT = 0x0400, /* A monster is leaving the block. */
BLOCK_EVENT_SPELL_CAST = 0x0800, /* A spell is being started; sent to the party's block. */
BLOCK_EVENT_KEYBOARD_ACTIVATION = 0xffff /* Not an event: the gate of the keyboard wall activation, every bit set. */
} BlockEventMask;

BLOCK_EVENT_STEP_COUNT, BLOCK_EVENT_WALL_DECORATION and BLOCK_EVENT_TIMER need no enabling bit in the block state.

Who sends each event​

Positions are written [XX:YY], column then row, for block index YY × 32 + XX.

EventBlock that receives itSent by
BLOCK_EVENT_PARTY_ENTERThe party's new blockMoving the party
BLOCK_EVENT_PARTY_LEAVEThe party's previous blockMoving the party
BLOCK_EVENT_ITEM_PLACEDThe block receiving the itemDropping on the floor, a niche, keyboard drop and pick-up, end of a flight
BLOCK_EVENT_ITEM_REMOVEDThe block losing the itemPicking up from the floor, a niche, keyboard pick-up
BLOCK_EVENT_FLYING_OBJECTThe block entered, or whose wall was struckFlying-object loop; special walls through the flying-object step
BLOCK_EVENT_STEP_COUNT[00:00] (block index 0)Step trigger
BLOCK_EVENT_WALL_DECORATIONThe block in front of the partyWall-decoration click; special walls through the front-block record run
BLOCK_EVENT_TIMERThe timer's target blockScript timers
BLOCK_EVENT_ITEM_USEDThe block in front of the partyUsing an inventory item
BLOCK_EVENT_MONSTER_ENTERThe monster's new block; [00:00] when a monster diesPlacing a monster, including a monster's death
BLOCK_EVENT_MONSTER_EXITThe monster's old blockPlacing a monster, including a monster's death
BLOCK_EVENT_SPELL_CASTThe party's blockCasting a spell

The reference scripts compare the event mask with ten of these values; they never compare it with BLOCK_EVENT_STEP_COUNT or BLOCK_EVENT_TIMER.

Wall activation from the keyboard​

The lever and script-only wall handlers pass a gate value instead of a fixed event: BLOCK_EVENT_WALL_DECORATION for a click on the wall in front, BLOCK_EVENT_FLYING_OBJECT for a flying object, and BLOCK_EVENT_KEYBOARD_ACTIVATION, every bit set, for the keyboard command that activates the wall in front. A script started that way sees BLOCK_EVENT_KEYBOARD_ACTIVATION, which equals no single event; see activating walls.2

Sources​

Locations refer to the game executable reference.

Footnotes​

  1. Block event dispatcher. A byte scan of the whole executable finds 23 far calls to it, all in the resident code; the callers are linked in the table above. Comparative source: the runLevelScript calls in REF-SCUMM-012. ↩

  2. The gate value is written by the keyboard activation, the front-block record run and the flying-object step, and read by the wall-click dispatchers. ↩