There are some cooldowns that can decrease their remaining time thanks to talents or set bonuses.
My intent is to keep track of the remaining cooldown time so that any change in the remaining time is not attributable to the global cooldown.
Does this script have any weaknesses? Are there any points where it could be improved?
Lua Code:
f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
f:SetScript("OnEvent", function(self,event,...)
if arg4 == UnitName("player") then
local start, duration = GetSpellCooldown(arg9)
if arg10 == "Riptide" then
self.start = start
self.duration = duration
self.endtime = start + duration
self.id = arg9
end
-- This is the crucial part: is it right? Does this part actually ensure that the change in the
-- remaining cooldown duration is not attributable to the global cooldown?
if select(2,GetSpellCooldown(self.id)) > 1.5 then
self.endtime = self.start + select(2,GetSpellCooldown(self.id))
end
end
end)
f:SetScript("OnUpdate", function(self)
self.timer = self.endtime - GetTime()
if (self.timer > 0) then
-- Hide frame
else
-- Show frame
end
end)