Skip to main content

Change hit points

SCRIPT_MODIFY_CHARACTER_HP · opcode 0xf4 · 3 bytes

Script virtual machine · Opcode list · Adjusting character hit points

Adds a signed amount to the hit points of one party member or of the whole party, without exceeding their maximum. No reference script uses this instruction.

Encoding​

Offsets count from the opcode byte.

OffsetTypeFieldMeaning
0u8opcode0xf4
1s8characterParty slot 0–5, or SCRIPT_CHARACTER_ALL (−1) from ScriptCharacterTarget.
2s8adjustmentSigned amount added to the hit points, −128 to 127.

Example (constructed, not from a level): f4 ff 05 adds 5 hit points to every eligible party member.

Behavior​

The handler applies the adjustment once to the given slot, or to slots 0 to 5 in turn for SCRIPT_CHARACTER_ALL. For each slot:1

  1. The slot must pass the eligibility test for a present, not dead member (CHARACTER_ELIGIBLE_PRESENT and CHARACTER_ELIGIBLE_NOT_DEAD of CharacterEligibilityMask); otherwise it is skipped.
  2. adjustment is added to hit_points (CharacterRuntime), and a result above hit_points_max is lowered to it. There is no lower limit.
  3. The character's hit-point display is redrawn — a bar with the "Bar Graphs" option, the two numbers otherwise; with the character panel open, only for the selected character — and then its portrait.

Nothing else happens: no message and no sound. The same hit-point routine heals characters when they drink a potion.

Edge cases​

  • Slot values outside 0–5 other than −1 are not checked: they read and write the memory past (or before) the six character records as if it held a character, 345 bytes per slot, wrapping round within the data segment.
  • With the original files, slots 6 and 7 never pass the test for a present, not dead member, so they do nothing. Slot 6's status byte is the high byte of the step limit, 0 on every level. Slot 7's is entry 32 of the sound-effect table: 6 or 0 with an SND file, which is not present, and 13 or 255 with an ADL file, which is present but has CHARACTER_STATUS_PETRIFIED set and so fails NOT_DEAD.
  • Other values reach unrelated data around the data segment, and which of them pass depends on that data at the moment. In one run on level 1 with CATACOMB.ADL loaded, 30 did: 24, 27, 29 to 31, 36, 37, 48, 49, 52 to 54, 58, 59, 80, 87, 103, −128, −104, −103, −87, −49, −45, −39, −35, −31, −29, −25, −21 and −3. When those bytes pass the test, a word of that data is changed and the hit-point display and portrait are drawn from it (what appears is unknown).

Anomaly

ANOMALY-86 — A negative adjustment can leave the hit points at any value. Unlike damage, which stops at −10 and then runs the death routine, this instruction neither clamps at −10 nor kills: the character keeps its conditions, food and lasting effects. From −10 down it fails the NOT_DEAD test, so the game treats it as dead: no later adjustment, positive or negative, applies to it any more. The inventory page prints DEAD only at exactly −10 and no state below it. A faithful reimplementation applies the sum without a lower limit. The reference scripts never run this instruction.1

Sources​

Footnotes​

  1. Handler for 0xf4, the hit-point adjustment, the hit-point display, the portrait, the eligibility test and the death routine of damage. Comparative source: oeob_modifyCharacterHitPoints in REF-SCUMM-003. Usage comes from decoding the scripts reachable in the 16 reference INF files. The values that pass the test come from running the handler in a processor emulator. ↩ ↩2