fix: let learner turn-ins drive arrow spawns
This commit is contained in:
@@ -18,6 +18,7 @@ local _Learner = QuestieLearner.private or {}
|
||||
|
||||
local GetDataSourceMode
|
||||
local DeepCopy
|
||||
local HasQuestNpcReferences
|
||||
|
||||
local floor = math.floor
|
||||
local abs = math.abs
|
||||
@@ -930,9 +931,10 @@ local function _ApplyNpcLiveUpdate(npcId)
|
||||
if existing.mc < threshold then return false end
|
||||
if not (QuestieDB and QuestieDB.npcDataOverrides and existing[7] and next(existing[7])) then return false end
|
||||
|
||||
local allowSpawnMerge = existing[7] and next(existing[7]) and HasQuestNpcReferences(npcId)
|
||||
local ovr = QuestieDB.npcDataOverrides[npcId]
|
||||
if not ovr then
|
||||
if IsAscensionProtected("NPC", npcId, 7) then
|
||||
if IsAscensionProtected("NPC", npcId, 7) and not allowSpawnMerge then
|
||||
QuestieDB.npcDataOverrides[npcId] = DeepCopy(CopyWithoutField(existing, 7))
|
||||
else
|
||||
QuestieDB.npcDataOverrides[npcId] = DeepCopy(existing)
|
||||
@@ -945,7 +947,7 @@ local function _ApplyNpcLiveUpdate(npcId)
|
||||
end
|
||||
end
|
||||
-- Always merge spawn coords.
|
||||
if existing[7] and not IsAscensionProtected("NPC", npcId, 7) then
|
||||
if existing[7] and (not IsAscensionProtected("NPC", npcId, 7) or allowSpawnMerge) then
|
||||
ovr[7] = ovr[7] or {}
|
||||
for zid, coords in pairs(existing[7]) do
|
||||
ovr[7][zid] = ovr[7][zid] or {}
|
||||
@@ -2228,6 +2230,42 @@ local function HasQuestObjectReferences(objectId)
|
||||
return false
|
||||
end
|
||||
|
||||
HasQuestNpcReferences = function(npcId)
|
||||
local learned = Questie and Questie.dbLearner and Questie.dbLearner.global
|
||||
if not learned or not learned.quests then
|
||||
return false
|
||||
end
|
||||
|
||||
for _, qData in pairs(learned.quests) do
|
||||
if qData[2] and qData[2][1] then
|
||||
for _, entry in ipairs(qData[2][1]) do
|
||||
local entryId = type(entry) == "table" and entry[1] or entry
|
||||
if entryId == npcId then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
if qData[3] and qData[3][1] then
|
||||
for _, entry in ipairs(qData[3][1]) do
|
||||
local entryId = type(entry) == "table" and entry[1] or entry
|
||||
if entryId == npcId then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
if qData[10] and qData[10][1] then
|
||||
for _, entry in ipairs(qData[10][1]) do
|
||||
local entryId = type(entry) == "table" and entry[1] or entry
|
||||
if entryId == npcId then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function QuestieLearner:LearnItem(itemId, name, itemLevel, requiredLevel, itemClass, itemSubClass)
|
||||
if not self:IsEnabled() then return end
|
||||
if not Questie.dbLearner.global.settings.learnItems then return end
|
||||
@@ -2361,14 +2399,19 @@ function QuestieLearner:LearnObject(objectId, name, spawnX, spawnY, spawnZoneId,
|
||||
|
||||
-- Live injection into objectDataOverrides so QueryObjectSingle works without reload
|
||||
if self:IsLearnerLiveEnabled() and QuestieDB and QuestieDB.objectDataOverrides then
|
||||
local allowSpawnMerge = existing.questRelevant or HasQuestObjectReferences(objectId)
|
||||
local ovr = QuestieDB.objectDataOverrides[objectId]
|
||||
if not ovr then
|
||||
QuestieDB.objectDataOverrides[objectId] = existing
|
||||
if allowSpawnMerge then
|
||||
QuestieDB.objectDataOverrides[objectId] = existing
|
||||
else
|
||||
QuestieDB.objectDataOverrides[objectId] = DeepCopy(CopyWithoutField(existing, 4))
|
||||
end
|
||||
else
|
||||
for k, v in pairs(existing) do
|
||||
if ovr[k] == nil and not IsAscensionProtected("OBJECT", objectId, k) then ovr[k] = v end
|
||||
end
|
||||
if existing[4] and not IsAscensionProtected("OBJECT", objectId, 4) then
|
||||
if existing[4] and (not IsAscensionProtected("OBJECT", objectId, 4) or allowSpawnMerge) then
|
||||
ovr[4] = ovr[4] or {}
|
||||
for zid, coords in pairs(existing[4]) do
|
||||
ovr[4][zid] = ovr[4][zid] or {}
|
||||
|
||||
Reference in New Issue
Block a user