pick homes in wilderness cells, remove titles from names

This commit is contained in:
Lilian Jónsdóttir 2020-09-14 21:57:27 -07:00
parent b9892e7946
commit 97cb4e53cb
2 changed files with 7 additions and 9 deletions

View file

@ -12,7 +12,6 @@ local contextualNPCs = {"^AM_"}
local this = {}
-- ? I honestly don't know if there are any wandering NPCs that "live" in close-by manors, but I wrote this anyway
this.livesInManor = function(cellName, npcName)
if not cellName or (cellName and not string.find(cellName, "Manor")) then return end
@ -71,15 +70,15 @@ end
-- looks through doors to find a cell that matches a wandering NPCs name
this.pickHomeForNPC = function(cell, npc)
-- wilderness cells don't have name
if not cell.name then return end
-- don't move contextual, such as Animated Morrowind, NPCs at all
for _, str in pairs(contextualNPCs) do if npc.object.id:match(str) then return end end
-- time to pick the "home"
local name = npc.object.name
local city = common.split(cell.name, ",")[1]
local name = npc.object.name:gsub(" the .*$","") -- remove "the whatever" from NPCs name
local city = cell.name and common.split(cell.name, ",")[1] or "wilderness"
-- don't need to pick a home if we already have one
if common.runtimeData.homes.byName[name] then return common.runtimeData.homes.byName[name] end
-- check if the NPC already has a house
for door in cell:iterateReferences(tes3.objectType.door) do
@ -88,9 +87,7 @@ this.pickHomeForNPC = function(cell, npc)
-- essentially, if npc full name, or surname matches the cell name
if dest.id:match(name) or this.livesInManor(dest.name, name) then
-- already have a home, don't create the table dataTables again
return common.runtimeData.homes.byName[name] and common.runtimeData.homes.byName[name] or
dataTables.createHomedNPCTableEntry(npc, dest, cell, true)
return dataTables.createHomedNPCTableEntry(npc, dest, cell, true)
end
end
end

View file

@ -7,6 +7,7 @@ local this = {}
-- todo: logging
local function log(level, ...) if config.logLevel >= level then common.log(...) end end
-- todo: check type of clothing/armour equipped: common, expensive, etc.
-- NPCs barter gold + value of all inventory items
this.calculateNPCWorth = function(npc, merchantCell)
-- start with this