74 lines
2.0 KiB
Lua
74 lines
2.0 KiB
Lua
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")
|
|
}
|