HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

ArmorUtils

05-08-2009, 08:12 PM#1
Rising_Dusk
ArmorUtils Library

Background:
This is a library that allows calculation of a unit's armor, it's full damage (before armor reduction), and the reduced damage (after armor reduction). Someone reminded me recently that using Daelin's old system was a pain to use, so I decided to submit this. Daelin's system also didn't account properly for that gameplay constant 'Armor Damage Reduction Multiplier', but this script does. After making my code portable, writing some documentation, and developing a testmap, here it is!

Requirements:Requirements (Optional):Credits:Code:
Expand Library:

Function List:
This library gives the following armor and damage manipulating functions.
  • function GetUnitArmor takes unit u returns real
  • function GetReducedDamage takes real baseDamage, real armor returns real
  • function GetFullDamage takes real damage, real armor returns real
05-08-2009, 08:17 PM#2
Troll-Brain
GetUnitArmor shouldn't returns an integer instead of a real ?
05-08-2009, 08:18 PM#3
Rising_Dusk
Heroes can have non-integer armor values. They display an integer, but for calculations they use the actual real value.
05-08-2009, 08:33 PM#4
Troll-Brain
Quote:
Originally Posted by Rising_Dusk
Heroes can have non-integer armor values. They display an integer, but for calculations they use the actual real value.
ok, i know reals are float, however does the game round the real like 3 numbers after the digit ?

For example you get 1.5236 with your function GetUnitArmor(), does it really takes 1.5236 or 1.524 when the unit receive damages ?
Maybe it's irrelevant in the result, just a thought.
05-08-2009, 08:42 PM#5
Rising_Dusk
Quote:
Originally Posted by Troll-Brain
For example you get 1.5236 with your function GetUnitArmor(), does it really takes 1.5236 or 1.524 when the unit receive damages ?
Maybe it's irrelevant in the result, just a thought.
I haven't actually verified this, I know it takes at least 3 digits, although I suspect that it wouldn't round at all. You can easily test it with the demo map in the first post.
05-08-2009, 08:53 PM#6
Troll-Brain
Quote:
Originally Posted by Rising_Dusk
I haven't actually verified this, I know it takes at least 3 digits, although I suspect that it wouldn't round at all. You can easily test it with the demo map in the first post.
You have to, because if it round up you should edit your functions :p
05-08-2009, 09:10 PM#7
Rising_Dusk
I have never heard of it rounding at all, so I'm not worried. I have dinner and a movie to go to, so test it yourself if you care. :p
05-08-2009, 09:14 PM#8
Mr.Malte
It doesn't round up, but in text messages it does only display 3 digits after the comma.
05-08-2009, 09:16 PM#9
Troll-Brain
Quote:
Originally Posted by Mr.Malte
It doesn't round up, but in text messages it does only display 3 digits after the comma.
And Blizzard invented R2SW.

@Rising_Dusk : I will test it myself later, good evening.
05-09-2009, 07:35 AM#10
wraithseeker
Thank god my bugging made you post this, next up is hero selection system :)
05-09-2009, 10:33 AM#11
Deaod
theres no way to modify the damage increase when a units armor is less than 0. Its hardcoded to 0.06, and hardcapped at seventy something percent damage increase, iirc.
05-09-2009, 10:53 AM#12
Mr.Malte
You could use Vex's Logartihm to detect armor below 0.
05-09-2009, 11:35 AM#13
Troll-Brain
I've tested, and sometimes the actual damage is exactly the same as the calculated damage and sometimes not, but the imprecision is for the eight number under the digit, so it doesn't really matter (at all).
05-09-2009, 12:20 PM#14
Litany
You should probably include a note that changes to Chaos Damage in Gameplay Constants will break this.
05-09-2009, 07:13 PM#15
Rising_Dusk
Did I not? I thought I did in that massive documentation. Huh, guess I didn't. Thanks for bringing it to my attention.
Quote:
Originally Posted by Deaod
theres no way to modify the damage increase when a units armor is less than 0. Its hardcoded to 0.06, and hardcapped at seventy something percent damage increase, iirc.
Really? Is this verified? If so, I'll update.