Blizzard Nameplate Aura Filter

Someone on the forums helped me with a script to filter debuffs on the Blizzard nameplates by spell ID a while back. As far as I understand, this is how it works:

  • Clear Blizzard nameplate auras
  • Whitelist all nameplate auras with identical spell name and caster to listed spell ID
  • Hide all auras with different duration from the listed spell ID’s current duration to ensure that only the listed spell ID is shown, and not those with identical spell names (not a perfect solution, open to alternatives).

This works like a charm, and I’m perfectly happy with the way it functions on the personal resource display and enemy nameplates so far. If possible, I would like it to show whitelisted buffs (not debuffs) on friendly nameplates in the same way that it does on the personal resource display. I’m not sure whether or not this is possible, but it would be extremely useful for healers (displaying HoTs and other buffs on nameplates rather than only raid frames). If it isn’t possible to show buffs on friendly nameplates, I would like to have a separate filter for debuffs on friendly nameplates (e.g., show only whitelisted auras on friendly nameplates).

I’m aware of Blizzard’s changes to the way addons interact with friendly nameplates in certain PvE instances. I don’t mind if this script only works outside of those instances.

If you’re willing to help, feel free to modify the script in any way you want to get it to function as described. I would really appreciate it, and I’m sure others would like to have a script like this instead of a nameplate overhaul addon.

local whitelist = {
	[spellID] = "player",
	[spellID] = "pet",
	[spellID] = "all",
}

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 (caster and 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
2 Likes