• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[JASS] Pow with negative exponent

Level 6
Joined
Jul 3, 2006
Messages
102
I am trying to calculate damage before armor reductions and have created this simple function:
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:
for negetive armor, its hardcoded as
JASS:
negative_armor[1] = -0.06
negative_armor[2] = -0.1164
negative_armor[3] = -0.16941
negative_armor[4] = -0.21925
negative_armor[5] = -0.26609
negative_armor[6] = -0.31013
negative_armor[7] = -0.35152
negative_armor[8] = -0.39043
negative_armor[9] = -0.427
negative_armor[10] = -0.46138
negative_armor[11] = -0.4937
negative_armor[12] = -0.52407
negative_armor[13] = -0.55263
negative_armor[14] = -0.57947
negative_armor[15] = -0.6047
negative_armor[16] = -0.62842
negative_armor[17] = -0.65072
negative_armor[18] = -0.67167
negative_armor[19] = -0.69137
negative_armor[20] = -0.70989

// capped at -20
 
Back
Top