Spell definition flags
SpellDefinitionFlags · 16-bit little-endian flags field of
SpellDefinitionRuntime
Mage and cleric spells · Casting a spell › The steps of a cast · The engine in ten minutes
Every spell definition carries a word of flags that the casting code reads around the spell's own routine: whether the caster must choose a target or needs a free hand, whether the spell is refused when its effect is already active, how long it lasts, where its lasting effect is recorded, and which portraits are animated and redrawn.1
The animations are named after what their routines draw; their exact images are not examined.
/* Flags of a spell definition (EOB II DOS). */
typedef enum SpellDefinitionFlags {
SPELL_FLAG_CHARACTER_EFFECT_MASK = 0x0001, /* Set, then clear, the effect mask on the target character. */
SPELL_FLAG_RECALCULATE_DEFENSE = 0x0002, /* Recompute a character's defense after setting or clearing the effect. */
SPELL_FLAG_GLOBAL_EFFECT_MASK = 0x0004, /* Set, then clear, the effect mask on the party. */
SPELL_FLAG_TIMED = 0x0008, /* Start a timer on the target; when it expires, the effect ends. */
SPELL_FLAG_NO_REPEAT = 0x0010, /* Refuse the spell when the target or the party already has its effect. */
SPELL_FLAG_CHOOSE_TARGET = 0x0020, /* Ask which character to cast on. */
SPELL_FLAG_PARTY_DISPLAY = 0x0040, /* Animate and redraw every portrait; refuse if the party has the effect. */
SPELL_FLAG_TARGET_DISPLAY = 0x0080, /* Animate and redraw the target's portrait. */
SPELL_FLAG_ENDS_INVISIBILITY = 0x0100, /* Casting ends the caster's Invisibility. */
SPELL_FLAG_MEMBERS_EFFECT_MASK = 0x0200, /* Set, then clear, the effect mask on every present party member not dead. */
SPELL_FLAG_NEEDS_FREE_HAND = 0x0400, /* The caster needs a free hand, not holding another item of this kind. */
SPELL_FLAG_INCLUDE_DEAD_MEMBERS = 0x0800, /* With SPELL_FLAG_MEMBERS_EFFECT_MASK, dead members too. */
SPELL_FLAG_VIEW_ANIMATION = 0x1000, /* Play an animation over the dungeon view. */
SPELL_FLAG_REDRAW_TARGET = 0x2000, /* Redraw the target's portrait afterwards. */
SPELL_FLAG_UNKNOWN_4000 = 0x4000, /* Set by no definition; no test found. */
SPELL_FLAG_UNKNOWN_8000 = 0x8000 /* Set by no definition; no test found. */
} SpellDefinitionFlags;
What each flag does
The steps are those of casting a spell.
| Flag | When it is tested | Effect |
|---|---|---|
SPELL_FLAG_ENDS_INVISIBILITY | Casting | If the caster has SPELL_EFFECT_INVISIBILITY, the Invisibility effect ends first, with its message. |
SPELL_FLAG_NEEDS_FREE_HAND | Casting | With both hands full, the game prints "You must have a free hand for this spell." and stops; if a hand holds an item that a check recognizes (item entries 11 to 17: the conjured-weapon entries and one more), it prints "You can't have two of this spell type active." and stops. |
SPELL_FLAG_CHOOSE_TARGET | Casting, start | The game asks "Cast spell on which character?" and starts the spell once a character is chosen; at the start it prints the chosen character's name. Without it, the caster is the target. |
SPELL_FLAG_TARGET_DISPLAY | Start, end | The animation is played on the target's portrait, and the portrait is redrawn; SPELL_FLAG_CHOOSE_TARGET has the same effect. |
SPELL_FLAG_PARTY_DISPLAY | Start, end | When neither of the previous two is set: the animation is played on every portrait, and every portrait is redrawn. |
SPELL_FLAG_VIEW_ANIMATION | Start | When none of the previous three is set: an animation is played over the dungeon view. |
SPELL_FLAG_NO_REPEAT | Start | With it or with SPELL_FLAG_CHOOSE_TARGET, a target that already has a bit of the effect mask refuses the spell: "name is already under the effect of a spell spell." With it or with SPELL_FLAG_PARTY_DISPLAY, the same test on the party's effects: "The party is already under the effect of a spell spell." |
SPELL_FLAG_TIMED | Start | Starts a character timer on the target; see lasting spells. |
SPELL_FLAG_CHARACTER_EFFECT_MASK | Start, end | Sets, then clears, the effect mask in the target's spell_effects. |
SPELL_FLAG_GLOBAL_EFFECT_MASK | Start, end | Sets, then clears, the effect mask in the party's spell effects. |
SPELL_FLAG_MEMBERS_EFFECT_MASK | Start, end | Sets, then clears, the effect mask in the spell_effects of every member that is present (CHARACTER_ELIGIBLE_PRESENT) and not dead (CHARACTER_ELIGIBLE_NOT_DEAD), or only present with SPELL_FLAG_INCLUDE_DEAD_MEMBERS. |
SPELL_FLAG_RECALCULATE_DEFENSE | Start, end | Recomputes the defense of the last spell's target (see below). |
SPELL_FLAG_REDRAW_TARGET | Start, end | Like SPELL_FLAG_TARGET_DISPLAY for the redraw only. |
The animation and redraw tests are exclusive and ordered: the target's
portrait first (SPELL_FLAG_CHOOSE_TARGET or SPELL_FLAG_TARGET_DISPLAY,
and SPELL_FLAG_REDRAW_TARGET for the redraw), then every portrait, then
the view. At the end of a spell the redraw happens only when the end is
announced by a message.
Anomaly
When a lasting effect ends, SPELL_FLAG_RECALCULATE_DEFENSE recomputes the
defense of the target of the most recent spell, not necessarily that of the
character whose effect ends.2
Sources
Locations refer to the game executable reference; comparative sources are listed in the technical references.