Skip to content

OnActorAttack

An actor’s blow landed on its opponent - change the damage, cancel it, or let it through.

The same shape and return rules as OnPlayerDamage. The blow is priced by the victim’s own game - the actor’s weapon through their armour - times [actors] attack_scale, at most [actors] max_damage. A mode without this callback hears the blow as OnPlayerDamage(pid, -1, ...).

function OnActorAttack(id, pid, damage, zone, part, weapon, dtype)
-- ...
end
Parameter Type
id number the actor
pid number the player struck
damage number what the player is about to lose
zone number the attack zone
part number the body part struck, 1 .. 6; 0 unknown
weapon string the actor’s weapon by its table name; "" bare-handed
dtype string "stab", "slash", "smash" or ""

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

-- the training dummy never really hurts
function OnActorAttack(id, pid, damage, zone, part, weapon, dtype)
if GetEntityData(id, "role") == "trainer" then return 1 end
end

OnActorDamage · SetActorHostile · OnPlayerDamage · the NPC actors group of the index