Ignore inventory containers in AoE Loot

This commit is contained in:
Dusk-92
2026-09-01 18:19:07 +02:00
parent 66be31dbdb
commit ebf78b5c75
+39
View File
@@ -14,6 +14,23 @@ module.enable = function(self)
local frame = CreateFrame("Frame", "ShaguTweaksAoELoot")
local pending = false
local releaseDeadline = 0
local containerLootDeadline = 0
local function TrackContainerUse(bag, slot)
if not C_Container or not C_Container.IsContainerItemOpenable then return end
local isOpenable, canOpen = C_Container.IsContainerItemOpenable(bag, slot)
if isOpenable and canOpen then
-- LOOT_OPENED is also fired by clams, lockboxes and similar bag items.
-- Mark that session before UseContainerItem runs so it remains under the
-- normal client handling and the consumed container can leave the bag.
containerLootDeadline = GetTime() + 3
end
end
-- Use the ShaguTweaks hook explicitly because its prepend mode records the
-- bag item before UseContainerItem can synchronously fire LOOT_OPENED.
ShaguTweaks.hooksecurefunc("UseContainerItem", TrackContainerUse, true)
local function IsMasterLootActive()
if not GetLootMethod then return false end
@@ -31,6 +48,15 @@ module.enable = function(self)
return true
end
local function HasNearbyLootableCorpse()
-- Older ClassicAPI builds may not expose the query yet. Keep AoE Loot
-- functional there; the container hook above still protects bag items.
if not C_Loot or not C_Loot.GetNearbyLootableUnits then return true end
local units = C_Loot.GetNearbyLootableUnits()
return type(units) == "table" and table.getn(units) > 0
end
local function StartAoELoot()
-- Defer for one frame so the normal loot session can close cleanly.
frame:SetScript("OnUpdate", nil)
@@ -67,6 +93,14 @@ module.enable = function(self)
frame:SetScript("OnEvent", function()
if event == "LOOT_OPENED" then
-- Inventory containers use the same loot events as corpses. Let the
-- normal client finish them instead of closing their loot session.
if containerLootDeadline > 0 then
local isContainerLoot = GetTime() <= containerLootDeadline
containerLootDeadline = 0
if isContainerLoot then return end
end
-- The master looter must keep the normal window to inspect and assign loot.
if IsMasterLootActive() then
pending = false
@@ -75,6 +109,11 @@ module.enable = function(self)
return
end
-- Chests, fishing nodes and other non-corpse sources also emit
-- LOOT_OPENED. AoE Loot only has work to do when ClassicAPI can actually
-- see at least one nearby lootable unit.
if not HasNearbyLootableCorpse() then return end
if pending or not CanStartAoELoot() then return end
pending = true