Magic Resistance

Magic resistance is an attribute of heroes, similar to armor. Instead of reducing physical damage, it reduces magical damage. All heroes, except Meepo and Visage, possess 25% magic resistance from their armor type. This percentage is completely independent of their amount of armor. Certain Hero summons, such as Enigma's Eidolons, also possess intrinsic magic resistance.

Magical damage
Magical damage is a type of damage caused mostly by abilities. Unlike physical damage, it is not affected by armor. However, it is affected by magic resistance dealing more or less damage, depending on the unit's current magic resistance. Besides magic resistance, magical damage, just like physical and pure damage, is also affected by damage manipulation.

Mechanics
All Heroes have a basic 25% magic resistance, except for Meepo and his clones, who have 35% and Visage, who has 10%. This means that, by default, for most heroes, all magical damage is reduced by 25%, or only 75% of the ability's damage is dealt. Most non-hero units have a 0% base magic resistance.

Stacking
There are many abilities and items which can increase or decrease a unit's magic resistance. All sources of magic resistance bonuses and reductions stack diminishingly. This means a unit's magic resistance value changes less, the higher its magic resistance is, and more, the lower it is. This means that the value changes more the lower the magic resistance value is.

Formula

For total magic resistance of a unit (multiply the result by 100 to get the percentage value):
 * Total magic resistance = 1 − ((1 − natural resistance) × (1 − first resistance bonus) × (1 − second resistance bonus) × (1 + first resistance reduction) × (1 + second resistance reduction))

For magical damage after magic resistance:
 * Actual damage = magical damage × (1 − natural resistance) × (1 − first resistance bonus) × (1 − second resistance bonus) × (1 + first resistance reduction) × (1 + second resistance reduction)

Example:
 * with level 4 and a  has a magic resistance of:
 * 1 - (1 - 0.25) × (1 - 0.5) × (1-0.15) = 68.125%
 * under the effect of and a level 4  has a magic resistance of:
 * 1 - (1 - 0.1) × (1 + 0.25) × (1 + 0.6) = -80%

As one can conclude, it is not possible to reach 100% magic resistance, no matter how many sources are stacked or how much the sources grant or reduce. However, there are several abilities which grant 100% magic resistance. Because of the stacking rules, these abilities prevent a unit's magic resistance to be reduced or increased, as the formula will always result in 100%, no matter how big the magic resistance bonus or reduction.

Effective HP
Despite each source of magic resistance increasing the magic resistance value less the higher it is and making them seem less effective, each sources increases the unit's effective HP against magical damage by their base value. Effective HP means, how much damage can a unit take before dying, after reductions. In this case, magic resistance increases a unit's effective HP against magical damage. A unit with 0% magic resistance has 100% effective HP against magical damage, means magical damage equaling 100% of its health is required to kill it. Most heroes have 25% magic resistance by default, making their effective HP against magical damage 133.33%

Formula:
 * Effective HP = Total HP / ( 1 - magic resistance × 0.01)

Example:
 * Anti-Mage has 1480 health at max level. With his basic magic resistance, max level Spell Shield and a Cloak, he has an effective HP of:
 * 1480 / (1 - 68.125 × 0.01) = 4643.14 effective HP
 * Visage has 2031 health at max level. With his basic magic resistance, while under the effect of Veil of Discord and level 4 Decrepify, he has an effective HP of:
 * 2031 / (1 - -80 × 0.01) = 1128.33 effective HP

Sources of 100% magic resistance
These abilities grant 100% magic resistance to the affected units, reducing every magical damage they take to 0, and ceasing the effects of magic resistance reductions.

Magical damage barrier
A magical damage barrier absorbs a set amount of magical damage. It absorbs the damage before it is reduced by magic resistance, unless the resistance is provided by spell immunity.

This means when a hero with a 25% magic resistance and a 300 health damage barrier gets hit by 400 magical damage, the shield will absorb 300 of that. The exceeding 100 are not absorbed and are now reduced by the 25% magic resistance down to 75. So in this scenario, the hero takes 75 damage. This means a barrier is more effective the lower a unit's magic resistance is, similar to how damage block is more effective, the lower the armor is.

Multiple sources of magical damage barriers do not stack. When affected by multiple, all of them deplete at the same time. For example, if a unit is affected by a level 4 Flame Guard (500 barrier health) and by Pipe of Insight (400 barrier health), and then takes 300 magical damage, both shields lose 300 capacity, leaving Flame Guard with 200 and Pipe of Insight 100 absorb capacity.