Curve math |
Similar to my linear math post, but with damage reduction according to an exponential decay curve.
WARNING: If math angers/frustrates you, then this will REALLY piss you off...
This is the math for a weapon to reduce damage according to an exponential decay curve.
Definitions:
f(m) is damage modifier from levels.
f(p) is percentage of m which applies, as expressed by a number from 0.00 (for 0%) to 1.00 (for 100%).
f(r) is the percentage of the range of the weapon as it relates to its maximum possible range, as expressed by a number from 0.00 (for 0%)
to 1.00 (for 100%). Example: If the max range is 60, then 30 is 50% of 60 (or one half), so r = 0.5.
f(m) = damage by level * (p)
f(p) = a + b * (Power(c, (-1 * (r))))
f(r) = range formula
Notes:
a + b = 1 = 100% damage
b is the ammount of damage lost. b = 0.45 = 45% damage lost.
So, if you want the damage lost to be at 25%, b = 0.25. a + b = 1. a + 0.25 = 1. a = 1 - 0.25. Therefore, a = 0.75.
c is the steepness of the curve. c = 1 = totally flat curve at a + b. As c increases, curve becomes more steep (more like a 90 degree angle).
c = 100 seems to be just about right.
Script function definitions:
Power is the formula command for exponents. Power (A, B) means A to the power of B. Squareing something would be Power (A, 2).
Cubing would be Power (A, 3). Another text notation for this would be A^B.
iif is an if - then - else command. iif(A, B, C) = if A is true, do B, otherwise do C.
Min is take the minimum of two values. Min(A, B) = take the minimum of A or B, whichever is lower.
So, iif([%Range%] Min(90, (([%Level%] - 1) * 10) + 30), 10000, 0)
(23 + (([%Level%] - 1) * 5)) - (([%Range%] / 10) * 1.67) - iif([%Range%] > Min(90, (([%Level%] - 1) * 10) + 30), 10000, 0)
Simplified formulas:
iif([%Range%] <= Min(90, (([%Level%] - 1) * 10) + 30), (20 + (([%Level%] - 1) * 15)) - (([%Range%] / 10) * 1.67), 0)
iif([%Range%] <= Min(90, (([%Level%] - 1) * 10) + 30), (23 + (([%Level%] - 1) * 15)) - (([%Range%] / 10) * 1.67), 0)
Work:
iif([%Range%] <= Min(100, (([%Level%] - 1) * 10) + 30), (20 + (m)) , 0)
f(m) = (([%Level%] - 1) * 15) * (p)
f(p) = 0.5 + 0.5 * (Power(100, (-1 * (r))))
f(r) = [%Range%] / Min(100, (([%Level%] - 1) * 10) + 30)
Result:
iif([%Range%] <= Min(90, (([%Level%] - 1) * 10) + 30), (20 + (([%Level%] - 1) * 5) * (0.5 + 0.5 * (Power(100, (-1 * ([%Range%] / Min(90, (([%Level%] - 1) * 10) + 30))))))) , 0)
iif([%Range%] <= Min(90, (([%Level%] - 1) * 10) + 30), (23 + (([%Level%] - 1) * 5) * (0.5 + 0.5 * (Power(100, (-1 * ([%Range%] / Min(90, (([%Level%] - 1) * 10) + 30))))))) , 0)
This allows for a more organic and consistant damage dropoff accross all levels, but requires additional testing.




Re: Curve math
This is really good, you must like math! Its's good for people to like math