diff --git a/README.md b/README.md index df7df42..d781d29 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,7 @@ Other modules can also benefit indirectly from ClassicAPI through shared ShaguTw ### Loot +- AoE Loot - Improved Roll Frames - Loot Cursor @@ -174,6 +175,8 @@ Additional maintenance and Turtle WoW work by **paokkerkir**. ClassicAPI compatibility fork maintained by **Dusk-92**. +Special thanks to **Sandrea** for providing **AoELoot**, adapted here as the **AoE Loot** module. + Additional code and ideas from **pfUI** and **zUI**. Extended Movable Unit Frames support adapted from **TokensWorth/ShaguTweaks-mods**, originally released under MIT by **GryllsAddons**. See `THIRD_PARTY_NOTICES.md`. diff --git a/ShaguTweaks.toc b/ShaguTweaks.toc index e823f89..04c1195 100644 --- a/ShaguTweaks.toc +++ b/ShaguTweaks.toc @@ -91,6 +91,7 @@ mods\turtle-wow.lua mods\superwow.lua mods\reduced-actionbar.lua mods\no-toggle.lua +mods\aoe-loot.lua mods\loot-cursor.lua mods\improved-roll-frames.lua mods\improved-castbar.lua diff --git a/mods/aoe-loot.lua b/mods/aoe-loot.lua new file mode 100644 index 0000000..ae7dd67 --- /dev/null +++ b/mods/aoe-loot.lua @@ -0,0 +1,66 @@ +-- Adapted from AoELoot by Sandrea / ChatGPT for ShaguTweaks-ClassicAPI. + +local T = ShaguTweaks.T + +local module = ShaguTweaks:register({ + title = T["AoE Loot"], + description = T["Automatically loots all nearby corpses using ClassicAPI. Leaves Master Loot untouched."], + expansions = { ["vanilla"] = true }, + category = T["Loot"], + enabled = nil, +}) + +module.enable = function(self) + local frame = CreateFrame("Frame", "ShaguTweaksAoELoot") + local pending = false + + local function IsMasterLootActive() + if not GetLootMethod then return false end + return GetLootMethod() == "master" + end + + local function CanStartAoELoot() + if IsMasterLootActive() then return false end + if not C_Loot or not C_Loot.LootAllCorpses then return false end + + if C_Loot.IsScanInProgress and C_Loot.IsScanInProgress() then + return false + end + + return true + end + + local function StartAoELoot() + -- Defer for one frame so the normal loot session can close cleanly. + frame:SetScript("OnUpdate", nil) + + if CanStartAoELoot() then + C_Loot.LootAllCorpses() + end + end + + frame:RegisterEvent("LOOT_OPENED") + frame:RegisterEvent("LOOT_CLOSED") + + frame:SetScript("OnEvent", function() + if event == "LOOT_OPENED" then + -- The master looter must keep the normal window to inspect and assign loot. + if IsMasterLootActive() then + pending = false + frame:SetScript("OnUpdate", nil) + return + end + + if pending or not CanStartAoELoot() then return end + + pending = true + CloseLoot() + return + end + + if event == "LOOT_CLOSED" and pending then + pending = false + frame:SetScript("OnUpdate", StartAoELoot) + end + end) +end