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, without armour on the actor.

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 ""

a number replaces the damage (0 cancels); false cancels the hit; nothing keeps it

-- 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