Skip to content

Commit

Permalink
Implement master looter ticker to fix failed loots
Browse files Browse the repository at this point in the history
  • Loading branch information
AeroScripts committed Dec 2, 2020
1 parent 4d18858 commit eca16f2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mkdir build
cd ..
zip -r GogoLoot/build/GogoLoot GogoLoot -i '*.lua' '*.toc' '*.xml' 'GogoLoot/LICENSE' 'GogoLoot/README.md'
cd GogoLoot/build
open GogoLoot/build

31 changes: 24 additions & 7 deletions loot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ events:SetScript("OnEvent", function()

local events = CreateFrame("Frame")
local canLoot = true
local lootTicker = nil
local lootAPIOpen = false

events:RegisterEvent("LOOT_BIND_CONFIRM")
events:RegisterEvent("LOOT_READY")
Expand All @@ -308,7 +310,9 @@ events:SetScript("OnEvent", function()
events:SetScript("OnEvent", function(self, evt, arg, message, a, b, c, ...)
--if ("LOOT_READY" == evt or "LOOT_OPENED" == evt) and not canLoot then
-- canOpenWindow = true
if ("LOOT_OPENED" == evt) and canLoot then
if "LOOT_READY" == evt then
lootAPIOpen = true
elseif ("LOOT_OPENED" == evt) and canLoot then
debug("LootReady! " .. evt)
GogoLoot.canOpenWindow = true
if GetCVarBool("autoLootDefault") ~= IsModifiedClick("AUTOLOOTTOGGLE") then
Expand All @@ -327,10 +331,10 @@ events:SetScript("OnEvent", function()
end
else
canLoot = false
local index = GetNumLootItems()
local targetPlayer = strlower(UnitName("Player"))--GogoLoot_Config.players["all"]
if targetPlayer then
local function doLootLoop()
local index = GetNumLootItems()
local playerIndex = {}

while index > 0 do -- we run this in its own loop to ensure the player name is available for all slots. Triggering a master loot event can mess with it
for i = 1, GetNumGroupMembers() do
local playerAtIndex = GetMasterLootCandidate(index, i)
Expand All @@ -348,26 +352,35 @@ events:SetScript("OnEvent", function()

local hasNormalLoot = false

while index > 0 do
local couldntLoot = GogoLoot:VacuumSlot(index, playerIndex[index])
for i=1,index do
index = GetNumLootItems()
local couldntLoot = GogoLoot:VacuumSlot(i, playerIndex[i])
hasNormalLoot = hasNormalLoot or couldntLoot
index = index - 1
end

if hasNormalLoot then
lootTicker:Cancel()
lootTicker = nil
GogoLoot:showLootFrame("has normal loot")
else
debug("No normal loot")
end
end
doLootLoop()
lootTicker = C_Timer.NewTicker(0.3, doLootLoop)
end
end
else
GogoLoot:showLootFrame("autoloot disabled")
end
elseif "LOOT_CLOSED" == evt then
lootAPIOpen = false
canLoot = true
GogoLoot.canOpenWindow = false
if lootTicker then
lootTicker:Cancel()
lootTicker = nil
end
elseif "START_LOOT_ROLL" == evt then
local rollid = tonumber(arg)
if rollid and GogoLoot_Config.autoRoll then
Expand All @@ -394,6 +407,10 @@ events:SetScript("OnEvent", function()
GogoLoot:showLootFrame("bind confirm")
elseif "UI_ERROR_MESSAGE" == evt and message and (message == ERR_ITEM_MAX_COUNT or message == ERR_INV_FULL or string.match(strlower(message), "inventory") or string.match(strlower(message), "loot")) and not badErrors[message] then
debug(message)
if lootTicker then
lootTicker:Cancel()
lootTicker = nil
end
GogoLoot:showLootFrame("inventory error " .. message)
elseif "BAG_UPDATE" == evt and GogoLoot_Config.enableAutoGray then

Expand Down

0 comments on commit eca16f2

Please sign in to comment.