Entity Injured Incident||doc135518

September 20, 2022

Format

 ENTITY_DAMAGE
  • The class to which the function belongs:Entity

Description

This event is triggered when the entity takes damage.


Context

The context content of the event

name type Description
obj1 Entity Injured entity instance
obj2 Entity Entity instance of the damage source
damage number damage
oriDamage number Original damage value (damage before damage reduction is calculated)
skillName string skills that deal damage
damageIsCrit boolean Whether it is critical damage
cause string Cause of injury


Code Samples

On the server side of the entity templatemount script, register when the entity of this type is injuredCallback, if the damage dealt is greater than 5, thenbroadcast tipsInjured entity name

Trigger.RegisterHandler(this:cfg(), "ENTITY_DAMAGE", function(context)
    local entity = context.obj1
    local from = context.obj2
    local damage = context.damage
    if damage > 5 then
       World.CurWorld.SystemNotice(1, entity.name, 40)           --Broadcast object name    
    end
end)