OnActorDamage
A player hit an actor - change the damage, cancel it, or let it through.
The same shape and the same return rules as OnPlayerDamage: a number replaces the damage (0 cancels), false
cancels, nothing keeps it. The hit went through the same model as a hit on a player, without armour on the actor.
Syntax
Section titled “Syntax”function OnActorDamage(id, attacker, damage, zone, part, weapon, dtype) -- ...end| Parameter | Type | |
|---|---|---|
id |
number | the actor |
attacker |
number | the player who struck |
damage |
number | what the actor is about to lose |
zone |
number | the attack zone the attacker’s game recorded |
part |
number | the body part struck, 1 .. 6; 0 unknown |
weapon |
string | the weapon’s table name; "" bare-handed |
dtype |
string | "stab", "slash", "smash" or "" |
Returns
Section titled “Returns”a number replaces the damage (0 cancels); false cancels the hit; nothing keeps it
Example
Section titled “Example”-- the shopkeeper cannot be hurt; the arena opponent takes halffunction OnActorDamage(id, attacker, damage, zone, part, weapon, dtype) if GetEntityData(id, "role") == "shopkeeper" then return false end return damage * 0.5endSee also
Section titled “See also”OnActorDeath · OnActorAttack · OnPlayerDamage · GetActorHealth · the NPC actors group of the index
