From 31f6837535d665419601e9fd61090615af02d54c Mon Sep 17 00:00:00 2001 From: shagu Date: Sun, 20 Sep 2020 19:21:07 +0200 Subject: [PATCH] unitframes: cache max durations for player debuffs --- api/unitframes.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/api/unitframes.lua b/api/unitframes.lua index a8457acd..32d85f11 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -27,6 +27,7 @@ local glow2 = { local maxdurations = {} local function BuffOnUpdate() + if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .2 end local timeleft = GetPlayerBuffTimeLeft(GetPlayerBuff(PLAYER_BUFF_START_ID+this.id,"HELPFUL")) local texture = GetPlayerBuffTexture(GetPlayerBuff(PLAYER_BUFF_START_ID+this.id,"HELPFUL")) local start = 0 @@ -112,9 +113,21 @@ local function BuffOnClick() end local function DebuffOnUpdate() - if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .4 end + if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .2 end local timeleft = GetPlayerBuffTimeLeft(GetPlayerBuff(PLAYER_BUFF_START_ID+this.id,"HARMFUL")) - CooldownFrame_SetTimer(this.cd, GetTime(), timeleft, 1) + local texture = GetPlayerBuffTexture(GetPlayerBuff(PLAYER_BUFF_START_ID+this.id,"HARMFUL")) + local start = 0 + + if timeleft > 0 then + if not maxdurations[texture] then + maxdurations[texture] = timeleft + elseif maxdurations[texture] and maxdurations[texture] < timeleft then + maxdurations[texture] = timeleft + end + start = GetTime() + timeleft - maxdurations[texture] + end + + CooldownFrame_SetTimer(this.cd, start, maxdurations[texture], timeleft > 0 and 1 or 0) end local function DebuffOnEnter()