Skip to main content

Monster routines

Routines · Data · Address index

How monsters move, notice the party, attack, cast spells, take damage, appear and die, and how undead are turned. The routines page explains how the entries are written.

0x19974 — Move toward a destination​

0x19bac — Wake peaceful monsters​

0x19c1a — Notice the party​

0x19cdc, 0x19da7 — Positions within an occupied block​

  • Ranges: 0x19cdc–0x19da6 (occupied-position mask), 0x19da7–0x19e59 (position for an entering monster); faulty class-1 lookup at 0x19df0
  • Status: reading the occupancy class as monster size is inferred from comparison.
  • Role: The mask routine refuses a block holding four monsters (−2) or an occupant of another occupancy class (−1; byte +0x1e of the type properties). It moves a centre occupant without MONSTER_RUNTIME_TURNED_TO_STONE to a corner, even an occupied one: position 0 for class 1, otherwise the corner table entry of its direction (0x19d3a–0x19d7d); it returns the mask of occupied positions. The search for an entering monster refuses class 2, which never enters an occupied block (0x19dc5). Class 1, which shares a block in pairs on the diagonal positions 0 and 3, takes its position from the class-1 table by mask (mask 9 refused), and the monster placed takes the direction stored at DS:0x92a6 (0x19e01). Class 0, up to four per block, takes the first free position in the search order of its facing (0x19e0d–0x19e4f). The class-1 lookup at 0x19df0 indexes the table with the whole mask, 0 to 31, so masks of 12 or more read the close-attack tables that follow it.
  • Comparative source: REF-SCUMM-008, REF-SCUMM-020, getNextMonsterPos and findFreeMonsterPos.
  • Used by: Obstacles and other monsters › Sharing a block, Monster slot › Layout, Level data (INF), Anomalies and bugs

0x19e5a — Place a monster on a block​

0x19ef5 — Check a candidate move​

0x1a0d5 — React to provocation​

0x1a107 — Move within its block​

0x1a168 — Close-range action​

0x1ac1f — Attack position check​

0x1aead — Target choice of a close attack​

0x1a333 — Ranged action​

0x1a2cc — Monster spell​

0x1a5a3 — Pursuit decision​

0x1a6a3 — Patrol modes​

0x1a706 — Wander modes​

0x1a823 — Timed inactivity​

0x1a845 — Turn a block's monsters​

0x1a88c — Monster update and mode dispatch​

0x1a9de — Flash a damaged monster​

0x1aa42 — Finish deferred damage​

0x1aabe — Kill a monster​

0x1ad07, 0x1ad24 — Monster attack​

  • Ranges: 0x1ad07–0x1aeac: attack loop 0x1ad24–0x1ad96, with the faulty argument pushed at 0x1ad30; effects 0x1ad98–0x1aea4
  • Role: Arguments: a character slot and a monster; the target choice calls it for each character it attacks. Repeats a hit roll as many times as the type's attack count (+0x06) and, for each hit, adds the dice of attack i (type +0x07 + 3 × i) to a total. The hit roll receives the attack number as its character slot: the loop pushes its counter (%si) at 0x1ad30, so attack i is rolled against the defense and spell effects of the character in slot i, not of the target. With a positive total, a type with MONSTER_CAP_ITEM_LOSS makes the target lose an item when 1d4 − 1 ≠ 3 (0x1ada1–0x1adca); the total is dealt through 0x209fc with no saving throw (0x1add6–0x1addc); then MONSTER_CAP_POISONS (0x1aded), MONSTER_CAP_PARALYZES (0x1ae3c) and MONSTER_CAP_PETRIFIES (0x1ae78) afflict the target with CHARACTER_STATUS_POISONED, CHARACTER_STATUS_PARALYZED and CHARACTER_STATUS_PETRIFIED: saving-throw categories 0, 2 and 2, durations 1, 5 and 0, timer events 8, 9 and 0. The poison call is followed by an unconditional clear of spell_effects bit 0x2000 (0x1ae27).
  • Comparative source: REF-SCUMM-008; REF-SCUMM-021, monsterCloseAttack.
  • Used by: Lasting spell effects, Melee attacks › The attack sequence, Monster capabilities › Where it is used, Level data (INF), Anomalies and bugs

0x1afb2 — Initialize a monster slot​

0x1b0ee — Spawn a monster​

0x1bb1e — Turn-undead threshold​

  • Range: 0x1bb1e–0x1bb3e
  • Role: (level, resistance) → the signed byte of the turn-undead table at 14 × resistance + min(level, 14) (0x1bb25–0x1bb37), with no lower bound. A level of 14 or more reads the first byte of the next row, past the 14 entries of the row (ANOMALY-131).
  • Used by: Attack spells, Anomalies and bugs

0x1ec1f, 0x24b56 — Turn undead​

  • Range: 0x1ec1f–0x1ecb5 for one monster; 0x24b56 is its caller.
  • Callers: 0x24b56 is the start routine of definition 62, Turn undead; it examines at most five monsters of the list (0x24c41).
  • Role: 0x24b56 takes the block in front of the party and stops if no monster occupies it. It rolls one twenty-sided die with the dice roll. Then, for each monster there whose type has type flag 0x0004 and which was not tried before, it marks the monster as tried (state bit 0x10) and calls 0x1ec1f with the roll and a level. 0x1ec1f reads the threshold for the type's turn resistance and that level, the cleric or paladin level (0x24bad). A threshold of −1 calls the monster damage routine 0x20808 with 500 points, damage flag 0x200, no saving throw and no experience. A roll below the threshold (0x1ec50) does nothing. Otherwise the monster switches to MONSTER_MODE_PURSUE with MONSTER_RUNTIME_AVOID_CLOSER_BLOCK and a counter of 40, and turns to face away from the party.
  • Comparative source: REF-SCUMM-013, spellCallback_start_turnUndead and turnUndeadHit.
  • Used by: Modes and provocation › Changing mode, Modes and provocation › What a monster's state changes, Monster state flags › Avoiding the party, Sound effects, Attack spells, Level data (INF)

0x2059d — Damage a monster​

0x20da4 — Monster explosion​

0x20c4b, 0x19b49 — Spell effects on a monster​

  • Range: 0x20c4b–0x20d95, with a seven-entry jump table at 0x20d96. 0x20d20 is the paralysis branch. 0x19b49 is called by effect 6.

  • Callers: the spell routines: Hold Person and Hold Monster (effects 0 and 1), Power Word Stun (2), Finger of Death and Slay Living (3), Disintegrate (4), Flesh to Stone (5) and Fear (6); the fourth argument is the saving-throw category, 5 never saving.

  • Role: Applies one of seven effects, numbered 0 to 6, to a monster. When asked, it first tries an evasion: if that succeeds, or if the type's immunity flags have bit 0x0010, it returns −1. Then a successful saving throw returns 0. The conditions below test the type's immunity flags and type flags:

    EffectConditionEffect on the monster
    0, 1, 2type flag 0x0001 (0) or 0x0002 (1); immunity not 0x0002MONSTER_MODE_PARALYZED with a counter of 15 (at 0x20d20).
    3immunity not 0x00081000 points of damage.
    4none1000 points of damage.
    5noneSets state bit 0x20 and the state-change flag.
    6immunity not 0x00040x19b49: unless the monster is delayed, peaceful or paralyzed, MONSTER_MODE_PURSUE with MONSTER_RUNTIME_AVOID_CLOSER_BLOCK, a counter of 20 and one move attempt away from the party.

    Effect 2 has no type-flag condition. Each applied effect returns 1.

  • Comparative source: REF-SCUMM-013, magicObjectStatusHit and spellCallback_start_fear.

  • Used by: Monster behavior modes › How each mode behaves