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
This commit is contained in:
Lilian Jónsdóttir 2020-10-27 21:49:11 -07:00
parent 05dea565c7
commit 35283d0bfd

View file

@ -15,6 +15,8 @@ end
-- keep track of followers -- keep track of followers
local followers = {} local followers = {}
local spellEffects = {}
-- {{{ internal functions -- {{{ internal functions
local function notActuallyFriend(friend) local function notActuallyFriend(friend)
if not friend then return true end if not friend then return true end
@ -52,15 +54,15 @@ end
local function isHarmfulSpell(source) local function isHarmfulSpell(source)
-- look for harmful effects in the source spell -- look for harmful effects in the source spell
local isHarmful = false
for i = 1, 8 do for i = 1, 8 do
local effect = source.effects[i] local effect = source.effects[i]
if effect and effect.object then if effect and effect.object then
-- todo: get name of spell effect instead of id log(common.logLevels.big, "effect #%s %s is harmful:%s", i, spellEffects[effect.object.id + 1], effect.object.isHarmful)
log(common.logLevels.big, "effect #%s id:%s: harmful:%s", i, effect.object.id, effect.object.isHarmful) if effect.object.isHarmful then isHarmful = true end -- found one!
if effect.object.isHarmful then return true end -- found one!
end end
end end
return false -- found nothing return isHarmful
end end
-- }}} -- }}}
@ -164,6 +166,11 @@ local function onInitialized()
log(common.logLevels.small, "%s event registered", name) log(common.logLevels.small, "%s event registered", name)
end 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 "") log(common.logLevels.no, "Successfully initialized%s", mag and " with More Attentive Guards interop" or "")
end end