Hi! This code can be used for tracking any buff duration on a bar timer! When the buff duration timer matches the warning_time you set it will change the color on the bar!
The code will read the color you pick in the WeakAuras Display Color Box and the Animation/Main Color Box.
I have this code working for Vampiric Embrace but I'm sure it will work for any other buff.
Why change the color on the bar for a buff?
For me I have the Animation color set to red and the warning_time at 5 so when the buff has 5 seconds left on it...the bar color will change to red & I will know the buff duration is almost gone.
On Weakauras you add this code in the animation tab on main. Select custom and put the code in the custom function box next to the color box.
I also posted this same code format to work for spell cooldowns. If you do the math and set up the time right in weakauras (not the warning_time) you can have your buff timer bar appear first then have your cooldown timer bar appear next. Thanks to everyone on here that helped me out getting the codes to work right! :cool:
function(progress, r1, g1, b1, a1, r2, g2, b2, a2)
-- Set the debuff and threshold time here:
local debuff_name, warning_time = "Vampiric Embrace", 5
local _,_,_,_,_,_,expires, etc = UnitAura("PLAYER", debuff_name,
if expires ~= nil then
local time_left = expires - GetTime()
if time_left < warning_time then
return r2, g2, b2, a2
return r1,g1,b1, a1