fix: draw pins from immediate learner kill evidence
This commit is contained in:
@@ -233,6 +233,43 @@ local function _GetLearnerRecord(storeName, id)
|
||||
return store[id] or store[tostring(id)]
|
||||
end
|
||||
|
||||
local function _BuildSpawnTableFromGuidEvidence(evidence)
|
||||
if type(evidence) ~= "table" then
|
||||
return nil
|
||||
end
|
||||
|
||||
local spawns = {}
|
||||
local hasEntries = false
|
||||
for _, entry in pairs(evidence) do
|
||||
if type(entry) == "table" and entry.zoneId and entry.x and entry.y then
|
||||
local zoneId = tonumber(entry.zoneId)
|
||||
local x = tonumber(entry.x)
|
||||
local y = tonumber(entry.y)
|
||||
if zoneId and x and y then
|
||||
spawns[zoneId] = spawns[zoneId] or {}
|
||||
local zoneSpawns = spawns[zoneId]
|
||||
local exists = false
|
||||
for _, coord in ipairs(zoneSpawns) do
|
||||
if coord[1] == x and coord[2] == y then
|
||||
exists = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if not exists then
|
||||
zoneSpawns[#zoneSpawns + 1] = { x, y }
|
||||
hasEntries = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not hasEntries then
|
||||
return nil
|
||||
end
|
||||
|
||||
return spawns
|
||||
end
|
||||
|
||||
---@type QuestieQuest
|
||||
local QuestieQuest = QuestieLoader:ImportModule("QuestieQuest")
|
||||
---@type QuestieQuestPrivate
|
||||
@@ -2157,6 +2194,14 @@ function QuestieDB:GetNPC(npcId)
|
||||
local friendlyToFaction = npc.friendlyToFaction
|
||||
npc.friendly = (not friendlyToFaction) and true or factionReactions[friendlyToFaction]
|
||||
|
||||
if (not npc.spawns or next(npc.spawns) == nil) and mode == "learner" then
|
||||
local guidSpawns = rawdata[8]
|
||||
local learnedSpawns = _BuildSpawnTableFromGuidEvidence(guidSpawns)
|
||||
if learnedSpawns then
|
||||
npc.spawns = learnedSpawns
|
||||
end
|
||||
end
|
||||
|
||||
_QuestieDB.npcCache[npcId] = npc
|
||||
return npc
|
||||
end
|
||||
|
||||
@@ -181,7 +181,7 @@ monster = function(npcId, objective)
|
||||
|
||||
local isLearned = false
|
||||
|
||||
if dataSourceMode == "none" or dataSourceMode == "learner" then
|
||||
if dataSourceMode == "none" then
|
||||
spawns = {}
|
||||
end
|
||||
|
||||
@@ -276,7 +276,7 @@ object = function(objectId, objective)
|
||||
end
|
||||
|
||||
local isLearned = false
|
||||
if dataSourceMode == "none" or dataSourceMode == "learner" then
|
||||
if dataSourceMode == "none" then
|
||||
spawns = {}
|
||||
end
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ describe("QuestieLearner data source mode", function()
|
||||
local priv = read("Modules/Quest/QuestieQuestPrivates.lua")
|
||||
local tip = read("Modules/Tooltips/Tooltip.lua")
|
||||
assert.is_true(has(quest, "dataSourceMode == \"auto\" or dataSourceMode == \"learner\""))
|
||||
assert.is_true(has(priv, "dataSourceMode == \"none\" or dataSourceMode == \"learner\""))
|
||||
assert.is_true(has(priv, "dataSourceMode == \"none\""))
|
||||
assert.is_true(has(tip, "mode ~= \"static\" and mode ~= \"none\""))
|
||||
end)
|
||||
|
||||
@@ -167,6 +167,27 @@ describe("QuestieDB learner source fallback", function()
|
||||
assert.equals(44, npc.zoneID)
|
||||
end)
|
||||
|
||||
it("turns learner kill evidence into NPC spawn coordinates immediately in learner mode", function()
|
||||
Questie.dbLearner.global.npcs[9003] = {
|
||||
[1] = "Learner Kill",
|
||||
[8] = {
|
||||
[101] = {
|
||||
zoneId = 44,
|
||||
x = 18.5,
|
||||
y = 27.25,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
local npc = QuestieDB:GetNPC(9003)
|
||||
assert.is_table(npc)
|
||||
assert.is_table(npc.spawns)
|
||||
assert.is_table(npc.spawns[44])
|
||||
assert.equals(1, #npc.spawns[44])
|
||||
assert.equals(18.5, npc.spawns[44][1][1])
|
||||
assert.equals(27.25, npc.spawns[44][1][2])
|
||||
end)
|
||||
|
||||
it("returns learner object data when static queries are unavailable", function()
|
||||
local obj = QuestieDB:GetObject(9002)
|
||||
assert.is_table(obj)
|
||||
|
||||
Reference in New Issue
Block a user