I'm doing something almost similar in my personal layout, except that I color by debuff type color I can dispell.
the 'RAID|HARMFUL' filter in the UnitAura call will filter the debuff type I can dispell, magic debuff filtering is a little buggy as for paladin, druid, shaman it's now a talent, and for warlock it's a pet spell, so I made a workaround to check if you can dispell it.
it the code below there is a function UpdateMagicDispell which will check if you can dispell magic, this function should be called by PLAYER_TALENT_UPDATE and SPELLS_CHANGED events.
SetCureableDebuff will update the color of the based on the debuff type you can dispell, it should be called by UNIT_AURA event.
I only post the code relevant to the debuff coloring as this is part to a personal element that is managing all my own indicators.
Code:
local UpdateMagicDispell, SetCureableDebuff
do
local GetTalentInfo, IsSpellKnown = _G.GetTalentInfo, _G.IsSpellKnown
local canDispellMagic
local function checkTalent(tab, index)
return (select(5, GetTalentInfo(tab, index)) or 0) >= 1
end
function UpdateMagicDispell()
if playerClass == 'PALADIN' then
canDispellMagic = checkTalent(1, 14) and true or nil
elseif playerClass == 'DRUID' then
canDispellMagic = checkTalent(3, 17) and true or nil
elseif playerClass == 'SHAMAN' then
canDispellMagic = checkTalent(3, 12) and true or nil
elseif playerClass == 'WARLOCK' then
canDispellMagic = IsSpellKnown(89808, true) and true or nil
else
canDispellMagic = nil
end
end
function SetCureableDebuff(self, unit)
local i = 0
while true do
i = i + 1
local _, _, texture, _, debuffType = UnitAura(unit, i, 'RAID|HARMFUL')
if texture then
if debuffType ~= 'Magic' or canDispellMagic then
local color = DebuffTypeColor[debuffType or 'none']
self.CurrDebuff:SetVertexColor(color.r, color.g, color.b)
end
else
self.CurrDebuff:SetVertexColor(0, 0, 0)
end
end
end
end