Skip to main content

How the systems affect one another

The engine · The game loop · Scripts

In brief​

The systems of the game share a small amount of state: each block's walls, monster count and items; the monster slots; the party's block and facing; the characters; and global flags. Each system changes that state, and the changes send block events that other systems, mostly scripts, react to. A script can itself send events, so one change can start a chain of scripts within the same step.

What each change causes​

CauseEffectDetails
The party stepsRefused by a wall without party passage or by a monster in the target block; otherwise leave and enter events, one step towards the step-triggered script, and monsters may notice the party.Moving the party, noticing the party
The party walks into a temporary wallThe wall disappears and the party passes.Moving the party
The party handles items, walls or spellsItem placed, removed or used, wall-decoration and spell-cast events.How the systems connect
A monster is damagedIt becomes provoked and pursues the party; a provoked peaceful monster wakes every peaceful monster.Reacting to damage
A monster diesIts items fall into its block, the party may gain experience, it is moved to [00:00] with exit and enter events, and a peaceful victim wakes the others.When a monster dies
A monster movesLimited by walls, doors, the party's block and other monsters; monster-exit and monster-enter events.Obstacles, monster events
A monster attacksDamage and possible poison, paralysis or petrification of characters.Ranged and melee attacks
A flying object is stoppedA magic object applies its own effect; otherwise it hits a monster in the block it is entering, or the party if no monster is there and the party is.Flying objects hit
A door operatesIts walls change one step per door update, which changes what blocks the party, monsters and projectiles.Walls and doors, timed updates
The level changesFlying objects land or vanish and doors finish; the level's walls, monsters and temporary walls are kept in a level record and restored on return.Changing level
A script runsIt can change walls, doors, items, monsters, characters, flags, the party's block and the level, and those changes send their own events.What scripts can do, scripts started by scripts
Time passesMonsters act, flying objects and doors move, food runs out, timed scripts run.Timed updates

Positions are written [XX:YY], column then row, both counted from 00; the block index is YY × 32 + XX.

Flying objects hit​

When a flying object cannot advance, the game decides what it hits. Until an object's flight first heads into another block, it can hit the party only if a monster or a script launched it, and the monsters of its own block only if a character did. Otherwise a magic object applies its own effect; any other object tries each monster at the place it is entering, in slot order, and stops at the first one it hits. Only when that block holds no monster and is the party's block does it hit the party. How a hit is resolved is described under flying weapons.1

The same test also runs without the object moving: after every monster update and every move of the party, each object in flight is tested on its own block and position, and a hit ends its flight. A monster or the party stepping into the block of an object in flight is therefore hit at once, not only when the object advances.2

Scripts started by scripts​

A command that sends a block event starts the target block's script inside the running one, before the command finishes. Nothing in the interpreter prevents this. Moving the party saves and restores the running script's state around the move. Commands that place monsters, SCRIPT_MOVE_MONSTERS and SCRIPT_SPAWN_MONSTER, do not. When their monster-exit or monster-enter event runs a script, the nested run ends by setting the stop flag or the level-loading flag, which these commands do not restore. The command finishes, and the outer script stops right after it.3

The original levels never reach this case. Monster events are enabled on 35 blocks of levels 2, 3, 5, 11, 12 and 13, and no script of the 16 levels places a monster on one of them or moves monsters onto or off one of them. A spawned monster leaves its slot's previous block, [00:00] for a free slot, and no level enables the monster-exit event there.4

Sources​

Locations refer to the game executable reference; comparative sources are listed in the technical references.

Footnotes​

  1. Flying-object hit test, called by the flying-object mover. Comparative source: REF-SCUMM-014, updateFlyingObjectHitTest. ↩

  2. Test every flying object where it is, called by the monster update and move the party. ↩

  3. Block event dispatcher, the stop flag and the state it overwrites: block, event mask, run variable and selected character; the save and restore in the party-move command; place a monster on a block. Comparative source: REF-SCUMM-014, EoBInfProcessor::run. ↩

  4. The cell bindings of the 16 reference INF files and every SCRIPT_SPAWN_MONSTER and SCRIPT_MOVE_MONSTERS instruction reachable from them, decoded with script_decoder.py; the event bits follow LevelBlockStateFlags. ↩