option to not disable NPCs in wilderness cells, some cleanup
This commit is contained in:
parent
e4d85c1fcc
commit
5e3d30ccb2
|
@ -13,6 +13,7 @@ local defaultConfig = {
|
||||||
showMessages = true,
|
showMessages = true,
|
||||||
-- npc settings
|
-- npc settings
|
||||||
disableNPCs = true,
|
disableNPCs = true,
|
||||||
|
disableNPCsInWilderness = false,
|
||||||
moveNPCs = true, -- move NPCs to homes
|
moveNPCs = true, -- move NPCs to homes
|
||||||
keepBadWeatherNPCs = true,
|
keepBadWeatherNPCs = true,
|
||||||
-- classes and races that are ignored during inclement weather
|
-- classes and races that are ignored during inclement weather
|
||||||
|
|
|
@ -4,12 +4,6 @@ local config = require("celediel.NPCsGoHome.config").getConfig()
|
||||||
local dataTables = require("celediel.NPCsGoHome.functions.dataTables")
|
local dataTables = require("celediel.NPCsGoHome.functions.dataTables")
|
||||||
local cellEvaluators = require("celediel.NPCsGoHome.functions.cellEvaluators")
|
local cellEvaluators = require("celediel.NPCsGoHome.functions.cellEvaluators")
|
||||||
|
|
||||||
-- {{{ local variables and such
|
|
||||||
|
|
||||||
-- city name if cell.name is nil
|
|
||||||
local wilderness = "Wilderness"
|
|
||||||
-- }}}
|
|
||||||
|
|
||||||
-- {{{ local functions
|
-- {{{ local functions
|
||||||
local function log(level, ...) if config.logLevel >= level then common.log(...) end end
|
local function log(level, ...) if config.logLevel >= level then common.log(...) end end
|
||||||
|
|
||||||
|
@ -80,15 +74,10 @@ this.isCityCell = function(internalCellId, externalCellId)
|
||||||
end
|
end
|
||||||
|
|
||||||
this.isIgnoredCell = function(cell)
|
this.isIgnoredCell = function(cell)
|
||||||
log(common.logLevels.large, "[CHECKS] %s is %s, %s is %s", cell.id,
|
log(common.logLevels.large, "[CHECKS] %s is %s", cell.id,
|
||||||
config.ignored[cell.id] and "ignored" or "not ignored", cell.sourceMod,
|
config.ignored[cell.id:lower()] and "ignored" or "not ignored")
|
||||||
config.ignored[cell.sourceMod] and "ignored" or "not ignored")
|
|
||||||
|
|
||||||
-- don't do things in the wilderness
|
return config.ignored[cell.id:lower()] -- or config.ignored[cell.sourceMod:lower()] -- or wilderness
|
||||||
-- local wilderness = false
|
|
||||||
-- if not cell.name then wilderness = true end
|
|
||||||
|
|
||||||
return config.ignored[cell.id] or config.ignored[cell.sourceMod] -- or wilderness
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ! this one depends on tes3 ! --
|
-- ! 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
|
local obj = creature.baseObject and creature.baseObject or creature.object
|
||||||
|
|
||||||
-- todo: more pets?
|
-- todo: more pets?
|
||||||
|
-- pack guars
|
||||||
if obj.id:match("guar") and obj.mesh:match("pack") then
|
if obj.id:match("guar") and obj.mesh:match("pack") then
|
||||||
return true
|
return true
|
||||||
|
-- imperial carriages
|
||||||
elseif obj.id:match("_[Hh]rs") and obj.mesh:match("_[Hh]orse") then
|
elseif obj.id:match("_[Hh]rs") and obj.mesh:match("_[Hh]orse") then
|
||||||
return true, true
|
return true, true
|
||||||
else
|
else
|
||||||
|
@ -188,7 +179,7 @@ this.isPublicHouse = function(cell)
|
||||||
city = common.split(cell.name, ",")[1]
|
city = common.split(cell.name, ",")[1]
|
||||||
publicHouseName = common.split(cell.name, ",")[2]:gsub("^%s", "")
|
publicHouseName = common.split(cell.name, ",")[2]:gsub("^%s", "")
|
||||||
else
|
else
|
||||||
city = wilderness
|
city = "Wilderness"
|
||||||
publicHouseName = cell.id
|
publicHouseName = cell.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,8 @@ local function disableOrMove(npc, cell)
|
||||||
local npcHome = config.moveNPCs and housing.pickHomeForNPC(cell, npc) or nil
|
local npcHome = config.moveNPCs and housing.pickHomeForNPC(cell, npc) or nil
|
||||||
if npcHome then
|
if npcHome then
|
||||||
moveNPC(npcHome)
|
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)
|
disableNPC(npc)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -122,7 +123,8 @@ end
|
||||||
-- search in a specific cell for moved or disabled NPCs
|
-- search in a specific cell for moved or disabled NPCs
|
||||||
local function checkForMovedOrDisabledNPCs(cell)
|
local function checkForMovedOrDisabledNPCs(cell)
|
||||||
-- NPCs don't get moved to exterior cells, so no need to check them for moved NPCs
|
-- 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)
|
log(common.logLevels.medium, "[PROC] Looking for moved NPCs in cell %s", cell.id)
|
||||||
for npc in cell:iterateReferences(tes3.objectType.npc) do
|
for npc in cell:iterateReferences(tes3.objectType.npc) do
|
||||||
|
|
|
@ -38,6 +38,12 @@ 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 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({
|
category:createYesNoButton({
|
||||||
label = "Move NPCs into their homes at night and in bad weather instead of disabling them?",
|
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" ..
|
||||||
|
|
Loading…
Reference in a new issue