don't attack friendly actors

This commit is contained in:
Lilian Jónsdóttir 2020-07-30 00:12:18 -07:00
parent b6059b2bb8
commit 6a75e5a158

View file

@ -7,6 +7,15 @@ local this = {}
local function log(...) if config.debug then common.log(...) end end
local function isFriendlyActor(actor)
for friend in tes3.iterate(tes3.mobilePlayer.friendlyActors) do
if actor.object.id == friend.object.id or actor.object.baseObject.id == friend.object.baseObject.id then
return true
end
end
return false
end
local function alertGuards(aggressor, cell)
-- a wanted player gets no help
if tes3.mobilePlayer.bounty > 0 then
@ -53,6 +62,11 @@ this.onCombatStart = function(e)
return
end
if isFriendlyActor(e.actor) then
log("Friendly actor, not helping.")
return
end
local cell = tes3.getPlayerCell()
if cell.isInterior and not cell.behavesAsExterior then