OnActorAttackActor
An actor’s blow landed on another actor - change the damage, cancel it, or let it through.
Fires for an actor set on another with SetActorHostileToActor (or one fighting back). The server decides these
blows itself: the attacker’s weapon - or its fists - against the body part struck, times [actors] attack_scale, at
most [actors] max_damage. A blow the target blocked, or one on an invulnerable actor, never
comes here. The return rules are OnActorAttack’s.
Syntax
Section titled “Syntax”function OnActorAttackActor(id, target, damage, zone, part, weapon, dtype, bleeds, armour) -- ...end| Parameter | Type | |
|---|---|---|
id |
number | the attacking actor |
target |
number | the actor struck |
damage |
number | what the target is about to lose |
zone |
number | the attack zone |
part |
number | the body part struck, 1 .. 6 |
weapon |
string | the attacker’s weapon by its table name; "fists" 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 target’s armour on that part took, 0 .. 0.85 |
Returns
Section titled “Returns”a number replaces the damage (0 cancels); false cancels the blow; nothing keeps it. A second value true / false decides the bleeding
Example
Section titled “Example”-- the town guard never kills a bandit, it beats him down to a tenth of his healthfunction OnActorAttackActor(id, target, damage, zone, part, weapon, dtype) if GetEntityData(id, "role") == "guard" then return math.min(damage, GetActorHealth(target) - 10) endendSee also
Section titled “See also”SetActorHostileToActor · OnActorAttack · OnActorDeath · the NPC actors group of the index
