How to account total Armor into a variable?

Level 2
Jun 19, 2012
Well I was wondering if anyone knew of a way to account total armor for a unit including bonuses from Agi and items and then use that as a variable for another purpose? Preferably in GUI but I'll take JASS as well.

General idea: Unit X deals +Y damage on attacks, where Y is Z% of Total Armor of Unit X.

Trigger as a whole:

Event: A unit is attacked
Condition: Attacking unit = Unit X
- Set variable "Armor Count" to ...
- Cause Unit X to Damage Triggering Unit equal to Z% * variable (Armor Count).
Level 19
Sep 26, 2009
It is possible to calculate it, but it's quite complicated and you will need damage detection system or a trigger that fires upon "unit takes damage" event.

First, go to Object Editor and create a dummy unit, which deals 10 chaos damage per attack - I will call that unit "TestDamager".
Second, create a trigger that fires when your unit takes damage (the one whose armor value you want to find out), or import a damage detection system. One or the other, I will call this for simplicity "DamageEvent"

Now when you want to calculate how much armor value your unit has, create TestDamager and order him to damage your unit.

When TestDamager deals damage to your hero, DamageEvent fires and notes how much damage your hero took.

Now, through equation "Z = 1 - (A / B)" you can find out how much armor reduction your hero has.
Z = Armor reduction
A = Damage your hero took
B = TestDamager base damage (this should be 10, unless you set different amount in object editor)

This will return % reduction converted to real value.
Ex. TestDamager deals 10 base damage, your hero took 6,25 damage.
Z = 1 - (6,25 / 10) = 1 - 0,625 = 0,375
=> this is 37,5% armor reduction converted to real number.

Now to find out armor value, you need to know Armor Damage Reduction Coefficient. This coefficient is same for all armor types.
You can find it Advanced -> Gameplay Constants -> "Combat - Armor Damage Reduction Multiplier", by default, that value is 0,06.

X = armor value
Y = armor damage reduction multiplier
Z = armor reduction you calculated above

X = Z / (Y - YZ)

So this is what you need:
Z = 1 - (A / B)
X = Z / (Y - YZ)

A = Damage taken
B = Base damage (you need to remember this value yourself)
X = Armor value for which you calculate all this
Y = Armor Damage Reduction Multiplier (found in Gameplay Constants)
Z = Armor Reduction

Important thing:
TestDamager has to have attack type set to "Chaos", because Chaos damage deals full damage to all armor types (= Heavy armor, Hero armor, etc.) - unless you changed that yourself in Gameplay Constants

Another thing is for negative armor value... for that I think there are different equations and has a cap