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.
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:
| Face | Type without MONSTER_CAP_OPENS_DOORS | Type with MONSTER_CAP_OPENS_DOORS |
|---|---|---|
Has WALL_RUNTIME_MONSTER_PASSAGE (open doors among others) | Goes on to the occupancy check | Same |
| A closed door with a switch | Move refused | Opens the door, turns toward it and stays |
| A door with a switch that is opening | Move refused | Turns toward it and stays |
Any other face without WALL_RUNTIME_MONSTER_PASSAGE | Move refused | Move 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 property | Monster use |
|---|---|
WALL_RUNTIME_MONSTER_PASSAGE | Moves; the openings a wandering monster looks for. |
WALL_RUNTIME_DOOR_CLOSED_ENDPOINT | A closed switch door, in the door branch. |
WALL_RUNTIME_PASSAGE, WALL_RUNTIME_SMALL_PROJECTILE_PASSAGE | The 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
- A block whose occupancy count is 4 is full.
- Every monster already there must have the entering monster's class.
- 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.
- 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.
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.