Skip to main content

Modes and provocation

Monsters · MonsterMode · MonsterRuntimeFlags

In brief​

A monster's behavior is its mode: pursuing, wandering, waiting, patrolling, delayed, peaceful or paralyzed. The level data or a script gives the first mode; during play, noticing the party, being provoked, the end of a counter and some spells change it. A monster attacked by a character is provoked for good: whenever it stops pursuing, it sets off again toward the party, wherever the party is.

How a monster changes mode during play. A waiting, patrolling or wandering monster pursues the party when it notices it or is provoked; a pursuing monster starts wandering when the block ahead is its destination and the party is not there. A delayed or paralyzed monster pursues when its counter reaches zero. Every peaceful monster pursues when a peaceful monster is provoked by an attack or dies. Hold Person, Hold Monster and Power Word Stun paralyze a monster in any mode. Fear, Turn undead and a script that provokes a monster set the pursuit mode without changing the destination.
Most changes lead to pursuit; only losing the party or a hold lead out of it.

Reacting to damage​

When a character attacks a monster — hit or miss — or a monster is damaged and survives, it is marked MONSTER_RUNTIME_PROVOKED; if it is damaged within distance 3 of the party, it also records the party's block as its destination.1

On its next update, a provoked monster switches to MONSTER_MODE_PURSUE and records the party's block, unless it is paralyzed. A provoked peaceful monster wakes every peaceful monster at once: they all switch to pursuit. See provoked monsters. The flag is never cleared, so this happens again at every update in which the monster is in another mode; see what a monster's state changes.1

Changing mode​

A monster's mode comes from the level's INF data or from SCRIPT_SPAWN_MONSTER, together with a counter; only these give MONSTER_MODE_DELAYED, MONSTER_MODE_PEACEFUL or MONSTER_MODE_UNKNOWN_9. During play, the mode changes only in these cases:2

CauseModes affectedNew modeDestination
The monster notices the party0 to 6MONSTER_MODE_PURSUEThe party's block
It is provoked, at its next update1 to 9, except peaceful and paralyzedMONSTER_MODE_PURSUEThe party's block
A peaceful monster is provoked or diesEvery MONSTER_MODE_PEACEFUL monsterMONSTER_MODE_PURSUEThe party's block
A script sets a flag of the monster (SCRIPT_FLAG_TARGET_MONSTER)AnyMONSTER_MODE_PURSUEUnchanged
In pursuit, the block ahead is the destination and the party is not thereMONSTER_MODE_PURSUEMONSTER_MODE_WANDER_LEFT or _RIGHT, at randomUnchanged
Its counter reaches zeroDelayed, paralyzedMONSTER_MODE_PURSUEUnchanged
Hold Person, Hold Monster, Power Word StunAnyMONSTER_MODE_PARALYZED, counter 15Unchanged
FearAll but delayed, peaceful, paralyzedMONSTER_MODE_PURSUE, fleeing, counter 20Unchanged
Turn undead succeedsAnyMONSTER_MODE_PURSUE, fleeing, counter 40Unchanged

The conditions of each spell — the monster types it affects, immunities and saving throws — are in the attack spells. Counters count the updates of the monster's own group, so a hold lasts 15 times the level's update interval. A monster that leaves a counted mode, flees or is provoked by a script keeps whatever destination it had: the block where it last noticed the party, or [00:00] if it never did.

A monster killed to free its slot for SCRIPT_SPAWN_MONSTER dies like any other, so a peaceful one wakes the others. A peaceful monster that is held, turned or provoked by a script leaves the peaceful mode alone, without waking the others: only its provocation by an attack or its death wakes the whole group.2

Anomaly

ANOMALY-147 — The routine that wakes peaceful monsters keeps a pointer to the last one it woke and, after its loop, reads that monster's type to set a global script flag. It does not test that it woke any: with no monster in MONSTER_MODE_PEACEFUL, the pointer is whatever the stack holds, and the byte it reads could set the flag (inferred). The case is latent: both callers run the routine only for a monster that is itself peaceful, so the loop always wakes at least one. A faithful reimplementation keeps that guard and has nothing else to reproduce.2

What a monster's state changes​

Besides its mode, a monster's decisions depend on a few fields of its MonsterRuntime slot and on its state flags:3

StateSet byEffectEnds
No hit pointsDeathNever updated, never notices the party.A new monster in the slot
MONSTER_RUNTIME_PROVOKEDA character's hit roll against it, hit or miss; damage; a scriptEach update outside pursuit, peaceful and paralyzed modes sends it back to pursuit, toward the party's current block.Never
MONSTER_RUNTIME_AVOID_CLOSER_BLOCKFear, Turn undeadIt flees: moves away from its destination and refuses any block closer to the party.Damage, or its counter running out
MONSTER_RUNTIME_MELEE_ALTERNATEEach melee opportunity toggles itIt attacks only when the toggle leaves it set: every second opportunity.Toggled again
MONSTER_RUNTIME_TURNED_TO_STONEFlesh to StoneNever updated or animated; any melee attack hits it and destroys it, with experience.Never
MONSTER_RUNTIME_TURN_UNDEAD_TRIEDA Turn undead attempt on itNo later Turn undead affects it, whatever the result of the first.Never
Skip-update byteA class-1 monster on its block turning itIt misses its next update.That update
CounterLevel data, spawn, spellsDelayed and paralyzed: updates left. Fleeing: steps left.Zero

Provocation lasts. Nothing clears MONSTER_RUNTIME_PROVOKED. A provoked monster that loses the party in pursuit switches to a wander mode as usual, but its next update sends it back to pursuit with the party's current block as destination, at any distance and through walls. Once attacked, a monster therefore keeps finding the party; only death, a hold or the peaceful mode stops it.

Fleeing. While MONSTER_RUNTIME_AVOID_CLOSER_BLOCK is set, each step toward the destination goes the opposite way and lowers the counter. When the counter reaches zero the flag is cleared and the monster moves normally again; damage clears the flag at once. Attacks are still tried before moving, as in any pursuit.

Turned to stone. The monster keeps its block, hit points and mode, so it still occupies its block, stands in the way of ranged attacks and keeps the party from resting nearby. No code turns it back.

Standing still. After the mode routine, the walking frame alternates at every update unless the monster is then waiting, delayed or peaceful. A paralyzed monster and a MONSTER_MODE_UNKNOWN_9 monster therefore keep alternating their walking frames while they stand in place.

Sources​

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

Footnotes​

  1. A character's hit roll, damage a monster, react to provocation, wake peaceful monsters. Comparative source: REF-SCUMM-020, characterAttackHitTest, inflictMonsterDamage and updateMonsterAttackMode. ↩ ↩2

  2. Initialize a monster slot, notice the party, react to provocation, wake peaceful monsters, pursuit decision, timed inactivity, spell effects on a monster, turn undead, the set flags handler, kill a monster and spawn a monster. Comparative source: REF-SCUMM-020, updateMonsterDest, updateMonsterAttackMode, turnFriendlyMonstersHostile, updateMonstersSpellStatus, magicObjectStatusHit and turnUndeadHit. ↩ ↩2 ↩3

  3. Monster update, react to provocation, a character's hit roll, damage a monster, move toward a destination, check a candidate move, close-range action, melee attack, turn undead, the idle animation and the monster rounds while resting. Comparative source: REF-SCUMM-020, walkMonster, characterAttackHitTest, closeDistanceAttack and timerUpdateMonsterIdleAnim. ↩