Combat routines
Routines · Data · Address index
Weapon attacks, hit rolls, damage, and flying objects that hit monsters or the party. The routines page explains how the entries are written.
0x1fdb9, 0x1f930 — Use a weapon slot, melee attack
- Ranges:
0x1fdb9–0x1ff45;0x1f930–0x1fb77 - Role:
0x1fdb9(character, hand slot, item) ends the character's Invisibility (0x21a8d(10, character, 1)) when itsspell_effectshave bit0x40, then dispatches on the item kind (properties_raw&0x7f): 1 →0x1f930(a result of 0 becomes −1), 2 →0x1fb78(thrown), 3 →0x1fbfd(launcher). When the result is positive (0x1fe76): item flag0x08adds it to the character'shit_points, uncapped (0x1fe85–0x1fe99); flag0x10clears the hand slot (0x1feb0–0x1fec8); then0x2059d(the monster inDS:0xcb70, result, 1). Always toggles bit slot ofdisabled_slots, stores the result in+0x14e+ slot and sets a character timer of 18 ticks with event slot + 2 (or slot when the result is below −2).0x1f930returns −3 for slots above 1, takes the nearest monster ahead, kills a monster with state bit0x20("The monster crumbles to dust!",DS:0x5571, result −2), otherwise makes the hit roll (type 1) and calls0x20662(monster, character, item, 1,0x100, plus0x01for a conjured item, category 5, effect 3). - Comparative source: REF-SCUMM-013,
useSlotWeaponandcloseDistanceAttack. - Webs: in
0x1f930, when no monster stands ahead (0x1f966), the attack reads the interaction type of the face ahead; when it is −1, every side of the block ahead whose reference has type −1 moves to the next reference and the view is marked for redraw (0x1f99f–0x1f9d3). Level 1 uses it to cut webs. Types 8 and 9 take another branch (0x1f9d8). - Used by: Attacking with a weapon › Using a weapon, Kinds of damage dealt to a monster, Lasting spell effects, Modes and provocation › What a monster's state changes, Monster state flags › Alternating melee attacks, Monster state flags › Turned to stone, Formation › Formation, Sound effects, Item kinds, Level 1: reference tables › The spider quarter
0x1fb78, 0x1fab3 — Throw a weapon, refill the hand
- Ranges:
0x1fb78–0x1fbfc;0x1fab3–0x1fb77 - Role:
0x1fb78(item kind 2) launches the hand item from the party's block at the launch position of the character's row (slots 0 and 1 front, 2 to 5 back), with the item's type as weapon type. Only when the launch succeeds (0x1fbbd) does it play sound0x0b, clear the hand and call0x1fab3(0x1fbec). Returns 0.0x1fab3(character, hand slot, type, quiver)moves into the hand the first item of inventory slots 24, 23 and 22 whose type is not type, or the first item at all when type is −1 (0x1fb06–0x1fb6a). With quiver nonzero and a quiver that is not empty, it takes the top quiver item instead (0x1fabd–0x1fb00). Its only caller passes −1 and 0 (0x1fbe0–0x1fbe6), so the game uses neither the quiver branch nor the type test. - Used by: On the floor and in the air › Throwing and launching items, Sound effects
0x1fbfd — Use a launcher
- Range:
0x1fbfd–0x1fdb8; the failure branch is at0x1fd8f - Role: (Item kind 3.) Takes the ammunition type of
the launcher's item type. Arrows are taken from hand 0, hand 1, then the
top of the quiver chain; other ammunition from the first of the 27 slots
holding that type. Without ammunition it returns −4, NO AMMO (
0x1fdb0). The ammunition is removed (0x1fc67,0x1fca7,0x1fcdc,0x1fd36), then launched from the character's row position with the launcher's type as weapon type; when no flight record is free, the branch at0x1fd8freturns without putting it back. Returns 0. - Used by: On the floor and in the air › Throwing and launching items, On the floor and in the air, Sound effects, Item types, Anomalies and bugs
0x1f55c — A character's hit roll
- Range:
0x1f55c–0x1f6e1, with the helpers0x1baa9(to-hit against an armour class),0x1b630(strength hit modifier),0x1b689(strength damage modifier) and0x1b6e2(dexterity hit modifier) - Role: Arguments: attacker slot, monster, item, attack type (1 melee and
the wound spells, 0 missiles). Hits when the attacker is negative or the
monster has
MONSTER_RUNTIME_TURNED_TO_STONE(0x1f5aa). With an item of kind 1 to 3, or none, misses a type with immunity0x0200when the item's value is at most 0, or with0x1000when it is at most 1. Needed roll =0x1baa9(slot, type armour class+0x00) − (value + strength or dexterity modifier);0x1baa9returns 20 − ((+0x26− 1) /DS:0x3466[g]) ×DS:0x3462[g] − AC with g =DS:0x1ed7[class]. Rolls 1d20, adds 1 when the party's spell effects have0x8400or the character's0x1000(0x1f692–0x1f6ad), clamps to 1–20 and sets the monster'sMONSTER_RUNTIME_PROVOKEDwhatever the result (0x1f68d, after the 1d20 at0x1f679); hits when the roll reaches the needed value. The modifier tables are the combat tables. - Comparative source: REF-SCUMM-013,
REF-SCUMM-020,
characterAttackHitTest. - Used by: Hit rolls › A character's hit roll, Lasting spell effects, Lasting spells › What lasting effects do, Modes and provocation › Reacting to damage, Modes and provocation › What a monster's state changes, Monster capabilities › Where it is used, Monster immunities, Monster state flags › Alternating melee attacks, Monster state flags › Provoked monsters, Monster state flags › Turned to stone, Level data (INF)
0x1ac5f — A monster's hit roll
- Range:
0x1ac5f–0x1ad06;0x1bb13returns hit chance − defense - Role: Rolls 1d20; unless it is 20, subtracts 2 for
spell_effectsbit0x800, 2 for bit0x10and 1 for party bit0x8000; hits on a 20 or when the roll reaches the type's hit chance (+0x01) minus the character'sdefense. Called by the monster melee attack with the attack number as its third argument, the character slot, and by the magic object hit with the target. - Comparative source: REF-SCUMM-013,
REF-SCUMM-021,
monsterAttackHitTest. - Used by: Hit rolls › A monster's hit roll, Lasting spell effects, Lasting spells › What lasting effects do, Melee attacks › The attack sequence, Level data (INF)
0x20662 — Damage to a monster
- Range:
0x20662–0x20807;0x1ecb6is the evasion test and0x1f7a1the missile test (item kind 2 or 3) - Role: Arguments: monster, count or attacker, sides or item, bonus or
strength switch, damage flags, saving-throw category and effect. With flag
0x100, the weapon damage; otherwise a dice roll. Unless the category is 5, a saving throw(monster, 0, type level+0x02, category, race 6) reduces the damage (0x206d7–0x2070c). Flags0x110with an item that is not a missile give 1 (0x2070e). Flag0x100with immunity0x0100halves the damage unless the class byte of item-type entry item number, atDS:0x9473+ 16 × item, has0x04(0x20736–0x20756): the entry is indexed by the item, not its type, and item numbers of 64 and more read past the table. Immunity0x2000divides weapon damage by 4 for a value below 3 and by 2 for 3, giving the value when the result is 0, and halves other damage (0x20758–0x207b4). Flag0x01with 1d100 below the type's signed byte+0x2agives 0. Then each pair of the immunity pair table whose flag and immunity are both set gives 0 (0x207d1–0x207fe). Returns the damage as a signed word;0x20808applies it when positive. - Comparative source: REF-SCUMM-013,
calcMonsterDamage,calcDamageModifers,tryMonsterAttackEvasion. - Used by: Damage to a monster › How the damage is reduced, Kinds of damage dealt to a monster, Monster immunities, Damage flags › Effects, Level data (INF), Anomalies and bugs
0x1f8b8 — A flying object hits a monster
- Range:
0x1f8b8–0x1f92f - Role: Arguments: a flight record and a monster slot. When the record's
launcher (
+0xb) is a character, makes the hit roll with attack type 0 (dexterity) and returns 0 on a miss; with −1 (a monster, a wall or a script) there is no roll. Then calls0x20808(monster, launcher, item, 0, flags, 5, 3) with flags0x110, or0x910for a character's throw, and returns 1. The item of the record, the flying one, gives the value and the dice. - Used by: Flying weapons › What a flying item hits
0x1f7c9 — A flying object hits the party
- Range:
0x1f7c9–0x1f8b7; the two> 2tests are at0x1f824and0x1f83b - Role: Argument: a flight record. Turns the item's quarter into a
quarter relative to the party with
DS:0x2352(0 front left, 1 front right, 2 back left, 3 back right) and picks up to two characters inDS:0x5530from twice that quarter, adding 1d2 − 1 when the quarter is above 2. Each candidate that passes the eligibility test with mask 3 takes damage(character, −1, item, 0,0x110, 5, 3); no hit roll is made. A second candidate is tried only when the quarter is above 2 and the record's direction is the party's or its opposite; the loop ends after the first candidate otherwise (0x1f89d–0x1f8ad). Returns 1 when someone was hit. The front/back test of the loop is< 2, the other two> 2: the location of the back-left anomaly. - Comparative source: REF-SCUMM-014,
flyingObjectPartyHit. - Used by: Flying weapons › What a flying item hits, Anomalies and bugs, Damage flags › Item-based damage
0x1b51e — A monster at a place
- Range:
0x1b51e–0x1b54c - Role: Arguments: a monster slot, a block, a position and a switch. Returns 1 when the monster stands on that block at that position, or at position 4, the middle of the block, when the switch is set. The flying-object hit test calls it with the switch set for every slot.
- Used by: Flying weapons › What a flying item hits