Skip to content

DamageableComponent

Beta
DamageableComponent is a component which defines properties, events, and functions for objects which take damage. You can only apply this API to both a player and a non-player character (NPC). To convert an object to an NPC, attach a Character or Monster component to it.

Properties

number HitPointsBeta
Current amount of hit points.
number MaxHitPointsBeta
Maximum amount of hit points.

Functions

void ApplyDamage(number amount, [YaEntity enemy])Beta
Damages the damageable object.
  • amount indicates the numeric amount of damage to inflict. If it is negative, the object will be healed.
  • enemy identifies the one who caused the damage or heal. It will be sent to YaDamage via DamagedEvent.

Events

DamagedEvent<YaDamage>Beta
Fired when the damageable object takes damage.
ZeroHpEvent<void>Beta
Fired when the hit points are decreased to zero.