Skip to content

Health ​

class in OpalScript

Tracks HP, applies damage and healing, and emits damaged/died/healed events.

Properties ​

MemberDescription
Health.HpCurrent health. Reaches 0 to trigger the died event.
Health.MaxHpUpper bound for HP; healing can't exceed this.
Health.InvulnerableIgnore all incoming damage while on (healing still works).

Methods ​

MemberDescription
Health.TakeDamageSubtract HP and emit damaged. Emits died if HP reaches zero.
Health.TakeDamageResultSubtract HP and emit damaged. Emits died if HP reaches zero.
Health.TakeDamageBatchPreflight distinct Health targets, then return one committed result per exact endpoint.
Health.HealAdd HP without exceeding maxHp.
Health.HealResultAdd HP without exceeding maxHp.
Health.SetHpSet current health, clamped to the supported health range.
Health.SetMaxHpSet maximum health and optionally adjust current health.
Health.RefillRestore HP to maxHp.
Health.KillForce HP to 0 and emit died.
Health.IsAliveWhether current health is above zero.
Health.IsDeadWhether current health is zero.
Health.IsAtFullWhether current health has reached maximum health.
Health.HpAtLeastWhether current health is at least the supplied value.
Health.HpBelowWhether current health is below the supplied value.

Events ​

MemberDescription
Health.damagedFires after HP decreases.
Health.healedEmitted after a committed heal; carries the immutable health change snapshot.
Health.diedFires for the committed transition to zero, even if a damage listener heals afterward.

See also ​