Kanegasi makes valid points and may well be closer to best method. This is a rework of the original with just an "ignore" for non-player friendlies.
I've been scratching my head as to if/why I would have redefined Mixin like that but...
Lua Code:
local whitelist = {
[116841] = "player",--Tiger's Lust
[228287] = "player",--Mark of the Crane
[115078] = "all",--Paralysis
}
local function newShouldShowBuff(self, name, caster, nameplateShowPersonal, nameplateShowAll, duration)
if not name then return false end
local filter = "INCLUDE_NAME_PLATE_ONLY"
if UnitIsUnit(self.unit, "player") then
filter = "HELPFUL|"..filter
elseif UnitIsFriend(self.unit, "player") then
return true
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
if (caster and whitelist[spellId] == spellCaster) or whitelist[spellId] == "all" then
return true
end
end
end
return false
end
local f = CreateFrame("Frame")
f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
f:SetScript("OnEvent", function(_,_,unitId)
C_NamePlate.GetNamePlateForUnit(unitId).UnitFrame.BuffFrame.ShouldShowBuff = newShouldShowBuff
end)
for _,baseFrame in pairs(C_NamePlate.GetNamePlates()) do
baseFrame.UnitFrame.BuffFrame.ShouldShowBuff = newShouldShowBuff
end