attackHit⚓︎
This event is invoked whenever an actor makes an attack with their fists or a weapon, or a creature makes any attack. It occurs at the moment a melee attack would hit, at the end of a melee weapon strike. For projectile attacks, it is when an arrow is about to detach from its bow. A target is not required to be present for this event.
Lockpicks and probes do not invoke this event.
--- @param e attackHitEventData
local function attackHitCallback(e)
end
event.register(tes3.event.attackHit, attackHitCallback)
Tip
This event can be filtered based on the reference
event data.
Tip
An event can be claimed by setting e.claim
to true
, or by returning false
from the callback. Claiming the event prevents any lower priority callbacks from being called.
Event Data⚓︎
mobile
(tes3mobileActor): Read-only. The mobile actor making the attack.reference
(tes3reference): Read-only. A shortcut to the reference that is attacking.targetMobile
(tes3mobileActor): Read-only. The mobile actor being attacked. May be nil, e.g. if nothing was targeted.targetReference
(tes3reference): Read-only. A shortcut to the reference being attacked. May be nil, e.g. if nothing was targeted.
Examples⚓︎
Example: Convert Hits to Misses
local function onAttackHitCallback(e)
-- Set damage to zero to convert the physical hit to a miss.
tes3.messageBox("Somehow it missed!")
e.mobile.actionData.physicalDamage = 0
end
event.register(tes3.event.attackHit, onAttackHitCallback)