option to not disable NPCs in wilderness cells, some cleanup

This commit is contained in:
Lilian Jónsdóttir 2020-10-04 11:49:48 -07:00
parent e4d85c1fcc
commit 5e3d30ccb2
4 changed files with 19 additions and 19 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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")