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, ...). An animal’s bite (SetAnimalHostile) comes here too: id is the animal, the damage is its bite’s (SetAnimalAttack) through the player’s armour, weapon is "a bite".

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

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

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