• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] How can I detect the amount of damage absorved by armor value ?

Status
Not open for further replies.
Level 11
Joined
Oct 9, 2015
Messages
721
How can I detect the amount of damage that is reduced by armor when unit takes damage?
For example, when a unit with 10 armor takes damage, I want to know how much damage was absorved by the armor. I need to modify unit's current/max health based on it
(I'm using Bribe's damage detection engine)
 
Last edited:
Level 14
Joined
Jan 16, 2009
Messages
716
If you have access the the unit's armor and the attack type you can simulate the exact reduction of the armor. The exact formula can be found somewhere (just do a google search).
Though I am almost sure that you won't have the exact unit's armor value nor the attack type. In this case, the best way is to compare the damage before it is dealt to the unit and after this event. I am not familiar with Bribe's engine but it seems that you can do that easily.
 
It's not possible to get the damage value before reduction with Bribe's damage engine. Nor is it possible to get the amount of damage reduced by defence type & defence value.

Which variable do I use to refer to the damage before armor reductions? For example, Meat Wagon has 100 damage, after armor reduction from a Medium armor unit 50 damage is dealt, I want to get the 100 damage.
That's impossible (very difficult to implement and too full of bugs to be reliable) unless you only modify your damage through triggers. Blizzard did not give us the ability to access a unit's attack value via triggers.
i think that's possible, by applying the inverse function of armor effectiveness given the result damage, i think that would output the original value(tho what would be hard is that it would apply the attack type table values)
>> Armor value

That's what I'm referring to as being too unreliable. I disregard it as impossible unless Blizzard gives us a GetUnitArmorValue native. You just have to read the criticism of existing armor libraries to discover the method can fail in countless unpredictable ways.
 
You could track each units armor and damage which is usually what everyone does otherwise if you don't mind interrupting orders, Blizzard has given us a way to detect pure damage that goes through armor just its in the object editor. Cleave with instant attack which can be done through many methods and artillery attack type. Which means that there actually is a way to get units attack damage and armor without constantly storing it, just nobody revealed it properly or knew about it.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,192
You can deal 100 damage odd and then compute the armor to some extent. It will be inaccurate for very large armor amounts (floating point error) and also will be wrong for very low armor amounts (there is a cap on negative armor).

Other way is to manually track armor a unit has from all armor adding sources. Be aware armor and hero stats are fractional so that that 0.25 agility per level does count towards armor.
 
Status
Not open for further replies.
Top