Just use Channel with Target type set to No target (Instant). Then, pick every unit within 400 range of the hero's position, add them to a global group, save 400 (MaximumDamage) as a real via hashtable, and, whenever they receive magical damage, save MaximumDamage - DamageDealt. If the result is 0, then remove the unit from the global group, clear its hashtable values and destroy the trigger you created for it.
Best way would be jass, so that you can actually create one trigger per unit and then easily destroy it.