Skip to main content

Character eligibility tests

CharacterEligibilityMask · 16-bit argument of the character eligibility routine

The party · CharacterRuntime · The engine in ten minutes

Many effects apply only to some party members: the living ones, the conscious ones, those present. The game asks one routine whether a party slot passes a set of tests, and these bits choose the tests. The routine returns a nonzero value when the character passes every selected test.1

typedef enum CharacterEligibilityMask {
CHARACTER_ELIGIBLE_PRESENT = 0x01, /* CHARACTER_STATUS_PRESENT is set. */
CHARACTER_ELIGIBLE_NOT_DEAD = 0x02, /* hit_points is above -10 and CHARACTER_STATUS_PETRIFIED is clear. */
CHARACTER_ELIGIBLE_CONSCIOUS = 0x04, /* hit_points is above 0 and CHARACTER_STATUS_PETRIFIED is clear. */
CHARACTER_ELIGIBLE_NOT_PARALYZED_OR_PETRIFIED = 0x08, /* CHARACTER_STATUS_PARALYZED and CHARACTER_STATUS_PETRIFIED are both clear. */
CHARACTER_ELIGIBLE_NOT_POISONED = 0x10, /* CHARACTER_STATUS_POISONED is clear. */
CHARACTER_ELIGIBLE_NOT_PARALYZED = 0x20, /* CHARACTER_STATUS_PARALYZED is clear. */
CHARACTER_ELIGIBLE_HAS_FOOD = 0x40 /* food is greater than zero (unsigned). */
} CharacterEligibilityMask;

The comments describe what the routine tests, not necessarily why. The names NOT_DEAD and CONSCIOUS are inferred from the hit-point thresholds. The status bits are those of CharacterStatusFlags and the fields those of CharacterRuntime; hit_points is read as signed. food is also the byte that the death path sets to zero.2

How the routine behaves​

  • A mask bit that is not set adds no test, so a mask of 0 accepts every slot.
  • Higher mask bits are not tested.
  • The routine does not check that the slot is in range: a slot of -1 would read the memory before the first character.

Masks used by scripts​

MaskValueUsed by
CHARACTER_ELIGIBLE_PRESENT0x01Counting the party members who hold an item, in conditions.
PRESENT and NOT_DEAD0x03Hit-point changes, damage, experience awards, choosing the character named in a message.
PRESENT and CONSCIOUS0x05Finding a character in conditions.
PRESENT, NOT_DEAD, CONSCIOUS and NOT_PARALYZED_OR_PETRIFIED0x0fCounting the active characters in conditions.

These are the masks passed by the routines in the sources below; other callers can pass other masks.3

Masks used by character actions​

MaskValueUsed by
CHARACTER_ELIGIBLE_PRESENT0x01Swapping two characters; a single-target projectile reaching a slot.
PRESENT and NOT_DEAD0x03Choosing the character a monster attacks in melee.
PRESENT and CONSCIOUS0x05Eating the item in hand.
PRESENT, CONSCIOUS and NOT_PARALYZED_OR_PETRIFIED0x0dUsing a hand item (attacks, casting); the party check that starts the defeat sequence when nobody passes.

What each condition then allows is summarized under conditions.4

Masks used by resting​

MaskValueUsed by
CHARACTER_ELIGIBLE_PRESENT0x01Counting the characters present for Insal; the first test of the poison checks.
CHARACTER_ELIGIBLE_NOT_DEAD0x02After PRESENT: finding Insal.
CHARACTER_ELIGIBLE_NOT_POISONED0x10Failed after PRESENT: the poison question and the hourly poison damage.
PRESENT and NOT_DEAD0x03Choosing the most injured character; the eight-hour wounds and hunger.
PRESENT and CONSCIOUS0x05Recovering a spell.
PRESENT, CONSCIOUS and NOT_PARALYZED_OR_PETRIFIED0x0dThe healer that lets the game offer healing; the end of the rest when nobody passes.
PRESENT, NOT_DEAD and HAS_FOOD0x43Deciding whether spells are left to recover.

The resting section sums up what each condition allows during a rest.5

Sources​

Locations refer to the game executable reference.

Footnotes​

  1. Character eligibility routine. Comparative source: EoBCoreEngine::testCharacter in REF-SCUMM-013. ↩

  2. Character damage routines, death path. ↩

  3. Callers: hit-point adjustment, character damage, party experience, print a message, item-holder count and the expression evaluator. ↩

  4. Swap two characters, magic object hit, target choice, eat the item in hand, use the item of a slot and the party status check. ↩

  5. Rest with the most injured character, spells left to recover and Insal leaves. ↩