From 551bcfeba7016612850299692386eac3569f4281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Sun, 11 Oct 2020 17:34:39 -0700 Subject: [PATCH] some loggin + support for Local Lore - SS&C (Silt Strider and Caravanner Dialogue) --- .../celediel/NPCsGoHome/functions/checks.lua | 7 +++++++ .../NPCsGoHome/functions/processors.lua | 20 ++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/MWSE/mods/celediel/NPCsGoHome/functions/checks.lua b/MWSE/mods/celediel/NPCsGoHome/functions/checks.lua index c1e04a3..303cfed 100644 --- a/MWSE/mods/celediel/NPCsGoHome/functions/checks.lua +++ b/MWSE/mods/celediel/NPCsGoHome/functions/checks.lua @@ -165,6 +165,13 @@ this.isNPCPet = function(creature) -- > isPet, isLinkedToTravelNPC end end +this.isSiltStrider = function(activator) + local id = activator.object.id:lower() + log(common.logLevels.large, "[PROC] Is %s a silt strider??", id) + return id:match("siltstrider") or + id:match("kil_silt") +end + -- checks NPC class and faction in cells for block list and adds to publicHouse list -- todo: rewrite this this.isPublicHouse = function(cell) diff --git a/MWSE/mods/celediel/NPCsGoHome/functions/processors.lua b/MWSE/mods/celediel/NPCsGoHome/functions/processors.lua index d0ec699..d10bd45 100644 --- a/MWSE/mods/celediel/NPCsGoHome/functions/processors.lua +++ b/MWSE/mods/celediel/NPCsGoHome/functions/processors.lua @@ -11,6 +11,10 @@ local function log(level, ...) if config.logLevel >= level then common.log(...) local this = {} local function moveNPC(homeData) + -- do some logging + log(common.logLevels.medium, "[PROC] Moving %s to home %s (%s, %s, %s)", homeData.npc.object.name, homeData.home.id, + homeData.homePosition.x, homeData.homePosition.y, homeData.homePosition.z) + local npc = homeData.npc -- add to in memory table @@ -31,19 +35,18 @@ local function moveNPC(homeData) cell = homeData.ogPlaceName } + -- do the move tes3.positionCell({ cell = homeData.home, reference = homeData.npc, position = homeData.homePosition, orientation = homeData.homeOrientation }) - - log(common.logLevels.medium, "[PROC] Moving %s to home %s (%s, %s, %s)", homeData.npc.object.name, homeData.home.id, - homeData.homePosition.x, homeData.homePosition.y, homeData.homePosition.z) end local function disableNPC(npc, cell) - -- same thing as moveNPC, but disables instead + -- do some logging + log(common.logLevels.medium, "[PROC] Disabling un-homed %s", npc.name and npc.name or npc.id) -- add to runtimeData if checks.isBadWeatherNPC(npc) then common.runtimeData.NPCs.disabledBadWeather[cell.id] = common.runtimeData.NPCs.disabledBadWeather[cell.id] or {} @@ -58,11 +61,10 @@ local function disableNPC(npc, cell) -- npc:disable() -- ! this one sometimes causes crashes mwscript.disable({reference = npc}) -- ! this one is deprecated -- tes3.setEnabled({reference = npc, enabled = false}) -- ! but this one causes crashes too - -- do some logging - log(common.logLevels.medium, "[PROC] Disabling un-homed %s", npc.name and npc.name or npc.id) end local function putNPCsBack(npcData) + log(common.logLevels.large, "[PROC] Moving back NPCs:\n%s", json.encode(npcData)) -- for i = #npcData, 1, -1 do for id, data in pairs(npcData) do if data.npc.object then @@ -90,9 +92,10 @@ local function putNPCsBack(npcData) end local function reEnableNPCs(npcs) + log(common.logLevels.large, "[PROC] Re-enabling NPCs:\n%s", json.encode(npcs)) for id, ref in pairs(npcs) do + log(common.logLevels.medium, "[PROC] Making attempt at re-enabling %s", id) if ref.object and ref.disabled then - log(common.logLevels.medium, "[PROC] Enabling homeless %s", id) -- ref:enable() mwscript.enable({reference = ref}) @@ -245,8 +248,7 @@ this.processSiltStriders = function(cell) log(common.logLevels.small, "[PROC] Looking for silt striders to process in cell:%s", cell.id) for activator in cell:iterateReferences(tes3.objectType.activator) do - log(common.logLevels.large, "[PROC] Is %s a silt strider??", activator.object.id) - if activator.object.id:match("siltstrider") then + if checks.isSiltStrider(activator) then if checks.isNight() or (checks.isInclementWeather() and not config.keepBadWeatherNPCs) then if not activator.disabled then log(common.logLevels.medium, "[PROC] Disabling silt strider %s!", activator.object.name)