Problem statement: attempting to create a feral energy tick that doesn't "reset" when leaving/exiting forms.
Current (working) code:
function(a, e, t)
local currEnergy = UnitPower("player", 3)
local inc = currEnergy - (aura_env.lastEnergy or currEnergy)
if (e == "UNIT_POWER_FREQUENT"
and currEnergy > (aura_env.lastEnergy or 0)
and inc ~= 5
and inc ~= 8
and inc ~= 25
and inc ~= 35
and inc ~= 60
and inc ~= 100)
or (e == "UNIT_POWER_FREQUENT"
and currEnergy > (aura_env.lastEnergy or 0)
and currEnergy == UnitPowerMax("player", 3))
or (e == "OVERLAYTICK" and t and currEnergy == UnitPowerMax("player", 3))
then
if not a[""] then
a[""] = {
show = true,
changed = true,
duration = 2,
expirationTime = GetTime() + 2,
progressType = "timed"
}
else
local s = a[""]
s.changed = true
s.duration = 2
s.expirationTime = GetTime() + 2
s.show = true
C_Timer.After(2, function() WeakAuras.ScanEvents("OVERLAYTICK", true) end)
end
end
aura_env.lastEnergy = currEnergy
return true
end
Video: https://www.youtube.com/watch?v=sILBIiDSWWQ
Dynamic group (for reference): https://i.imgur.com/Y0mzbVe.png
My issue with this is that leaving/exiting cat form re-triggers "UNIT_POWER_FREQUENT," resetting the auras duration/expirationTime. My goal is to make an aura that will persist where the tick ("Energy Tick 2" aura in screenshot) should be so it can "resume" dynamically. The problem with this is that you can't set a start point for "timed" states, only the duration.
My hack to get around this is to dynamically calculate to attempt to calculate the remaining duration and corresponding frame width/offset relative to the energy bar's ("Energy bar" aura) frame.
Currently, after calls to aura_env.region:SetWidth(x) on the tick's frame, the frame width is resetting to whatever static width is set in the aura's settings.
Hacky code:
function(a, e, t)
if aura_env.intended_width then
aura_env.region:SetWidth(aura_env.intended_width)
print("Setting width to" .. aura_env.intended_width)
end
local currEnergy = UnitPower("player", 3)
local dur = 2
if (e == "UNIT_POWER_FREQUENT" and t and currEnergy > (aura_env.lastEnergy or 0))
or (e == "ENERGYTICK" and t == aura_env.id and currEnergy == UnitPowerMax("player", 3))
then
if (e == "UNIT_POWER_FREQUENT") then
local curTime = GetTime()
if (aura_env.lastFreqEventTime
and curTime - aura_env.lastFreqEventTime >= 2.000
and curTime - aura_env.lastFreqEventTime <= 2.026) then
aura_env.lastIntervalEnergyTickTime = curTime
aura_env.intended_width = 100
local s = a[""]
s.changed = true
s.duration = dur
s.expirationTime = GetTime() + dur
s.show = true
local id = aura_env.id
C_Timer.After(2, function() WeakAuras.ScanEvents("ENERGYTICK", id) end)
end
aura_env.lastFreqEventTime = GetTime()
end
if not a[""] then
a[""] = {
show = true,
changed = true,
duration = dur,
expirationTime = GetTime() + dur,
progressType = "timed"
}
end
end
aura_env.lastEnergy = currEnergy
return true
end
Video: https://www.youtube.com/watch?v=JnO-i6QgUGU
What approach should I be taking here? I figure region:SetWidth was not built for this purpose, so what other approaches do I have for this?