• 🏆 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!

Detecting Armor

Status
Not open for further replies.
Level 4
Joined
Apr 28, 2016
Messages
33
Hi, before i go to far, please accept my apologize lastly for those who know my problem in contest. Okay so i know where is my mistake, and i won't do it again, it won't happen again, okay? That's deal.

Now, i want a system, where armor points from a unit is detected by trigger/system. Is it possible to know how much armor on a unit like =(Integer - Hero Attribute - *** of a Unit (Include Bonuses) in trigger editor?

I have read a post on http://www.hiveworkshop.com/threads/defense-related-question-gui.197760/#post-1941493 , posted a solution by ap0calypse, and it reduce unit armor to zero (0). I need a system that reads unit armor points and change the value into level of ability. It will be like:

- A unit have 5 points armor.
- Set level of (A spell of unit) to amount of armor he has.
and also, including the bonuses (like 5 (+5) or 5 (-2)).
Anyone can help? And also, JASS is okay because here i want to learn.
 
Level 4
Joined
Jul 26, 2016
Messages
88
1. Create a copy of the unit with max life.
2. Set the units max life to a real (for example x) variable.
3. Damage the unit for 100 chaos damage (only works if you haven't touched armor type/damage type interactions in gameplay constants)
4. Do real y = real x - current life of the copied unit
5. now check : 100 * (0.94^z) = real y (note, if you changed the amount of damage each armor point reduces, you wont have 0.94 as part of your formula, but rather 1-damage reduction instead)
6. formula would be 0.94^z = y/100 or (okay, my lesson on logarithms was a while ago, so forgive me if im wrong here)

z = log[base 0.94](y/100)

z is your units armor

edit: i forgot that there might not be a log function in GUI. The one solution i can think about right now is, after getting the y variable, use a JASS loop:

set an integer counter I to 0, set a real R to 100.00, every iteration of the loop, check if R == y, if yes, exit the loop, if not, do set R = R*0.94 and I = I + 1. That way your I represents the armor value, and once you reach the n-th point of armor where the predicted damage R is equal to actual damage taken y, the loop exits and you have found your armor value (I).

edit; wietlol is correct. Just damage the original unit and do calculations from there, though you have to be careful you don't accidentally kill your unit and that the stats go back to where they were after calculation
 
Last edited:

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,191
5. now check : 100 * (0.94^z) = real y (note, if you changed the amount of damage each armor point reduces, you wont have 0.94 as part of your formula, but rather 1-damage reduction instead)
6. formula would be 0.94^z = y/100 or (okay, my lesson on logarithms was a while ago, so forgive me if im wrong here)
Uh... WHAT?!

Blizzard said:
Damage Reduction or Increases for Armor
For positive Armor, damage reduction =((armor)*0.06)/(1+0.06*(armor))
For negative Armor, it is damage increase = 2-0.94^(-armor) since you take more damage for negative armor scores.
Only exponential is for negative armor. Positive armor can be computed without log, but negative armor needs a log. Negative armor seems to cap at 100 or some amount of damage increase (I forget which).
 
Level 4
Joined
Apr 28, 2016
Messages
33
Only exponential is for negative armor. Positive armor can be computed without log, but negative armor needs a log. Negative armor seems to cap at 100 or some amount of damage increase (I forget which).

So when the armor value is positive, just use 0.06. I get it!

Now i have a new problem here. Because of the trigger damage the unit with 100 chaos damage, when the unit have life below 100, it kills it! I trigger it like this:

  • Defense System
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set Temp_Unit_Group = (Units in (Playable map area))
      • Unit Group - Pick every unit in Temp_Unit_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Defense Points for (Picked unit)) Greater than 0
            • Then - Actions
              • Set defenseTempReal = (Life of (Picked unit))
              • Set Temp_Point = (Position of (Picked unit))
              • Unit - Create 1 dummy for (Owner of (Picked unit)) at Temp_Point facing Default building facing degrees
              • Custom script: call RemoveLocation (udg_Temp_Point)
              • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
              • Unit - Cause (Last created unit) to damage (Picked unit), dealing 100.00 damage of attack type Chaos and damage type Normal
              • Set defenseDamage = (defenseTempReal - (Life of (Picked unit)))
              • Unit - Set life of (Picked unit) to defenseTempReal
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • defenseDamage Greater than 100.00
                • Then - Actions
                  • Unit - Set life of (Picked unit) to defenseTempReal
                • Else - Actions
                  • Set defenseArmor = ((100.00 - defenseDamage) / (defenseDamage x 0.06))
                  • Unit - Set life of (Picked unit) to defenseTempReal
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • defenseArmor Greater than 0.50
                    • Then - Actions
                      • Unit - Set level of Defense Points for (Picked unit) to (Integer((defenseArmor + 0.50)))
                    • Else - Actions
      • Custom script: call DestroyGroup (udg_Temp_Unit_Group)
I use Event - Time Periodic to check every unit armor value. So when the armor value chance, it chance the level of an ability, but it kills the unit when it has life below 100. What is the solution?
 
Level 4
Joined
Jul 26, 2016
Messages
88
@crabas_sakti I apologize crabas, I gave you the wrong damage reduction formula.

I thought damage reduction was (1-armorreduction)^armor

If we follow @Dr Super Good 's damage reduction formula, we would have

For positive Armor, damage reduction =((armor)*0.06)/(1+0.06*(armor))

So, if we deal 100 chaos damage to our unit, and it takes y damage, we have

y = 100 * (1 - (z * k)/(1+ (z * k)))

where z is your armor and k is 0.06, the reduction constant

y/100 = 1 - ((zk)/1+zk)

y/100 - 1 = - 1/((1/zk) + 1)

((y/100) - 1) ((1/zk) + 1) = - 1

(1/zk) ((y/100) - 1) = - y/100

1/z = k((- y/100)/(y/100 - 1))

z = 1 / (k((- y/100)/(y/100 - 1)))

Which would be your armor. If you were doing the triggers as I told you beforehand, erase them, here's the fresh (and hopefully more correct) way:

Event - whatever event you want to check the armor for


Actions

Set unitCheckUnit = the unit you want to check armor for

Set realCurrLife = current life of CheckUnit
save the current life of the checked unit

Set life of CheckUnit to (Life of CheckUnit + 100)
add some hp to the checked unit so it doesn't die

Set realy = current life of CheckUnit

Cause (some dummy unit) to damage CheckUnit for 100 chaos damage

Set realy = realy - current life of CheckUnit
check the damage really taken by the unit after we have dealt it 100 chaos damage
(y will be some value between 0 and 100)
ONLY WORKS WITH POSITIVE ARMOR VALUES

Set realArmor = 1 / ( ( 0.06 * ( - realy / 100 ) ) / ( ( realy / 100 ) - 1 ) )
We calculate the armor using the formula

Set life of CheckUnit to realCurrLife
Give our unit it's original life value back


Again, many apologies for my first false statement. Confused the armor system with another game I play.

This should be correct.

Convert realArmor to an integer if needed, retrieve your armor value.

Cheers!


PS; this should also only work for positive armor values.
 
Level 4
Joined
Apr 28, 2016
Messages
33
I have tried it and it's didn't work, because the armor will detected as 0 (life+100 and damage 100). I try to chance damage to 5, it still work but only when the unit have life greater than or equal to 5. If it's life below it, it will die soon. But thanks for helping me, i appreciate every of you guys!
 
Level 4
Joined
Jul 26, 2016
Messages
88
@crabas_sakti

full


Here, someone made one based on the explanations above and it worked for them. I hope this might help. Note that they use the constant 0.01 instead of 0.06, since they changed the damage reduction constant to that in their game files.

The trigger are from a french world editor but theyre mostly in english anyways.

Guerrier refers to a specific unit.

Vie means Life.

If I can offer any further help let me know.
 
Status
Not open for further replies.
Top