- Joined
- Jul 3, 2006
- Messages
- 102
I am trying to calculate damage before armor reductions and have created this simple function:
For positive armor, it seems to work correctly. For negative armor however, I am getting very weird results:
-2 armor: hand calculation = -0.131, function = 0.116
-5 armor: hand calculation = -0.362, function = 0.266
Is there a known issue with Pow and negative exponents?
Edit: never mind, fixed my formula after looking a little bit more online and it matches now.
JASS:
function getArmorReductionPerc takes real armor returns real
local real c = 0.06
if armor >= 0 then
return (c * armor) / (c * armor + 1)
else
if armor < -20 then
set armor = -20
endif
return -1 + Pow(1 - c, -armor)
endif
endfunction
For positive armor, it seems to work correctly. For negative armor however, I am getting very weird results:
-2 armor: hand calculation = -0.131, function = 0.116
-5 armor: hand calculation = -0.362, function = 0.266
Is there a known issue with Pow and negative exponents?
Edit: never mind, fixed my formula after looking a little bit more online and it matches now.
Last edited:
