You'd need to loop through the debuffs on the unit and check if any of them are Magic debuffs:
local function HasMagicDebuff(unit)
for i = 1, 100 do
local name, _, _, _, debuffType = [URL="http://www.wowwiki.com/API_UnitDebuff"]UnitDebuff[/URL](unit, i)
if not name then
-- We've passed the last debuff on the unit; quit looking.
-- This is why the 100 above doesn't really matter;
-- it just needs to be greater than the number of debuffs
-- a unit will ever have.
if debuffType == "Magic" then
-- We've found a magic debuff; no need to keep looking.
-- If we've reached this point, the unit doesn't have any Magic debuffs,
-- but we don't need to explicitly return false.
Now you can just do this anywhere in your code:
if HasMagicDebuff(unit) then
-- this unit has a Magic debuff
-- this unit doesn't have a Magic debuff
"When used with a HELPFUL filter it will show auras the player can cast on party/raid members (as opposed to self buffs). If used with a HARMFUL filter it will return debuffs the player can cure." [source]
Why are you querying auras in an OnUpdate script? You should avoid doing anything in an OnUpdate script unless there is absolutely no alternative. You should especially never use an OnUpdate script to determine when things happen that fire an event specifically to announce that they happen.
Instead, you should use an event handler and register for the UNIT_AURA event. The event will fire each time a unit's buffs or debuffs change.
If you only wanted to highlight Magic debuffs if the player could cure them, then yes, the "RAID" filter would work. But, if you wanted to do that, then you should just check whether the player's class can cure Magic debuffs once when they log in, and not even bother checking auras at all if they can't.
UNIT_HEALTH and UNIT_POWER are both throttled to fire no more than 5 times per second. As someone who's been successfully healing high-end raid content for about five years now, I assure you, 5 health updates per second is plenty. Any healer who is letting people die because he's waiting until the health bar shows them at 20% to start casting any heals is either using the worst raid frames in the world and has no idea who is taking damage or is likely to start taking damage, or is just a bad healer.
0.2s delay for the HealthBar is unaccaptable. I can remember some situations where I watched the combat log to react fast enough, e.g. Patchwerk classic. Most of the time it probably doesn't really matter, but I think it is more fun without the delay.
To each his own, I suppose. I wouldn't use an addon that forced me to waste CPU cycles on useless polling code to update the health bar imperceptibly faster. I remember healing Patchwerk, and 0.2 seconds was always plenty fast enough for me. It wasn't/isn't that hard to figure out who's about to take damage if you're paying attention and know the encounter.
Ok, you convinced me. Now my healthbars are reacting to UNIT_HEALTH, UNIT_MAXHEALTH and some combatlog events, wich is in most cases as quick as updating the health every frame.
There is no event for UnitInRange, is there?