Skip to main content

Noticing the party

Monsters · Moving toward the destination · MonsterMode

In brief​

Monsters do not see the party: they remember a destination block. A monster notices the party when it is at most one block away, whatever its facing, or two or three blocks away anywhere but in the sector behind it; walls do not count. It then pursues the party and records the party's block as its destination. If the party slips away, it walks to the block where it last noticed it, then starts wandering.

A monster facing north in the middle of a grid of blocks, and for each block around it whether a party standing there is noticed. Distance is the larger of the column and row differences plus half the smaller, rounded down; walls do not count. At distance 0 or 1 the party is always noticed. At distance 2 or 3 it is noticed unless it is in the sector behind the monster: south-west, south or south-east of it. At distance 4 or more it is not noticed.
A monster notices the party up to three blocks away, except behind it, and through walls.

The check​

A monster that passes this check switches to MONSTER_MODE_PURSUE and records the party's current block as its destination. The check runs for every monster just before and just after each move of the party, and for each monster at the start of its own update. While the party stays within reach of the check, the destination therefore follows it block by block.1

The check is skipped for dead monsters and for monsters that are delayed (MONSTER_MODE_DELAYED), peaceful (MONSTER_MODE_PEACEFUL), paralyzed (MONSTER_MODE_PARALYZED) or in MONSTER_MODE_UNKNOWN_9. For the others, it depends on distance and on where the party is relative to the monster's facing:

Distance to the partyResult
0 or 1Noticed, whatever the monster's facing.
2 or 3Noticed, unless the party is in the sector behind it.
4 or moreNot noticed; destination and mode are left unchanged.

Distance is not counted in steps along a path. Treating the level as a grid of 32 columns, with dx and dy the column and row differences, it is max(dx, dy) + floor(min(dx, dy) / 2). Walls are not taken into account.

The direction from one block to another is one of eight, numbered clockwise from north (0) to north-west (7). It is diagonal when neither axis dominates — when 2 × |dy| ≥ |dx| and 2 × |dx| ≥ |dy| — and otherwise the dominant straight direction. Two equal blocks have no direction.2 The sector test compares this direction from the monster to the party with the monster's four-way facing:

if monster is dead
or monster.mode in [MONSTER_MODE_DELAYED, MONSTER_MODE_PEACEFUL,
MONSTER_MODE_UNKNOWN_9, MONSTER_MODE_PARALYZED]:
do nothing
else:
distance = block_distance(monster.block, party.block)
if distance < 4:
direction = direction_to(monster.block, party.block) # 0..7
sector = direction - 2 * monster.direction - 3
if sector < 0:
sector = sector + 8
if distance < 2 or sector > 2:
monster.mode = MONSTER_MODE_PURSUE
monster.destination = party.block

Where the destination comes from​

A monster slot starts with destination 0, the block [00:00]: initializing a slot clears it, for the level's initial monsters and for spawned ones. Afterwards only four events write it, always with the party's current block:3

EventWhenAlso
Noticing the partyThe check above succeedsThe mode becomes MONSTER_MODE_PURSUE
DamageThe monster survives within distance 3, except during area damage on a monster in viewMONSTER_RUNTIME_PROVOKED is set
ProvocationAt the start of an update, the monster is provoked and neither pursuing, peaceful nor paralyzedThe mode becomes MONSTER_MODE_PURSUE
Waking the peaceful monstersA peaceful monster is provoked or diesEvery MONSTER_MODE_PEACEFUL monster pursues

Nothing clears the destination, and only the pursuit routine reads it. A level record keeps it with the rest of the slot when the party leaves the level or saves. As a consequence (inferred):

  • a monster that its level places in MONSTER_MODE_PURSUE heads for [00:00], the north-west corner, until it notices the party; 104 of the placed monsters of the reference levels start in that mode;
  • a script that provokes a monster, and the Fear and Turn undead effects, set the pursuit mode but keep the old destination;
  • during area damage, a monster in view that survives keeps its old destination; being provoked, it still turns on the party at its next update unless it already pursues — see what a monster's state changes.

Losing the party​

Failing the check never changes the destination. A pursuing monster therefore walks to the block where it last noticed the party. Its movement never enters that block: when the block becomes adjacent, the monster turns to face it. At its next update the block ahead is the destination; if the party is not there, the monster switches to MONSTER_MODE_WANDER_LEFT or MONSTER_MODE_WANDER_RIGHT with an even chance and from then on follows the wandering rules, until it notices the party again or, if it has been provoked, at its next update.4

Sources​

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

Footnotes​

  1. Notice the party, run from move the party and the monster update; uses distance and direction. Comparative source: REF-SCUMM-020, updateMonsterDest. ↩

  2. Direction between two blocks with the direction table. Comparative source: REF-SCUMM-020, getNextMonsterDirection. ↩

  3. Notice the party, damage a monster with the deferred-damage flag and finish deferred damage, react to provocation, wake peaceful monsters, initialize a monster slot and read initial monster states. Comparative source: REF-SCUMM-020, initMonster, updateMonsterDest, updateMonsterAttackMode, turnFriendlyMonstersHostile and inflictMonsterDamage. ↩

  4. Pursuit decision, with ranged action, close-range action and movement. Comparative source: REF-SCUMM-020, updateMoveMonster. ↩