From ba880908b3fe15a1a9cf7eb34b3db45cb536b73d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Sun, 16 Aug 2020 15:34:56 -0700 Subject: [PATCH] better city detection --- MWSE/mods/celediel/NPCsGoHome/main.lua | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/MWSE/mods/celediel/NPCsGoHome/main.lua b/MWSE/mods/celediel/NPCsGoHome/main.lua index 2751343..d640579 100644 --- a/MWSE/mods/celediel/NPCsGoHome/main.lua +++ b/MWSE/mods/celediel/NPCsGoHome/main.lua @@ -336,6 +336,29 @@ end -- {{{ checks +local function isCityCell(internalCellId, externalCellId) + -- easy mode + if string.match(internalCellId, externalCellId) then + log(common.logLevels.large, "easy mode city: %s in %s", internalCellId, externalCellId) + return true + end + + local cityMatch = "^(%w+), (.*)" + -- check for "advanced" cities + local _, _, internalCity = string.find(internalCellId, cityMatch) + local _, _, externalCity = string.find(externalCellId, cityMatch) + + if externalCity and externalCity == internalCity then + log(common.logLevels.large, "hard mode city: %s in %s, %s == %s", + internalCellId, externalCellId, externalCity, internalCity) + return true + end + + log(common.logLevels.large, "hard mode not city: %s not in %s, %s ~= %s or both are nil", + internalCellId, externalCellId, externalCity, internalCity) + return false +end + local function fargothCheck() local fargothJournal = tes3.getJournalIndex({id = "MS_Lookout"}) if not fargothJournal then return false end @@ -482,7 +505,7 @@ local function isIgnoredDoor(door, homeCellId) end -- Only doors in cities and towns (interior cells with names that contain the exterior cell) - local inCity = string.match(door.destination.cell.id, homeCellId) + local inCity = isCityCell(door.destination.cell.id, homeCellId) -- peek inside doors to look for guild halls, inns and clubs local leadsToPublicCell = isPublicHouse(door.destination.cell)