Base Damageable
Base class for all Damageable entities. It provides Health and Damage related methods and events.
Base ClassAPI Source
๐ชBase Class
This is a Base Class, an abstract definition that shares common methods and events with it's child classes. You cannot spawn it, and you cannot call anything on the Base Class name itself. Use any class that inherits it.
Classes that share methods and events from this Base Class: Character, CharacterSimple, VehicleWheeled, VehicleWater.
Classes that share methods and events from this Base Class: Character, CharacterSimple, VehicleWheeled, VehicleWater.
๐ฆ ย Functionsโ
| Returns | Name | Description | |
|---|---|---|---|
| integer | ApplyDamage | Do damage to this entity | |
| float | GetDamageMultiplier | Gets the Damage Multiplier of a bone | |
| integer | GetHealth | Gets the current health | |
| integer | GetMaxHealth | Gets the Max Health | |
| boolean | IsDead | 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 |
Moderate

ApplyDamageโ
Do damage to this entity, will trigger all related events and apply modified damage based on bone. Also will apply impulse if it's a heavy explosion
local ret = my_damageable:ApplyDamage(damage, bone_name?, damage_type?, from_direction?, instigator?, causer?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| integer | damage | Required parameter | Amount of damage |
| string | bone_name? | | Name of the bone or socket |
| DamageType | damage_type? | DamageType.Shot | Type of the damage, used for effects and in the damage events |
| Vector | from_direction? | Vector(0, 0, 0) | Direction the damage came from |
| Player | instigator? | nil | The player which caused the damage |
| any | causer? | nil | The object which caused the damage |
Returns
| Type | Description |
|---|---|
| integer | the damage applied |
Optimal

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

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

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

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

Respawnโ
Respawns the Entity, filling its Health and moving it to its Initial Location
my_damageable:Respawn(location?, rotation?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector | location? | initial location | If not passed will use the initial location passed when the Entity spawned |
| Rotator | rotation? | Rotator(0, 0, 0) | Rotation to respawn with |
Optimal

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

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

SetMaxHealthโ
Sets the MaxHealth of this Entity
my_damageable:SetMaxHealth(max_health)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| integer | max_health | Required parameter | The new MaxHealth of this Entity |
See also GetMaxHealth.
๐ย Eventsโ
| Name | Description | |
|---|---|---|
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
| Type | Argument | Description |
|---|---|---|
| Base Damageable | self | The Damageable that triggered the event |
| integer | last_damage_taken | Damage of the hit that killed it |
| string | last_bone_damaged | Bone hit by the last damage |
| DamageType | damage_type_reason | Type of the damage that killed it |
| Vector | hit_from_direction | Direction the last damage came from |
| Player or nil | instigator | The Player responsible for the death, if any |
| Base Actor or nil | causer | 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
| Type | Argument | Description |
|---|---|---|
| Base Damageable | self | The Damageable that triggered the event |
| integer | old_health | Health before the change |
| integer | new_health | Health after the change |

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

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

