Finally the post you’ve been waiting for!

**MATH!!!**

So I’m *finally* getting around to adding combat algorithms and I needed to decide a basis for how to balance the game, so that I don’t end up shooting myself in the foot when I design the primary/secondary stats, so that I don’t want to curl up and die six months down the road.

First step was to decide on an algorithm. I decided to go full-on ratios, so the damage value is going to be multiplied by a ratio of the form (2 * atk / ( atk + def ) ). This means that if attack is equal to defense, the ratio is exactly 1, so damage will be transmitted directly. Otherwise, damage is scaled based on the difference between attack and defense.

In the upper left chart, you can see this ratio in action. You’ll do roughly 2/3rds damage against something with twice as much defense, and about 20% more damage against something with 2/3rds as much. This might seem like something bad, but bear with me here.

My core rule for game balance is that I want the *average* enemy to take a set number of average-powered hits to finish. For now, I’m sticking with 3, but probably going to switch it down to 2.75 or something so that there’s some leeway for players. In the upper right chart, you can see that when you have half as much attack power, it takes 4.5 hits to kill an enemy, which is quite a bit more! But still in the ‘doable’ range.

But while that’s kind of important, it’s not that big a deal in the long term. Primarily this just tells us how long it will take us to kill tanky enemies (pretty long!) vs not so tanky enemies (not too much faster!), and that’s a good balance, but what we’re really interested is the level differentials.

And there enters the lower left chart!

That one shows how many attacks it would take an average level 20 character to kill an ‘average’ enemy of higher or lower level. You’ll notice it’s a fairly straight line but scales up rather rapidly. Not terribly unexpected nor terribly out of line. But why does it work that way?

Well, to achieve the enemy dying in 3 hits at ratio 1, on average, you set the HP value to the average damage they will take times 3. Their defense is still higher, and still mitigates damage from lower damage levls.

What does this mean? I have exactly *two* coefficients for balancing!

- The average number of hits to defeat an enemy.
- The rate at which defense scales wrt attack with level.

With these two values I will know (a) exactly how long fights will take, and (b) what the viable range for the players is. I can then make the players scale lower so that they have to use more powerful skills/items to push through what would normally be an ‘easy’ fight. I also know how far ahead they can push before the game gives them diminishing returns and forces them to grind a little for stats and/or items.

Next: Primary and secondary stats!