|
|
|
@ -114,23 +114,6 @@ function Spell:GetCooldown() |
|
|
|
|
return select(2, GetSpellCooldown(self:GetID())) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
-- Get the full cooldown (time until all charges are available) |
|
|
|
|
---@return number |
|
|
|
|
function Spell:GetFullRechargeTime() |
|
|
|
|
local start, duration, enabled = GetSpellCooldown(self:GetID()) |
|
|
|
|
if enabled == 0 then |
|
|
|
|
return 0 |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local charges, maxCharges, chargeStart, chargeDuration = GetSpellCharges(self:GetID()) |
|
|
|
|
if charges == maxCharges then |
|
|
|
|
return 0 |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local totalChargeTime = ((maxCharges - charges) * chargeDuration) - ((chargeStart + chargeDuration) - GetTime()) |
|
|
|
|
return totalChargeTime |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
-- Return the castable function |
|
|
|
|
function Spell:GetCastableFunction() |
|
|
|
|
return self.CastableIfFunc |
|
|
|
@ -296,9 +279,10 @@ function Spell:IsUsable() |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
-- Check if the spell is castable |
|
|
|
|
---@param override? boolean |
|
|
|
|
---@return boolean |
|
|
|
|
function Spell:IsKnownAndUsable() |
|
|
|
|
return self:IsKnown() and not self:IsOnCooldown() and self:IsUsable() |
|
|
|
|
function Spell:IsKnownAndUsable(override) |
|
|
|
|
return self:IsKnown(override) and not self:IsOnCooldown() and self:IsUsable() |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
-- Check if the spell is castable |
|
|
|
@ -441,29 +425,41 @@ function Spell:GetMaxCharges() |
|
|
|
|
return select(2, GetSpellCharges(self:GetID())) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
---@return number |
|
|
|
|
function Spell:GetCastLength() |
|
|
|
|
return select(4, GetSpellInfo(self:GetID())) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
-- Get the spells charges |
|
|
|
|
-- Get the full cooldown (time until all charges are available) |
|
|
|
|
---@return number |
|
|
|
|
function Spell:GetChargesFractional() |
|
|
|
|
local charges, maxCharges, start, duration = GetSpellCharges(self:GetID()) |
|
|
|
|
function Spell:GetFullRechargeTime() |
|
|
|
|
local charges, maxCharges, _, duration = GetSpellCharges(self:GetID()) |
|
|
|
|
if not charges or not maxCharges or charges == maxCharges then |
|
|
|
|
return 0 |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
return (maxCharges - self:GetChargesFractional()) * duration |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function Spell:Recharge() |
|
|
|
|
local charges, maxCharges, startTime, duration = GetSpellCharges(self:GetID()) |
|
|
|
|
if charges == maxCharges then |
|
|
|
|
return maxCharges |
|
|
|
|
return charges |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
if charges == 0 then |
|
|
|
|
return 0 |
|
|
|
|
local recharge = startTime + duration - GetTime() |
|
|
|
|
return recharge > 0 and recharge or 0 |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local timeSinceStart = GetTime() - start |
|
|
|
|
local timeLeft = duration - timeSinceStart |
|
|
|
|
local timePerCharge = duration / maxCharges |
|
|
|
|
local chargesFractional = charges + (timeLeft / timePerCharge) |
|
|
|
|
-- Get the spells charges plus fractional |
|
|
|
|
---@return number |
|
|
|
|
function Spell:GetChargesFractional() |
|
|
|
|
local charges, maxCharges, _, duration = GetSpellCharges(self:GetID()) |
|
|
|
|
|
|
|
|
|
return chargesFractional |
|
|
|
|
if charges == maxCharges then |
|
|
|
|
return charges |
|
|
|
|
end |
|
|
|
|
return charges + ((duration - self:Recharge()) / duration) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
-- Get the spells charges remaining |
|
|
|
|