Armor Ignoring Attacks

Level 22
Joined
Jul 25, 2009
Messages
3,112
This seems like it should be simple but I'm not sure where to begin.

I have a DDS in my map and what I want to do is, when certain units take damage from other certain units, I simply want to ignore their armor value (not armor type), for example a unit could have 12 armor points and that could be 65% damage resistance or whatever, I need to be able to

1. Find a unit's armor value with trigger's (I think)

2. Change damage amount done in my DDS to a calculation based on the armor value * 0.06 etc
 
Level 25
Joined
Jul 18, 2010
Messages
1,793
Hmm don't ignoring Armor Type that is not so Easy cause there is no get Attack-/ArmorType, You'll need to save/load Armor and attack Type of each Unit-Type, write its specific value in some kind of table form:
This Trigger does not work cause of wrong Hashtable access:
  • Init Armor Attack Type
    • Ereignisse
    • Bedingungen
    • Aktionen
      • Hashtabelle - Create a hashtable
      • -------- Use AttackType as 0/1/2/3/4/5/6 --------
      • -------- ArmorType as 0/10/20/30/40/50.... --------
      • -------- The Index is later ArmorType + AttackType --------
      • -------- Hero Attack Damage = 0 --------
      • Set AttackArmorType_Multiplier[0] = 1.00
      • Set AttackArmorType_Multiplier[10] = 1.00
      • Set AttackArmorType_Multiplier[20] = 1.00
      • Set AttackArmorType_Multiplier[30] = 0.50
      • Set AttackArmorType_Multiplier[40] = 1.00
      • Set AttackArmorType_Multiplier[50] = 0.05
      • Set AttackArmorType_Multiplier[60] = 1.00
      • -------- Next AttackType --------
      • Set AttackArmorType_Multiplier[1] = 1.00
      • Set AttackArmorType_Multiplier[11] = 1.00
      • Set AttackArmorType_Multiplier[21] = 1.00
      • Set AttackArmorType_Multiplier[31] = 1.00
      • -------- Save Attack Type Hero for Mountain King Type. --------
      • Custom script: call SaveIntegerBJ( 0, 0, 'Hmkg', GetLastCreatedHashtableBJ() )
      • -------- Save Armor Type Improved for Townhall. --------
      • Custom script: call SaveIntegerBJ( 30, 1, 'htow', GetLastCreatedHashtableBJ() )

If you don't use harden skin (dat moutain Giant Skill, blocking fix damage) & dat % Protection from Nerbuian Hero you could damage a Unit with 10 Chaos damage calculate the taken damage and heal it again.
Convert this Taken damage into a % of the full damage.
Use this % value its the dmg reduction:

To make your Attack deal full damage we use following formular:
Taken damage = Attack-Damage * Damage Reduction
wanted Taken Damage = Attack Damage
Therefore we do Taken Damage = Attack Damage * Damage Reduction / Damage Reduction

Example using Bribes Damage Engine:
  • Ignore Armor
    • Events
      • Game - DamageModifierEvent becomes Equal 2.00
    • Conditions
      • IsDamageSpell Equal False
      • Bergkönig 0020 <gen> Equal DamageEventSource
    • Actions
      • -------- Avoid Endless Loop --------
      • Trigger - Turn off DamageEventTrigger
      • -------- Save Old Life --------
      • Set My_OldLife = (Life of DamageEventTarget)
      • -------- Avoid Killing --------
      • Unit - Set life of DamageEventTarget to 100.00%
      • -------- Calc % dmg taken --------
      • Unit - Cause DamageEventTarget to damage DamageEventTarget, dealing 10.00 damage of attack type Chaos and damage type Normal
      • Set MY_DamageTaken = ((Max. Life of DamageEventTarget) - (Life of DamageEventTarget))
      • Set MY_DamageTaken = (MY_DamageTaken / 10.00)
      • -------- Restore Life --------
      • Unit - Set life of DamageEventTarget to My_OldLife
      • Trigger - Turn on DamageEventTrigger
      • -------- Damage * DamageReduction / ArmorValue Reduction = Damage * ArmorType Reduction --------
      • Set DamageEventAmount = (DamageEventAmount / MY_DamageTaken)
Math stuff not needed here but good to know:
Only +Armor:
DamageReduction (x) = x / (x + 1 / ArmorMultiplier)
often this formular is shown in this form y = x * ArmorMultiplier / ( x * ArmorMultiplier + 1)
Only With X [0 -> 1[
Armor (x) = (1 / Armor Multiplier) / ( 1/x - 1)

If you use Armor Multiplier of 0.06:
1/0.06 = 16,66666666667 or 16 + 2/3 or 50/3
If you use Armor Multiplier of 0.01:
1/0.01 = 100
 
Last edited:

Jampion

Code Reviewer
Level 13
Joined
Mar 25, 2016
Messages
1,288
I think it,s not that hard to get the armor of a specific unit. I used Bribe's damage engine, deal physical damage to a unit, check the damage and calculate the armor and set the damage to deal no damage.

Hit Escape to get the armor of all selected units.
 

Attachments

  • ArmorTest.w3x
    33.2 KB · Views: 38
Level 25
Joined
Jul 18, 2010
Messages
1,793
I think it,s not that hard to get the armor of a specific unit. I used Bribe's damage engine, deal physical damage to a unit, check the damage and calculate the armor and set the damage to deal no damage.

Hit Escape to get the armor of all selected units.
Right a misstake of mine you need to Divide the Damage by Reduction done by Armor.
The Damagereduction done by Armor is the value we gain from the chaos dmg no armor Type included at all :|.
Forget this Saving Armor Attack types:
  • Ignore Armor
    • Events
      • Game - DamageModifierEvent becomes Equal 2.00
    • Conditions
      • IsDamageSpell Equal False
      • Your Unit Equal DamageEventSource
    • Actions
      • -------- Avoid Endless Loop / other Influences --------
      • Trigger - Turn off DamageEventTrigger
      • -------- Save Old Life --------
      • Set My_OldLife = (Life of DamageEventTarget)
      • -------- Avoid Killing --------
      • Unit - Set life of DamageEventTarget to 100.00%
      • -------- Calc % dmg taken --------
      • Unit - Cause DamageEventTarget to damage DamageEventTarget, dealing 10.00 damage of attack type Chaos and damage type Normal
      • Set MY_DamageTaken = ((Max. Life of DamageEventTarget) - (Life of DamageEventTarget))
      • Set MY_DamageTaken = (MY_DamageTaken / 10.00)
      • -------- Restore Life --------
      • Unit - Set life of DamageEventTarget to My_OldLife
      • Trigger - Turn on DamageEventTrigger
      • -------- Damage * DamageReduction / ArmorValue Reduction = Damage * ArmorType Reduction --------
      • Set DamageEventAmount = (DamageEventAmount / MY_DamageTaken)
 
Last edited:
Level 22
Joined
Jul 25, 2009
Messages
3,112
I changed my method of damage calculation entirely by setting the unit's armor in arrays and reducing the damage taken.

The problem is setting a unit's armor in an array means it can't be easily edited or changed by abilities, is there an easier more fluid way to detect a unit's armor value?
 

Jampion

Code Reviewer
Level 13
Joined
Mar 25, 2016
Messages
1,288
I just provided one only using Bribe's damage engine. You don't need any tables and it's completely fluid.
It's not even much work, I did it in less than 5 minutes.
 
Level 22
Joined
Jul 25, 2009
Messages
3,112
I removed damage reduction from armor, instead of 0.06, it's 0. I did this so I could make armor reduce flat damage. I need a way to track armor changes in real time.

Right now I save the armor values for every unit in arrays.
 

Jampion

Code Reviewer
Level 13
Joined
Mar 25, 2016
Messages
1,288
Well then my method does not work. However you can change armor back to 0.06 or whatever > 0, so you can use my method. After that you can revert the relative armor reduction.
I think the only ways to detect armor real time is either storing all armor values of units and checking, which abilities, ugrades and buffs the unit has or you detect the effect of armor (my method).
 
Top