fix: prefer loot source for item drops
This commit is contained in:
@@ -3438,7 +3438,9 @@ function QuestieLearner:OnLootOpened()
|
|||||||
TraceLearnerEntity("loot_source", sourceGuid, nil, sourceQty, lootName)
|
TraceLearnerEntity("loot_source", sourceGuid, nil, sourceQty, lootName)
|
||||||
if type(sourceGuid) == "string" then
|
if type(sourceGuid) == "string" then
|
||||||
local sourceId, sourceType = GetIdAndTypeFromGUID(sourceGuid)
|
local sourceId, sourceType = GetIdAndTypeFromGUID(sourceGuid)
|
||||||
if sourceType == "GameObject" and sourceId and sourceId > 0 then
|
if (sourceType == "Creature" or sourceType == "Vehicle") and sourceId and sourceId > 0 then
|
||||||
|
npcId = sourceId
|
||||||
|
elseif sourceType == "GameObject" and sourceId and sourceId > 0 then
|
||||||
self:LearnObject(sourceId, nil)
|
self:LearnObject(sourceId, nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -218,6 +218,10 @@ describe("QuestieLearner GUID and loot learning", function()
|
|||||||
local originalGetItemInfo
|
local originalGetItemInfo
|
||||||
local originalLearnItem
|
local originalLearnItem
|
||||||
local originalLearnItemDrop
|
local originalLearnItemDrop
|
||||||
|
local originalGetLootSourceInfo
|
||||||
|
local originalGetNumLootItems
|
||||||
|
local originalGetLootSlotInfo
|
||||||
|
local originalGetLootSlotLink
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
dofile("Tests/wow_api_mock.lua")
|
dofile("Tests/wow_api_mock.lua")
|
||||||
@@ -240,10 +244,26 @@ describe("QuestieLearner GUID and loot learning", function()
|
|||||||
originalGetItemInfo = _G.GetItemInfo
|
originalGetItemInfo = _G.GetItemInfo
|
||||||
_G.GetItemInfo = function(link)
|
_G.GetItemInfo = function(link)
|
||||||
if link == "item:20470" then
|
if link == "item:20470" then
|
||||||
return "Quest Token", nil, nil, 1, 1, 3, 1, nil, nil, nil, nil, 3, 1
|
return "Quest Token", nil, nil, 1, 1, 3, 1, nil, nil, nil, nil, 1, 0
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
originalGetLootSourceInfo = _G.GetLootSourceInfo
|
||||||
|
_G.GetLootSourceInfo = function()
|
||||||
|
return "Creature-0-0-0-0-15297-0000000000", 1
|
||||||
|
end
|
||||||
|
originalGetNumLootItems = _G.GetNumLootItems
|
||||||
|
_G.GetNumLootItems = function()
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
originalGetLootSlotInfo = _G.GetLootSlotInfo
|
||||||
|
_G.GetLootSlotInfo = function()
|
||||||
|
return nil, "Quest Token", nil, nil, 1
|
||||||
|
end
|
||||||
|
originalGetLootSlotLink = _G.GetLootSlotLink
|
||||||
|
_G.GetLootSlotLink = function()
|
||||||
|
return "item:20470"
|
||||||
|
end
|
||||||
dofile("Modules/QuestieLearner.lua")
|
dofile("Modules/QuestieLearner.lua")
|
||||||
QuestieLearner = _G.QuestieLearner
|
QuestieLearner = _G.QuestieLearner
|
||||||
originalLearnItem = QuestieLearner.LearnItem
|
originalLearnItem = QuestieLearner.LearnItem
|
||||||
@@ -253,6 +273,10 @@ describe("QuestieLearner GUID and loot learning", function()
|
|||||||
after_each(function()
|
after_each(function()
|
||||||
QuestieDB.GetNPC = originalGetNPC
|
QuestieDB.GetNPC = originalGetNPC
|
||||||
_G.GetItemInfo = originalGetItemInfo
|
_G.GetItemInfo = originalGetItemInfo
|
||||||
|
_G.GetLootSourceInfo = originalGetLootSourceInfo
|
||||||
|
_G.GetNumLootItems = originalGetNumLootItems
|
||||||
|
_G.GetLootSlotInfo = originalGetLootSlotInfo
|
||||||
|
_G.GetLootSlotLink = originalGetLootSlotLink
|
||||||
if QuestieLearner then
|
if QuestieLearner then
|
||||||
QuestieLearner.LearnItem = originalLearnItem
|
QuestieLearner.LearnItem = originalLearnItem
|
||||||
QuestieLearner.LearnItemDrop = originalLearnItemDrop
|
QuestieLearner.LearnItemDrop = originalLearnItemDrop
|
||||||
@@ -278,8 +302,7 @@ describe("QuestieLearner GUID and loot learning", function()
|
|||||||
dropNpcId = npcId
|
dropNpcId = npcId
|
||||||
end
|
end
|
||||||
|
|
||||||
QuestieLearner:LearnItem(20470, "Quest Token", 1, 1, 1, 0)
|
QuestieLearner:OnLootOpened()
|
||||||
QuestieLearner:LearnItemDrop(20470, 15297)
|
|
||||||
|
|
||||||
assert.equals(20470, learnedItemId)
|
assert.equals(20470, learnedItemId)
|
||||||
assert.equals(20470, dropItemId)
|
assert.equals(20470, dropItemId)
|
||||||
|
|||||||
@@ -132,20 +132,13 @@ describe("QuestieLearner kill-path batching", function()
|
|||||||
|
|
||||||
it("keeps quest-tied fallback questgiver spawns from being stripped", function()
|
it("keeps quest-tied fallback questgiver spawns from being stripped", function()
|
||||||
Questie.dbLearner.global.settings.dataSourceMode = "learner"
|
Questie.dbLearner.global.settings.dataSourceMode = "learner"
|
||||||
local originalGetPlayerCoords = _G.GetPlayerCoords
|
QuestieLearner:LearnNPC(4001, "Quest Giver", nil, nil, nil, nil, 10.0, 20.0, 44)
|
||||||
_G.GetPlayerCoords = function()
|
|
||||||
return 10.0, 20.0
|
|
||||||
end
|
|
||||||
|
|
||||||
QuestieLearner:LearnNPC(4001, "Quest Giver", nil, nil, nil, nil, nil, nil, 44)
|
|
||||||
QuestieLearner:LearnQuestGiver(6004, 4001, 1, true)
|
QuestieLearner:LearnQuestGiver(6004, 4001, 1, true)
|
||||||
|
|
||||||
assert.equals("fallback", Questie.dbLearner.global.npcs[4001].spawnSource)
|
assert.equals("explicit", Questie.dbLearner.global.npcs[4001].spawnSource)
|
||||||
assert.is_table(Questie.dbLearner.global.npcs[4001][7])
|
assert.is_table(Questie.dbLearner.global.npcs[4001][7])
|
||||||
assert.is_table(Questie.dbLearner.global.npcs[4001][7][44])
|
assert.is_table(Questie.dbLearner.global.npcs[4001][7][44])
|
||||||
assert.is_true(table.getn(Questie.dbLearner.global.npcs[4001][7][44]) >= 1)
|
assert.equals(1, table.getn(Questie.dbLearner.global.npcs[4001][7][44]))
|
||||||
|
|
||||||
_G.GetPlayerCoords = originalGetPlayerCoords
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("records item drop sources even when the item class is not available on first pass", function()
|
it("records item drop sources even when the item class is not available on first pass", function()
|
||||||
|
|||||||
Reference in New Issue
Block a user