Base Damageable
Base class for all Damageable entities. It provides Health and Damage related methods and events
Classes that share methods and events from this Base Class: Character, CharacterSimple, VehicleWheeled, VehicleWater.
๐ฆ Functionsโ
ApplyDamage: integer | Do damage to this entity | |
GetDamageMultiplier: float | Gets the Damage Multiplier of a bone | |
GetHealth: integer | Gets the current health | |
GetMaxHealth: integer | Gets the Max Health | |
IsDead: boolean | Returns if the entity is dead | |
Respawn | Respawns the Entity, filling its Health and moving it to its Initial Location | |
SetDamageMultiplier | Changes how much damage this entity takes on specific bones | |
SetHealth | Sets the Health of this Entity | |
SetMaxHealth | Sets the MaxHealth of this Entity |

ApplyDamageModerateโ
Do damage to this entity
It triggers all the related events and modifies the damage based on the bone. A heavy explosion also applies an impulse
local ret = my_damageable:ApplyDamage(damage, bone_name?, damage_type?, from_direction?, instigator?, causer?)
Parameters
| Name | Type | Description |
|---|---|---|
damage | integer | Amount of damage |
bone_name? | string | Name of the bone or socket Default |
damage_type? | DamageType | Type of the damage, used for effects and in the damage events Default DamageType.Shot |
from_direction? | Vector | Direction the damage came from Default Vector(0, 0, 0) |
instigator? | Player | The player which caused the damage Default nil |
causer? | any | The object which caused the damage Default nil |
Returns
| Type | Description |
|---|---|
| integer | the damage applied |

GetDamageMultiplierOptimalโ
Gets the Damage Multiplier of a bone
local multiplier = my_damageable:GetDamageMultiplier(bone_name)
Parameters
| Name | Type | Description |
|---|---|---|
bone_name | string | Name of the bone or socket |
Returns
| Type | Description |
|---|---|
| float | the damage multiplier of the bone |
See also SetDamageMultiplier.

GetHealthOptimalโ
Gets the current health
local health = my_damageable:GetHealth()
Returns
| Type | Description |
|---|---|
| integer | Current health |
See also SetHealth.

GetMaxHealthOptimalโ
Gets the Max Health
local max_health = my_damageable:GetMaxHealth()
Returns
| Type | Description |
|---|---|
| integer | Max Health |
See also SetMaxHealth.

IsDeadOptimalโ
Returns if the entity is dead
local is_dead = my_damageable:IsDead()
Returns
| Type | Description |
|---|---|
| boolean | Whether the entity is dead |

RespawnModerateโ
Respawns the Entity, filling its Health and moving it to its Initial Location
my_damageable:Respawn(location?, rotation?)

SetDamageMultiplierOptimalโ
Changes how much damage this entity takes on specific bones
my_damageable:SetDamageMultiplier(bone_name, multiplier)
Parameters
| Name | Type | Description |
|---|---|---|
bone_name | string | Name of the bone or socket |
multiplier | float | Damage multiplier for that bone, 1 is the default |
See also GetDamageMultiplier.

SetHealthOptimalโ
Sets the Health of this Entity
You can only call it on alive Entities (call Respawn first)
my_damageable:SetHealth(new_health)
Parameters
| Name | Type | Description |
|---|---|---|
new_health | integer | The new Health of this Entity |
See also GetHealth.

SetMaxHealthOptimalโ
Sets the MaxHealth of this Entity
my_damageable:SetMaxHealth(max_health)
Parameters
| Name | Type | Description |
|---|---|---|
max_health | integer | The new MaxHealth of this Entity |
See also GetMaxHealth.
๐ Eventsโ
Death | When Entity Dies | |
HealthChange | When Entity has its Health changed, or because took damage or manually set through scripting or respawning | |
Respawn | When Entity Respawns | |
TakeDamage | Triggered when this Entity takes damage |

Deathโ
When Entity Dies
<AnyDamageableClass>.Subscribe("Death", function(self, last_damage_taken, last_bone_damaged, damage_type_reason, hit_from_direction, instigator, causer)
-- Death was called
end)
Arguments
| Name | Type | Description |
|---|---|---|
self | Base Damageable | The Damageable that triggered the event |
last_damage_taken | integer | Damage of the hit that killed it |
last_bone_damaged | string | Bone hit by the last damage |
damage_type_reason | DamageType | Type of the damage that killed it |
hit_from_direction | Vector | Direction the last damage came from |
instigator | Player or nil | The Player responsible for the death, if any |
causer | Base Actor or nil | The object which caused the damage |

HealthChangeโ
When Entity has its Health changed, or because took damage or manually set through scripting or respawning
<AnyDamageableClass>.Subscribe("HealthChange", function(self, old_health, new_health)
-- HealthChange was called
end)
Arguments
| Name | Type | Description |
|---|---|---|
self | Base Damageable | The Damageable that triggered the event |
old_health | integer | Health before the change |
new_health | integer | Health after the change |

Respawnโ
When Entity Respawns
<AnyDamageableClass>.Subscribe("Respawn", function(self)
-- Respawn was called
end)
Arguments
| Name | Type | Description |
|---|---|---|
self | Base Damageable | The Damageable that triggered the event |

TakeDamageโ
Triggered when this Entity takes damage
<AnyDamageableClass>.Subscribe("TakeDamage", function(self, damage, bone, type, from_direction, instigator, causer)
-- TakeDamage was called
return 1.0
end)
Arguments
| Name | Type | Description |
|---|---|---|
self | Base Damageable | The Damageable that triggered the event |
damage | integer | Amount of damage taken |
bone | string | Damaged bone |
type | DamageType | Damage Type |
from_direction | Vector | Direction of the damage relative to the damaged actor |
instigator | Player | The player which caused the damage |
causer | any | The object which caused the damage |
Returns
| Type | Description |
|---|---|
| number | Return the multiplier to the final damage. Return 0 to cancel the damage (will still display animations, particles and apply impact forces). The default 1.0 |

