Skip to content

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, through the armour the actor wears of the items SetActorInventory gave it (an actor dressed by its presets has no armour that counts).

function OnActorDamage(id, attacker, damage, zone, part, weapon, dtype, bleeds, armour)
-- ...
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 ""
bleeds boolean whether the blow opens a bleeding wound by the server’s rules (SetBleedRules)
armour number the share of the blow the actor’s armour on that part took, 0 .. 0.85

a number replaces the damage (0 cancels); false cancels the hit; nothing keeps it. A second value true / false decides the bleeding

-- the shopkeeper cannot be hurt; the arena opponent takes half
function OnActorDamage(id, attacker, damage, zone, part, weapon, dtype)
if GetEntityData(id, "role") == "shopkeeper" then return false end
return damage * 0.5
end

OnActorDeath · OnActorAttack · OnPlayerDamage · GetActorHealth · the NPC actors group of the index