Health
class in OpalScript
Tracks HP, applies damage and healing, and emits damaged/died/healed events.
Properties
| Member | Description |
|---|---|
| Health.Hp | Current health. Reaches 0 to trigger the died event. |
| Health.MaxHp | Upper bound for HP; healing can't exceed this. |
| Health.Invulnerable | Ignore all incoming damage while on (healing still works). |
Methods
| Member | Description |
|---|---|
| Health.TakeDamage | Subtract HP and emit damaged. Emits died if HP reaches zero. |
| Health.TakeDamageResult | Subtract HP and emit damaged. Emits died if HP reaches zero. |
| Health.TakeDamageBatch | Preflight distinct Health targets, then return one committed result per exact endpoint. |
| Health.Heal | Add HP without exceeding maxHp. |
| Health.HealResult | Add HP without exceeding maxHp. |
| Health.SetHp | Set current health, clamped to the supported health range. |
| Health.SetMaxHp | Set maximum health and optionally adjust current health. |
| Health.Refill | Restore HP to maxHp. |
| Health.Kill | Force HP to 0 and emit died. |
| Health.IsAlive | Whether current health is above zero. |
| Health.IsDead | Whether current health is zero. |
| Health.IsAtFull | Whether current health has reached maximum health. |
| Health.HpAtLeast | Whether current health is at least the supplied value. |
| Health.HpBelow | Whether current health is below the supplied value. |
Events
| Member | Description |
|---|---|
| Health.damaged | Fires after HP decreases. |
| Health.healed | Emitted after a committed heal; carries the immutable health change snapshot. |
| Health.died | Fires for the committed transition to zero, even if a damage listener heals afterward. |