Skip to main content

Moving toward the destination

Monsters · Noticing the party · Obstacles and other monsters

In brief​

A pursuing monster that attacks neither at range nor in melee takes one step toward its destination. It first turns toward the destination, at most a quarter turn, then tries the straight directions in a fixed order, the way back last. Next to its destination it only turns to face it, or steps sideways when the destination is on a diagonal. A frightened or turned monster moves away from its destination instead.

The order in which a moving monster tries the directions around it, starting from the direction it turned to, here north. Diagonal directions are skipped. Order A tries north, then east, then west, then south; order B tries north, then west, then east, then south. The two orders alternate every eleven movement steps counted over all monsters together.
Straight ahead first, then one side or the other, the way back last.

One step​

When a pursuing monster attacks neither at range nor in melee, it takes one step toward its destination. A monster faces the way it moves, except for the sideways step below. Directions are numbered as in noticing the party, clockwise from north (0) to north-west (7); a facing f is direction 2 f:1

count += 1 # one count for all monsters
if count > 10: count = 0; switch order
s = 2 * monster.facing
d = direction(monster.block, destination)
if monster is fleeing: # MONSTER_RUNTIME_AVOID_CLOSER_BLOCK
monster.counter -= 1
if monster.counter > 0: d = (d + 4) % 8 # away from the destination
else: monster.counter = 0; stop fleeing
if destination is the neighbor in direction d:
if d is straight:
face d; done # no move
side = SIDESTEP[d][monster.facing] # 0 unless the monster faces
# one half of the diagonal
if side and (type lacks MONSTER_CAP_SIDESTEP_SOMETIMES
or roll 1d4 < 4):
if move to the block beside, keeping the facing: done
diff = (d - s) % 8
if diff != 0:
turn = 1 if d is diagonal else 2
s = s + turn if diff < 5 else s - turn # toward the destination
for t in order(s): # the 8 directions
if t is straight and move to the neighbor in direction t, facing t:
done

Order A tries s, s + 1, s − 1, s + 2, s − 2, s + 3, s − 3, s + 4; order B the same with the signs reversed. The two orders alternate every eleven movement steps counted over all monsters together, so a monster's choice between left and right depends on the others. Diagonal directions are skipped. Each move goes through the move check, which also refuses, for a fleeing monster, any block closer to the party. In plain terms:

  • Destination farther away: the first direction tried is at most a quarter turn from the monster's facing, toward the destination; with the destination straight behind, it tries its right first. Only when that is blocked does it try the other sides, and the way back last.
  • Destination adjacent in a straight line: the monster only turns to face it. At its next update it attacks if the party is there, and starts wandering otherwise.
  • Destination adjacent on a diagonal: when the monster faces one of the two directions that make up the diagonal, it first tries a sideways step that puts the destination straight ahead — for north-east, east when facing north and north when facing east. A type with MONSTER_CAP_SIDESTEP_SOMETIMES skips that step one time in four.
  • Fleeing, after Fear or Turn undead: the monster moves away from its destination, not from the party, while its counter, lowered at each step, stays above zero.

Bug

The direction routine returns a one-byte "no direction" value for two equal blocks, but the movement routine compares it with a two-byte value, so the test never succeeds. A pursuing monster standing on its own destination — for instance a wandering monster stopped on its old destination and then provoked by a script, frightened or turned — reads its direction tables past their end. Not fleeing, it treats the destination as a diagonal and steps to a neighboring block. Fleeing, it first tries to move to the block 7, 5, 3 or 13 places further in the block numbering, according to its facing north, east, south or west, keeping its facing, before falling back to the neighboring blocks. That far block goes through the same move check, which never tests that a block is adjacent: it compares the far block's distance to the party with the current one, and reads the far block's face opposite the monster's facing. When the check accepts, the monster is placed on the far block at once, whatever lies between. A closed switch door on that face is instead opened by a type with MONSTER_CAP_OPENS_DOORS, from where the monster stands. A faithful reimplementation reproduces these steps.1

Sources​

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

Footnotes​

  1. Move toward a destination with the direction offsets, the sideways steps, the step orders and their selector, and check a candidate move. Comparative source: REF-SCUMM-020, walkMonster and walkMonsterNextStep. ↩ ↩2