Magic routines
Routines · Data · Address index
Spell books, casting from the book or from an item, targets, spell effects and their timers, and spell animations. The routines page explains how the entries are written.
0x21a8d — End a spell's effect
- Range:
0x21a8d–0x21bfa(file offset0x14c8d); the end routine is called at0x21af0 - Role: Arguments: definition number, party slot, announce flag. When the
flag is set, prints the message at
DS:0x574e("%s's %s spell expires."). Calls the definition's end routine (+0x0e) if not null, then clears theeffect_mask(+0x13): definition flag0x0001from the slot'sspell_effects(+0x149, at0x21b24),0x0004from the party spell effects, and0x0200from each character that passes the eligibility test with mask 1, then mask 2 unless flag0x0800is set (0x21b50–0x21bb1). Flag0x0002calls the defense recomputation for the slot inDS:0xcbc2(0x21bbe), the last spell's target, not the slot given. With the announce flag, flags0x20a0redraw the slot's portrait and otherwise0x0040every portrait. Called by the character timer handler for a negative event code (0x28469–0x2848c), and by the cast routine to end Invisibility. - Comparative source: REF-SCUMM-013,
removeCharacterEffect. - Used by: Character record › Status, hit points and class, Lasting spell effects, Lasting spells › The timer, Spell definition flags › Anomaly, Spell definition flags, Spell definition › How the game uses it, Character timers › Setting and running a timer, Magic, Anomalies and bugs
0x21f47 — Draw the spell-book page
- Range:
0x21f47–0x222c6, with0x21e4fand0x21f05 - Status: the coordinates and colours of its drawing calls
(
0x21f4f–0x220ff,0x2218a–0x2221c) are not read. - Role: Draws six tabs numbered 1 to 6 (x
0x44+ 18 i), the selected group beingDS:0xcd16(spell level − 1), then six lines: line i shows the name of slot 10 × group +DS:0xd0ab+ i when its value is 0 or more andDS:0xd0ab+ i < 9, so used slots and entry 9 are never shown, and an empty slot draws the empty name. A seventh row is ABORT SPELL (DS:0x57a5,DS:0x57b1when selected). While bit 2 of the caster's+0x20is set,0x21f05covers the lines with a grid of a shape; when slot 6 of the level is not ready, a shape (DS:0xe4ca) covers the page arrows, drawn by0x21e4f. The line selected isDS:0x936a(0–5, 6 for the abort row). For the cleric book (DS:0xe4c6= 1) a line's definition is the slot value + 33 (0x22c6a–0x22c9a). - Used by: Choosing a spell in the book › The book, Casting a spell
0x22326, 0x22428, 0x22ad1, 0x222c7 — Spell-book buttons
- Anomaly:
ANOMALY-152: in0x22ad1, the readiness test0x22c07–0x22c0bis bypassed for argument 7, the Space button, at0x22c0d–0x22c11; the selected slot is then read and passed to the cast with no test (0x22c6a–0x22ca4). - Role: The book's buttons (records from
DS:0x4840, entries 1 to 16 of the arrayDS:0x50d0that the button list links while the book is open).0x22326, the six tabs and keys 1–6: sets the group, shows the first page and selects its first ready line, otherwise the abort row, and writes+0x151,+0x150and+0x152back (0x22378–0x2239e).0x22428, a click on the arrows: swaps the page when slot 6 is ready or the second page is shown, selects line 0 and writes the position back (0x22461–0x22474).0x22ad1, the six lines, keys,and.(codes0x35,0x36) and Space (0x3d); the two keys first testdiat0x22b10, set only when a slot is ready (0x22b05), so a value left by the caller (0x2fb7b) passes the test (ANOMALY-144): a click on a ready line selects it and, unless bit 2 of the caster's+0x20is set (0x22c5c), casts it through0x2252e(0x22ca4); the two keys move to the previous or next ready entry, wrapping through the abort row and turning the page; Space casts the selected line, or closes the book on the abort row (0x22ca9–0x22cc2); the position is written back at0x22cd7–0x22cea.0x222c7, ABORT SPELL and Escape: clearsDS:0xe441, restores the background under the book and rebuilds the buttons. It is also called when the caster drops to 0 hit points or below (0x20aec), is paralyzed or petrified (0x20bbb), on a swap of characters, and from0x1ed9b, reached on the party's defeat and on a level load. - Used by: Choosing a spell in the book › The book, Choosing a spell in the book, Casting a spell, Anomalies and bugs
0x20f40 — Sort a character's spell slots
- Role: Bubble-sorts each of the 16 groups of ten slots from
+0x39(both slot arrays) by a key: a ready ID itself, a used one − ID + 40, an empty slot 80; ready spells come first by ID, then used ones, then empty slots. The camp menu calls it for every character when it closes (overlay 2470x44bf4) and at some points inside it (0x44b44). - Comparative source: REF-SCUMM-013,
sortCharacterSpellList. - Used by: Casting a spell › Using the spell book
0x2252e — Cast a spell from the book
- Range:
0x2252e–0x227bb(file offset0x1572e) - Role: Arguments: definition number and the hand slot used, or −1.
Records the number as the last spell cast. With definition
flag
0x0100, ends the caster's Invisibility when itsspell_effectshave bit0x40(0x21a8d(10, caster, 1)). With0x0400, refuses when both hand slots (+0xdd,+0xdf) hold items (messageDS:0x57bd) or when0x20e64accepts either hand's item (messageDS:0x57e8). Unless the definition is 62 (Turn undead), updates the spell slot (0x22646–0x22737) or, whenDS:0x71c8is set, spends the hand item. The slot update moves the entries after the cast one, up to entry 8 of the level, up one place (0x226cc) and stores −ID in entry 8 (0x226e8); entry 9 is never touched. When the selected line no longer holds a ready spell, the selection moves up one line, from the second page's first line to the first page's sixth, and from the first line to the ABORT SPELL row. Prints "%s casts %s." (DS:0x5817). With0x0020it asks for the target and returns; otherwise the caster becomes the target (DS:0xcbc2,DS:0xe5a8) and the spell is started. - Comparative source: REF-SCUMM-013,
castSpell. - Used by: Lasting spell effects, Casting a spell › The steps of a cast, Casting a spell › Using the spell book, Mage and cleric spells › Special entries, Spell definition flags, Spell definition › How the game uses it, Texts, Character record, Level 11: reference tables › The carvings and Dispel Magic
0x227bc — Start a spell
- Range:
0x227bc–0x22a8f(file offset0x159bc) - Role: Copies the definition's start routine to the
copied handler and plays its sound effect (
+0x12,0x2ca9a). Plays an animation on the target's portrait (flags0x00a0), otherwise on every portrait (0x0040), otherwise in the view (0x1000). With0x0020prints the target's name. Refuses the spell when flags0x0030and the target'sspell_effectsshare a bit with theeffect_mask(messageDS:0x582a), or flags0x0050and the party spell effects do (DS:0x5859). Otherwise, from0x22902: with0x0008starts the spell timer from the parameter pointer (+0x0a); calls the copied handler, skipped when null (0x2293d–0x22946), and stops if it setsDS:0xdf38, jumping from0x22951to the epilogue, past the end of an item cast (0x22a32–0x22a3a) that its other refusals reach, and, for a spell from the book, past its wait, page redraw and block event (0x22a3f–0x22a84, ANOMALY-69); only the conjured-weapon routines set the flag (0x23d49,0x24069,0x248fe); sets theeffect_maskwhere the end routine clears it (0x2296b,0x22988,0x22993–0x229f0);0x0002recomputes the target's defense;0x20a0redraws the target's portrait, otherwise0x0040every portrait. Then, for a spell from a book slot, sets bit 2 of the caster's byte+0x20and a 72-tick character timer with event 11; and dispatches block event0x800to the party's block with the spell being cast. - Comparative source: REF-SCUMM-013,
startSpell. - Used by: Anomalies and bugs, Block events › Who sends each event, The engine › How the systems connect, Lasting spell effects, Casting a spell › The steps of a cast, Casting a spell › Using the spell book, Magic › How the game stores spells, Events that start scripts, Mage and cleric spells › Special entries, Spell definition flags, Spell definition › How the game uses it, Sound effects, Level 11: reference tables › The carvings and Dispel Magic
0x20247 — Recompute a character's defense
- Range:
0x20247–0x2049f;0x202c7(file offset0x134c7), formerly listed as an "equipment modifier", is the per-item test inside its loop, whose anchorr-202c7is kept for links - Anomaly: the helmet slot's absence from the defense slot list is the location of an anomaly.
- Role: Sets the character's
defense(+0x1f) to 10 plus the dexterity modifier of byte+0x15. Then, for the four slots of the defense slot list (body armour, both hands, bracers; loop0x20283–0x20336), adds the type'sdefense_adjustment_rawand subtracts the item'svalue_rawfor an item of kind 0 whose type's class mask matches the character; in a hand only types 27 and 57 count (0x20303,0x20309), and hand 1 only when it can be used. When the body-armour slot's item has value 0, subtracts the larger value of the kind-0 items in the two ring slots (0x20341–0x203ef). At0x203f6–0x2041b, while+0x145is positive (Armor), a defense above 6 + the modifier becomes 6 + the modifier; otherwise+0x145is set to 0. Shield caps the defense at 4 and Magical Vestment at 5 + (cleric level − 5) / 3, through theirspell_effectsbits; the defense never goes below −10. Called after every exchange of items by the player (0x1d897,0x1d987) and by spells, not by the item loss. - Comparative source: REF-SCUMM-013,
recalcArmorClass. - Used by: Item kinds, What worn items change › Defense and rings, Lasting spell effects, Casting a spell › The steps of a cast, Lasting spells › What lasting effects do, Attributes and classes › Attributes, Attack spells › Notation, Spell definition flags › Anomaly, Spell definition flags, Move an inventory item to a block, The inventory, Characters of the game, Item types (ITEMTYPE.DAT), Item types, Item type entry, Anomalies and bugs
0x20e64 — Check a hand item for a hand spell
- Range:
0x20e64–0x20e7e - Role: Returns 1 for the item entries 11 to 17 (unsigned bounds
0x20e6band0x20e70,cmp si,0x11; ja), the conjured-weapon items and entry 17, one beyond the 11 to 16 that the conjured-item search0x21125examines (0x21148) (ANOMALY-137); a hand holding one keeps a character from casting a spell withSPELL_FLAG_NEEDS_FREE_HAND, and Remove Curse leaves them alone. - Comparative source: REF-SCUMM-013,
isMagicEffectItem. - Used by: Anomalies and bugs
0x22a90, 0x22485, 0x20fff — Cast a spell from an item
- Ranges:
0x22a90–0x22ad0;0x22485–0x2252d;0x20fff–0x2105c - Anomaly: the jump at
0x22951in the spell start. - Role:
0x22a90(character, definition, slot) saves the caster (DS:0xd0b0) and the book shown (DS:0xe4c6) inDS:0xef46andDS:0xef4a, setsDS:0x71c8to slot + 1, makes the character the caster, shows the cleric book for a definition above 33 and calls the cast routine. There0x22485replaces the marking of a book slot: item types 26, 34, 35 and 58 are removed; for types 48 and 62, unless the value is 5, the item is removed when the six low bits of itsflagsare 1 and those bits are decremented otherwise; other types are kept. At the end of the start (0x22a32), and when the target prompt is cancelled,0x20ffftoggles the hand's bit ofdisabled_slots, sets an 18-tick timer with event hand + 2, redraws the portrait, restores the saved caster and book and clearsDS:0x71c8. - Used by: Potions, scrolls and wands › Spells cast from items, Potions, scrolls and wands, Initial items (ITEM.DAT), Item state flags, Item types, Anomalies and bugs
0x215ff — Choose a spell's target
- Range:
0x215ff–0x21669 - Role: Button handler of the target prompt: stores the
chosen character as the target and starts the last spell
cast; with no character, prints "Spell aborted." (
DS:0x573d) and, for a spell cast from an item, runs0x20fff: the item is already spent. - Used by: Potions, scrolls and wands › Spells cast from items, The play screen › Waiting for a character
0x21d16 — Open a spell book
- Range:
0x21d16–0x21e4e - Role: Arguments: a character and a cleric flag. Makes the character
the caster, selects the cleric or mage slots and restores the book
position kept in the character's bytes
+0x150(entry),+0x151(group) and+0x152(offset 0 or 6); when the remembered entry is not a ready spell, selects the first ready one of its group, or none. Draws the book unless it is already open (DS:0xe441), rebuilds the button list (far call0xdfe:0x2fat0x21e40) and draws the page. The book buttons write the position back. - Used by: Using items › Food and other uses, Choosing a spell in the book › The book, Casting a spell, Character record
0x20ec1 — Start a spell timer
- Range:
0x20ec1–0x20f3f - Role: Arguments: definition number and the four parameter words base, unit, per level and update. Takes a
level of the caster (
DS:0xd0b0) from0x21219whenDS:0xe4c6is 1, otherwise from0x211b0, and sets a character timer on the target (DS:0xcbc2) of unit × base + unit × (per level × level) ticks, with the definition number negated as event code and update as the last argument. - Comparative source: REF-SCUMM-013,
setSpellEventTimer. - Used by: Lasting spells › The timer, Spell definition › How the game uses it, Magic
0x212c5 — Ask for a spell's target
- Role: Prints "Cast spell on which character? " (
DS:0x571d) and sets up the choice of a character; the spell starts once one is chosen. - Comparative source: REF-SCUMM-013,
castOnWhomDialogue. - Used by: Casting a spell › The steps of a cast, The play screen › Waiting for a character
0x21385, 0x212dc, 0x2140a — Spell animations
- Status: the images are not examined.
- Role:
0x21385(slot, or −1 for every character) draws eight steps over the portraits, redrawing each portrait in turn; a present character is drawn only if the character panel is closed or the character is selected.0x212dc(slot, step)draws one step: the portrait, then up to four small shapes, each chosen by a 2-bit field of the byteDS:0x55dc[step] (0x55e4,0x55e8), from the table atDS:0xcc34, placed byDS:0x55ecaround the portrait's position (DS:0x55f4,DS:0x5600), or at a fixed place when the panel is open;0x2140asaves part of the view and draws sixteen steps over it through slot 44 of the driver function table. - Comparative source: REF-SCUMM-013,
sparkEffectDefensiveandsparkEffectOffensive. - Used by: Casting a spell › The steps of a cast, The game clock › Pauses
0x22f37, 0x233b6 — Explosion and vortex animations
- Ranges:
0x22f37–0x233b5,0x233b6–0x23912 - Status: the bodies of the two routines apart from the counter stops
(
0x22f4a–0x2339f,0x233b9–0x23902) are not read, so the images are not examined. - Role:
0x22cfb(object)runs the explosion routine for a flying object's block.0x22f37draws an explosion over the view; the explosion routine0x22d19calls it at0x22f1cwith one of three parameter sets.0x22d19(block, …, flying object)first decides whether to draw: while the party rests it only plays sound 35 from the party's block (0x22d24–0x22d3b). Otherwise it looks for the block among the 18 visible blocks; when it is not there, nothing at all happens (0x22d72–0x22d77). The byteDS:0x56b7[position] (0, 0, 1, 2, 1, 0, 0, 0, 1, 2, 1, 0, 0, 2, 0, 0, 2, 0) then decides: 0 plays sound 35 from the party's block without a picture (0x22d86); 1 does the same when the object's direction and the party's are not on the same axis (0x22d9f–0x22dbe); otherwise the explosion is drawn and sound 35 played at once (0x22e9c).0x233b6draws the vortex of Cone of Cold, called by its start routine at0x24252. Both stop the shared counter while they draw (0x22f43–0x233a3,0x2348b–0x23906). - Comparative source: REF-SCUMM-022,
explodeObject(drawExplosion) andspellCallback_start_coneOfCold(drawVortex). - Used by: The game clock › Pauses, Sound effects
0x23a72–0x24eca — Spell start and end routines
-
Role: The routines named by the initial definition table, segment
0x13a7. "Hit" marks the second routine of a projectile spell, which0x2166acopies into the flying object and the hit test calls with the object (0x27d4c); for the other spells the second routine runs when the effect ends.Start Second Spell (definitions) What the routine does 0x23a72— Dispel Magic (12, 44) 0x2391bon every present character.0x23a9c— Improved Identify (9) Sets 0x40in the item flags (DS:0x71cc+ 14 × item) of both hand items of the target.0x23ad0— Armor (1) Byte +0x145= mage level + 8; messageDS:0x58e2when the target'sdefenseis already at most 6 + its dexterity modifier.0x23b33— Burning Hands (2) Six shapes ( DS:0x5890,0x5896,0x589c), then0x1b319on the block ahead: 1d3 + 2 × level, category 4.0x23c0d0x23c2bDetect Magic (3, 37) Redraw the held item ( 0x18c77) and the cursor (0x33cb0); called at0x22946, before the mask is set at0x22978, and at0x21b03, before it is cleared at0x21b31.0x23c490x23c6ahitMagic Missile (4) Launch object type 0; hit (1, 4, 1) × max(1, (level − 1) >> 1). 0x23c9d0x23d54Shocking Grasp (6) Conjured weapon of 1d8 + level in the free hand ( 0x21199); failure:DS:0x5912, ends definition 6,DS:0xdf38= 1. End: frees the first conjured item of the hands.0x23d9b0x23dbdhitMelf's Acid Arrow (11) Type 1; hit (2, 4, 0) × max(1, level / 3), with a hit roll. 0x23df20x23e14hitFireball (13) Type 2; hit (1, 6, 0) × level on the whole block. 0x23e430x23e65hitHold Person (15, 41) Type 3; hit on monsters: effect 0, category 4; on the party: up to 1d4 characters ( 0x23eea), from slot 1d6, 1 to 6 (0x23efd), held for 5 units.0x23f6a0x23f8chitLightning Bolt (17) Type 4; hit (1, 6, 0) × level; always reports a miss. 0x23fbb0x24074Vampiric Touch (18) Conjured weapon of (level >> 1)d6; failure DS:0x5929. End: capshit_pointsat+0x1d, then0x23d54.0x2409b— Fear (19) Effect 6, category 4, on every monster of the block ahead. 0x240f90x2411bhitIce Storm (20) Type 5; hit (1, 6, 0) × level, repeated on the four neighbours ( DS:0x58a2) when it hit.0x241ac— Remove Curse (22) Inventory slots 0–26 except 16: items with flag 0x20that are not conjured get0x20cleared and0x40set.0x2420f— Cone of Cold (23) Vortex ( 0x233b6); seven blocks from the cone offsetsDS:0x58d2[dir];0x20808(level, 4, level,0x41, category 4, effect 0).0x243040x24326hitHold Monster (24) Type 6; effect 1, category 4. 0x24440— Wall of Force (25) Temporary wall ahead. 0x24595— Disintegrate (26) Effect 4, category 4, on the first monster in line; then the wall of force ahead. 0x245f9— Flesh to Stone (27) Effect 5, category 4, on the nearest monster ahead; otherwise DS:0x594c.0x24661— Stone to Flesh (28) Clears status bit 0x08, otherwise0x20e52.0x2467d0x2468cTrue Seeing (29, 57) Illusion walls hidden, then shown. 0x2469b— Finger of Death (30), Slay Living (56) Effect 3, category 4; when saved (0), damage 2d8 + 1 with experience. 0x24708— Power Word Stun (31) Effect 2, category 5, when the monster's current hit points ( +0x0e) are below 90.0x2474e— Cause Light Wounds (35) 0x21bfb(1, 8, 0).0x24766— Cure Light Wounds (36) Heal 1d8. 0x2478a0x24839Aid (39) Fails on a dead or absent target; on an aided target ( +0x148> 0), messageDS:0x5966(0x247bb) and the Aid ends (0x24818–0x2482d); otherwise 1d8 into+0x148andhit_points, uncapped, and bit0x1000ofspell_effects. End: removes what is left of the bonus.0x2485f0x23d54Flame Blade (40) Conjured weapon of 1d4 + 4; failure DS:0x5997, but ends definition 6 and timer −6 (0x248e1–0x248f6).0x249090x24962Slow Poison (42) On a poisoned target: bit 0x2000ofspell_effectsand a timer(1, 32760, cleric level from0x24939, 1) at0x24930–0x24951; otherwise0x20e52, leaving the timer set at0x22905. End: clears the bit.0x24978— Create Food (43) food= 100 for every present living character.0x249a8— Remove Paralysis (47) Clears status bit 0x04on up to four characters.0x249e1— Cure Serious Wounds (49) Heal 2d8 + 1. 0x24a05— Cause Serious Wounds (48) 0x21bfb(2, 8, 1).0x24a1e— Neutralize Poison (50) 0x20e7fon a poisoned target, otherwise0x20e52.0x24a41— Cause Critical Wounds (52) 0x21bfb(3, 8, 3).0x24a5a— Cure Critical Wounds (53) Heal 3d8 + 3. 0x24a7e0x24aa0hitFlame Strike (54) Type 7; hit (6, 8, 0) on the whole block. 0x24abf— Raise Dead (55) When hit_pointsis −10 andrace_and_sex>> 1 is not 1:hit_points= 1; otherwise0x20e52.0x24af4— Harm (58) 0x21bfb(−1, −1, −1): the monster's maximum hit points (+0x0c) minus 1d4.0x24b07— Heal (59) Heal up to the maximum hit points; otherwise 0x20e52.0x24b56— Turn undead (62) Turn undead. 0x24e18— Lay on Hands (61) Heal 2 × the caster's byte +0x26.— 0x24e3dhitMonster spell, type 8 (63) Hit (12, 10, 6, 0); while party effect bit 17 ( DS:0x6dde& 2) is set, (4, 10, 6, 0) instead, and a hit clears the bit.— 0x24eadhitMonster spell, type 9 (65) Hit (0, 0, 18, 0): 18 to each present character, halved by a saving throw. — 0x24cdahitMonster spell, type 10 (66) On the party block: "The party has been hit by a death spell!" ( DS:0x59c5); from the first spell target, up to 1d4 characters whose first class level (+0x26) is below 8 take 300 points of damage.— 0x24c66hitMonster spell, type 11 (67) On the party block: the first spell target takes 300 points of damage, with "%s has been disintegrated!" ( DS:0x59a9), unless the ray saving throw with value 1 returns nonzero, which never happens. A saved target would be retried without moving on (0x24c91); unreachable.— 0x24d51hitMonster spell, type 12 (68) On the party block: the first spell target takes 3d8 + 3 with "%s has been hit by cause serious wounds." ( DS:0x59f1). The dice are those of Cause Critical Wounds (0x24a41), not those of Cause Serious Wounds (2d8 + 1,0x24a05).— 0x24db3hitMonster spell, type 13 (69) On the party block: from the first spell target, the first character for which the ray saving throw with value 2 returns 0 is petrified (category 5); otherwise the next target is tried ( 0x24e04). That saving throw always returns 1, so nobody is petrified. -
Comparative source: REF-SCUMM-013, the
spellCallback_start_*andspellCallback_end_*functions; REF-SCUMM-021, thespellCallback_end_monster_*functions. -
Used by: Character conditions, Lasting spell effects, Attack spells › Notation, Saving-throw categories
0x21735 — Magic object hit
- Role: Arguments: flying object, dice count, sides, bonus and level.
Reads the object's flags (
+0x0c):0x10also hits the attacker's side,0x01a single target,0x02the whole block,0x04a hit roll,0x08a saving throw of category 4 that halves the damage (otherwise category 5, which never saves). The level is taken as 1 when it is 0 or less. Monsters of the object's block, listed by0x1b442, each take the dice roll × level, kept in a signed byte (0x21834,0x2191b,0x21a27), through0x20808, with the definition'sdamage_flagsand the experience flag0x800when the attacker is a character. On the party's block, a whole-block object hits each slot 0–5 that passes the eligibility test with mask 1, each with its own hit roll and damage (0x218cc–0x21946). A single target is the spot of the object's position for the party's direction in the object spots (0x2194f–0x2196d); only a spot above 2 (cmpw $0x2/jleat0x21970) can become spot + 2, on a 1d2 roll, when slot 5 or 6 passes mask 1 (0x2197a–0x21992), so slot 4 is never chosen. A Magic Missile on a character withSPELL_EFFECT_SHIELDdoes no damage; otherwise the slot is hit only if itsstatus_flagsbit 0 is set (0x219ec), after a hit roll when the object needs one. With flag0x40, a hit makes the object explode (0x22cfb). - Comparative source: REF-SCUMM-013,
magicObjectDamageHit. - Used by: Character eligibility tests › Masks used by character actions, Kinds of damage dealt to a monster, Lasting spell effects, Conditions › Conditions, Formation › Who a projectile hits, Attack spells › Notation, Spell definition › How the game uses it, Saving-throw categories, Anomalies and bugs
0x211b0, 0x21219, 0x21199 — Caster levels and free hand
- Role:
0x211b0returns a character's mage level,0x21219its cleric or paladin level, from the level bytes at+0x26; a paladin level above 8 counts as level − 8, otherwise 1. Both return 9 whileDS:0x71c8is set, and, for slot −1, 5 or 9 depending on the current level.0x21199returns the hand slot a conjured weapon goes to: 1 when the second hand is empty, otherwise 0. - Comparative source: REF-SCUMM-013,
getMageLevel,getClericPaladinLevel. - Used by: Ranged attacks › Monster spells, Attack spells › Notation, Launch an object › Behavior
0x2391b — Remove all of a character's effects
- Role: Clears
spell_effectsand the bytes+0x145–+0x148(0x23947), then, from0x23977, for each of the ten character timers ends the effect of a negative event silently (0x21a8dwith announce 0) and clears every deadline and event, whatever its code. Then re-arms the timers, recomputes the defense, clears+0x20and+0x14d–+0x14f, resets+0x0dand+0x0ffrom+0x0eand+0x10, and redraws the portraits. Used by Dispel Magic and by the death path. - Comparative source: REF-SCUMM-013,
removeAllCharacterEffects. - Used by: Lasting spell effects, Attack spells › Notation, Character timers › Setting and running a timer, Character record › Unused bytes, Damage characters › Behavior, Attributes and classes, Anomalies and bugs
0x288e6 — Clear a character's timers with a given event
- Role: Clears every timer of the character whose event code is the one given, then re-arms the character's timer update.
- Used by:
0x20e52, 0x19956 — Spell messages
- Role:
0x20e52prints "no effect." (DS:0x5711);0x19956prints a warning and plays sound 79. - Comparative source: REF-SCUMM-013,
printWarning. - Used by: Sound effects
0x20e7f — Neutralize poison on a character
- Role: Clears status bit
0x02andSPELL_EFFECT_SLOW_POISON, clears the character's timers with event −34 (0x20ea9,0x288e6), and redraws its portrait. −34 is the end event of definition 34, Bless, not of Slow Poison (42). - Used by: Lasting spell effects, Anomalies and bugs
0x1b6fd — Dexterity defense modifier
- Role: Returns the word of the table at
DS:0x32e8for a dexterity score. - Comparative source: REF-SCUMM-013,
getDexterityArmorClassModifier. - Used by: Attributes and classes › Attributes
0x21bfb — Cause wounds
- Role: Arguments: dice count, sides and bonus. Refuses with "%s must be
in the front ranks to hit!" (
DS:0x577e) when the byte of the caster's slot inDS:0x56a2is 0. The four bytes there are 1, 1, 0, 0 and the next two bytes, read for slots 4 and 5, belong to the following table and are nonzero, so slots 4 and 5 may cast. Then takes the nearest monster ahead ("%s missed the monster.",DS:0x5766, when there is none), makes a hit roll (0x1f55c) and calls0x20808with damage flags0x801, category 4 and effect 2, which keeps the full damage on a successful save. With −1 for all three, the damage is the monster's maximum hit points (+0x0c) minus 1d4. - Comparative source: REF-SCUMM-013, the Cause Wounds and Harm spell callbacks.
- Used by: Attack spells › Notation, Anomalies and bugs
0x20808 — Damage a monster, with a saving throw
- Role: Arguments: monster, dice count, sides, bonus, damage flags,
saving-throw category and effect. Computes the damage with
0x20662, which rolls the saving throw (category 5 never saves; effect 0 halves, effect 2 keeps the damage), then calls the monster damage with the experience flag0x800of the damage flags when the damage is positive. - Comparative source: REF-SCUMM-013,
calcAndInflictMonsterDamage. - Callers:
0x1b3a0(Burning Hands through0x1b319, flags0x21),0x1eca2(turn undead,0x200),0x1f91f(flying item,0x110or0x910),0x21882(magic object hit, the definition'sdamage_flags),0x21caa(cause wounds,0x801) and0x242db(Cone of Cold,0x41); the melee attack calls0x20662directly (0x1fa9d,0x100or0x101). No overlay calls either routine and no pointer to them is stored, so no damage of kind0x0080or0x0400is ever produced. - Used by: Attack spells › Notation, Damage to a monster › Kinds that never occur, Kinds of damage dealt to a monster
0x1b442, 0x1b299, 0x24395, 0x1b319 — Finding spell targets
- Role:
0x1b442lists the monsters of a block hit at a position and direction, singly or the whole block.0x1b299finds the nearest monster ahead of a character: the centre spot first, then the spots ofDS:0x30e6.0x24395follows the line ahead for up to the given number of blocks (0x1e36f) and stops at a wall withoutWALL_RUNTIME_PASSAGE(0x243db).0x1b319damages the monsters at the six positions of the table at file offset0x2d340for the party's direction; for north the entry is 2, 3, 4, 1, 2, 5, so position 0 is never hit and position 2 twice. - Comparative source: REF-SCUMM-013,
findBlockMonsters,getClosestMonster,findSingleSpellTarget; the data-tool tablekEoB2BurningHandsDestDOS. - Used by: Attack spells › Notation, Wall properties, Anomalies and bugs
0x1b242 — Monsters of a block by position
- Range:
0x1b242–0x1b298 - Role:
0x1b242(array, block)fills six words with −1, then stores in the entry position the slot of each monster of the block. When two monsters share a position the later slot stays.0x1b299and0x1b319use it (0x1b2a9,0x1b329). - Used by:
0x1b3ba — The monster a single-target object hits
- Range:
0x1b3ba–0x1b441 - Role:
0x1b3ba(block, position, direction)searches the 30 monster slots for monsters of the block. One at exactly position is returned at once (0x1b405–0x1b409), even if an earlier slot already ranked in the table. Otherwise it keeps the monster whose position comes first in the row of the table for that direction and position, the earlier slot on a tie (0x1b40f–0x1b426), and returns −1 when the block has no monster.0x1b442calls it for an object with flag0x01and without0x02(0x1b4b3, flags read by the magic object hit at0x2174c–0x2175b). - Used by: Attack spells › Projectiles
0x239e7, 0x23a36 — First and next spell target in the party
- Ranges:
0x239e7–0x23a35,0x23a36–0x23a71 - Role:
0x239e7starts at slot 1d6, 1 to 6 (0x239eb–0x239fc), and returns the first slot passing eligibility mask 3, wrapping to 0 only after slot 6 (0x23a1e), within six tests counted inDS:0xef48;0x23a36continues from a given slot with the same count. Slot 6 lies past the six character records. Both return −1 when no slot passes. Used by Hold Person on the party and by the monster spell hits of types 10 to 13. - Comparative source: REF-SCUMM-021,
findFirstCharacterSpellTargetandfindNextCharacterSpellTarget. - Used by: Ranged attacks › Monster spells
0x20b26 — Afflict a character with a condition
- Range:
0x20b26–0x20c4a - Role: Arguments: a character, a
CharacterStatusFlagsbit, a string, a saving-throw category, a duration, a timer event and a no-refresh flag. Returns without effect when the bit is already set and the no-refresh flag is set (0x20b37–0x20b48), when the character fails eligibility mask 3 (0x20b4b), or when the category is not 5 and the character saves (0x20b61–0x20b76).CHARACTER_STATUS_PETRIFIEDends all the character's spells and leaves onlyCHARACTER_STATUS_PRESENTandCHARACTER_STATUS_PETRIFIED; another bit is added to the status. Paralysis and petrification close the spell book when it is open for that character (0x20bbb–0x20bdc). A nonzero duration starts a character timer of duration × 546 ticks with the event (0x20bdf–0x20c09). Prints "%s is %s!" (DS:0x55cf). Users: the monster melee attack (poison, paralysis, petrification), the mind blast of the ranged action, the petrification of monster spell type 13 (0x24db3), which its saving throw never lets through, and Hold Person on the party (CHARACTER_STATUS_PARALYZED, "held", 5 units, event 9). - Comparative source: REF-SCUMM-013,
REF-SCUMM-021,
statusAttack. - Used by: Character conditions › How a character gets a condition, Character conditions, Melee attacks › Effects on characters, Monster capabilities › Where it is used, Saving-throw categories › Other uses of the categories, Character record › Status, hit points and class
0x21d69, 0x21db1, 0x22646 — Spell names and slots
- Addresses:
0x21d69,0x21db1,0x22646(file offsets0x14f69,0x14fb1,0x15846) - Role: Pair spell names with a character's spell slots, scan for positive slots, and rearrange and negate slots.
- Used by: Character record › Spell slots, Spell name entry › Layout