Melee attacks
Monsters · Ranged attacks · Who a monster attacks
In brief
A monster attacks in melee when the party is in the block ahead and the monster stands in the half of its block that faces the party, and then only every second time. Each attack sequence rolls the type's attacks against one character; damage that gets through can take an item, poison, paralyze or petrify. Monsters test no wall between their block and the party's, and the game has no rounds: a monster acts at its group's update.
The attack sequence
A monster attacks in melee only when the block ahead is the party's block. It must also stand in the half of its own block that faces the party, unless it stands in the centre of its block or its type's occupancy class is 1; otherwise it moves within its block and its update ends. Even in position it attacks only every second time: each chance flips a bit of its state, and only one of the two values leads to an attack. A monster directly in front of the party is animated as it attacks. Which character it attacks depends on the party's formation; see who a monster attacks.1
A monster type gives a number of attacks and a set of damage dice for each.
For each character the monster attacks — the first eligible one of its
order, or every one with MONSTER_CAP_ATTACKS_ALL — the game runs one attack sequence:2
total = 0
for i in 0 .. type.attacks - 1:
if hit_roll(monster, character in slot i): # see the bug below
total += roll(type.damage[i])
if total > 0:
if MONSTER_CAP_ITEM_LOSS and 1d4 != 4: lose an item (below)
damage the character by total # no saving throw
if MONSTER_CAP_POISONS: afflict POISONED (category 0)
and end its Slow Poison effect
if MONSTER_CAP_PARALYZES: afflict PARALYZED (category 2)
if MONSTER_CAP_PETRIFIES: afflict PETRIFIED (category 2)
The hit roll has no term for the character's condition. The damage reduces any Aid and Armor reserves as described for the character record; a character reduced to −10 hit points dies before the conditions are tested, and then escapes them. Slow Poison ends whether the poisoning succeeds or not.
The hit roll of attack number i, counted from 0, uses the defense and the Blur and Protection from Evil effects of the character in slot i, not those of the character attacked; projectile hits pass the target to the same roll. With one attack, slot 0 decides every melee hit, wherever the target stands; Prayer, a party effect, is unaffected. A faithful reimplementation rolls attack i against slot i.2
Item loss. A monster with MONSTER_CAP_ITEM_LOSS makes the character
lose, three times in four, the first item met from a random inventory slot
whose item type marks it as losable —
weapons, armour, helmets, shields, rings, bracers, wands, an amulet and lock
picks among the original item types: "name has lost her (his) item.".
The item leaves the inventory without being placed anywhere.2
Effects on characters
Poison, paralysis and petrification, from a monster's melee attack or mind blast, go through one routine:3
- Nothing happens if the character already has that condition, or is not living: absent, at −10 hit points or turned to stone.
- The character makes a saving throw of the given category, with its class and first level; success avoids the effect.
- Petrification ends every spell on the character and leaves only
CHARACTER_STATUS_PRESENTandCHARACTER_STATUS_PETRIFIED; the other effects add theirCharacterStatusFlagsbit. A paralyzed or petrified character's open spell book closes. - A character timer is set, then the game prints "name is poisoned!", "paralyzed!" or "PETRIFIED!".
| Condition | Saving throw | Timer | What the timer does |
|---|---|---|---|
| Poisoned | category 0 | 546 ticks, then every 546 | While poisoned: 5 points of damage ("name feels the effects of poison!"), none under Slow Poison. |
| Paralyzed (melee) | category 2 | 2 730 ticks | "name is no longer paralyzed!" |
| Paralyzed (mind blast) | category 1 | 2 730 ticks | The same. |
| Petrified | category 2 | none | Lasts until Stone to Flesh. |
Poison thus costs 5 hit points per unit of time until Neutralize Poison or death, which clears the condition. Reading a unit of 546 ticks as a minute of game time is inferred from resting, where an hour is 60 such units.
What stops an attack
Monsters test no line of sight beyond the ranged trace: noticing the party
ignores walls, a melee attack needs only the party in the block ahead, and
the ranged trace stops on reaching the party's block before testing that
block's face. A type with MONSTER_CAP_ATTACKS_ANY_SIDE attacks a party in
any of the four neighboring blocks without turning; the characters it hits
are still chosen from its own facing.1
The face between the monster's block and the party's block is never tested by an attack, although the move check refuses the same faces. A monster beside a face that lets the party through but keeps monsters out, or facing the party through a closed door from the next block, cannot cross it but strikes the party beyond it in melee, and its ranged attack starts. A launched object is then stopped by the door as it flies; a mind blast, which has no flying object, reaches the party. A faithful reimplementation applies no face test to melee attacks or to the last step of the ranged trace.1
Faces that let the party through but keep monsters out, doors aside, are common in the original levels. Nearly all belong to blocks with such a reference on all four sides, which monsters cannot walk into. The number of these faces with a block on their other side that has a monster passage of its own is:4
| Level | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Faces | 17 | 45 | 25 | 3 | 17 | 18 | 34 | 28 | 49 | 8 | 66 | 96 | 14 | 96 | 61 | 10 |
Most of them use a few references: on level 2, 35 of the 45 hold reference 26; on level 12, 29 of the 96 hold reference 25 and 28 hold reference 38. Levels 12 and 14 share one map. The count does not say whether a level's scripts let the party stay on a given block.
Attack timing
There is no game round. A monster attacks only in pursuit, during its
group's update — every 15, 25 or 35 ticks
in the original levels — and does one thing per update: a ranged attack, a
melee attempt, or a move, followed by a second melee attempt for
MONSTER_CAP_POST_MOVE_ACTION. One attack sequence — the type's number of
hit rolls against one character — is what a monster does to that character
in one update. In position it attacks every second update; ranged attacks
come two to four updates apart. A character's hand is ready again 54 ticks
after an attack, 27 under Haste; see
what decides a fight.5
Sources
Locations refer to the game executable reference; comparative sources are listed in the technical references.