Drive power from UNIT_POWER_UPDATE and UNIT_MAXPOWER

1.12's UNIT_MANA, UNIT_RAGE and the rest fire for every power a unit
has, not only the one it shows, so a druid in cat or bear form redrew
every frame showing them, health colours and texts included, on each
mana tick. ClassicAPI's generic power events name the power in arg2.

Unit frames register them on their own token and redraw only for the
power their bar shows, or for mana under a druid mana bar. They fire
for tokens only, so the GUID-followed target-of-X frames keep the
per-type events; those now share one list with UNIT_AURA, so a frame
swaps auras and power on the same check.

energytick counts gains on the power it tracks alone, so a cat druid's
mana regen is no longer read as energy. It forgets the power while
hidden, so a bear's mana ticks are not measured against rage, and
re-baselines on a shift, so leaving cat form is not a fake mana gain.

The equipment manager's dining trigger wakes on mana changes only.
This commit is contained in:
Brues
2026-10-31 11:55:54 -05:00
parent b6f58b0e04
commit 480889cb05
3 changed files with 40 additions and 20 deletions
+30 -13
View File
@@ -1137,6 +1137,13 @@ function pfUI.uf.OnEvent()
else
this.update_auratime = true
end
elseif event == "UNIT_POWER_UPDATE" or event == "UNIT_MAXPOWER" then
-- every power of the unit reports, a cat druid's mana regen too; redraw
-- for the one the bar shows, and for mana under a druid mana bar
local _, shown = UnitPowerType(arg1)
if arg2 == shown or (arg2 == "MANA" and this.druidmana) then
this.update_base = true
end
elseif event == "UNIT_FACTION" then
this.update_pvp = true
elseif event == "UNIT_COMBAT" then
@@ -1376,13 +1383,22 @@ end
local UNIT_EVENTS = {
"UNIT_DISPLAYPOWER",
"UNIT_HEALTH", "UNIT_MAXHEALTH",
"UNIT_PORTRAIT_UPDATE", "UNIT_MODEL_CHANGED",
"UNIT_FACTION",
"INCOMING_RESURRECT_CHANGED", -- frame=ressIcon
}
-- Auras and power. ClassicAPI's UNIT_AURA_DELTA also reports refreshes and new
-- durations and says what changed; its generic power events name the power, so
-- a frame skips the ones it does not draw. Both fire for tokens only, so a
-- chained unit, followed by GUID, keeps 1.12's events instead.
local TOKEN_EVENTS = { "UNIT_AURA_DELTA", "UNIT_POWER_UPDATE", "UNIT_MAXPOWER" }
local GUID_EVENTS = {
"UNIT_AURA",
"UNIT_MANA", "UNIT_MAXMANA",
"UNIT_RAGE", "UNIT_MAXRAGE",
"UNIT_ENERGY", "UNIT_MAXENERGY",
"UNIT_FOCUS",
"UNIT_PORTRAIT_UPDATE", "UNIT_MODEL_CHANGED",
"UNIT_FACTION",
"INCOMING_RESURRECT_CHANGED", -- frame=ressIcon
}
-- Point this frame's unit-event subscriptions at `unit` (a token, or a chained
@@ -1401,16 +1417,17 @@ function pfUI.uf:RegisterUnitEvents(unit)
end
end
-- auras (frame=buff, frame=debuff, indicators): UNIT_AURA_DELTA, which also
-- reports refreshes and new durations and says what changed. It fires for
-- tokens only, so a chained unit, followed by GUID, keeps UNIT_AURA.
local aura, other = "UNIT_AURA_DELTA", "UNIT_AURA"
if self.chain then aura, other = other, aura end
self:UnregisterEvent(other)
if unit then
self:RegisterUnitEvent(aura, unit)
else
self:UnregisterEvent(aura)
local events, other = TOKEN_EVENTS, GUID_EVENTS
if self.chain then events, other = other, events end
for i = 1, table.getn(other) do
self:UnregisterEvent(other[i])
end
for i = 1, table.getn(events) do
if unit then
self:RegisterUnitEvent(events[i], unit)
else
self:UnregisterEvent(events[i])
end
end
-- UNIT_COMBAT rides along only while the frame draws combat feedback text.