Thread Tools Display Modes
01-21-21, 08:43 PM   #1
Hzereve
A Defias Bandit
Join Date: Jan 2021
Posts: 2
Filter on nameplates debuffs.

Hello there !

I'm a long time user of the Blizzard nameplates and i know this can be done by just getting Plater or whatever.

I'm currently working on a small addon who will allow me to show all my debuffs over the ennemy nameplates. Today, with the help of Tomcat (twitch.tv/TomCat), he explained me a lot about it and deep dived for me in the nameplates features.

Right now, the code is looking like this :

Lua Code:
  1. local function UpdateBuffs(self, unit, filter, showAll)
  2.     if (not showAll) then
  3.         self:UpdateBuffs(unit, filter, true)
  4.     end
  5. end
  6.  
  7. local updateFrame = CreateFrame("FRAME")
  8.  
  9. local tracker = { }
  10.  
  11. local minDelay = 1.0
  12. local totalElapsed = 0
  13.  
  14. local function OnUpdate(self, elapsed)
  15.     totalElapsed = totalElapsed + elapsed
  16.     if (totalElapsed > minDelay) then
  17.         totalElapsed = 0
  18.         for i = 1, 20 do
  19.             if (not tracker[i]) then
  20.                 local nameplate = _G["NamePlate" .. i]
  21.                 if (nameplate and nameplate.UnitFrame and nameplate.UnitFrame.BuffFrame) then
  22.                     tracker[i] = true
  23.                     hooksecurefunc(nameplate.UnitFrame.BuffFrame, "UpdateBuffs", UpdateBuffs)
  24.                 end
  25.             end
  26.         end
  27.     end
  28. end
  29.  
  30. updateFrame:SetScript("OnUpdate", OnUpdate)

What is does : showing all the debuffs over the nameplates, including your friends warrior debuffs for example.

What i want in the final : showing all my debuffs and only mine, and if it includes also my pet mortal wounds, better but i guess, harder to do.

For this problem, i found many ask how to do that, some solutions who seems to not work nowadays like :

https://www.mmo-champion.com/threads...-BuffContainer

Here are 2 solutions, the first one isnt working and my understanding in lua is not enough to fix it on my own. And the second one who is a whitelisting but removing everything else and also, doesn't work with some things like Sinful Revelation.

The goal is to show like a concussive shots like a debuff over the nameplates. This will help many PvPer who dont wanna jump in a full nameplates addon.

If you have any suggestions, any time to help me, i will be super grateful.
  Reply With Quote
01-22-21, 12:24 PM   #2
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
I don't see a way to do it without taint but this didn't throw any errors the little I tested at a training dummy:
Lua Code:
  1. local GetNamePlateForUnit = C_NamePlate.GetNamePlateForUnit
  2. local OriginalUpdateBuffs = NameplateBuffContainerMixin.UpdateBuffs
  3.  
  4. local alteredNamePlates = { }
  5.  
  6. local function ShouldShowBuff(frame, name, caster)
  7.     return name -- already filtered
  8. end
  9.  
  10. local function UpdateBuffs(self, unit, filter, showAll)
  11.     OriginalUpdateBuffs(self, unit, "HARMFUL|PLAYER")
  12. end
  13.  
  14. local frame = CreateFrame("Frame")
  15.  
  16. frame:SetScript("OnEvent", function(self, event, unit)
  17.     local nameplate = GetNamePlateForUnit(unit)
  18.     if nameplate and not alteredNamePlates[nameplate] then
  19.         alteredNamePlates[nameplate] = true
  20.         local buffFrame = nameplate.UnitFrame.BuffFrame
  21.         buffFrame.ShouldShowBuff = ShouldShowBuff
  22.         buffFrame.UpdateBuffs = UpdateBuffs
  23.     end
  24. end)
  25.  
  26. frame:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  Reply With Quote
01-22-21, 04:19 PM   #3
Hzereve
A Defias Bandit
Join Date: Jan 2021
Posts: 2
I'm a little bit scared of what the addon will eat as memory. Will try this out this evening.

Thank you so much for providing assistance !
  Reply With Quote
01-23-21, 08:07 AM   #4
Taudier
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 53
Originally Posted by Vrul View Post
I don't see a way to do it without taint but this didn't throw any errors the little I tested at a training dummy:
you can hooksecurefunc "UpdateBuffs" but it will update the buffs two times; your solution is better I guess. Not sure you need to hook "ShouldShowBuff".

Originally Posted by Hzereve View Post
I'm a little bit scared of what the addon will eat as memory. Will try this out this evening.

Thank you so much for providing assistance !
Less resource consumption would be probably no addon.

Last edited by Taudier : 01-23-21 at 08:40 AM.
  Reply With Quote
02-01-21, 08:48 AM   #5
Sylen
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 50
I use this. It hides all debuffs and just shows the debuffs you add into the whitelist.

Lua Code:
  1. --Filter Buffs and Debuffs on Nameplates (including Personal Resource Display)
  2.  
  3. local whitelist = {
  4.     --Priest Debuffs
  5.     ["Shadow Word: Pain"] = "player",
  6.     ["Mind Soothe"] = "all",
  7. }
  8.  
  9. --This function is for name filtering
  10. local function newShouldShowBuff(_,name,caster)
  11.     return name and caster and (whitelist[name] == caster or whitelist[name] == "all")
  12. end
  13.  
  14. local function Mixin(baseFrame)
  15.     baseFrame.UnitFrame.BuffFrame.ShouldShowBuff = newShouldShowBuff
  16. end
  17.  
  18. local f = CreateFrame("Frame")
  19.     f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  20.     f:SetScript("OnEvent", function(_,_,unitId)
  21.    
  22.     Mixin(C_NamePlate.GetNamePlateForUnit(unitId))
  23. end)
  24.  
  25. for _,baseFrame in pairs(C_NamePlate.GetNamePlates()) do
  26.     Mixin(baseFrame)
  27. end
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Filter on nameplates debuffs.

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