make sure proprietor provides services

This commit is contained in:
Lilian Jónsdóttir 2021-08-22 00:28:08 -07:00
parent e677d37870
commit bd3de379a5
2 changed files with 20 additions and 1 deletions

View file

@ -354,6 +354,21 @@ this.isBadWeatherNPC = function(npc)
return is return is
end 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 return this
-- vim:set fdm=marker -- vim:set fdm=marker

View file

@ -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, 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) 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 .. msg = msg ..
string.format(" Talk to %s, %s for services.", publicHouse.proprietor.object.name, string.format(" Talk to %s, %s for services.", publicHouse.proprietor.object.name,
publicHouse.proprietor.object.class) publicHouse.proprietor.object.class)
@ -107,6 +108,9 @@ local function updateCells()
end end
-- todo: more robust trespass checking... maybe take faction and rank into account? -- 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 -- todo: maybe re-implement some or all features of Trespasser
local function updatePlayerTrespass(cell, previousCell) local function updatePlayerTrespass(cell, previousCell)
cell = cell or tes3.getPlayerCell() cell = cell or tes3.getPlayerCell()