Skip to main content

Lasting spells

Magic · Casting a spell · SpellEffectFlags

In brief​

A lasting spell sets effect bits on its target, on the party or on every member, and starts a character timer whose length grows with the caster's level. Until the timer ends, the places of the game that test those bits change: hit rolls, defense, attacks, hands, poison, what the party sees. When the timer expires, the spell's end routine runs and the bits are cleared; some events end an effect earlier.

The timeline of a lasting spell. At the cast, the effect bits are set on the target, on the party or on every living member, and a character timer starts for unit × (base + per level × caster level) ticks. While it runs, the places of the game that test the bits change. When it expires, the game prints that the spell expires, runs the spell's end routine and clears the bits. Dispel Magic, an attack under Invisibility, poison under Slow Poison and the end of the Armor reserve end an effect earlier.
An effect lasts until its timer expires, unless an event ends it earlier.

The timer​

A spell with SPELL_FLAG_TIMED starts a character timer on its target, whose event is the definition number made negative. It lasts:

duration = unit × (base + per_level × caster_level) # in ticks

with the four timer parameters of the definition; the level is the caster's cleric level (a paladin's level minus 8) for a spell from the cleric book, and its mage level for a spell from the mage book; a spell cast from an item always counts level 9. The values of every timed spell are listed in the spell catalogue: a unit is 546 ticks, for instance Haste lasts 546 × (3 + level) ticks.

When the timer expires, the game prints "name's spell spell expires.", runs the spell's end routine and clears the effect bits from where the start put them.1

How long each spell lasts​

The definitions with TIMED last unit × (base + per level × level) ticks, where the level is the caster's; see lasting spells. A unit is 546 ticks except for Slow Poison.

DefinitionSpellBasePer levelUnit
3Detect Magic (mage)02546
5Shield05546
6Shocking Grasp01546
7Blur31546
8Detect Invisible05546
14Haste31546
18Vampiric Touch01546
21Improved Invisibility51546
29True Seeing (mage)01546
34Bless60546
37Detect Magic (cleric)02546
38Protection from Evil03546
39Aid11546
40Flame Blade41546
42Slow Poison0132760
45Magical Vestment05546
46Prayer01546
51Protection from Evil 10'03546
57True Seeing (cleric)01546

What lasting effects do​

Every test of the effect bits in the executable is accounted for; the complete list is on the SpellEffectFlags page.

A lasting spell acts in two ways: through its own routines, described in the attack spells, and through the places of the game that test its effect bit. The second kind is summed up here.2

What changesEffects
A character's hit roll+1 under Bless or Prayer, on the party, or Aid, on the character; see a character's hit roll.
A monster's hit roll on a character−2 for Protection from Evil and −2 for Blur on the character, −1 for Prayer on the party; see a monster's hit roll.
DefenseShield caps it at 4 and Magical Vestment at 5 + (L − 5) / 3. Armor gives 6, adjusted by dexterity, while its reserve lasts; when the defense is recomputed and the character's own is already better, the reserve is dropped and Armor protects no more, although its effect lasts.
Being attackedUnder Invisibility or Improved Invisibility, a monster's close attack passes over the character unless a 1d20 roll is below 5; under Shield, Magic Missiles do nothing.
HandsUnder Haste, a hand is ready 27 ticks after an attack instead of 54.
DamageUnder Slow Poison, poison deals nothing.
What the party seesDetect Invisible and True Seeing show hidden monsters; True Seeing also lifts illusion walls; Detect Magic tints magical items in the inventory, in the hands and under the cursor.
ScriptsA character under Invisibility is skipped by the script test for an eligible character.
Monster spellsMystic defense weakens one kind of monster spell, and that spell's hit ends it.

Some events end an effect before its timer: Dispel Magic ends them all; attacking with a hand item, or casting a spell that ends invisibility, ends Invisibility but not Improved Invisibility; being poisoned, by a monster or by a potion, ends Slow Poison, as does Neutralize Poison; damage that uses up the Armor reserve ends Armor.

The portraits show the effects too. Around each portrait the frame takes one colour when a protection is active — Shield, Blur, Protection from Evil, Magical Vestment, an Armor reserve or mystic defense on the party, which changes that colour — and another colour for Aid, Slow Poison, Haste or the party's Bless, Prayer or Detect Invisible; with both kinds, the two colours alternate along the frame. An invisible character's face is drawn with other colours, as are a poisoned and a petrified one, and the inventory page writes "POISON (SLOW)" instead of "POISONED" under Slow Poison.3

Magic reaches the rest of the game through the spells' own routines: monsters take damage, saving throws and conditions; the party is healed and cured; walls of force appear and disappear; items are identified, uncursed or conjured; food is created. Level scripts can react to any spell, through the spell-cast event and the last spell cast; see events that start scripts. Monsters cast their own spells at the party; see monster spells.

Sources​

Locations refer to the game executable reference.

Footnotes​

  1. Start a spell timer, the character timer handler and end a spell's effect. Comparative source: REF-SCUMM-013, setSpellEventTimer and removeCharacterEffect. ↩

  2. The tests listed on the SpellEffectFlags page, among them the character hit roll, the monster hit roll, the target choice of a close attack, the defense recomputation and the character timer handler. ↩

  3. The portrait frame, the face drawing and the character sheet. ↩