# Adding armor of non-heroic unit to trigger damage ?

Status
Not open for further replies.

A

#### Ardenian

Hello,
I have a trigger that should damage a non-heroic for a certain amount depending on the level of the ability being casted as well as the armor.
Positive armor of the unit ability is being casted on means the damage is reduced, negative armor means the damage is increased.
So far, so good.

But, I cannot find anywhere an option to get the armor value from the unit the ability is casted on. How do I get the current armor value of an unit ( non-heroic!) ?

#### Nichilus

Level 25
You don't. There's no built-in function as far as I know. All you can do is to keep track of everything yourself.

A

#### Ardenian

All you can do is to keep track of everything yourself.
There is no way top get a unit's armor ?

How does Zwiebelchen created the armor = percentage reduction trigger ? ( armor = the percentage of reduction, meaning that 5 armor would be 5% damage reduction). It is not the same, but doesn't it work with the armor value itself ? Or is it super complicated with some triggers including agility state and item influences ?

Your statement makes me desperate, one big feature is ruined now...

#### Xonok

Level 21
Zwiebelchen keeps track of armor values. Also, the damage reduction is not 1%, but rather 1 point per armor.

#### Nichilus

Level 25
Well now that I think about it, there's a partial workaround on how you can get unit's armor, though it is not perfect.

The equation to calculate % reduction is like this:
( [reduction constant] * [armor value] ) / ( [reduction constant] * [armor value] +1 ) = % Damage reduction

So if you do constant damage (e.g. 100 damage to said unit) and detect the real damage taken, you could calculate the armor value this way.
This has some drawbacks of course - you need to use correct attack and damage type, since some types deal more damage to certain armor types, problem could be also if unit has divine shield, mana shield, defend, etc.

A

#### Ardenian

Zwiebelchen keeps track of armor values. Also, the damage reduction is not 1%, but rather 1 point per armor.

What does it mean, keeping track of the armor values ( I know what it mean, but what does it mean for triggering ?).

Oh, alright, this is EXACTLY what I need. I want to write triggers that damage a target ( A death coil with no default damage for example). A trigger damages the attacked unt, taking care of the armor. If the unit has a positive armor, the damage is reduced by the exact armor value. On the other hand, negative armor increases the damage by the exact negative armor value.
I wrote the full trigger, but I cannot find the armor value I need for the special armor reduce and increase part.

Well now that I think about it, there's a partial workaround on how you can get unit's armor, though it is not perfect.

The equation to calculate % reduction is like this:
( [reduction constant] * [armor value] ) / ( [reduction constant] * [armor value] +1 ) = % Damage reduction

So if you do constant damage (e.g. 100 damage to said unit) and detect the real damage taken, you could calculate the armor value this way.
This has some drawbacks of course - you need to use correct attack and damage type, since some types deal more damage to certain armor types, problem could be also if unit has divine shield, mana shield, defend, etc.
Hm, I see. Isn't this the other way around
?
I noticed I gave too limited information, I am very sorry. Therefore I explain/ed it further.
The problem is, my units do not damage by default ways, but only with triggers. That means, all spells dealing damage are only dummy spells for targetting, the damage is triggered.
I think this is the only way to add the armor system I would like to have in my map, as described above. I would be glad if you could help me again.

#### Dr Super Good

Spell Reviewer
Level 64
The default WC3 armor system already means units take less damage when positive and more when negative. Trigger damage can be affected by armor if set correctly.

Positive armor -> multiplies toughness by the factor defined in gameplay constants (default 0.06). Eg a unit with 100 hp and 10 armor with default multiplier will be able to take 160 damage from armor reduced sources.
Negative armor -> quickly raises towards double damage taken with diminishing returns. Armor multiplier is used to determine rate of decay. For example a unit with 100 hp and -10 armor at default constant would be able to survive 68 damage from armor reduced sources. At -100 armor (10 times lower) the amount only changes to 50 damage survival.

Hence where as positive armor linearly increases your ability to take damage, negative armor quickly doubles damage taken and becomes meaningless. Why they did not make negative armor increase damage linearly is beyond me.

#### Nichilus

Level 25
I noticed I gave too limited information, I am very sorry. Therefore I explain/ed it further.
The problem is, my units do not damage by default ways, but only with triggers. That means, all spells dealing damage are only dummy spells for targetting, the damage is triggered.
I think this is the only way to add the armor system I would like to have in my map, as described above. I would be glad if you could help me again.
You will have to keep track of everything yourself then.
That means manually making a list of each unit type and how much armor it has, then detecting if owner of said unit applied to that unit upgrades, if that unit has armor increasing items and buffs, etc.

A

#### Ardenian

Hm, I see, this is a bit more complicated. I got it now, thanks guys!

About the trigger, it would look like:

Event - A Unit is attacked
Condition
Action - If - Armor-influencing buff has ?
Then - modifiy an indexed variable ( I have to use indexed variable as it is a tower defence project)
Else If - ...
then - ...

I continue the trigger at Else ? I never know what is the difference between using separate If/Then/Else and combined ones ( so else leads to the next If/Then/Else)

#### Xonok

Level 21
If you have multiple ITE cycles after eachother, they all get run, but if you put an ITE inside an ITE, then it only gets run when the condition is run(then actions) or when it doesn't get run(else actions.

About keeping track of armor, you'll almost definitely need to keep track of all spells that modify it in some way.
Fundamentally you have 3 possible approaches:
1. Detect damage amount by dealing damage with a trigger and then calculating armor based on the actual damage taken. Then prevent the damage. (Easy with a DDS, but can't properly account for things like defend, hardened skin, etc)
2. Keep track of the current armor amount of each unit and detect when it changes either periodically(high constant cost and some delay) or with an event-based approach(fast, but not easy).
3. Whenever the armor amount is checked, look at all the buffs and other things that the unit has to calculate the current armor amount.
3a. If you use JASS or vJASS you can start a 0-timer whenever the armor amount is checked and thus avoid recalculating the amount if the armor value is checked several times in the same event(where it's unlikely to change).

A

#### Ardenian

Thank you, Xonok, for pointing out the different choices and explaining the use of ITE.

I think I decided to do the second one, but I need help with it, please.

The map I work on is a TD, therefore I can create an indexed variable that is set to the different unit-types / waves base armor.
Then I create a trigger for each custom ability ( as the abilities have different damage values).
Before damaging the target via trigger, I have multiple ITE that check if a unit has certain armor influencing buffs and they change a new variable that was set to tbe wave armor before.
As far as good, but the trigger does not work, sadly. I will post the trigger later and hope that we can solve it. I think it has to do with 'unit is attacked' as event and 'ability being cast' as condition.

EDIT: I created a new thread as the original topic is solved. Thank you, guys!

Last edited by a moderator:
Status
Not open for further replies.

Replies
2
Views
858
Replies
3
Views
991
A
Replies
32
Views
1K
Ardenian
A
Replies
16
Views
2K
Replies
13
Views
1K