Increased reliability of lag bar

It's still, at it's core, a guess because Blizzard doesn't offer the necessary events to make a reliable decision, so it tends to be wrong semi-frequently in a chain-casting scenario. But it's better than it was.
This commit is contained in:
Parnic
2018-08-18 11:00:09 -05:00
parent a8f175fad4
commit 7dfe505db2

View File

@ -4,7 +4,6 @@ local CastBar = IceCore_CreateClass(IceCastBar)
local IceHUD = _G.IceHUD
CastBar.prototype.spellCastSent = nil
CastBar.prototype.sentSpell = nil
-- Constructor --
function CastBar.prototype:init()
@ -416,7 +415,6 @@ function CastBar.prototype:SpellCastSent(event, unit, target, castGuid, spellId)
if IceHUD.WowVer < 70000 then
self.spellCastSent = GetTime()
end
self.sentSpell = castGuid
end
-- OVERRIDE
@ -430,34 +428,14 @@ end
-- OVERRIDE
function CastBar.prototype:SpellCastStart(event, unit, castGuid, spellId)
CastBar.super.prototype.SpellCastStart(self, event, unit, castGuid, spellId)
if (unit ~= self.unit) then return end
if (unit ~= self.unit or not spellId) then return end
if not self:IsVisible() or not self.actionDuration then
return
end
if self.sentSpell ~= castGuid then
self.spellCastSent = nil
end
local scale
if self.unit == "vehicle" then
scale = 0
elseif self.useFixedLatency then
scale = IceHUD:Clamp(self.fixedLatency / self.actionDuration, 0, 1)
else
local now = GetTime()
local lag = now - (self.spellCastSent or now)
if lag >= self.actionDuration then
scale = 0
else
scale = IceHUD:Clamp(lag / self.actionDuration, 0, 1)
end
end
self:SetBarCoord(self.lagBar, scale, true, true)
self.spellCastSent = nil
self:UpdateLagBar()
self.nextLagUpdate = GetTime() + (select(2, GetSpellCooldown(IceHUD.GlobalCoolDown:GetSpellId())) / 2)
end
@ -470,13 +448,34 @@ function CastBar.prototype:SpellCastChannelStart(event, unit)
return
end
self:UpdateLagBar(self.moduleSettings.reverseChannel)
end
-- OVERRIDE
function CastBar.prototype:SpellCastSucceeded(event, unit, castGuid, spellId)
CastBar.super.prototype.SpellCastSucceeded(self, event, unit, castGuid, spellId)
if not self.actionDuration then
return
end
self:UpdateLagBar()
self.nextLagUpdate = GetTime() + (select(2, GetSpellCooldown(IceHUD.GlobalCoolDown:GetSpellId())) / 2)
end
function CastBar.prototype:UpdateLagBar(isChannel)
local now = GetTime()
if self.nextLagUpdate and now <= self.nextLagUpdate then
return
end
local scale
if self.unit == "vehicle" then
scale = 0
elseif self.useFixedLatency then
scale = IceHUD:Clamp(self.fixedLatency / self.actionDuration, 0, 1)
else
local now = GetTime()
local lag = now - (self.spellCastSent or now)
if lag >= self.actionDuration then
scale = 0
@ -485,8 +484,7 @@ function CastBar.prototype:SpellCastChannelStart(event, unit)
end
end
local top = not self.moduleSettings.reverseChannel
self:SetBarCoord(self.lagBar, scale, top, true)
self:SetBarCoord(self.lagBar, scale, not isChannel, true)
self.spellCastSent = nil
end