Files
wow-weakauras/LegionWA/CooldownAlert/Init.lua
2022-08-19 12:15:20 +02:00

68 lines
2.1 KiB
Lua

aura_env.trackedSpells = {
20271, -- Judgement
26573, -- Consecration
209202, -- Eye of Tyr
213652, -- Hand of the Protector
31935, -- Avenger's Shield
53600, -- Shield of the Righteous
1044, -- Hand of Freedom
155145, -- Arcane Torrent
853, -- Hammer of Justice
6940, -- Hand of Sacrifice
31850, -- Ardent Defender
86659, -- Guardian of Ancient Kings
204018, -- Blessing of Spellwarding
}
local iconDisplayDuration = 0.4
local gcdDuration = 1.5
aura_env.workData = {}
for k, spellId in pairs(aura_env.trackedSpells) do
aura_env.workData[spellId] = {
ready = true,
hasCharges = false,
}
if GetSpellCharges(spellId) then
aura_env.workData[spellId].hasCharges = true
aura_env.workData[spellId].charges = select(1, GetSpellCharges(spellId))
end
end
aura_env.processEvent = function(allstates)
for k, spellId in pairs(aura_env.trackedSpells) do
-- Handle spells with charges
local isReady
if (aura_env.workData[spellId].hasCharges) then
local charges = select(1, GetSpellCharges(spellId))
if (charges > aura_env.workData[spellId].charges) then
isReady = true
aura_env.workData[spellId].charges = charges
else
isReady = false
aura_env.workData[spellId].charges = charges
end
else
isReady = select(2, GetSpellCooldown(spellId)) < gcdDuration
end
if (not aura_env.workData[spellId].ready and isReady) then
local icon = select(3, GetSpellInfo(spellId))
allstates[spellId] = {
show = true,
changed = true,
index = GetTime(),
resort = true,
icon = icon,
progressType = "timed",
expirationTime = GetTime() + iconDisplayDuration,
duration = iconDisplayDuration,
autoHide = true,
}
end
aura_env.workData[spellId].ready = isReady
end
end