Skip to main content

Obstacles and other monsters

Monsters · Moving toward the destination · Walls and doors

In brief​

Each move of a monster goes through one check: it never enters the party's block, it passes only faces that let monsters through, and some monster types open doors with a switch. A block holds up to four monsters, on its four quarters and its centre, and only monsters of the same occupancy class share a block: up to four of class 0, pairs of class 1, a single monster of class 2.

A block holds four positions, 0 to 3, its quarters, numbered like the floor positions of items, and position 4, its centre. A monster of occupancy class 0 entering an occupied block takes the first free position in an order set by its facing, front half first: facing north 0, 1, 2, 3; east 1, 3, 0, 2; south 2, 3, 0, 1; west 0, 2, 1, 3. Class 1 monsters pair on the diagonal 0 and 3. Class 2 monsters never enter an occupied block.
Class 0 fills the front half first, class 1 pairs on a diagonal, class 2 stays alone.

The move check​

Each move into a neighboring block goes through one check that looks, in order, at the party, the face of the destination block turned toward the monster and the monsters already there. A move to the monster's own block is a turn on the spot. After a real move the monster's type plays its step sound, except while the party rests.1

Walls and doors​

A monster never enters the party's block, and one with MONSTER_RUNTIME_AVOID_CLOSER_BLOCK refuses any block closer to the party than its current one. Otherwise the game reads the wall properties of the destination's face:

FaceType without MONSTER_CAP_OPENS_DOORSType with MONSTER_CAP_OPENS_DOORS
Has WALL_RUNTIME_MONSTER_PASSAGE (open doors among others)Goes on to the occupancy checkSame
A closed door with a switchMove refusedOpens the door, turns toward it and stays
A door with a switch that is openingMove refusedTurns toward it and stays
Any other face without WALL_RUNTIME_MONSTER_PASSAGEMove refusedMove refused

A monster that opens a door uses the same request as the scripts' open a door; it passes once the door is open, on a later update. "Turns and stays" counts as a successful move: the monster tries no other direction in that update, and no step sound plays.

The door test accepts only faces whose wall reference has no decoration selector, which in the executable's tables are the doors with a switch (wall references 3 to 7 and 13 to 17); doors without a switch, and every wall that a level's INF file maps, keep monsters out until they are open. Monster code reads three wall properties:

Wall propertyMonster use
WALL_RUNTIME_MONSTER_PASSAGEMoves; the openings a wandering monster looks for.
WALL_RUNTIME_DOOR_CLOSED_ENDPOINTA closed switch door, in the door branch.
WALL_RUNTIME_PASSAGE, WALL_RUNTIME_SMALL_PROJECTILE_PASSAGEThe ranged trace.

On level 16, sublevel 1, the final opponent's second form (type 1, with MONSTER_CAP_WALL_SPECIAL_TYPE_1) does not open a closed switch door: it replaces both faces of the door's block with wall reference 72, which that sublevel's INF file maps to an open passage with its own decoration. Only the two forms of that opponent have this capability, so the replacement happens nowhere else; levels 6 and 15 map the same reference to walls of their own.

Sharing a block​

A block holds positions 0 to 3, its four quarters, numbered as the floor positions of items, and position 4, its centre. Each monster type has an occupancy class, the INF occupancy_class; reading it as a size is inferred. A monster that moves into an empty block keeps its position value; into an occupied block, the game decides:2

  1. A block whose occupancy count is 4 is full.
  2. Every monster already there must have the entering monster's class.
  3. An occupant standing in the centre is first moved to a corner — the front-left corner for its facing in class 0, position 0 in class 1 — unless it has been turned to stone; the corner is not checked, so two monsters can end up on the same position.
  4. Then, by class:
    • class 0: the first free position in an order set by the entering monster's facing, front half first — facing north 0, 1, 2, 3; east 1, 3, 0, 2; south 2, 3, 0, 1; west 0, 2, 1, 3;
    • class 1: monsters pair on a diagonal: with an occupant at 0 it takes 3, with one at 3 it takes 0, and it then faces north; any other layout refuses it, except occupants at 0, 1 and 3, which give position 1 although it is taken;
    • class 2: never enters an occupied block.

When a class-1 monster has been updated, every other monster of its block takes its facing, and each one that turns misses its next update; see how a monster acts.

A monster ready to attack in melee but standing in the half of its block away from the party moves within its block: to the centre when it is alone, otherwise to the next free position the rules above give; a class-2 monster sharing a block stays where it is.3

These rules apply to moves. A level's initial placement is not checked: level 9 starts two class-2 monsters in one block, and level 15 pairs class-1 monsters on positions 0 and 1. Spawning has its own, looser test.

Bug

The class-1 position lookup indexes a table with the whole mask of occupied positions, 0 to 31, although the table ends after twelve entries. A mask of 12 or more — an occupant kept in the centre because it has been turned to stone, or occupants at both 2 and 3 — reads the next table, the melee position table, and takes its byte as the position: 0 for a centre occupant alone, 1 with one more at 0 or at 3, 0 with occupants at 0 and 3 too, which is occupied. A faithful reimplementation reads those bytes.2

Sources​

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

Footnotes​

  1. Check a candidate move with the wall properties, the decoration selectors, the door operation wrappers, the resting flag and the environmental sound; the mappings of reference 72 come from the 16 reference INF files. Comparative source: REF-SCUMM-020, walkMonsterNextStep. ↩

  2. Positions within an occupied block with the position tables, place a monster on a block and turn a block's monsters. Comparative source: REF-SCUMM-020, getNextMonsterPos, findFreeMonsterPos and setBlockMonsterDirection. ↩ ↩2

  3. Close-range action, the attack position check, move within its block, the pursuit decision and the ranged action. Comparative sources: REF-SCUMM-018, updateMonsterTryCloseAttack; REF-SCUMM-020, updateMonsterTryDistanceAttack. ↩