Drive range, offline, aggro and combat state from events

Every unit frame re-checked its range fade, offline state, combat and
aggro glow and indicator icons on a 0.2-0.5s tick, and infight polled
aggro every 0.3s. Each now comes from an event.

Aggro: the 270-token scan and its cache are gone. UNIT_TARGET fires for
every unit in view (SuperWoW registers them all), so a table of which
hostile unit attacks which friendly one, by GUID, follows every attacker,
including ones no token reaches. A unit that comes into view mid-fight
is noted when a token first reaches it (target, focus, mouseover, a
nameplate, a member's target). A read drops attackers that left view,
where nothing fires, and a loading screen resets the table. Changes go
out as "aggro:changed" with the old and the new victim, so only the
frames showing those redraw; infight listens too.

Combat square and glow follow UNIT_FLAGS. Range fade follows ClassicAPI's
UNIT_IN_RANGE_UPDATE, registered only by frames that fade, by GUID for a
chained unit; with the 40y check off, frames fade by sight through
UNIT_DISTANCE_CHECK_UPDATE, which also swaps a portrait's question mark
for the model. A UnitXP threshold has no event and keeps its poll.
UNIT_CONNECTION refreshes a member who goes offline or comes back; the
PARTY_MEMBER_ENABLE/DISABLE branches were never registered.

A full refresh now draws the indicator icons and combat state, so a new
unit brings its own. UNIT_FACTION redraws the PvP icon and reaction
colour; its "pvp" refresh step drew nothing. Unlock mode and /pftest
re-apply the fade on entry and exit.

What stays on the tick: the pet frames and the UnitXP range check.
This commit is contained in:
Brues
2026-10-31 13:10:46 -05:00
parent d21d13bdfa
commit 54e66fea11
3 changed files with 198 additions and 185 deletions
+14 -13
View File
@@ -17,24 +17,24 @@ pfUI:RegisterModule("infight", function ()
end)
pulse:Play()
-- Combat, health and death come from events. Aggro has no event, so a
-- ticker polls it while that glow is enabled.
local combat, health, dead, aggro, poll
-- Combat, health, death and aggro all come from events.
local combat, health, dead, aggro
local function Refresh()
pfUI.infight:SetShown((combat or health or aggro) and not dead)
end
local function UpdateAggro()
aggro = C.appearance.infight.aggro == "1" and UnitHasAggro("player") > 0
Refresh()
end
-- a combat drop is also when an attacker that left view is let go
local function UpdatePlayer()
combat = C.appearance.infight.screen == "1" and UnitAffectingCombat("player")
health = C.appearance.infight.health == "1" and UnitHealth("player") / UnitHealthMax("player") <= .25
dead = UnitIsDeadOrGhost("player")
Refresh()
end
local function UpdateAggro()
aggro = UnitHasAggro("player") > 0
Refresh()
UpdateAggro()
end
pfUI.infight:RegisterEvent("PLAYER_ENTERING_WORLD")
@@ -47,16 +47,17 @@ pfUI:RegisterModule("infight", function ()
pfUI.infight:RegisterUnitEvent("UNIT_MAXHEALTH", "player")
pfUI.infight:SetScript("OnEvent", UpdatePlayer)
pfUI.events:RegisterCallback("aggro:changed", function(_, old, new)
local player = UnitGUID("player")
if old == player or new == player then UpdateAggro() end
end, "infight")
pfUI.infight.UpdateConfig = function(self)
pfUI.infight:SetBackdrop({
edgeFile = pfUI.media["img:glow"], edgeSize = tonumber(C.appearance.infight.intensity),
insets = {left = 0, right = 0, top = 0, bottom = 0},
})
if poll then poll:Cancel() end
poll = C.appearance.infight.aggro == "1" and C_Timer.NewTicker(.3, UpdateAggro)
aggro = nil
UpdatePlayer()
end
+3
View File
@@ -490,6 +490,9 @@ pfUI:RegisterModule("unlock", function ()
frame:Show()
end
-- lift the range and offline fade while unlocked
pfUI.uf:UpdateAllVisibility()
local txt = T["Unlock Mode allows you to move, scale and reset frames:\n\n|cff33ffcc[Left Click]|r Drag Frame\n|cff33ffcc[Middle Click]|r Reset Frame\n|cff33ffcc[Right Click]|r Option Box\n\nHold |cff33ffcc[Shift]|r to select all frames of the same kind\nHold |cff33ffcc[Ctrl]|r to select all frames of the same group\n\n|cff33ffcc[Scroll]|r to change the scale of a frame\n\n|cff33ffcc[Click]|r on an empty area or press |cff33ffcc[Esc]|r to exit\n"]
CreateInfoBox(txt, 15, pfUI.unlock, 180)
pfUI.gui:Hide()