Add personal cooldown announcer
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
-- CYKA_EVENT_TICKER
|
||||
function(e)
|
||||
for _, spell in ipairs(aura_env.spells) do
|
||||
---@cast spell Spell
|
||||
spell:Update()
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
-- PLAYER_ENTERING_WORLD GUILD_ROSTER_UPDATE
|
||||
function(e)
|
||||
if aura_env.debug then print(string.format("Current ticker: %s", tostring(aura_env.ticker))) end
|
||||
if aura_env.ticker == nil then
|
||||
if aura_env.debug then print("Creating ticker") end
|
||||
local aura_env = aura_env
|
||||
aura_env.ticker = C_Timer.NewTicker(0.5, function()
|
||||
if aura_env.debug then print("Ticker calling CYKA_EVENT_TICKER") end
|
||||
WeakAuras.ScanEvents("CYKA_EVENT_TICKER")
|
||||
end)
|
||||
end
|
||||
end
|
||||
73
Complete Projects/Legion/PersonalCooldownAnnouncer/init.lua
Normal file
73
Complete Projects/Legion/PersonalCooldownAnnouncer/init.lua
Normal file
@@ -0,0 +1,73 @@
|
||||
aura_env.debug = false
|
||||
aura_env.ticker = nil
|
||||
|
||||
---@class Spell
|
||||
---@field name string
|
||||
---@field id number
|
||||
---@field isOnCooldown boolean
|
||||
---@field announced boolean
|
||||
---@field remaining number
|
||||
Spell = {
|
||||
---@param id number
|
||||
---@param name string
|
||||
---@return Spell
|
||||
new = function(id, name)
|
||||
local self = setmetatable({}, {
|
||||
__index = Spell
|
||||
})
|
||||
self.id = id
|
||||
self.name = name
|
||||
self.isOnCooldown = false
|
||||
self.announced = false
|
||||
self.remaining = 0
|
||||
return self
|
||||
end,
|
||||
|
||||
---@param self Spell
|
||||
Update = function(self)
|
||||
local start, duration = GetSpellCooldown(self.id)
|
||||
local isOnCooldown = start > 0 and duration > 3
|
||||
local remaining = start + duration - GetTime()
|
||||
|
||||
if not isOnCooldown and self.isOnCooldown then
|
||||
self:playComplete()
|
||||
self.announced = false
|
||||
end
|
||||
if not self.announced and isOnCooldown and remaining < 10 then
|
||||
self:playSoon()
|
||||
self.announced = true
|
||||
end
|
||||
|
||||
self.isOnCooldown = isOnCooldown
|
||||
self.remaining = remaining
|
||||
end,
|
||||
|
||||
---@param self Spell
|
||||
playComplete = function(self)
|
||||
local soundFile = string.format("Interface\\Sounds\\cooldown\\%s.ogg", self.name)
|
||||
if aura_env.debug then print(string.format("%s is off cooldown, playing sound file at %s", self.name, soundFile)) end
|
||||
local success = PlaySoundFile(soundFile, "Master")
|
||||
if not success then
|
||||
print(string.format("Failed to play sound for %s", self.name))
|
||||
end
|
||||
end,
|
||||
|
||||
---@param self Spell
|
||||
playSoon = function(self)
|
||||
local soundFile = string.format("Interface\\Sounds\\cooldown\\%sSoon.ogg", self.name)
|
||||
if aura_env.debug then print(string.format("%s is almost off cooldown, playing sound file at %s", self.name, soundFile)) end
|
||||
local success = PlaySoundFile(soundFile, "Master")
|
||||
if not success then
|
||||
print(string.format("Failed to play sound for %s", self.name))
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
aura_env.spells = {
|
||||
Spell.new(107574, "Avatar"),
|
||||
Spell.new(1719, "BattleCry"),
|
||||
Spell.new(205545, "OdynsFury"),
|
||||
Spell.new(26297, "Berserking"),
|
||||
Spell.new(12292, "Bloodbath"),
|
||||
Spell.new(23881, "Bloodthirst")
|
||||
}
|
||||
Reference in New Issue
Block a user