Lasting spell effects
SpellEffectFlags · 32 bits: the effect_mask of a
SpellDefinitionRuntime, and the
spell_effects field of a CharacterRuntime
or the party's spell effects
Magic · Mage and cleric spells · Spell definition flags
A spell that lasts leaves a mark while it is active: when it starts, the game sets the bits of its definition's effect mask on the target character, on the party as a whole or on each living party member, according to its definition flags; when it ends, it clears them. Other parts of the game then test these bits.
/* Bits of a spell's lasting effect (EOB II DOS); named after the spells that set them. */
typedef enum SpellEffectFlags {
SPELL_EFFECT_ARMOR = 0x00000001, /* Mage Armor. */
SPELL_EFFECT_DETECT_MAGIC = 0x00000002, /* Mage and cleric Detect Magic. */
SPELL_EFFECT_SHIELD = 0x00000008, /* Mage Shield. */
SPELL_EFFECT_BLUR = 0x00000010, /* Mage Blur. */
SPELL_EFFECT_DETECT_INVISIBLE = 0x00000020, /* Mage Detect Invisible. */
SPELL_EFFECT_INVISIBILITY = 0x00000040, /* Invisibility and Invisibility 10'; also in Improved Identify's mask. */
SPELL_EFFECT_IMPROVED_INVISIBILITY = 0x00000100, /* Mage Improved Invisibility. */
SPELL_EFFECT_TRUE_SEEING = 0x00000200, /* Mage and cleric True Seeing. */
SPELL_EFFECT_BLESS = 0x00000400, /* Cleric Bless. */
SPELL_EFFECT_PROTECTION_FROM_EVIL = 0x00000800, /* Protection from Evil and Protection from Evil 10'. */
SPELL_EFFECT_AID = 0x00001000, /* Set and cleared by Aid's own routines, not by a definition mask. */
SPELL_EFFECT_SLOW_POISON = 0x00002000, /* Cleric Slow Poison. */
SPELL_EFFECT_MAGICAL_VESTMENT = 0x00004000, /* Cleric Magical Vestment. */
SPELL_EFFECT_PRAYER = 0x00008000, /* Cleric Prayer. */
SPELL_EFFECT_HASTE = 0x00010000, /* Mage Haste; also set by a potion of value 5. */
SPELL_EFFECT_MYSTIC_DEFENSE = 0x00020000 /* Party effect of definition 64, "mystic defense", cast only by a wand of value 5. */
} SpellEffectFlags;
SPELL_EFFECT_MYSTIC_DEFENSE is carried by spell definition 64, which has
no entry in the spell books: only a wand of
value 5 casts it, for 546 ticks. Potions also set SPELL_EFFECT_HASTE and
SPELL_EFFECT_INVISIBILITY directly; see
potions. Aid sets and clears
SPELL_EFFECT_AID in its own start and end routines; its definition's mask
is empty. No code sets the bits that have no name here. Improved Identify
has SPELL_EFFECT_INVISIBILITY in its mask but none of the flags that
apply a mask, so the bit is never set by that spell.
Some bits are kept on the character, others on the party, according to the
definition flags; the table says which. Two writers besides the casting
steps also clear bits: Dispel Magic clears every bit of every character,
and being poisoned, by a monster or a potion, clears
SPELL_EFFECT_SLOW_POISON, as does Neutralize Poison.
Where the bits are tested
| Bit | Kept on | What tests it |
|---|---|---|
SPELL_EFFECT_ARMOR | The character | Only the refusal of a second Armor. The protection itself comes from the armor reserve of CharacterRuntime, which the defense recomputation uses and damage uses up. |
SPELL_EFFECT_DETECT_MAGIC | The party | The held item and the items drawn in the inventory: a magical item is drawn with another colour table. |
SPELL_EFFECT_SHIELD | The character | The defense is at most 4; a Magic Missile does no damage; the portrait frame. |
SPELL_EFFECT_BLUR | The character | A monster's hit roll on the character loses 2; the portrait frame. |
SPELL_EFFECT_DETECT_INVISIBLE | The party | Hidden monsters are drawn (monsters in the view); the portrait frame. |
SPELL_EFFECT_INVISIBILITY | The character | A monster's close attack passes over the character unless a 1d20 roll is below 5 (who a monster attacks); attacking with a hand item, or casting a spell with SPELL_FLAG_ENDS_INVISIBILITY, ends it; SCRIPT_EXPR_NO_ELIGIBLE_CHARACTER skips the character; its face is drawn through a colour table. |
SPELL_EFFECT_IMPROVED_INVISIBILITY | The character | As SPELL_EFFECT_INVISIBILITY for close attacks and the face, but neither attacking nor casting ends it. |
SPELL_EFFECT_TRUE_SEEING | The party | Hidden monsters are drawn. The spell's start and end routines also change the look of WALL_REFERENCE_ILLUSION walls, without testing the bit. |
SPELL_EFFECT_BLESS | The party | A character's hit roll gains 1; the portrait frame. |
SPELL_EFFECT_PROTECTION_FROM_EVIL | The character | A monster's hit roll on the character loses 2; the portrait frame. |
SPELL_EFFECT_AID | The character | The character's hit roll gains 1; the portrait frame. |
SPELL_EFFECT_SLOW_POISON | The character | Damage with SCRIPT_DAMAGE_STATUS_CHECK, the poison's, becomes 0 (damage flags); the inventory page shows "POISON (SLOW)" instead of "POISONED"; the portrait frame. |
SPELL_EFFECT_MAGICAL_VESTMENT | The character | The defense is at most 5 + (cleric level − 5) / 3; the portrait frame. |
SPELL_EFFECT_PRAYER | The party | A character's hit roll gains 1 and a monster's loses 1; the portrait frame. |
SPELL_EFFECT_HASTE | The character | A hand is ready again 9 ticks after its recovery starts instead of 36; the portrait frame. |
SPELL_EFFECT_MYSTIC_DEFENSE | The party | One kind of monster spell hits with smaller dice, and its hit clears the bit; the portrait frame. |
Every bit that a spell can set is also checked when a spell is cast: the spell is refused when one of its bits is already set on its target, or on the party. The portrait frame is drawn around each character's portrait from these bits; see what lasting effects show.
Sources
Locations refer to the game executable reference; the values are listed in the mage and cleric spells.
Setting and clearing: apply and remove a spell definition
and start a spell, with the
initial definition table (entry 64); the
potion routine; the spell routines of
Aid and Slow Poison in the spell routine table;
neutralize poison, the
monster attack,
remove all of a character's effects and the
character timer handler. These write the
character's spell_effects and the
party's spell effects.
Tests: the monster hit roll, the target choice of a close attack, the character hit roll, using a weapon, the defense recomputation, the character damage routines, the magic object hit, casting from the book, the monster spell hit, the condition evaluator, the held item and item drawing, the portrait frame, the face drawing, the character sheet and the monster drawing.