I’m developing an open-ended strategy game. I am using the following formula to calculate damage:
$rand = rand($a, $b) + $c;
$damage = $rand * sqrt(($d / 20) * $c));
$a, $b, $c, and $d are all values that can be modified by the user over the course of play, either by buying a better item ($a and $b), investing in the item ($c), or investing in their character $d.
What I want to do now is add a bit of randomness to the outcome of the equation. However, because the game is open ended:
- a static value would become unnoticeable/negligible over time.
- a percentage based value would allow for too much noise over time.
So, I want to add a random value that is small at first, grows with increased input, but has diminishing returns. I’m sure I need some kind of logarithmic formula, but I’m not sure how to go about it!
If you calculate your original damage as D and R is random in [-1,1], you have lots of options. You didn’t want static:
or percentage
Something in between might be
Any function of D between constant and linear will give you a different balance.