Hit rolls
Combat · Attacking with a weapon · Damage to a monster
In brief
A character's attack on a monster, and a monster's attack on a character, is decided by a roll of a twenty-sided die. A character must reach a number that falls as its level and the monster's armour class rise; the weapon's value helps, and so does strength in melee or dexterity with thrown weapons and launchers. A 20 is not an automatic hit. A monster must reach a number set by its hit chance and the character's defense, and always hits on a 20. An item thrown by a monster, a wall or a script hits a monster without a roll, and so does any attack on a monster turned to stone.
A character's hit roll
if the attacker is not a character: hit
if the monster is turned to stone: hit
bonus = weapon value, for a melee weapon, thrown weapon or launcher, else 0
if (weapon of those kinds, or no item):
if immunity MONSTER_IMMUNE_NEEDS_MAGIC_WEAPON and bonus <= 0: miss
if immunity MONSTER_IMMUNE_NEEDS_PLUS_TWO and bonus <= 1: miss
bonus += strength hit modifier (melee) or dexterity hit modifier (missiles)
needed = to_hit(class, first level, monster armour class) - bonus
roll = 1d20, + 1 if the party has Bless or Prayer or the character has Aid
roll = clamp(roll, 1, 20); the monster becomes provoked
hit if roll >= needed
There is no automatic hit on a 20. The number needed, to_hit, is
20 − ((first level − 1) / divisor) × step − armour class, rounded toward
zero. The character's class gives the divisor and the step: 1 and 1 for
warriors, 3 and 1 for wizards, 3 and 2 for priests, 2 and 1 for rogues. A
multi-class character uses one group, the same as for its
saving throw. The immunities
are those of the monster type, in
MonsterImmunityFlags.1
Strength and dexterity modifiers
Strength adds to the hit roll of a melee blow, and to its damage; dexterity adds to the hit roll of a thrown weapon or a missile.
| Score | Strength, to hit | Strength, to damage | Dexterity, to hit |
|---|---|---|---|
| 1 | −5 | −4 | −6 |
| 2 | −3 | −2 | −4 |
| 3 | −3 | −1 | −3 |
| 4 | −2 | −1 | −2 |
| 5 | −2 | −1 | −1 |
| 6 | −1 | 0 | 0 |
| 7 | −1 | 0 | 0 |
| 8–11 | 0 | 0 | 0 |
| 12 | 0 | 0 | 1 |
| 13 | 0 | 0 | 2 |
| 14 | 0 | 0 | 2 |
| 15 | 0 | 0 | 3 |
| 16 | 0 | 1 | 3 |
| 17 | 1 | 1 | 4 |
| 18 | 1 | 2 | 4 |
| 19 | 3 | 7 | 4 |
| 20 | 3 | 8 | — |
| 21 | 4 | 9 | — |
| 22 | 4 | 10 | — |
| 23 | 5 | 11 | — |
| 24 | 6 | 12 | — |
| 25 | 7 | 14 | — |
Exceptional strength, a score of 18 with a percentage, replaces both strength modifiers:
| Percentage from | 1 | 51 | 76 | 91 | 100 |
|---|---|---|---|---|---|
| To hit | +1 | +2 | +2 | +2 | +3 |
| To damage | +3 | +3 | +4 | +5 | +6 |
ANOMALY-20 — The dexterity table has 19 entries: a score of 20 to 22 reads
the three bytes that follow it, 5, 5 and 5, which belong to the next table.
A faithful reimplementation gives these scores a modifier of 5.1
A monster's hit roll
roll = 1d20
if roll != 20:
roll -= 2 if the character has SPELL_EFFECT_PROTECTION_FROM_EVIL
roll -= 2 if the character has SPELL_EFFECT_BLUR
roll -= 1 if the party has SPELL_EFFECT_PRAYER
hit if roll == 20 or roll >= monster hit chance - character defense
The effects are SpellEffectFlags. The
character is the one attacked, except in a monster's melee attack, where
attack number i uses the character in slot i; see
the bug.1
Sources
Locations refer to the game executable reference; comparative sources are listed in the technical references.