From 2d67781c6f8eef352df1e1a9cb61291e58acd828 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Thu, 21 May 2026 03:20:08 -0500 Subject: [PATCH] unit-frame tooltip/click handlers via SetUnitAura MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BuffOnClick/DebuffOnClick switch to lazy bid lookup before CancelPlayerBuff (matching the pattern in buff.lua/buffwatch.lua). DebuffOnEnter unifies its player and non-player branches through GameTooltip:SetUnitAura — the only divergent path is the selfdebuff caster-correlation lookup that still needs libdebuff. --- api/unitframes.lua | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/api/unitframes.lua b/api/unitframes.lua index 46f0593e..98ac8bef 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -84,41 +84,36 @@ end local function BuffOnClick() if this:GetParent().label == "player" then - CancelPlayerBuff(GetPlayerBuff(PLAYER_BUFF_START_ID+this.id,"HELPFUL")) + local bid = GetPlayerBuff(PLAYER_BUFF_START_ID + this.id, "HELPFUL") + if bid >= 0 then CancelPlayerBuff(bid) end end end local function DebuffOnEnter() if not this:GetParent().label then return end + local unitstr = this:GetParent().label .. this:GetParent().id GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT") - if this:GetParent().label == "player" then - GameTooltip:SetPlayerBuff(GetPlayerBuff(PLAYER_BUFF_START_ID+this.id,"HARMFUL")) - else - local unitstr = this:GetParent().label .. this:GetParent().id + + if this:GetParent().label ~= "player" then local parent = this:GetParent() - + -- For "only own debuffs" mode: find the REAL slot by matching spell name AND caster if parent.config and parent.config.selfdebuff == "1" and libdebuff then - -- Get the spell name from our filtered list local ownDebuffName = libdebuff:UnitOwnDebuff(unitstr, this.id) - if ownDebuffName then - -- Search through all game slots to find OUR debuff with matching name for gameSlot = 1, 16 do local gameName, _, _, _, _, _, _, gameCaster = libdebuff:UnitDebuff(unitstr, gameSlot) - -- Match both name AND caster (must be ours) if gameName == ownDebuffName and gameCaster == "player" then - GameTooltip:SetUnitDebuff(unitstr, gameSlot) + GameTooltip:SetUnitAura(unitstr, gameSlot, "HARMFUL") return end end end end - - -- Normal mode: use visual id directly - GameTooltip:SetUnitDebuff(unitstr, this.id) end + + GameTooltip:SetUnitAura(unitstr, this.id, "HARMFUL") end local function DebuffOnLeave() @@ -127,7 +122,8 @@ end local function DebuffOnClick() if this:GetParent().label == "player" then - CancelPlayerBuff(GetPlayerBuff(PLAYER_BUFF_START_ID+this.id,"HARMFUL")) + local bid = GetPlayerBuff(PLAYER_BUFF_START_ID + this.id, "HARMFUL") + if bid >= 0 then CancelPlayerBuff(bid) end end end