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, ...).
Syntax
Section titled “Syntax”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 "" |
Returns
Section titled “Returns”a number replaces the damage (0 cancels); false cancels the blow; nothing keeps it
Example
Section titled “Example”-- the training dummy never really hurtsfunction OnActorAttack(id, pid, damage, zone, part, weapon, dtype) if GetEntityData(id, "role") == "trainer" then return 1 endendSee also
Section titled “See also”OnActorDamage · SetActorHostile · OnPlayerDamage · the NPC actors group of the index
