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])
end
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])
-- cooldown tracker
if Gladdy.db.cooldown and Cooldowns.cooldownSpellIds[spellName] then
@ -177,10 +176,6 @@ function EventListener:COMBAT_LOG_EVENT_UNFILTERED()
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
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)
@ -191,6 +186,7 @@ end
function EventListener:ARENA_OPPONENT_UPDATE(unit, updateReason)
--[[ updateReason: seen, unseen, destroyed, cleared ]]
unit = Gladdy:GetArenaUnit(unit)
local button = Gladdy.buttons[unit]
local pet = Gladdy.modules["Pets"].frames[unit]
if button or pet then
@ -332,12 +328,29 @@ function EventListener:UNIT_SPELLCAST_CHANNEL_START(unit)
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
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
self:DetectSpec(unit, Gladdy.specSpells[spellName])
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

View File

@ -203,7 +203,7 @@ end
function Racial:RACIAL_USED(unit, expirationTime, spellName)
local racial = self.frames[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
end
if expirationTime and Gladdy:Racials()[button.race].spellName ~= spellName then

View File

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