Skip to main content
4 of 4
edited body
Kyy13
  • 760
  • 3
  • 10

You essentially want your crit to scale from 0% to 100% with diminishing returns. Here is a formula that is 0% at luck=0 and approaches 100% as luck goes to infinity.

f = 2.71; // you can mess with this factor to change how quickly it diminishes
crit = Math.random() > Math.pow(f, -luck); // assuming random is in the range [0.0, 1.0]

Then use a multiplier if there was a crit

mult = 2; // set for a multiplier of 2

Then calculate the base power of the attack. I just set it to strength + 10

base_power = strength + 10;

Then just use the multiplier if crit was true

damage = base_power * (crit ? mult : 1);

Let me know if you need something different, and I can update my answer.

Kyy13
  • 760
  • 3
  • 10