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.
| Offset | Type | Field | Meaning |
|---|---|---|---|
| 0 | u8 | opcode | 0xf4 |
| 1 | s8 | character | Party slot 0–5, or SCRIPT_CHARACTER_ALL (−1) from ScriptCharacterTarget. |
| 2 | s8 | adjustment | Signed 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
- The slot must pass the eligibility test for a present, not dead member
(
CHARACTER_ELIGIBLE_PRESENTandCHARACTER_ELIGIBLE_NOT_DEADofCharacterEligibilityMask); otherwise it is skipped. adjustmentis added tohit_points(CharacterRuntime), and a result abovehit_points_maxis lowered to it. There is no lower limit.- 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_PETRIFIEDset and so failsNOT_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.ADLloaded, 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-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