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

[Spell] How to create a spell with ratio armor

Status
Not open for further replies.
Level 4
Joined
Jul 26, 2016
Messages
88
You have to be able to detect the armor of the unit somehow, and there's no quick'n'easy way to do that. You could damage it for a certain amount of damage and calculate its armor based on how much damage it took.

----------

Tu peux pas le faire de maniere facile. Y'a pas de fonctions de base pour ca, faut que tu fasses un systeme ou tu infliges des degats fixes a ton unite et tu calcule l'armure basee sur la difference.
 
Level 3
Joined
Jul 27, 2016
Messages
33
OK, then I make what you have say down here, after I do cast the spell?

@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
Jul 26, 2016
Messages
88
OK, then I make what you have say down here, after I do cast the spell?

Yep. Just put your unit casting the spell as the event, run the actions I listed, then the variable realArmor holds your armor, which you can do whatever you want with.

(though I did not test it since I do not have access to the world editor right now, but this should technically work, if you have any issues with that do tell)

Also, if you plan having negative armor values in your game, (through debuffs for example) just this trigger won't suffice.

Cheers!
 
Level 3
Joined
Jul 27, 2016
Messages
33
It works, great thank you. I made my trigger like that. I skip "Set unitCheckUnit = the unites you want to check armor for" because I already have him on another trigger which names the unity. (The damages was just for test :) )
 
Last edited:
Level 4
Joined
Jul 26, 2016
Messages
88
It works, great thank you. I made my trigger like that. I skip "Set unitCheckUnit = the unites you want to check armor for" because I already have him on another trigger which names the unity. (The damages was just for test :) )

Ok, great. Although, from what I can see, your calculations do not calculate armor, but rather some multiple of it, since your constant is 0.01 and intended is 0.06. But regardless, good job!
 
Last edited:
Status
Not open for further replies.
Top