This event is invoked whenever an actor commits to an attack with their fists or a weapon, or a creature makes any attack. It occurs at the release time of the attack, such as the downstroke of a melee weapon or when an arrow is shot. For the player, it is when the attack button is released. A target is not required to be present for this event. For the actual moment the attack hits, use the
This event has specific combat mechanics occuring at this point. This is the time when the target has a chance to use its block skill, when on-strike enchantments may be applied, and when elemental shields do reflected damage. There is still a small period of time while the attack animation completes before the hit, so it is still possible for a target to move out of range (normally only seen with short weapons).
Lockpicks and probes do not invoke this event.
--- @param e attackEventData local function attackCallback(e) end event.register(tes3.event.attack, attackCallback)
This event can be filtered based on the
reference event data.
An event can be claimed by setting
true, or by returning
false from the callback. Claiming the event prevents any lower priority callbacks from being called.
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.
Example: Show a Message when the Player Attacks
local function myOnAttackCallback(e) -- Someone other than the player is attacking. if (e.reference ~= tes3.player) then return end -- We hit someone! if (e.targetReference ~= nil) then tes3.messageBox("You hit %s!", e.targetReference.object.name or e.targetReference.object.id) end end event.register(tes3.event.attack, myOnAttackCallback)