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.
| Selector | Byte | Operands after the selector | Size |
|---|---|---|---|
SCRIPT_EXPERIENCE_PARTY | 0xe2 | amount: s16le | 4 bytes |
| Any other value | — | None | 2 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-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