Skip to content

Commit

Permalink
feat(Equipment): Add excludeTrinkets parameter for GetUseableItems
Browse files Browse the repository at this point in the history
- Allow us to exclude trinket items for profiles that manually handle trinkets
- During UpdateEquipment(), check ItemObject:OnUseSpell() to avoid issues with ItemObject:IsUsable(), such as some items not showing usable if no target is selected, which is when UpdateEquipment is most often called
  • Loading branch information
Cilraaz committed Aug 11, 2024
1 parent 913aa29 commit 7281355
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions HeroLib/Class/Unit/Player/Equipment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ function Player:UpdateEquipment()
else
ItemObject = Item(ItemID)
end
if ItemObject:IsUsable() or UsableItemOverride[ItemID] then
if ItemObject:OnUseSpell() or UsableItemOverride[ItemID] then
table.insert(UseableItems, ItemObject)
end
end
Expand Down Expand Up @@ -402,14 +402,17 @@ do
end

-- Return the trinket item of the first usable trinket that is not blacklisted or excluded
function Player:GetUseableItems(ExcludedItems, slotID)
function Player:GetUseableItems(ExcludedItems, slotID, excludeTrinkets)
for _, Item in ipairs(UseableItems) do
local ItemID = Item:ID()
local IsExcluded = false

-- Did we specify a slotID? If so, mark as excluded if this trinket isn't in that slot
if slotID and Equipment[slotID] ~= ItemID then
IsExcluded = true
-- Exclude trinket items if excludeTrinkets is true
elseif excludeTrinkets and (Equipment[13] == ItemID or Equipment[14] == ItemID) then
IsExcluded = true
-- Check if the trinket is ready, unless it's blacklisted
elseif Item:IsReady() and not Player:IsItemBlacklisted(Item) then
for i=1, #ExcludedItems do
Expand Down

0 comments on commit 7281355

Please sign in to comment.