diff --git a/MWSE/mods/celediel/NPCsGoHome/functions/cellEvaluators.lua b/MWSE/mods/celediel/NPCsGoHome/functions/cellEvaluators.lua index 70d33bb..a00660b 100644 --- a/MWSE/mods/celediel/NPCsGoHome/functions/cellEvaluators.lua +++ b/MWSE/mods/celediel/NPCsGoHome/functions/cellEvaluators.lua @@ -6,15 +6,31 @@ local this = {} local function log(level, ...) if config.logLevel >= level then common.log(...) end end +-- cellEvaluators can't require checks because checks already requires cellEvaluators +-- this means I have too much spaghetti +local function isIgnoredNPCLite(npc) + local obj = npc.baseObject and npc.baseObject or npc.object + + local isGuard = obj.isGuard or (obj.name and (obj.name:lower():match("guard") and true or false) or false) -- maybe this should just be an if else + local isVampire = obj.head and (obj.head.vampiric and true or false) or false + + return config.ignored[obj.id:lower()] or + config.ignored[obj.sourceMod:lower()] or + isGuard or + isVampire +end + -- cell worth is combined worth of all NPCs this.calculateCellWorth = function(cell, proprietor) local worth = 0 local msg = "breakdown:\n" for innard in cell:iterateReferences(tes3.objectType.npc) do - local total = npcEvaluators.calculateNPCWorth(innard, innard == proprietor and cell or nil).total - worth = worth + total - msg = msg .. string.format("%s worth:%s, ", innard.object.name, total) + if not isIgnoredNPCLite(innard) then + local total = npcEvaluators.calculateNPCWorth(innard, innard == proprietor and cell or nil).total + worth = worth + total + msg = msg .. string.format("%s worth:%s, ", innard.object.name, total) + end end log(common.logLevels.medium, "[CELLEVAL] Calculated worth of %s for cell %s", worth, cell.id) @@ -29,18 +45,20 @@ this.pickCellFaction = function(cell) -- count all the npcs with factions for npc in cell:iterateReferences(tes3.objectType.npc) do - local faction = npc.object.faction + if not isIgnoredNPCLite(npc) then + local faction = npc.object.faction - if faction then - if not npcs.allFactions[faction.id] then npcs.allFactions[faction.id] = {total = 0, percentage = 0} end + if faction then + if not npcs.allFactions[faction.id] then npcs.allFactions[faction.id] = {total = 0, percentage = 0} end - if not npcs.allFactions[faction.id].master or npcs.allFactions[faction.id].master.object.factionIndex < - npc.object.factionIndex then npcs.allFactions[faction.id].master = npc end + if not npcs.allFactions[faction.id].master or npcs.allFactions[faction.id].master.object.factionIndex < + npc.object.factionIndex then npcs.allFactions[faction.id].master = npc end - npcs.allFactions[faction.id].total = npcs.allFactions[faction.id].total + 1 + npcs.allFactions[faction.id].total = npcs.allFactions[faction.id].total + 1 + end + + npcs.total = npcs.total + 1 end - - npcs.total = npcs.total + 1 end -- pick out all the factions that make up a percentage of the cell greater than the configured value