WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Filter on nameplates debuffs. (https://www.wowinterface.com/forums/showthread.php?t=58558)

Hzereve 01-21-21 08:43 PM

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.

Vrul 01-22-21 12:24 PM

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")

Hzereve 01-22-21 04:19 PM

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 !

Taudier 01-23-21 08:07 AM

Quote:

Originally Posted by Vrul (Post 338343)
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".

Quote:

Originally Posted by Hzereve (Post 338349)
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.

Sylen 02-01-21 08:48 AM

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


All times are GMT -6. The time now is 06:05 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI