View Single Post
01-21-22, 10:06 AM   #8
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
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:
  1. local whitelist = {
  2.     [116841] = "player",--Tiger's Lust
  3.     [228287] = "player",--Mark of the Crane
  4.     [115078] = "all",--Paralysis
  5.    
  6. }
  7.  
  8. local function newShouldShowBuff(self, name, caster, nameplateShowPersonal, nameplateShowAll, duration)
  9.     if not name then return false end
  10.     local filter = "INCLUDE_NAME_PLATE_ONLY"
  11.     if UnitIsUnit(self.unit, "player") then
  12.         filter = "HELPFUL|"..filter
  13.     elseif UnitIsFriend(self.unit, "player") then
  14.         return true
  15.     else
  16.         filter = "HARMFUL|"..filter
  17.     end
  18.     for i=1, BUFF_MAX_DISPLAY do
  19.         local spellName, _, _, _, spellDuration, _, spellCaster, _, _, spellId = UnitAura(self.unit, i, filter);
  20.         if not spellName then break end
  21.         if name == spellName and caster == spellCaster and duration == spellDuration then
  22.             if (caster and whitelist[spellId] == spellCaster) or whitelist[spellId] == "all" then
  23.                 return true
  24.             end
  25.         end
  26.     end
  27.     return false
  28. end
  29. local f = CreateFrame("Frame")
  30. f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  31. f:SetScript("OnEvent", function(_,_,unitId)
  32.     C_NamePlate.GetNamePlateForUnit(unitId).UnitFrame.BuffFrame.ShouldShowBuff = newShouldShowBuff
  33. end)
  34. for _,baseFrame in pairs(C_NamePlate.GetNamePlates()) do
  35.     baseFrame.UnitFrame.BuffFrame.ShouldShowBuff = newShouldShowBuff
  36. end
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote