fix racial/trinket usage tracking

This commit is contained in:
Sumsebrum 2022-07-31 18:17:49 +02:00
parent 14dc227c86
commit 5f1e1da895
3 changed files with 32 additions and 27 deletions

View File

@ -157,7 +157,6 @@ function EventListener:COMBAT_LOG_EVENT_UNFILTERED()
self:DetectSpec(srcUnit, Gladdy.specSpells[spellName]) self:DetectSpec(srcUnit, Gladdy.specSpells[spellName])
end end
if (eventType == "SPELL_CAST_SUCCESS" or eventType == "SPELL_AURA_APPLIED" or eventType == "SPELL_MISSED") then if (eventType == "SPELL_CAST_SUCCESS" or eventType == "SPELL_AURA_APPLIED" or eventType == "SPELL_MISSED") then
local unitRace = Gladdy.buttons[srcUnit].race
self:DetectSpec(srcUnit, Gladdy.specSpells[spellName]) self:DetectSpec(srcUnit, Gladdy.specSpells[spellName])
-- cooldown tracker -- cooldown tracker
if Gladdy.db.cooldown and Cooldowns.cooldownSpellIds[spellName] then if Gladdy.db.cooldown and Cooldowns.cooldownSpellIds[spellName] then
@ -177,10 +176,6 @@ function EventListener:COMBAT_LOG_EVENT_UNFILTERED()
end end
end end
end end
if Gladdy.db.racialEnabled and Gladdy:Racials()[unitRace].spellName == spellName and Gladdy:Racials()[unitRace][spellID] then
Gladdy:SendMessage("RACIAL_USED", srcUnit)
end
end end
if (eventType == "SPELL_AURA_REMOVED" and (spellID == 16188 or spellID == 17116) and Gladdy.buttons[srcUnit].class) then if (eventType == "SPELL_AURA_REMOVED" and (spellID == 16188 or spellID == 17116) and Gladdy.buttons[srcUnit].class) then
Cooldowns:CooldownUsed(srcUnit, Gladdy.buttons[srcUnit].class, spellID) Cooldowns:CooldownUsed(srcUnit, Gladdy.buttons[srcUnit].class, spellID)
@ -191,6 +186,7 @@ end
function EventListener:ARENA_OPPONENT_UPDATE(unit, updateReason) function EventListener:ARENA_OPPONENT_UPDATE(unit, updateReason)
--[[ updateReason: seen, unseen, destroyed, cleared ]] --[[ updateReason: seen, unseen, destroyed, cleared ]]
unit = Gladdy:GetArenaUnit(unit)
local button = Gladdy.buttons[unit] local button = Gladdy.buttons[unit]
local pet = Gladdy.modules["Pets"].frames[unit] local pet = Gladdy.modules["Pets"].frames[unit]
if button or pet then if button or pet then
@ -332,12 +328,29 @@ function EventListener:UNIT_SPELLCAST_CHANNEL_START(unit)
end end
end end
function EventListener:UNIT_SPELLCAST_SUCCEEDED(unit) function EventListener:UNIT_SPELLCAST_SUCCEEDED(...)
local unit, castGUID, spellID = ...
unit = Gladdy:GetArenaUnit(unit, true)
if Gladdy.buttons[unit] then if Gladdy.buttons[unit] then
local spellName = UnitCastingInfo(unit) local unitRace = Gladdy.buttons[unit].race
local spellName = GetSpellInfo(spellID)
-- spec detection
if Gladdy.specSpells[spellName] and not Gladdy.buttons[unit].spec then if Gladdy.specSpells[spellName] and not Gladdy.buttons[unit].spec then
self:DetectSpec(unit, Gladdy.specSpells[spellName]) self:DetectSpec(unit, Gladdy.specSpells[spellName])
end end
-- trinket
if spellID == 42292 or spellID == 59752 then
Gladdy:Debug("INFO", "UNIT_SPELLCAST_SUCCEEDED - TRINKET_USED", unit, spellID)
Gladdy:SendMessage("TRINKET_USED", unit)
end
-- racial
if Gladdy:Racials()[unitRace].spellName == spellName and Gladdy:Racials()[unitRace][spellID] then
Gladdy:Debug("INFO", "UNIT_SPELLCAST_SUCCEEDED - RACIAL_USED", unit, spellID)
Gladdy:SendMessage("RACIAL_USED", unit)
end
end end
end end

View File

@ -203,7 +203,7 @@ end
function Racial:RACIAL_USED(unit, expirationTime, spellName) function Racial:RACIAL_USED(unit, expirationTime, spellName)
local racial = self.frames[unit] local racial = self.frames[unit]
local button = Gladdy.buttons[unit] local button = Gladdy.buttons[unit]
if (not racial or not button or not button.race) then if (not racial or not button or not button.race or not Gladdy.db.racialEnabled) then
return return
end end
if expirationTime and Gladdy:Racials()[button.race].spellName ~= spellName then if expirationTime and Gladdy:Racials()[button.race].spellName ~= spellName then

View File

@ -247,14 +247,13 @@ function Trinket:Test(unit)
return return
end end
if (unit == "arena1" or unit == "arena2") then if (unit == "arena1" or unit == "arena2") then
self:Used(unit, GetTime() * 1000, 120000) Gladdy:SendMessage("TRINKET_USED", unit)
end end
end end
function Trinket:JOINED_ARENA() function Trinket:JOINED_ARENA()
self:RegisterEvent("ARENA_COOLDOWNS_UPDATE") self:RegisterEvent("ARENA_COOLDOWNS_UPDATE")
self:RegisterEvent("ARENA_CROWD_CONTROL_SPELL_UPDATE") self:RegisterEvent("ARENA_CROWD_CONTROL_SPELL_UPDATE")
self:RegisterUnitEvent("UNIT_SPELLCAST_SUCCEEDED", "arena1", "arena2", "arena3", "arena4", "arena5")
self:SetScript("OnEvent", function(self, event, ...) self:SetScript("OnEvent", function(self, event, ...)
if self[event] then if self[event] then
self[event](self, ...) self[event](self, ...)
@ -273,15 +272,11 @@ function Trinket:ARENA_CROWD_CONTROL_SPELL_UPDATE(...)
end end
end end
function Trinket:UNIT_SPELLCAST_SUCCEEDED(...) function Trinket:TRINKET_USED(unit)
local unitID, castGUID, spellID = ... if Gladdy.buttons[unit] then
if Gladdy.buttons[unitID] then self:Used(unit, GetTime() * 1000,
if spellID == 42292 or spellID == 59752 then Gladdy.buttons[unit].trinket.itemID and Gladdy:GetPvpTrinkets()[Gladdy.buttons[unit].trinket.itemID]
Gladdy:Debug("INFO", "Trinket:UNIT_SPELLCAST_SUCCEEDED", unitID, spellID) or 120000)
self:Used(unitID, GetTime() * 1000,
Gladdy.buttons[unitID].trinket.itemID and Gladdy:GetPvpTrinkets()[Gladdy.buttons[unitID].trinket.itemID]
or 120000)
end
end end
end end
@ -291,11 +286,11 @@ function Trinket:RACIAL_USED(unit) -- Wrath only
return return
end end
if Gladdy.buttons[unit].race == "Scourge" then if Gladdy.buttons[unit].race == "Scourge" then
if trinket.active and trinket.timeLeft >= 44 then if trinket.active and trinket.timeLeft >= 45 then
-- do nothing -- do nothing
else else
trinket.active = false trinket.active = false
self:Used(unit, GetTime() * 1000, 45000, true) self:Used(unit, GetTime() * 1000, 45000)
end end
elseif Gladdy.buttons[unit].race == "Human" then elseif Gladdy.buttons[unit].race == "Human" then
trinket.active = false trinket.active = false
@ -307,8 +302,8 @@ function Trinket:ARENA_COOLDOWNS_UPDATE()
for i=1, Gladdy.curBracket do for i=1, Gladdy.curBracket do
local unitID = "arena" .. i local unitID = "arena" .. i
local spellID, itemID, startTime, duration = C_PvP.GetArenaCrowdControlInfo(unitID) local spellID, itemID, startTime, duration = C_PvP.GetArenaCrowdControlInfo(unitID)
Gladdy:Debug("INFO", "Trinket:ARENA_COOLDOWNS_UPDATE", spellID, itemID, startTime, duration)
if (spellID) then if (spellID) then
Gladdy:Debug("INFO", "Trinket:ARENA_COOLDOWNS_UPDATE", spellID, itemID, startTime, duration)
if not Gladdy.db.trinketColored and Gladdy:GetPvpTrinkets()[itemID] then if not Gladdy.db.trinketColored and Gladdy:GetPvpTrinkets()[itemID] then
self.frames[unitID].texture:SetTexture(GetItemIcon(itemID)) self.frames[unitID].texture:SetTexture(GetItemIcon(itemID))
end end
@ -319,9 +314,9 @@ function Trinket:ARENA_COOLDOWNS_UPDATE()
end end
end end
function Trinket:Used(unit, startTime, duration, passive) function Trinket:Used(unit, startTime, duration)
local trinket = self.frames[unit] local trinket = self.frames[unit]
if (not trinket) then if (not trinket or not Gladdy.db.trinketEnabled) then
return return
end end
if not trinket.active then if not trinket.active then
@ -331,9 +326,6 @@ function Trinket:Used(unit, startTime, duration, passive)
if Gladdy.db.trinketColored then if Gladdy.db.trinketColored then
trinket:SetBackdropColor(Gladdy:SetColor(Gladdy.db.trinketColoredCd)) trinket:SetBackdropColor(Gladdy:SetColor(Gladdy.db.trinketColoredCd))
end end
if not passive then
Gladdy:SendMessage("TRINKET_USED", unit)
end
end end
end end