From 35283d0bfdb0a4510aca9d357bc7dcc95a013dd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Tue, 27 Oct 2020 21:49:11 -0700 Subject: [PATCH] check all effects because bailing early wasn't really going to save that much CPU time and I want to log all of the effects --- MWSE/mods/celediel/NoMoreFriendlyFire/main.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/MWSE/mods/celediel/NoMoreFriendlyFire/main.lua b/MWSE/mods/celediel/NoMoreFriendlyFire/main.lua index 2fc1fff..971b42c 100644 --- a/MWSE/mods/celediel/NoMoreFriendlyFire/main.lua +++ b/MWSE/mods/celediel/NoMoreFriendlyFire/main.lua @@ -15,6 +15,8 @@ end -- keep track of followers local followers = {} +local spellEffects = {} + -- {{{ internal functions local function notActuallyFriend(friend) if not friend then return true end @@ -52,15 +54,15 @@ end local function isHarmfulSpell(source) -- look for harmful effects in the source spell + local isHarmful = false for i = 1, 8 do local effect = source.effects[i] if effect and effect.object then - -- todo: get name of spell effect instead of id - log(common.logLevels.big, "effect #%s id:%s: harmful:%s", i, effect.object.id, effect.object.isHarmful) - if effect.object.isHarmful then return true end -- found one! + log(common.logLevels.big, "effect #%s %s is harmful:%s", i, spellEffects[effect.object.id + 1], effect.object.isHarmful) + if effect.object.isHarmful then isHarmful = true end -- found one! end end - return false -- found nothing + return isHarmful end -- }}} @@ -164,6 +166,11 @@ local function onInitialized() log(common.logLevels.small, "%s event registered", name) end + for effect, id in pairs(tes3.effect) do + -- I wish lua didn't start indexing at one, who does that ffs + spellEffects[id + 1] = effect + end + log(common.logLevels.no, "Successfully initialized%s", mag and " with More Attentive Guards interop" or "") end