From 8b33725c2ec9fd7e83fc391bfa165650e4b3331a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Sun, 2 Aug 2020 15:15:17 -0700 Subject: [PATCH] less false negatives but potentially more false positives net gain imo --- .../celediel/MoreAttentiveGuards/combat.lua | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/MWSE/mods/celediel/MoreAttentiveGuards/combat.lua b/MWSE/mods/celediel/MoreAttentiveGuards/combat.lua index af4f9d0..b404e16 100644 --- a/MWSE/mods/celediel/MoreAttentiveGuards/combat.lua +++ b/MWSE/mods/celediel/MoreAttentiveGuards/combat.lua @@ -16,13 +16,13 @@ local function isFriendlyActor(actor) return false end -local function doChecks(e) +local function doChecks(attacker, target) if not config.combatEnable then return false end -- if player initiates combat or combat is not against player, do nothing - if e.actor == tes3.mobilePlayer or e.target ~= tes3.mobilePlayer then + if attacker == tes3.mobilePlayer or target ~= tes3.mobilePlayer then return false end @@ -35,12 +35,12 @@ local function doChecks(e) return false end - if config.ignored[e.actor.object.id] or config.ignored[e.actor.object.baseObject.id] then + if config.ignored[attacker.object.id] or config.ignored[attacker.object.baseObject.id] then log("Ignored NPC or creature detected, not helping.") return false end - if isFriendlyActor(e.actor) then + if isFriendlyActor(attacker) then log("Friendly actor, not helping.") return false end @@ -50,7 +50,15 @@ local function doChecks(e) return false end - if e.actor.object.isGuard then + -- ? Guards don't know who started it if the player is being attacked with their weapon out ? + -- seems to fix weird issue when sneak attacking NPCs in town, guards would kill NPC, + -- then player would get murder bounty, so guards would come after player + if tes3.mobilePlayer.weaponReady and attacker.object.objectType == tes3.objectType.npc then + log("NPC Fight, not sure who started it, not helping.") + return false + end + + if attacker.object.isGuard then log("Guards don't fight guards!") return false end @@ -85,7 +93,7 @@ end -- {{{ returned event functions this.onCombatStarted = function(e) - if not doChecks(e) then return end + if not doChecks(e.actor, e.target) then return end for _, cell in pairs(tes3.getActiveCells()) do alertGuards(e.actor, cell)