Skip to main content

Damage flags

ScriptDamageFlags · signed byte in scripts, sign-extended to the 16-bit flags argument of the damage routine; fourth damage operand of Damage characters

Scripts · Saving-throw categories

These bits change how damage is computed and when it is cancelled: a ring of Feather Fall can cancel it, Slow Poison can cancel it, and damage can come from an item rather than from dice.1

typedef enum ScriptDamageFlags {
SCRIPT_DAMAGE_IGNORED_0002 = 0x0002, /* Used by reference scripts; read by no routine of the damage path. */
SCRIPT_DAMAGE_RING_NEGATES = 0x0004, /* Damage becomes zero if the target wears a ring of Feather Fall. */
SCRIPT_DAMAGE_FLYING_OBJECT = 0x0010, /* With ITEM_BASED: damage becomes one for an item that is not a missile. */
SCRIPT_DAMAGE_ITEM_BASED = 0x0100, /* Damage is the weapon damage of an item instead of a dice roll. */
SCRIPT_DAMAGE_STATUS_CHECK = 0x0400 /* Slow Poison cancels the damage; otherwise a poison message is printed. */
} ScriptDamageFlags;

What scripts can set​

The script operand is one signed byte, widened to a word with its sign: its seven low bits can be set directly, and a negative byte also sets all the bits above them. A script can therefore set SCRIPT_DAMAGE_ITEM_BASED only with a negative byte, which sets SCRIPT_DAMAGE_STATUS_CHECK too. The reference scripts use only SCRIPT_DAMAGE_RING_NEGATES and SCRIPT_DAMAGE_IGNORED_0002; the other bits come from other callers of the damage routine.2

Effects​

The damage routine applies the bits in this order, after the damage roll and any saving throw (see Damage characters):1

BitEffect
SCRIPT_DAMAGE_ITEM_BASEDThe three dice operands change meaning, and the weapon damage of an item replaces the dice roll: the first operand names the character whose strength bonus is added (−1 for none), the second the item, and a nonzero third asks for the strength bonus. The item's first damage profile is always used. See item-based damage.
SCRIPT_DAMAGE_ITEM_BASED and SCRIPT_DAMAGE_FLYING_OBJECTIf the item is not a missile (its kind is neither 2 nor 3), the damage becomes 1.
SCRIPT_DAMAGE_RING_NEGATESIf inventory slot 25 or 26 of the target holds an item of type ITEM_TYPE_RING whose value is 3, a ring of Feather Fall, the damage becomes 0.
SCRIPT_DAMAGE_STATUS_CHECKIf the target's spell_effects include SPELL_EFFECT_SLOW_POISON, the damage becomes 0; otherwise a message that includes the character's name is displayed. The poison timer uses it: every 546 ticks it deals 5 points with this flag, so Slow Poison cancels them, and the message reads "name feels the effects of poison!".3

No other bit is read: SCRIPT_DAMAGE_IGNORED_0002, which 27 of the 164 reachable damage instructions of the 16 reference INF files set, always together with saving-throw category 4, changes nothing, and neither do bits 0x01, 0x08, 0x20, 0x40, 0x80, 0x200 or those above 0x400. The routine that subtracts the damage receives only the amount. The character fields are those of CharacterRuntime.

Item-based damage​

The game itself sets SCRIPT_DAMAGE_ITEM_BASED with SCRIPT_DAMAGE_FLYING_OBJECT when a flying item hits a party member: no character, the flying item, no strength bonus, no saving throw. A script that sets the bit passes signed bytes, so it can name items 0 to 127 only, and its negative flags byte always adds the Slow Poison test and its message. No reference script does so.2

Sources​

Locations refer to the game executable reference.

Footnotes​

  1. Character damage routines, the item damage dice, the missile test and the ring search. Comparative source: EoBCoreEngine::calcCharacterDamage in REF-SCUMM-013. ↩ ↩2

  2. Damage characters handler, which sign-extends the operand, and the flying item hitting the party. ↩ ↩2

  3. The character timer events call the character damage routines with this flag. Comparative source: timerSpecialCharacterUpdate in REF-SCUMM-021. ↩