That looks cool JahwsUF!
Would you mind explaining us all the Math. functions?
Also great info Ministry!
To compute the natural logarithm of something:
Math.log(x)It's the inverse of exp(x). Using the following instead computes log base 10 of x:
Math.log10(x)This function grows really slowly. log10(10) = 1, log(100) = 2, log(1000) = 3. (The number of powers of ten that make up x's value.)
The last special math function used above raises x to the power of y:
Math.pow(x, y)I hear that in older versions, you used to be able to write "x ** y" in place of this. So, Math.pow(5, 2) = 25.
--------
In context of the formula above, the design is such that when attack and defense are perfectly matched, damage dealt grows at a rate of x * log x - it grows slightly faster than the attack value itself, so you'll always feel like your character is growing and dealing more damage as long as you aren't attempting a majorly low-level run. (Think variable attack, fixed defense for this part.) This is modified by the other log portion, which multiplies this "base" attack value according to the ratio of involved attack and defense.
Stronger attack values compared to defense will boost damage reasonably, while weaker attack values will progressively weaken damage without zeroing it out except for the most impossibly mismatched of cases. Defense thus serves to scale damage while not neutering it. Enemy damage output stays relevant for longer, though the growth rate of damage allows more rapid overpowering of old enemies.
Some rough figures are below. Note that in these figures below, it's best to think of the implications as if attack is fixed but defense is changing, as the "base damage" is solely based on the attack value - that atk * log10(atk) portion.
atk / def = 1 => exact base damage
atk / def = 3 => double base damage
atk / def = 7 => triple base damage
atk / def = 0.4142 => half base damage
atk / def = 0.26 => one-third base damage
atk = 0 would be required to do literally no damage except for extreme rounding effects.