Thread Tools Display Modes
07-26-18, 06:12 AM   #1
Shiezko
A Murloc Raider
Join Date: Jul 2018
Posts: 7
Nameplate Debuff Whitelist

I want to hide all buffs/debuffs on nameplates (including the personal resource display) and then whitelist the ones I want to show. I also want an option for showing debuffs casted only by the player or by anyone.

After doing some research, this is all I could come up with:

Code:
local whitelist = {
    ["Shadow Word: Pain"] = "player"
}
local function newShouldShowBuff(_,name,caster)
     return name and (whitelist[name] == caster or whitelist[name] == "all")
 end
local function Mixin(baseFrame)
  baseFrame.UnitFrame.BuffFrame.ShouldShowBuff = newShouldShowBuff
end
local f = CreateFrame("Frame")
f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
f:SetScript("OnEvent", function(_,_,unitId)
  Mixin(C_NamePlate.GetNamePlateForUnit(unitId))
end)
for _,baseFrame in pairs(C_NamePlate.GetNamePlates()) do
  Mixin(baseFrame)
end
It's a bit of code from MMO-Champion that I found on a post from these forums almost a year ago. I didn't want to necro the thread, but I would really like some help ironing it out. The code does exactly what I want, but it has some issues.

Non-whitelisted buffs appear on nameplates. The world buffs in battlegrounds always show up on my personal resource display, and random debuffs from friendly players will pop up from time to time. There also seems to be no way to distinguish between spells of the same name but different spell IDs. For example, I want to show the Disable root but not the slow unless I'm the one who casted it.

Any help is appreciated! I don't have much experience in this, so this is my last resort.
  Reply With Quote
07-26-18, 09:14 AM   #2
Sylen
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 50
I had the same idea at some point in Legion and tried what you are trying to do aswell. Turns out there isn't really a clean and simple solution to it. If you want to read a bit more check this thread

The blacklist idea from my last post in the linked post, resulted in big performance issues. After this i gave up on this idea.

If you really want this feature, my advice is to stick to an established nameplate addon. There are plenty of them out there. My personal recomendation in this case would be Plater Nameplates.
  Reply With Quote
07-26-18, 02:43 PM   #3
Shiezko
A Murloc Raider
Join Date: Jul 2018
Posts: 7
Originally Posted by Sylen View Post
I had the same idea at some point in Legion and tried what you are trying to do aswell. Turns out there isn't really a clean and simple solution to it. If you want to read a bit more check this thread

The blacklist idea from my last post in the linked post, resulted in big performance issues. After this i gave up on this idea.

If you really want this feature, my advice is to stick to an established nameplate addon. There are plenty of them out there. My personal recomendation in this case would be Plater Nameplates.
That's exactly where I found the script. I would really like something that doesn't alter the health bars, just the buffs. Even a full replacement that looks like the default would be okay with me. I've tried every nameplate addon, and I find it hard to play with them on, especially in PvP. Even FlyPlateBuffs made it harder to read the duration of CC at a glance. I was hoping someone might have a solution here because otherwise I'll just have to stick with the default plates.
  Reply With Quote
07-27-18, 03:26 AM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Well you "could" use oUF and create your own nameplates. Since nameplates are just regular unitframes you can use the oUF customfilter on your nameplate auras. That is what I am doing.
https://github.com/zorker/rothui/blo...eplate.lua#L49
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
07-27-18, 11:07 AM   #5
Shiezko
A Murloc Raider
Join Date: Jul 2018
Posts: 7
Originally Posted by zork View Post
Well you "could" use oUF and create your own nameplates. Since nameplates are just regular unitframes you can use the oUF customfilter on your nameplate auras. That is what I am doing.
https://github.com/zorker/rothui/blo...eplate.lua#L49
I'm probably less familiar with LUA than you think I am. Some clarification would help if you could.
  Reply With Quote
11-14-18, 03:39 PM   #6
Reser
A Kobold Labourer
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 1
A bit of a necro but the issue with the code letting non-whitelisted debuffs through seems to be that there's a lot of debuffs going around that don't have a caster tied to them. Seems to be world buffs e.g. in BGs, some azerite traits, and debuffs by people whose nameplates you are not in the range of. This makes

Code:
local function newShouldShowBuff(_,name,caster)
    return name and (whitelist[name] == caster or whitelist[name] == "all")
end
return true for debuffs that have a name but lack a caster and aren't found in the whitelist (caster == nil == whitelist[name]). Easy enough fix for this is to check the caster to make sure that non-whitelisted debuffs wont go through.

Code:
local function newShouldShowBuff(_,name,caster)
    return name and caster and (whitelist[name] == caster or whitelist[name] == "all")
end
  Reply With Quote
01-07-19, 04:00 AM   #7
Shiezko
A Murloc Raider
Join Date: Jul 2018
Posts: 7
Originally Posted by Reser View Post
A bit of a necro but the issue with the code letting non-whitelisted debuffs through seems to be that there's a lot of debuffs going around that don't have a caster tied to them. Seems to be world buffs e.g. in BGs, some azerite traits, and debuffs by people whose nameplates you are not in the range of. This makes

Code:
local function newShouldShowBuff(_,name,caster)
    return name and (whitelist[name] == caster or whitelist[name] == "all")
end
return true for debuffs that have a name but lack a caster and aren't found in the whitelist (caster == nil == whitelist[name]). Easy enough fix for this is to check the caster to make sure that non-whitelisted debuffs wont go through.

Code:
local function newShouldShowBuff(_,name,caster)
    return name and caster and (whitelist[name] == caster or whitelist[name] == "all")
end
I had all but given up on this for months now and just enabled all my personal debuffs instead. I'll spend tonight setting this up and tomorrow testing it. If it works, I will be extremely thankful! I've been trying to do this for years on and off with no success.

EDIT: I've run into a problem with this. I want to track the Monk class's Disable root but not the slow. Both of the debuffs have the same name, so is there a way for me to see the root on all my characters and both on my Monks?

Last edited by Shiezko : 01-07-19 at 05:22 AM.
  Reply With Quote
01-07-19, 06:07 AM   #8
Sylen
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 50
I'm using his fix for a longer period of time now and it works totally fine for me.

As for your problem with the "Disable"-spell, all i can think of right now is that you could try to change the whitelist to spellIds instead of spellNames.
  Reply With Quote
01-07-19, 06:44 AM   #9
Shiezko
A Murloc Raider
Join Date: Jul 2018
Posts: 7
Originally Posted by Sylen View Post
I'm using his fix for a longer period of time now and it works totally fine for me.

As for your problem with the "Disable"-spell, all i can think of right now is that you could try to change the whitelist to spellIds instead of spellNames.
Any idea how to do that? I have no experience with lua at all, and I'm not going to learn just for that. From what I've read, checking for spell ID requires a lot more processing power because it has to scan all buffs and debuffs, but I'm willing to give it a shot.
  Reply With Quote
01-08-19, 01:55 PM   #10
Sylen
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 50
I fiddled around with it but i can't get it to work as my Lua knowledge isn't the best either.
  Reply With Quote
01-09-19, 09:22 PM   #11
Shiezko
A Murloc Raider
Join Date: Jul 2018
Posts: 7
Originally Posted by Sylen View Post
I fiddled around with it but i can't get it to work as my Lua knowledge isn't the best either.
Thanks for trying. If anyone knows how to do it, please post here. I'll keep this bookmarked and check regularly.

EDIT: I've noticed that the issue also occurs with the Rake stun/bleed. They have the same name but different ID's. This is quickly becoming a problem because I really want to track all loss of control effects and not see random bleeds on players in PvP. If there's any way to whitelist additional spells by ID, I would like to know how.

Last edited by Shiezko : 01-10-19 at 01:16 AM.
  Reply With Quote
01-10-19, 06:58 PM   #12
Sylen
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 50
Ok I got a working version that uses spellIds instead of spellNames. It works for debuffs and buffs BUT still shows both debuffs if they have an identical name (tested with druids Rake ability).

Also I am kinda convinced now, that your desired behaviour is actually not possible to achieve because the Blizzard function is only looking for spellNames and even if you filter two spells with the same name for their respective spellIds you would still have to handover the spellName in the end which is identical again (at least for my understanding of how the code operates).

Lua Code:
  1. local whitelist = {
  2.     --[spellId] = {caster = unitId}
  3.     --[155722] = {caster = "player"},   --Rake Bleed
  4.     [163505] = {caster = "player"},     --Rake Stun
  5.     [155625] = {caster = "player"},     --Moonfire (Lunar Inspiration Talent)
  6.     [8936] = {caster = "player"}        --Regrowth
  7. }
  8.  
  9. local function newShouldShowBuff(_,name,caster)
  10.     for k, v in pairs(whitelist) do
  11.         local spellName, _, _, _, _, _, spellId = GetSpellInfo(k)
  12.         if spellName == name and spellId == k then             
  13.             return name and caster and (whitelist[k].caster == caster or whitelist[k].caster == "all") 
  14.         end
  15.     end
  16. end
  17. local function Mixin(baseFrame)
  18.     baseFrame.UnitFrame.BuffFrame.ShouldShowBuff = newShouldShowBuff
  19. end
  20.  
  21. local f = CreateFrame("Frame")
  22.     f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  23.     f:SetScript("OnEvent", function(_,_,unitId)
  24.    
  25.     Mixin(C_NamePlate.GetNamePlateForUnit(unitId))
  26. end)
  27.  
  28. for _,baseFrame in pairs(C_NamePlate.GetNamePlates()) do
  29.     Mixin(baseFrame)
  30. end

Last edited by Sylen : 01-10-19 at 07:00 PM.
  Reply With Quote
01-11-19, 05:47 PM   #13
Shiezko
A Murloc Raider
Join Date: Jul 2018
Posts: 7
Originally Posted by Sylen View Post
Ok I got a working version that uses spellIds instead of spellNames. It works for debuffs and buffs BUT still shows both debuffs if they have an identical name (tested with druids Rake ability).

Also I am kinda convinced now, that your desired behaviour is actually not possible to achieve because the Blizzard function is only looking for spellNames and even if you filter two spells with the same name for their respective spellIds you would still have to handover the spellName in the end which is identical again (at least for my understanding of how the code operates).

Lua Code:
  1. local whitelist = {
  2.     --[spellId] = {caster = unitId}
  3.     --[155722] = {caster = "player"},   --Rake Bleed
  4.     [163505] = {caster = "player"},     --Rake Stun
  5.     [155625] = {caster = "player"},     --Moonfire (Lunar Inspiration Talent)
  6.     [8936] = {caster = "player"}        --Regrowth
  7. }
  8.  
  9. local function newShouldShowBuff(_,name,caster)
  10.     for k, v in pairs(whitelist) do
  11.         local spellName, _, _, _, _, _, spellId = GetSpellInfo(k)
  12.         if spellName == name and spellId == k then             
  13.             return name and caster and (whitelist[k].caster == caster or whitelist[k].caster == "all") 
  14.         end
  15.     end
  16. end
  17. local function Mixin(baseFrame)
  18.     baseFrame.UnitFrame.BuffFrame.ShouldShowBuff = newShouldShowBuff
  19. end
  20.  
  21. local f = CreateFrame("Frame")
  22.     f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  23.     f:SetScript("OnEvent", function(_,_,unitId)
  24.    
  25.     Mixin(C_NamePlate.GetNamePlateForUnit(unitId))
  26. end)
  27.  
  28. for _,baseFrame in pairs(C_NamePlate.GetNamePlates()) do
  29.     Mixin(baseFrame)
  30. end
I've been talking with someone on the WoW forums about it, and they are trying to help by also checking the duration of the auras and only displaying duplicate names if their durations are the same as the original spell ID's aura. We're running into other issues with it, but if you want to try that, it seems like a reasonable solution.

Here's the link if you want to check it out:
https://us.forums.blizzard.com/en/wo...elist/69575/22

EDIT: It looks like we may have done it, but I wasn't able to test whether or not random auras from other players would show up. I'll post the script here, and you are free to test it.

Code:
local whitelist = {
	[116706] = "player", -- Disable WW Monk Root
	[137639] = "player", -- Storm, Earth, and Fire buff spell for player
--	[] = "all", -- Other spell from anyone
}

local function newShouldShowBuff(self, name, caster, nameplateShowPersonal, nameplateShowAll, duration)
	local filter = "INCLUDE_NAME_PLATE_ONLY"
	if UnitIsUnit(self.unit, "player") then
		filter = "HELPFUL|".. filter
	else
		filter = "HARMFUL|".. filter
	end
	for i=1, BUFF_MAX_DISPLAY do 
		local spellName, _, _, _, spellDuration, _, spellCaster, _, _, spellId = UnitAura(self.unit, i, filter);
		if not spellName then break end
		if name == spellName and caster == spellCaster and duration == spellDuration then -- fingers crossed we're testing for the same aura
			if whitelist[spellId] == spellCaster or whitelist[spellId] == "all" then
				return true
			end
		end
	end
	return false
end
local function Mixin(baseFrame)
	baseFrame.UnitFrame.BuffFrame.ShouldShowBuff = newShouldShowBuff
end
local f = CreateFrame("Frame")
f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
f:SetScript("OnEvent", function(_,_,unitId)
	Mixin(C_NamePlate.GetNamePlateForUnit(unitId))
end)
for _,baseFrame in pairs(C_NamePlate.GetNamePlates()) do
	Mixin(baseFrame)
end
EDIT: Just noticed extra auras appearing from other players. If you can manage to fix that, this seems to be working as intended, though I would like to see if you could edit your spell ID script to include duration first. Yours seems to work without any problems so far.

Last edited by Shiezko : 01-11-19 at 09:39 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Nameplate Debuff Whitelist

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