Skip to main content
Version: bleeding-edge 🩸

Base Damageable

Base class for all Damageable entities. It provides Health and Damage related methods and events.

👪Base Class
This is a Base Class. Base Classes are abstract definitions used to share common methods and events between related child classes, thus you cannot spawn it directly.

Classes that share methods and events from this Base Class: Character, CharacterSimple, VehicleWheeled, VehicleWater.
🧑‍💻API Source
This page is auto-generated! The Functions, Properties and Events described here are defined in our GitHub's API Repository! Feel free to commit suggestions and changes to the source .json API files!

🦠 Functions

ReturnsNameDescription
integerApplyDamageDo damage to this entity
floatGetDamageMultiplierGets the Damage Multiplier of a bone
integerGetHealthGets the current health
integerGetMaxHealthGets the Max Health
booleanIsDeadReturns if the entity is dead
RespawnRespawns the Entity, filling its Health and moving it to its Initial Location
SetDamageMultiplierChanges how much damage this entity takes on specific bones
SetHealthSets the Health of this Entity
SetMaxHealthSets the MaxHealth of this Entity

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

TypeParameterDefaultDescription
integerdamage Required parameter No description provided
stringbone_name?No description provided
DamageTypedamage_type?DamageType.ShotNo description provided
Vectorfrom_direction?Vector(0, 0, 0)No description provided
Playerinstigator?nilThe player which caused the damage
anycauser?nilThe object which caused the damage

Returns

TypeDescription
integerthe damage applied

GetDamageMultiplier

Gets the Damage Multiplier of a bone
local multiplier = my_damageable:GetDamageMultiplier(bone_name)

Parameters

TypeParameterDefaultDescription
stringbone_name Required parameter No description provided

Returns

TypeDescription
floatthe damage multiplier of the bone

See also SetDamageMultiplier.


GetHealth

Gets the current health
local health = my_damageable:GetHealth()

Returns

TypeDescription
integerhealth

See also SetHealth.


GetMaxHealth

Gets the Max Health
local max_health = my_damageable:GetMaxHealth()

Returns

TypeDescription
integermax_health

See also SetMaxHealth.


IsDead

Returns if the entity is dead
local is_dead = my_damageable:IsDead()

Returns

TypeDescription
booleanis_dead

Respawn

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

Parameters

TypeParameterDefaultDescription
Vectorlocation?initial locationIf not passed will use the initial location passed when the Entity spawned
Rotatorrotation?Rotator(0, 0, 0)No description provided

SetDamageMultiplier

Changes how much damage this entity takes on specific bones
my_damageable:SetDamageMultiplier(bone_name, multiplier)

Parameters

TypeParameterDefaultDescription
stringbone_name Required parameter No description provided
floatmultiplier Required parameter No description provided

See also GetDamageMultiplier.


SetHealth

Sets the Health of this Entity. You can only call it on alive Entities (call Respawn first)
my_damageable:SetHealth(new_health)

Parameters

TypeParameterDefaultDescription
integernew_health Required parameter No description provided

See also GetHealth.


SetMaxHealth

Sets the MaxHealth of this Entity
my_damageable:SetMaxHealth(max_health)

Parameters

TypeParameterDefaultDescription
integermax_health Required parameter No description provided

See also GetMaxHealth.

🚀 Events

NameDescription
DeathWhen Entity Dies
HealthChangeWhen Entity has its Health changed, or because took damage or manually set through scripting or respawning
RespawnWhen Entity Respawns
TakeDamageTriggered when this Entity takes damage

Death

When Entity Dies
Damageable.Subscribe("Death", function(self, last_damage_taken, last_bone_damaged, damage_type_reason, hit_from_direction, instigator, causer)
-- Death was called
end)

Arguments

TypeArgumentDescription
Base DamageableselfNo description provided
integerlast_damage_takenNo description provided
stringlast_bone_damagedNo description provided
DamageTypedamage_type_reasonNo description provided
Vectorhit_from_directionNo description provided
Player or nilinstigatorNo description provided
Base Actor or nilcauserThe object which caused the damage

HealthChange

When Entity has its Health changed, or because took damage or manually set through scripting or respawning
Damageable.Subscribe("HealthChange", function(self, old_health, new_health)
-- HealthChange was called
end)

Arguments

TypeArgumentDescription
Base DamageableselfNo description provided
integerold_healthNo description provided
integernew_healthNo description provided

Respawn

When Entity Respawns
Damageable.Subscribe("Respawn", function(self)
-- Respawn was called
end)

Arguments

TypeArgumentDescription
Base DamageableselfNo description provided

TakeDamage

Triggered when this Entity takes damage

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.
Damageable.Subscribe("TakeDamage", function(self, damage, bone, type, from_direction, instigator, causer)
-- TakeDamage was called
return 1.0
end)

Arguments

TypeArgumentDescription
Base DamageableselfNo description provided
integerdamageNo description provided
stringboneDamaged bone
DamageTypetypeDamage Type
Vectorfrom_directionDirection of the damage relative to the damaged actor
PlayerinstigatorThe player which caused the damage
anycauserThe object which caused the damage