detect fear ward cd when buffed pre arena start

This commit is contained in:
Sumsebrum 2022-01-11 00:05:31 +01:00
parent 1b2311fea2
commit 8df7aae3b6
2 changed files with 28 additions and 9 deletions

View File

@ -1,13 +1,14 @@
local select, string_gsub, tostring = select, string.gsub, tostring
local select, string_gsub, tostring, pairs = select, string.gsub, tostring, pairs
local CombatLogGetCurrentEventInfo = CombatLogGetCurrentEventInfo
local AURA_TYPE_DEBUFF = AURA_TYPE_DEBUFF
local AURA_TYPE_BUFF = AURA_TYPE_BUFF
local UnitName, UnitAura, UnitRace, UnitClass, UnitGUID, UnitIsUnit = UnitName, UnitAura, UnitRace, UnitClass, UnitGUID, UnitIsUnit
local UnitName, UnitAura, UnitRace, UnitClass, UnitGUID, UnitIsUnit, UnitExists = UnitName, UnitAura, UnitRace, UnitClass, UnitGUID, UnitIsUnit, UnitExists
local UnitCastingInfo, UnitChannelInfo = UnitCastingInfo, UnitChannelInfo
local GetSpellInfo = GetSpellInfo
local FindAuraByName = AuraUtil.FindAuraByName
local GetTime = GetTime
local Gladdy = LibStub("Gladdy")
local Cooldowns = Gladdy.modules["Cooldowns"]
@ -50,9 +51,9 @@ function EventListener:Reset()
self:SetScript("OnEvent", nil)
end
function Gladdy:DetectSpec(unit, specSpell)
if specSpell then
self.modules["Cooldowns"]:DetectSpec(unit, specSpell)
function Gladdy:DetectSpec(unit, spec)
if spec then
self.modules["Cooldowns"]:DetectSpec(unit, spec)
end
end
@ -73,11 +74,18 @@ function Gladdy:SpotEnemy(unit, auraScan)
end
if auraScan and not button.spec then
for n = 1, 30 do
local spellName,_,_,_,_,_,unitCaster = UnitAura(unit, n, "HELPFUL")
local spellName,_,_,_,_,expirationTime,unitCaster = UnitAura(unit, n, "HELPFUL")
if ( not spellName ) then
break
end
if Gladdy.specBuffs[spellName] then
if Gladdy.cooldownBuffs[spellName] then -- Check for auras that detect used CDs (like Fear Ward)
for arenaUnit,v in pairs(self.buttons) do
if (UnitIsUnit(arenaUnit, unitCaster)) then
Cooldowns:CooldownUsed(arenaUnit, v.class, Gladdy.cooldownBuffs[spellName].spellId, expirationTime - GetTime())
end
end
end
if Gladdy.specBuffs[spellName] then -- Check for auras that detect a spec
local unitPet = string_gsub(unit, "%d$", "pet%1")
if UnitIsUnit(unit, unitCaster) or UnitIsUnit(unitPet, unitCaster) then
Gladdy:DetectSpec(unit, Gladdy.specBuffs[spellName])
@ -202,6 +210,10 @@ Gladdy.exceptionNames = { -- TODO MOVE ME TO CLASSBUFFS LIB
[27010] = select(1, GetSpellInfo(27010)) .. " " .. select(1, GetSpellInfo(16689)),
}
Gladdy.cooldownBuffs = {
[GetSpellInfo(6346)] = { cd = 180, spellId = 6346 }, -- Fear Ward
}
function EventListener:UNIT_AURA(unit)
local button = Gladdy.buttons[unit]
if not button then
@ -220,6 +232,13 @@ function EventListener:UNIT_AURA(unit)
Gladdy:SendMessage("AURA_GAIN_LIMIT", unit, auraType, n - 1)
break
end
if Gladdy.cooldownBuffs[spellName] then -- Check for auras that hint used CDs (like Fear Ward)
for arenaUnit,v in pairs(Gladdy.buttons) do
if (UnitIsUnit(arenaUnit, unitCaster)) then
Cooldowns:CooldownUsed(arenaUnit, v.class, Gladdy.cooldownBuffs[spellName].spellId, expirationTime - GetTime())
end
end
end
if not button.spec and Gladdy.specBuffs[spellName] then
local unitPet = string_gsub(unit, "%d$", "pet%1")
if unitCaster and (UnitIsUnit(unit, unitCaster) or UnitIsUnit(unitPet, unitCaster)) then

View File

@ -502,7 +502,7 @@ function Cooldowns:UpdateCooldowns(button)
end
end
function Cooldowns:CooldownUsed(unit, unitClass, spellId)
function Cooldowns:CooldownUsed(unit, unitClass, spellId, expirationTimeInSeconds)
local button = Gladdy.buttons[unit]
if not button then
return
@ -547,7 +547,7 @@ function Cooldowns:CooldownUsed(unit, unitClass, spellId)
if (Gladdy.db.cooldown) then
-- start cooldown
self:CooldownStart(button, spellId, cd)
self:CooldownStart(button, spellId, expirationTimeInSeconds or cd)
end
--[[ announcement