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 CombatLogGetCurrentEventInfo = CombatLogGetCurrentEventInfo
local AURA_TYPE_DEBUFF = AURA_TYPE_DEBUFF local AURA_TYPE_DEBUFF = AURA_TYPE_DEBUFF
local AURA_TYPE_BUFF = AURA_TYPE_BUFF 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 UnitCastingInfo, UnitChannelInfo = UnitCastingInfo, UnitChannelInfo
local GetSpellInfo = GetSpellInfo local GetSpellInfo = GetSpellInfo
local FindAuraByName = AuraUtil.FindAuraByName local FindAuraByName = AuraUtil.FindAuraByName
local GetTime = GetTime
local Gladdy = LibStub("Gladdy") local Gladdy = LibStub("Gladdy")
local Cooldowns = Gladdy.modules["Cooldowns"] local Cooldowns = Gladdy.modules["Cooldowns"]
@ -50,9 +51,9 @@ function EventListener:Reset()
self:SetScript("OnEvent", nil) self:SetScript("OnEvent", nil)
end end
function Gladdy:DetectSpec(unit, specSpell) function Gladdy:DetectSpec(unit, spec)
if specSpell then if spec then
self.modules["Cooldowns"]:DetectSpec(unit, specSpell) self.modules["Cooldowns"]:DetectSpec(unit, spec)
end end
end end
@ -73,11 +74,18 @@ function Gladdy:SpotEnemy(unit, auraScan)
end end
if auraScan and not button.spec then if auraScan and not button.spec then
for n = 1, 30 do for n = 1, 30 do
local spellName,_,_,_,_,_,unitCaster = UnitAura(unit, n, "HELPFUL") local spellName,_,_,_,_,expirationTime,unitCaster = UnitAura(unit, n, "HELPFUL")
if ( not spellName ) then if ( not spellName ) then
break break
end 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") local unitPet = string_gsub(unit, "%d$", "pet%1")
if UnitIsUnit(unit, unitCaster) or UnitIsUnit(unitPet, unitCaster) then if UnitIsUnit(unit, unitCaster) or UnitIsUnit(unitPet, unitCaster) then
Gladdy:DetectSpec(unit, Gladdy.specBuffs[spellName]) 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)), [27010] = select(1, GetSpellInfo(27010)) .. " " .. select(1, GetSpellInfo(16689)),
} }
Gladdy.cooldownBuffs = {
[GetSpellInfo(6346)] = { cd = 180, spellId = 6346 }, -- Fear Ward
}
function EventListener:UNIT_AURA(unit) function EventListener:UNIT_AURA(unit)
local button = Gladdy.buttons[unit] local button = Gladdy.buttons[unit]
if not button then if not button then
@ -220,6 +232,13 @@ function EventListener:UNIT_AURA(unit)
Gladdy:SendMessage("AURA_GAIN_LIMIT", unit, auraType, n - 1) Gladdy:SendMessage("AURA_GAIN_LIMIT", unit, auraType, n - 1)
break break
end 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 if not button.spec and Gladdy.specBuffs[spellName] then
local unitPet = string_gsub(unit, "%d$", "pet%1") local unitPet = string_gsub(unit, "%d$", "pet%1")
if unitCaster and (UnitIsUnit(unit, unitCaster) or UnitIsUnit(unitPet, unitCaster)) then if unitCaster and (UnitIsUnit(unit, unitCaster) or UnitIsUnit(unitPet, unitCaster)) then

View File

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