Thread Tools Display Modes
10-29-22, 10:47 AM   #1
Deadlyz
A Wyrmkin Dreamwalker
 
Deadlyz's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 55
Hide Buffs/Debuffs on Target/Focus.

Hello!

With release of the DF prepatch this nice piece of code doesn't work anymore
Maybe some bored addon author could help me a bit?

Code:
TargetFrame:UnregisterEvent("UNIT_AURA", unit)
FocusFrame:UnregisterEvent("UNIT_AURA", unit)

hooksecurefunc(TargetFrame, "UpdateAuras", function()
    if frame ~= TargetFrame and frame ~= FocusFrame then return end

    local frameName = frame:GetName()

    for index = 1, MAX_TARGET_BUFFS do
        local buff = _G[frameName .. "Buff" .. index]
        if buff then
            buff:Hide()
        end
    end

    for index = 1, MAX_TARGET_DEBUFFS do
        local debuff = _G[frameName .. "Debuff" .. index]
        if debuff then
            debuff:Hide()
        end
    end
end)
Thanks in advance!
__________________

My last movie: Rogue Sweethearts
  Reply With Quote
10-29-22, 06:53 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,304
Surprisingly, it's simpler in Dragon Flight.
Lua Code:
  1. --  Doesn't need to be done, but saves some (not all) processing
  2. TargetFrame:UnregisterEvent("UNIT_AURA");
  3. FocusFrame:UnregisterEvent("UNIT_AURA");
  4.  
  5. local function ReleaseAllAuras(self)
  6.     for obj in self.auraPools:EnumerateActive() do obj:Hide(); end
  7.     self.auraPools:ReleaseAll()
  8. end
  9.  
  10. hooksecurefunc(TargetFrame,"UpdateAuras",ReleaseAllAuras);
  11. hooksecurefunc(FocusFrame,"UpdateAuras",ReleaseAllAuras);

Blizzard switched to using Mixins for most of TargetFrame's functions, meaning we can hook the Target and Focus frames directly without other inheriting frames triggering our hook. Secondly, buffs and debuffs are handled by frame pools now, which makes iterating through them easier as well.



Note: There's a bug in EditMode which throws taint errors if any addon touches any managed frame.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 10-30-22 at 03:03 PM.
  Reply With Quote
10-30-22, 05:23 AM   #3
Deadlyz
A Wyrmkin Dreamwalker
 
Deadlyz's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 55
Hello, and thanks for reply!

I'm getting a syntax error

Code:
3x FrameXML\Bindings.xml:1 Interface/AddOns/NoDebuffs/NoDebuffs.lua:1 Interface/AddOns/NoDebuffs/NoDebuffs.lua:5: syntax error near 'for'
__________________

My last movie: Rogue Sweethearts
  Reply With Quote
10-30-22, 05:47 AM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,865
Sounds like that line or the ones on either side have been worded wrong ..

Can you show us the for loop you have on line 1 or line 1 in total in case you have the word for by mistake
__________________
  Reply With Quote
10-30-22, 05:47 AM   #5
Deadlyz
A Wyrmkin Dreamwalker
 
Deadlyz's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 55
Here's a fixed version version for anyone who needs it
Lua Code:
  1. TargetFrame:UnregisterEvent("UNIT_AURA")
  2. FocusFrame:UnregisterEvent("UNIT_AURA")
  3.  
  4. local function ReleaseAllAuras(self)
  5.     for obj in self.auraPools:EnumerateActive() do
  6.         obj:Hide()
  7.     end
  8.  
  9.     self.auraPools:ReleaseAll()
  10. end
  11.  
  12. hooksecurefunc(TargetFrame, "UpdateAuras", ReleaseAllAuras)
  13. hooksecurefunc(FocusFrame, "UpdateAuras", ReleaseAllAuras)

Thanks Lightspark for the fix.
Originally Posted by Lightspark
I'd be careful with self.auraPools:ReleaseAll() tho, if you start getting weird errors related to UF auras while in combat, comment out that line.
-- self.auraPools:ReleaseAll()
Thanks SDPhantom for the original code
__________________

My last movie: Rogue Sweethearts

Last edited by Deadlyz : 10-30-22 at 05:56 AM.
  Reply With Quote
10-30-22, 06:13 AM   #6
Deadlyz
A Wyrmkin Dreamwalker
 
Deadlyz's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 55
Aha, it seems the story isn't over yet. Turns out this code somehow hides the default castbars of the target and focus frames

UPDT: with -- self.auraPools:ReleaseAll() commented out it seems to work.
Lua Code:
  1. TargetFrame:UnregisterEvent("UNIT_AURA")
  2. FocusFrame:UnregisterEvent("UNIT_AURA")
  3.  
  4. local function ReleaseAllAuras(self)
  5.     for obj in self.auraPools:EnumerateActive() do
  6.         obj:Hide()
  7.     end
  8.  
  9.    -- self.auraPools:ReleaseAll()
  10. end
  11.  
  12. hooksecurefunc(TargetFrame, "UpdateAuras", ReleaseAllAuras)
  13. hooksecurefunc(FocusFrame, "UpdateAuras", ReleaseAllAuras)
__________________

My last movie: Rogue Sweethearts

Last edited by Deadlyz : 10-30-22 at 06:17 AM.
  Reply With Quote
10-30-22, 03:39 PM   #7
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,304
Originally Posted by Lightspark
I'd be careful with self.auraPools:ReleaseAll() tho, if you start getting weird errors related to UF auras while in combat, comment out that line.
-- self.auraPools:ReleaseAll()
I'm imagining they're referring to taint issues. Nothing running that should be susceptible to taint though.
Also figures I would leave something (the function keyword) out while dry-coding.



I neglected to put in anchor correction for the castbar, though it would add another taint vector.
Lua Code:
  1. --  Doesn't need to be done, but saves some (not all) processing
  2. TargetFrame:UnregisterEvent("UNIT_AURA");
  3. FocusFrame:UnregisterEvent("UNIT_AURA");
  4.  
  5. local function ReleaseAllAuras(self)
  6.     for obj in self.auraPools:EnumerateActive() do obj:Hide(); end
  7.     self.auraPools:ReleaseAll()--   Cleanup
  8.  
  9.     self.auraRows,self.spellbarAnchor=0,nil;--  Revert to initial values
  10.     if self.spellbar then Target_Spellbar_AdjustPosition(self.spellbar); end--  Update anchor
  11. end
  12.  
  13. hooksecurefunc(TargetFrame,"UpdateAuras",ReleaseAllAuras);
  14. hooksecurefunc(FocusFrame,"UpdateAuras",ReleaseAllAuras);

Ideally, you'll always want to clean up after yourself. This is what self.auraPools:ReleaseAll() is for. Considering the original function already does this right before updating, it isn't as important in a practical sense.

The castbar reanchoring could be done with less taint, but if we can get away with reusing existing logic rather than recreating it, that would be better.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
10-31-22, 10:01 AM   #8
Deadlyz
A Wyrmkin Dreamwalker
 
Deadlyz's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 55
SDPhantom, thanks! I've updated my file with your code

Maybe you should release this as an addon. I'm pretty sure many people using addons like Raven, ElkanoBuffBars (or similar addons that provide extra buff/debuff bars, but no means of hiding the default ones) would like to use it.

Originally Posted by SDPhantom View Post

The castbar reanchoring could be done with less taint, but if we can get away with reusing existing logic rather than recreating it, that would be better.
I wonder if it's possible to detach the default castbar and move it using screen coordinates. If it's possible would that require a lot of efforts?
__________________

My last movie: Rogue Sweethearts

Last edited by Deadlyz : 10-31-22 at 10:22 AM.
  Reply With Quote
10-31-22, 02:40 PM   #9
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,304
Originally Posted by Deadlyz View Post
I wonder if it's possible to detach the default castbar and move it using screen coordinates. If it's possible would that require a lot of efforts?
You can replace the anchor adjustment section with this.
Lua Code:
  1. if self.spellbar then
  2.     self.spellbar:ClearAllPoints();
  3.     self.spellbar:SetPoint("TOPLEFT",self,"BOTTOMLEFT",43,-46);--   Default anchor on large frame with ToT shown
  4. end
Of course, you can change the anchor to whatever you want. This is just an example.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
11-01-22, 10:25 AM   #10
Deadlyz
A Wyrmkin Dreamwalker
 
Deadlyz's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 55
Originally Posted by SDPhantom View Post
You can replace the anchor adjustment section with this.
Lua Code:
  1. if self.spellbar then
  2.     self.spellbar:ClearAllPoints();
  3.     self.spellbar:SetPoint("TOPLEFT",self,"BOTTOMLEFT",43,-46);--   Default anchor on large frame with ToT shown
  4. end
Of course, you can change the anchor to whatever you want. This is just an example.
Thank you! Does it work for both target and focus?
__________________

My last movie: Rogue Sweethearts
  Reply With Quote
11-01-22, 04:18 PM   #11
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,304
It's one function that's hooked into both frames, that's why it's defined separately outside of the hooksecurefunc() calls instead of writing it twice.

I'd be wary of changing the anchor to something that isn't relative to self as you'd put both cast bars in the exact same spot overlapping each other. self points back to either TargetFrame or FocusFrame, whichever is currently calling the hook.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 11-01-22 at 04:28 PM.
  Reply With Quote
11-02-22, 11:30 AM   #12
Deadlyz
A Wyrmkin Dreamwalker
 
Deadlyz's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 55
I appreciate your help, but I don't seem to be able to make this work

Lua Code:
  1. --  Doesn't need to be done, but saves some (not all) processing
  2.     TargetFrame:UnregisterEvent("UNIT_AURA");
  3.     FocusFrame:UnregisterEvent("UNIT_AURA");
  4.      
  5.     local function ReleaseAllAuras(self)
  6.         for obj in self.auraPools:EnumerateActive() do obj:Hide(); end
  7.         self.auraPools:ReleaseAll()--   Cleanup
  8.      
  9.         self.auraRows,self.spellbarAnchor=0,nil;--  Revert to initial values
  10.             if self.spellbar then
  11.         self.spellbar:ClearAllPoints();
  12.         self.spellbar:SetPoint("TOPLEFT",self,"BOTTOMLEFT",43,-100);--   Default anchor on large frame with ToT shown
  13.     end--  Update anchor
  14.     end
  15.      
  16.     hooksecurefunc(TargetFrame,"UpdateAuras",ReleaseAllAuras);
  17.     hooksecurefunc(FocusFrame,"UpdateAuras",ReleaseAllAuras);
I change the coordiantes (e.g. 43,-100), then save the file and /reload ui but the castbars don't move. What am I doing wrong?
__________________

My last movie: Rogue Sweethearts

Last edited by Deadlyz : 11-02-22 at 11:42 AM.
  Reply With Quote
11-02-22, 12:16 PM   #13
Deadlyz
A Wyrmkin Dreamwalker
 
Deadlyz's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 55
The final version, that seems to be working:

Lua Code:
  1. TargetFrame:UnregisterEvent("UNIT_AURA")
  2. FocusFrame:UnregisterEvent("UNIT_AURA")
  3.  
  4. local function ReleaseAllAuras(self)
  5.     for obj in self.auraPools:EnumerateActive() do
  6.         obj:Hide()
  7.     end
  8.  
  9.     -- Cleanup
  10.     self.auraPools:ReleaseAll()
  11.  
  12.     -- Revert to initial values
  13.     self.auraRows, self.spellbarAnchor = 0, nil
  14.  
  15.     if self.spellbar then
  16.         -- Reset anchor
  17.         hooksecurefunc(self.spellbar, "SetPoint", function(spellBar, _, _, _, _, _, shouldIgnore)
  18.             if not shouldIgnore then
  19.                 spellBar:ClearAllPoints()
  20.  
  21.                 -- Default anchor on large frame with ToT shown
  22.                 spellBar:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 43, -100, true)
  23.             end
  24.         end)
  25.     end
  26. end
  27.  
  28. hooksecurefunc(TargetFrame, "UpdateAuras", ReleaseAllAuras)
  29. hooksecurefunc(FocusFrame, "UpdateAuras", ReleaseAllAuras)
UPDT: 43,-28 works the best for me.
__________________

My last movie: Rogue Sweethearts

Last edited by Deadlyz : 11-02-22 at 01:41 PM.
  Reply With Quote
11-02-22, 04:57 PM   #14
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,304
Originally Posted by Deadlyz View Post
Code:
hooksecurefunc(self.spellbar, "SetPoint", function(spellBar, _, _, _, _, _, shouldIgnore)
	if not shouldIgnore then
		spellBar:ClearAllPoints()

		-- Default anchor on large frame with ToT shown
		spellBar:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 43, -100, true)
	end
end)
You need to set this hook outside or it'll keep hooking itself indefinitely. Eventually, this will cause a stack overflow when the hook is called.



This is the alternative I came up with. It only applies the position hook once.
Lua Code:
  1. --  Doesn't need to be done, but saves some (not all) processing
  2. TargetFrame:UnregisterEvent("UNIT_AURA");
  3. FocusFrame:UnregisterEvent("UNIT_AURA");
  4.  
  5. local function ReleaseAllAuras(self)
  6.     for obj in self.auraPools:EnumerateActive() do obj:Hide(); end
  7.     self.auraPools:ReleaseAll()--   Cleanup
  8. end
  9.  
  10. hooksecurefunc(TargetFrame,"UpdateAuras",ReleaseAllAuras);
  11. hooksecurefunc(FocusFrame,"UpdateAuras",ReleaseAllAuras);
  12.  
  13. local function SpellBar_SetPoint(self)
  14.     local meta=getmetatable(self).__index;--    Calls through self will trigger our hook, so we're making them through the metatable
  15.     meta.ClearAllPoints(self);
  16.     meta.SetPoint(self,"TOPLEFT",meta.GetParent(self),"BOTTOMLEFT",43,-28);
  17. end
  18.  
  19. hooksecurefunc(TargetFrame.spellbar,"SetPoint",SpellBar_SetPoint);
  20. hooksecurefunc(FocusFrame.spellbar,"SetPoint",SpellBar_SetPoint);
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
11-03-22, 09:26 AM   #15
Deadlyz
A Wyrmkin Dreamwalker
 
Deadlyz's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 55
Originally Posted by SDPhantom View Post
You need to set this hook outside or it'll keep hooking itself indefinitely. Eventually, this will cause a stack overflow when the hook is called.



This is the alternative I came up with. It only applies the position hook once.
Lua Code:
  1. --  Doesn't need to be done, but saves some (not all) processing
  2. TargetFrame:UnregisterEvent("UNIT_AURA");
  3. FocusFrame:UnregisterEvent("UNIT_AURA");
  4.  
  5. local function ReleaseAllAuras(self)
  6.     for obj in self.auraPools:EnumerateActive() do obj:Hide(); end
  7.     self.auraPools:ReleaseAll()--   Cleanup
  8. end
  9.  
  10. hooksecurefunc(TargetFrame,"UpdateAuras",ReleaseAllAuras);
  11. hooksecurefunc(FocusFrame,"UpdateAuras",ReleaseAllAuras);
  12.  
  13. local function SpellBar_SetPoint(self)
  14.     local meta=getmetatable(self).__index;--    Calls through self will trigger our hook, so we're making them through the metatable
  15.     meta.ClearAllPoints(self);
  16.     meta.SetPoint(self,"TOPLEFT",meta.GetParent(self),"BOTTOMLEFT",43,-28);
  17. end
  18.  
  19. hooksecurefunc(TargetFrame.spellbar,"SetPoint",SpellBar_SetPoint);
  20. hooksecurefunc(FocusFrame.spellbar,"SetPoint",SpellBar_SetPoint);
Thanks a lot! I'm going to update my file with your code
__________________

My last movie: Rogue Sweethearts
  Reply With Quote
11-19-22, 04:42 PM   #16
Keysunao
A Kobold Labourer
Join Date: Nov 2022
Posts: 1
Hey!

For some reason this code is not working for me.
I put it in the .lua file of my self-made addon. But the code prevents the addon from loading (also the other lines wont load).

Can you maybe help?
I basically only want to remove the debuffs/buffs on the Focus Frame.

Thanks a lot!
  Reply With Quote
11-21-22, 03:40 PM   #17
Deadlyz
A Wyrmkin Dreamwalker
 
Deadlyz's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 55
Originally Posted by Keysunao View Post
Hey!

For some reason this code is not working for me.
I put it in the .lua file of my self-made addon. But the code prevents the addon from loading (also the other lines wont load).

Can you maybe help?
I basically only want to remove the debuffs/buffs on the Focus Frame.

Thanks a lot!
Try hiding it with MoveIt

P.S.: the code works perfectly for me.
__________________

My last movie: Rogue Sweethearts

Last edited by Deadlyz : 11-21-22 at 03:45 PM.
  Reply With Quote
11-23-22, 04:36 PM   #18
Odjur
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 7
Thought I'd comment because this may be a lower cost method:

Lua Code:
  1. FocusFrame:UnregisterEvent("UNIT_AURA")
  2.  
  3. hooksecurefunc(FocusFrame, "SetSmallSize", function(self)
  4.     self.maxBuffs = 0
  5.     self.maxDebuffs = 0
  6. end)

I believe SetSmallSize is the function that establishes the buff/debuff limits, so this should be a one time setup.
  Reply With Quote
12-23-22, 03:09 AM   #19
ironmoney
A Murloc Raider
Join Date: Apr 2010
Posts: 4
Originally Posted by Odjur View Post
Thought I'd comment because this may be a lower cost method:

Lua Code:
  1. FocusFrame:UnregisterEvent("UNIT_AURA")
  2.  
  3. hooksecurefunc(FocusFrame, "SetSmallSize", function(self)
  4.     self.maxBuffs = 0
  5.     self.maxDebuffs = 0
  6. end)

I believe SetSmallSize is the function that establishes the buff/debuff limits, so this should be a one time setup.
very nice, thanks. do you know how to make it work with large frames enables?
  Reply With Quote
01-02-23, 03:58 AM   #20
Adaseth
A Kobold Labourer
Join Date: Jan 2023
Posts: 1
Little help

Hi guys, sorry for the noob question but where do you enter this code? I've been searching how to remove this forever but even with MoveIt i can't really get it right.

Thanks in advance!
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Hide Buffs/Debuffs on Target/Focus.

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off