WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Nameplate Debuff Whitelist (https://www.wowinterface.com/forums/showthread.php?t=56443)

Shiezko 07-26-18 06:12 AM

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.

Sylen 07-26-18 09:14 AM

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.

Shiezko 07-26-18 02:43 PM

Quote:

Originally Posted by Sylen (Post 329009)
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.

zork 07-27-18 03:26 AM

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

Shiezko 07-27-18 11:07 AM

Quote:

Originally Posted by zork (Post 329079)
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.

Reser 11-14-18 03:39 PM

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


Shiezko 01-07-19 04:00 AM

Quote:

Originally Posted by Reser (Post 330857)
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?

Sylen 01-07-19 06:07 AM

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.

Shiezko 01-07-19 06:44 AM

Quote:

Originally Posted by Sylen (Post 331308)
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.

Sylen 01-08-19 01:55 PM

I fiddled around with it but i can't get it to work as my Lua knowledge isn't the best either.

Shiezko 01-09-19 09:22 PM

Quote:

Originally Posted by Sylen (Post 331327)
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.

Sylen 01-10-19 06:58 PM

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

Shiezko 01-11-19 05:47 PM

Quote:

Originally Posted by Sylen (Post 331346)
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.


All times are GMT -6. The time now is 06:32 PM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI