better city detection

This commit is contained in:
Lilian Jónsdóttir 2020-08-16 15:34:56 -07:00
parent 9343bcface
commit ba880908b3

View file

@ -336,6 +336,29 @@ end
-- {{{ checks -- {{{ 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 function fargothCheck()
local fargothJournal = tes3.getJournalIndex({id = "MS_Lookout"}) local fargothJournal = tes3.getJournalIndex({id = "MS_Lookout"})
if not fargothJournal then return false end if not fargothJournal then return false end
@ -482,7 +505,7 @@ local function isIgnoredDoor(door, homeCellId)
end end
-- Only doors in cities and towns (interior cells with names that contain the exterior cell) -- 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 -- peek inside doors to look for guild halls, inns and clubs
local leadsToPublicCell = isPublicHouse(door.destination.cell) local leadsToPublicCell = isPublicHouse(door.destination.cell)