From 0b7d23c6b2b79fde992aabe0422f0786cf851e19 Mon Sep 17 00:00:00 2001 From: Anonomit Date: Sat, 23 Nov 2024 14:50:31 -0500 Subject: [PATCH] Fix roll popup logic for quest drops --- Data.lua | 2 +- ItemConditions.lua | 33 ++++++++++++++++----------------- Server.lua | 2 +- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Data.lua b/Data.lua index 1d340c5..d96e0f5 100644 --- a/Data.lua +++ b/Data.lua @@ -14159,7 +14159,7 @@ function LootReserve.Data.CategorySorter(a, b, aID, bID) return aID < bID; end -function LootReserve.Data:GetQuestStarted(itemID) +function LootReserve.Data:GetQuestStarter(itemID) return self.QuestStarters[itemID]; end function LootReserve.Data:GetQuestDropRequirement(itemID) diff --git a/ItemConditions.lua b/ItemConditions.lua index 761e659..5903c40 100644 --- a/ItemConditions.lua +++ b/ItemConditions.lua @@ -149,26 +149,23 @@ end local function IsItemUsable(itemID, playerClass, isMe) + local item = LootReserve.ItemCache:Item(itemID); + local numOwned; if isMe then numOwned = GetItemCount(itemID, true) - LootReserve:GetTradeableItemCount(itemID); end - local item = LootReserve.ItemCache:Item(itemID); - if not item:Cache():IsCached() then - return item:IsUsableBy(playerClass), true; - end - - -- If item is Armor or Weapon then fail if class cannot equip it - if not item:IsUsableBy(playerClass) then return false end - -- If item starts a quest, make sure the quest is not completed and I do not already own the item -- If item requires a quest to loot, make sure the quest is not completed, I am on it, and I do not already own the item if isMe then - local questStartID = LootReserve.Data:GetQuestStarted(itemID); + local questStartID = LootReserve.Data:GetQuestStarter(itemID); local questDropID = LootReserve.Data:GetQuestDropRequirement(itemID); if questStartID or questDropID then - if C_QuestLog.IsQuestFlaggedCompleted(questStartID or questDropID) then + if questStartID and C_QuestLog.IsQuestFlaggedCompleted(questStartID) then + return false; + end + if questDropID and C_QuestLog.IsQuestFlaggedCompleted(questDropID) then return false; end if numOwned > 0 then @@ -186,25 +183,27 @@ local function IsItemUsable(itemID, playerClass, isMe) table.insert(collapsedHeaders, 1, i); ExpandQuestHeader(i); end - elseif questID == questStartID or questID == questDropID then + elseif questID == questDropID then found = true; break; end i = i + 1; end - for _, i in ipairs(collapsedHeaders) do CollapseQuestHeader(i); end - if found then - return false; - end + + return found; end end - if not item:IsUsableBy(playerClass) then - return false + if not item:Cache():IsCached() then + return item:IsUsableBy(playerClass), true; end + + -- If item is Armor or Weapon then fail if class cannot equip it + if not item:IsUsableBy(playerClass) then return false end + if isMe and numOwned > 0 and item:IsUnique() then return false end diff --git a/Server.lua b/Server.lua index 3efbae2..5ed197a 100644 --- a/Server.lua +++ b/Server.lua @@ -3051,7 +3051,7 @@ function LootReserve.Server:CancelRollRequest(item, winners, noHistory, advancin if reservedItem:GetEquipLocation() == "INVTYPE_FINGER" or reservedItem:GetEquipLocation() == "INVTYPE_TRINKET" then smartOverride = LootReserve.Constants.WinnerReservesRemoval.Single; -- Trying to filter to raid mats. Excluding equippable items, tokens, and quest drops. - elseif (reservedItem:GetEquipLocation() == "" or reservedItem:GetEquipLocation() == "INVTYPE_NON_EQUIP_IGNORE") and not LootReserve.Data:IsToken(reservedItem:GetID()) and not LootReserve.Data.QuestDrops[reservedItem:GetID()] then + elseif (reservedItem:GetEquipLocation() == "" or reservedItem:GetEquipLocation() == "INVTYPE_NON_EQUIP_IGNORE") and not LootReserve.Data:IsToken(reservedItem:GetID()) and not LootReserve.Data:GetQuestDropRequirement(reservedItem:GetID()) then smartOverride = LootReserve.Constants.WinnerReservesRemoval.Single; end end