From bd3de379a54fb57b20c1483fab53f5d567a6beaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Sun, 22 Aug 2021 00:28:08 -0700 Subject: [PATCH] make sure proprietor provides services --- .../mods/celediel/NPCsGoHome/functions/checks.lua | 15 +++++++++++++++ MWSE/mods/celediel/NPCsGoHome/main.lua | 6 +++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/MWSE/mods/celediel/NPCsGoHome/functions/checks.lua b/MWSE/mods/celediel/NPCsGoHome/functions/checks.lua index 72f1563..ed245e1 100644 --- a/MWSE/mods/celediel/NPCsGoHome/functions/checks.lua +++ b/MWSE/mods/celediel/NPCsGoHome/functions/checks.lua @@ -354,6 +354,21 @@ this.isBadWeatherNPC = function(npc) return is end +-- returns true if NPC offers any kind of service, otherwise false +this.isServicer = function(npc) + if not npc or not npc.mobile then return false end + + for service, value in pairs(tes3.merchantService) do + if tes3.checkMerchantOffersService(npc.mobile, value) then + log(common.logLevels.medium, "[CHECKS] %s offers service \"%s\"", npc.object.name, service) + return true + end + end + + log(common.logLevels.large, "[CHECKS] %s doesn't offer services", npc.object.name) + return false +end + return this -- vim:set fdm=marker diff --git a/MWSE/mods/celediel/NPCsGoHome/main.lua b/MWSE/mods/celediel/NPCsGoHome/main.lua index 98193f3..6c27944 100644 --- a/MWSE/mods/celediel/NPCsGoHome/main.lua +++ b/MWSE/mods/celediel/NPCsGoHome/main.lua @@ -54,7 +54,8 @@ local function checkEnteredPublicHouse(cell, city) local msg = string.format("Entering public space %s, a%s %s in the town of %s.", publicHouse.name, common.vowel(typeOfPub), typeOfPub:gsub("s$", ""), publicHouse.city) - if publicHouse.proprietor then + -- todo: check for more servicers, not just proprietor + if publicHouse.proprietor and checks.isServicer(publicHouse.proprietor) then msg = msg .. string.format(" Talk to %s, %s for services.", publicHouse.proprietor.object.name, publicHouse.proprietor.object.class) @@ -107,6 +108,9 @@ local function updateCells() end -- todo: more robust trespass checking... maybe take faction and rank into account? +-- maybe something like faction members you outrank don't mind you being in their house +-- also whether guildhalls are public or not, members can come and go as they please +-- todo maybe an esp with keys for guildhalls that are added when player joins or reaches a certain rank? -- todo: maybe re-implement some or all features of Trespasser local function updatePlayerTrespass(cell, previousCell) cell = cell or tes3.getPlayerCell()