From 5e3d30ccb20bf2999e9221ccf99c538f2200e278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Sun, 4 Oct 2020 11:49:48 -0700 Subject: [PATCH] option to not disable NPCs in wilderness cells, some cleanup --- MWSE/mods/celediel/NPCsGoHome/config.lua | 1 + .../celediel/NPCsGoHome/functions/checks.lua | 21 ++++++------------- .../NPCsGoHome/functions/processors.lua | 6 ++++-- MWSE/mods/celediel/NPCsGoHome/mcm.lua | 10 +++++++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/MWSE/mods/celediel/NPCsGoHome/config.lua b/MWSE/mods/celediel/NPCsGoHome/config.lua index f249ba4..357a38a 100644 --- a/MWSE/mods/celediel/NPCsGoHome/config.lua +++ b/MWSE/mods/celediel/NPCsGoHome/config.lua @@ -13,6 +13,7 @@ local defaultConfig = { showMessages = true, -- npc settings disableNPCs = true, + disableNPCsInWilderness = false, moveNPCs = true, -- move NPCs to homes keepBadWeatherNPCs = true, -- classes and races that are ignored during inclement weather diff --git a/MWSE/mods/celediel/NPCsGoHome/functions/checks.lua b/MWSE/mods/celediel/NPCsGoHome/functions/checks.lua index 0520b89..e7239d0 100644 --- a/MWSE/mods/celediel/NPCsGoHome/functions/checks.lua +++ b/MWSE/mods/celediel/NPCsGoHome/functions/checks.lua @@ -4,12 +4,6 @@ local config = require("celediel.NPCsGoHome.config").getConfig() local dataTables = require("celediel.NPCsGoHome.functions.dataTables") local cellEvaluators = require("celediel.NPCsGoHome.functions.cellEvaluators") --- {{{ local variables and such - --- city name if cell.name is nil -local wilderness = "Wilderness" --- }}} - -- {{{ local functions local function log(level, ...) if config.logLevel >= level then common.log(...) end end @@ -80,15 +74,10 @@ this.isCityCell = function(internalCellId, externalCellId) end this.isIgnoredCell = function(cell) - log(common.logLevels.large, "[CHECKS] %s is %s, %s is %s", cell.id, - config.ignored[cell.id] and "ignored" or "not ignored", cell.sourceMod, - config.ignored[cell.sourceMod] and "ignored" or "not ignored") + log(common.logLevels.large, "[CHECKS] %s is %s", cell.id, + config.ignored[cell.id:lower()] and "ignored" or "not ignored") - -- don't do things in the wilderness - -- local wilderness = false - -- if not cell.name then wilderness = true end - - return config.ignored[cell.id] or config.ignored[cell.sourceMod] -- or wilderness + return config.ignored[cell.id:lower()] -- or config.ignored[cell.sourceMod:lower()] -- or wilderness end -- ! this one depends on tes3 ! -- @@ -165,8 +154,10 @@ this.isNPCPet = function(creature) -- > isPet, isLinkedToTravelNPC local obj = creature.baseObject and creature.baseObject or creature.object -- todo: more pets? + -- pack guars if obj.id:match("guar") and obj.mesh:match("pack") then return true + -- imperial carriages elseif obj.id:match("_[Hh]rs") and obj.mesh:match("_[Hh]orse") then return true, true else @@ -188,7 +179,7 @@ this.isPublicHouse = function(cell) city = common.split(cell.name, ",")[1] publicHouseName = common.split(cell.name, ",")[2]:gsub("^%s", "") else - city = wilderness + city = "Wilderness" publicHouseName = cell.id end diff --git a/MWSE/mods/celediel/NPCsGoHome/functions/processors.lua b/MWSE/mods/celediel/NPCsGoHome/functions/processors.lua index 4635301..5e8f757 100644 --- a/MWSE/mods/celediel/NPCsGoHome/functions/processors.lua +++ b/MWSE/mods/celediel/NPCsGoHome/functions/processors.lua @@ -104,7 +104,8 @@ local function disableOrMove(npc, cell) local npcHome = config.moveNPCs and housing.pickHomeForNPC(cell, npc) or nil if npcHome then moveNPC(npcHome) - else + elseif cell.name or (not cell.name and config.disableNPCsInWilderness) then + -- todo: re-enable NPCs in wilderness if this config option is changed disableNPC(npc) end end @@ -122,7 +123,8 @@ end -- search in a specific cell for moved or disabled NPCs local function checkForMovedOrDisabledNPCs(cell) -- NPCs don't get moved to exterior cells, so no need to check them for moved NPCs - if not checks.isInteriorCell(cell) then return end + -- NPCs do get disabled in interior cells though + -- if not checks.isInteriorCell(cell) then return end log(common.logLevels.medium, "[PROC] Looking for moved NPCs in cell %s", cell.id) for npc in cell:iterateReferences(tes3.objectType.npc) do diff --git a/MWSE/mods/celediel/NPCsGoHome/mcm.lua b/MWSE/mods/celediel/NPCsGoHome/mcm.lua index cd9460e..7417b35 100644 --- a/MWSE/mods/celediel/NPCsGoHome/mcm.lua +++ b/MWSE/mods/celediel/NPCsGoHome/mcm.lua @@ -38,16 +38,22 @@ category:createYesNoButton({label = "Lock doors and containers at night?", varia category:createYesNoButton({label = "Disable non-Guard NPCs at night?", variable = createTableVar("disableNPCs")}) +category:createYesNoButton({ + label = "Disable NPCs in wilderness?", + description = "Cells that don't have a specific name (i.e. Region cells) are 'wilderness' cells.", + variable = createTableVar("disableNPCsInWilderness") +}) + category:createYesNoButton({ label = "Move NPCs into their homes at night and in bad weather instead of disabling them?", - description = "NOTE: Without the proper positions in data/positions.lua this could result in bad placement!!!\n\n".. + description = "NOTE: Without the proper positions in data/positions.lua this could result in bad placement!!!\n\n" .. "Make a PR with some more positions if you feel like it.", variable = createTableVar("moveNPCs") }) category:createYesNoButton({ label = "Move \"homeless\" NPCs to public spaces at night and in bad weather instead of disabling them?", - description = "NOTE: Without the proper positions in data/positions.lua this could result in bad placement, ".. + description = "NOTE: Without the proper positions in data/positions.lua this could result in bad placement, " .. "and if multiple NPCs are placed in the same spot, they might DIE!!!\n\n" .. "Make a PR with some more positions if you feel like it.", variable = createTableVar("homelessWanderersToPublicHouses")