Skip to content

Commit

Permalink
Fix roll popup logic for quest drops
Browse files Browse the repository at this point in the history
  • Loading branch information
Anonomit committed Nov 23, 2024
1 parent 87ca721 commit 0b7d23c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
33 changes: 16 additions & 17 deletions ItemConditions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0b7d23c

Please sign in to comment.