Add Mana Shield to a Spellbook, disable the Spellbook for the player. Make Mana Shield use 0 mana, and have 0 mana cost, then if it's a spell, then do
Every 0.10 seconds,
If unit has YourBuff, then
Add YourSpellbook to YourUnit
Order YourUnit to ManaShield
(I'm pretty sure this works)
Ordering a unit to use Manashield does NOT interrupt their current orders and using a Spellbook allows them to still use Manashield but the button does not appear on them.
You can also use this method to make units take MORE damage from targets, by putting a negative number in for Mana Shield.
Mana Shield by default absorbs 100% damage (But since damage in WC3 cannot go lower then .5, damage is still done) but it can be changed to absorb 75%, 50%, 25%, 11%, 23%, etc
Just set Data - Damage Absorbed (%) from 1.00 to whatever you want.
You can also use this method to create a makeshift Defensive Matrix like in StarCraft 1.