From ddbee386460cd2591babe6113897cd7274d85e36 Mon Sep 17 00:00:00 2001 From: NoM0Re Date: Mon, 2 Jun 2025 22:12:34 +0200 Subject: [PATCH] (fix/Power): fix regression causing stuttery power updates by re-adding FRAME_UPDATE for non-multi-unit units This change reintroduces FRAME_UPDATE for units not in multiUnitUnits (e.g., player, target) to ensure smooth power updates, similar to UNIT_POWER_FREQUENT in retail. The new logic tho avoids registering other unit events when FRAME_UPDATE is used, improving performance and preventing multiple updates per frame, than before. --- WeakAuras/GenericTrigger.lua | 3 +++ WeakAuras/Prototypes.lua | 27 +++++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/WeakAuras/GenericTrigger.lua b/WeakAuras/GenericTrigger.lua index 13a4e7f..ac62de8 100644 --- a/WeakAuras/GenericTrigger.lua +++ b/WeakAuras/GenericTrigger.lua @@ -694,6 +694,9 @@ local function RunTriggerFunc(allStates, data, id, triggernum, event, arg1, arg2 untriggerCheck = true; end elseif (data.statesParameter == "unit") then + if event == "FRAME_UPDATE" and not Private.multiUnitUnits[data.trigger.unit] then + arg1 = data.trigger.unit + end if arg1 then if Private.multiUnitUnits[data.trigger.unit] then if data.trigger.unit == "group" and IsInRaid() and Private.multiUnitUnits.party[arg1] then diff --git a/WeakAuras/Prototypes.lua b/WeakAuras/Prototypes.lua index ed515d7..e8cd3bb 100644 --- a/WeakAuras/Prototypes.lua +++ b/WeakAuras/Prototypes.lua @@ -2586,7 +2586,7 @@ Private.event_prototypes = { local unit = trigger.unit local result = {} local powerType = trigger.use_powertype and trigger.powertype - AddUnitEventForPowerEvents(result, unit, powerType) + if trigger.powertype == 4 then local _, class = UnitClass("player") AddUnitEventForEvents(result, unit, "UNIT_COMBO_POINTS") @@ -2594,9 +2594,15 @@ Private.event_prototypes = { if class == "DRUID" then AddUnitEventForEvents(result, unit, "UNIT_MODEL_CHANGED") end + -- For units not in multiUnitUnits, add FRAME_UPDATE to ensure smooth power updates + elseif unit and not Private.multiUnitUnits[unit] then + if not result.events then + result.events = {} + end + tinsert(result.events, "FRAME_UPDATE") + else + AddUnitEventForPowerEvents(result, unit, powerType) end - AddUnitEventForEvents(result, unit, "UNIT_DISPLAYPOWER") - AddUnitEventForEvents(result, unit, "UNIT_NAME_UPDATE") -- The api for spell power costs is not meant to be for other units if trigger.use_showCost and unit == "player" then @@ -2606,11 +2612,16 @@ Private.event_prototypes = { AddUnitEventForEvents(result, unit, "UNIT_SPELLCAST_SUCCEEDED") end - if trigger.use_ignoreDead or trigger.use_ignoreDisconnected then - AddUnitEventForEvents(result, unit, "UNIT_FLAGS") - end - if trigger.use_inRange then - AddUnitEventForEvents(result, unit, "UNIT_IN_RANGE_UPDATE") + -- Register shared events unless we're in the FRAME_UPDATE case + if not (unit and not Private.multiUnitUnits[unit]) then + AddUnitEventForEvents(result, unit, "UNIT_DISPLAYPOWER") + AddUnitEventForEvents(result, unit, "UNIT_NAME_UPDATE") + if trigger.use_ignoreDead or trigger.use_ignoreDisconnected then + AddUnitEventForEvents(result, unit, "UNIT_FLAGS") + end + if trigger.use_inRange then + AddUnitEventForEvents(result, unit, "UNIT_IN_RANGE_UPDATE") + end end return result; end,