Skip to main content
Version: latest - a1.73.x βš–οΈ

Base Damageable

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

πŸ§‘β€πŸ’»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!
πŸ‘ͺ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.

🦠 Functions​

ReturnsNameDescription
Do damage to this entity
Gets the current health
Gets the Max Health
Respawns the Entity, fullying it's Health and moving it to it's Initial Location
Sets the Health of this Entity
Sets 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

β€” Returns (the damage applied).

local ret = my_damageable:ApplyDamage(damage, bone_name?, damage_type?, from_direction?, instigator?, causer?)
TypeParameterDefaultDescription
damage Required parameter No description provided
bone_name?No description provided
damage_type?DamageType.ShotNo description provided
Vectorfrom_direction?Vector(0, 0, 0)No description provided
Playerinstigator?nilThe player which caused the damage
causer?nilThe object which caused the damage

GetHealth

Gets the current health

β€” Returns .

local ret = my_damageable:GetHealth()

See also SetHealth.


GetMaxHealth

Gets the Max Health

β€” Returns .

local ret = my_damageable:GetMaxHealth()

See also SetMaxHealth.


Respawn

Respawns the Entity, fullying it's Health and moving it to it's Initial Location

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

SetHealth

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

my_damageable:SetHealth(new_health)
TypeParameterDefaultDescription
new_health Required parameter No description provided

See also GetHealth.


SetMaxHealth

Sets the MaxHealth of this Entity

my_damageable:SetMaxHealth(max_health)
TypeParameterDefaultDescription
max_health Required parameter No description provided

See also GetMaxHealth.

πŸš€ Events​

NameDescription
When Entity Dies
When Entity has it's Health changed, or because took damage or manually set through scripting or respawning
When Entity Respawns
Triggered 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)
TypeArgumentDescription
selfNo description provided
last_damage_takenNo description provided
last_bone_damagedNo description provided
damage_type_reasonNo description provided
Vectorhit_from_directionNo description provided
Player or instigatorNo description provided
or causerThe object which caused the damage

HealthChange

When Entity has it's 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)
TypeArgumentDescription
selfNo description provided
old_healthNo description provided
new_healthNo description provided

Respawn

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

TakeDamage

Triggered when this Entity takes damage

Return false to cancel the damage (will still display animations, particles and apply impact forces)
Damageable.Subscribe("TakeDamage", function(self, damage, bone, type, from_direction, instigator, causer)
-- TakeDamage was called
end)
TypeArgumentDescription
selfNo description provided
damageNo description provided
boneDamaged bone
typeDamage Type
Vectorfrom_directionDirection of the damage relative to the damaged actor
PlayerinstigatorThe player which caused the damage
causerThe object which caused the damage