combatStart⚓︎
The combatStart event occurs when combat is about to begin between two actors. This event allows scripts to prevent combat from starting. An actor A can start combat with actor B, which will fire the event. Then the actor B may also start combat with actor A which will trigger the event again.
--- @param e combatStartEventData
local function combatStartCallback(e)
end
event.register(tes3.event.combatStart, combatStartCallback)
Tip
This event supports blocking by setting e.block
to true
or returning false
. Blocking the event prevents vanilla behavior from happening. For example, blocking an equip
event prevents the item from being equipped.
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⚓︎
actor
(tes3mobileActor): Read-only. The mobile actor who is entering combat.target
(tes3mobileActor): Read-only. The mobile actor who combat is being triggered against.
Examples⚓︎
Example: Stop certain actors from initiating combat with the player
---@param actor tes3mobileActor
local function isPacifistTarget(actor)
-- Here you can filter if the actor should initiate combat with the player.
-- ...
end
--- @param e combatStartEventData
local function forcedPacifism(e)
if (e.target == tes3.player and isPacifistTarget(e.actor)) then
return false
end
end
event.register(tes3.event.combatStart, forcedPacifism)