Skip to main content

Award experience

SCRIPT_AWARD_EXPERIENCE · opcode 0xeb · 2 or 4 bytes

Script virtual machine · Opcode list · Scripted experience awards

Shares an amount of experience between the eligible party members. No reference script uses this instruction.

Encoding​

Offsets count from the opcode byte. Words are little-endian. The byte at offset 1 is a ScriptExperienceTarget.

SelectorByteOperands after the selectorSize
SCRIPT_EXPERIENCE_PARTY0xe2amount: s16le4 bytes
Any other value—None2 bytes

Example (constructed, not from a level): eb e2 2c 01 shares 300 experience points.

Behavior​

For SCRIPT_EXPERIENCE_PARTY, the game counts the party slots that are present and not dead (CHARACTER_ELIGIBLE_PRESENT and CHARACTER_ELIGIBLE_NOT_DEAD of CharacterEligibilityMask). If there is at least one, amount is divided by that count with signed integer division, rounding toward zero, and each eligible member, in slot order, receives the share. If none is eligible, nobody receives anything.1

Each member's share goes through the ordinary experience rules, the same as for a killed monster: it is divided again between the character's classes, with signed division, and added to each class's experience; a class whose experience is then above its next threshold gains a level — one level at most per award — with its hit points, message and sound.1

A negative amount takes experience away the same way. It never removes a level.

Edge cases​

Anomaly

ANOMALY-87 — Experience is added as a signed value but compared with the thresholds as an unsigned one. A negative award that takes a class's experience below zero therefore leaves a value that reads as larger than any threshold: the class gains a level at once, with its hit points, message and sound, and one more at each later award of any kind, even an award of 0, while its experience stays below zero, up to level 13. A faithful reimplementation compares the 32-bit experience without its sign. The reference scripts never run this instruction.1

Sources​

Footnotes​

  1. Handler for 0xeb, the experience routines, the level gain and the eligibility test. Comparative sources: oeob_increasePartyExperience in REF-SCUMM-003 and EoBCoreEngine::increasePartyExperience in REF-SCUMM-013. Usage comes from decoding the scripts reachable in the 16 reference INF files. ↩ ↩2 ↩3