Skip to content

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.

function OnActorAttackActor(id, target, damage, zone, part, weapon, dtype)
-- ...
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 ""

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

-- the town guard never kills a bandit, it beats him down to a tenth of his health
function OnActorAttackActor(id, target, damage, zone, part, weapon, dtype)
if GetEntityData(id, "role") == "guard" then return math.min(damage, GetActorHealth(target) - 10) end
end

SetActorHostileToActor · OnActorAttack · OnActorDeath · the NPC actors group of the index