From 90d8b81324d4f308d5e18501b10f7b0c56896a3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Sun, 16 Aug 2020 15:33:23 -0700 Subject: [PATCH] disable pack guars also --- MWSE/mods/celediel/NPCsGoHome/main.lua | 31 +++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/MWSE/mods/celediel/NPCsGoHome/main.lua b/MWSE/mods/celediel/NPCsGoHome/main.lua index 85dda68..87201d2 100644 --- a/MWSE/mods/celediel/NPCsGoHome/main.lua +++ b/MWSE/mods/celediel/NPCsGoHome/main.lua @@ -391,6 +391,17 @@ local function isIgnoredNPC(npc) (obj.class and obj.class.id == "Dreamers") -- end +local function isNPCPet(creature) + local obj = creature.baseObject and creature.baseObject or creature.object + + -- todo: more pets? + if obj.id:match("guar") and obj.mesh:match("pack") then + return true + else + return false + end +end + -- checks NPC class and faction in cells for block list and adds to publicHouse list -- todo: rewrite this local function isPublicHouse(cell) @@ -708,7 +719,6 @@ local function processNPCs(cell) if not (checkTime() or checkWeather(cell)) then putNPCsBack() end end --- todo: deal with trader's guars, and other npc linked creatures/whatever local function processSiltStriders(cell) if not config.disableNPCs then return end @@ -736,6 +746,24 @@ local function processSiltStriders(cell) log(common.logLevels.large, "Done with silt striders") end +-- deal with trader's guars, and other npc linked creatures/whatever +local function processPets(cell) + if not config.disableNPCs then return end + + log(common.logLevels.small, "Looking for NPC pets to process in cell:%s", cell.name) + + for creature in cell:iterateReferences(tes3.objectType.creature) do + if isNPCPet(creature) then + if checkTime() then + -- disable + log(common.logLevels.medium, "Disabling NPC Pet %s!", creature.object.id) + else + -- enable + end + end + end +end + local function processDoors(cell) if not config.lockDoors then return end @@ -799,6 +827,7 @@ local function applyChanges(cell) -- Deal with NPCs and mounts in cell processNPCs(cell) + processPets(cell) processSiltStriders(cell) -- check doors in cell, locking those that aren't inns/clubs