Numbers and formulas
I'm sure almost all of you have wondered at one time how to deal with numbers. The most basic is damage, health, defense. Rewards for completing quests. Item power. Even player skills in a baseball game. Experience curve.

These numbers can either make or break the game. Too high and they become too powerful. Other items won't matter. Too low and they're worthless. Where is the right balance? You can experiment, but without a graphing tool and a lot of beta testing, it becomes much more complicated. That's where knowing how to use math becomes useful.


Uh oh, a multi part article
To keep this from getting too heavy, I'm going to split it into (at least) two parts:
Part 1: Easy
Part 2: Not so easy

This part should deal with the simple stuff most of you high schoolers should understand easily. The next part will still hover around high school math, but it'll be the type that gives people nightmares (which is why I put it somewhere else)


Know your scale
One thing you should take note of is the scale. What are you doing? Just normal weapons? Magic weapons? Guns, lasers? If you have a formula for strength, is it designed for the strength of the weakest human to the strongest one? Or is it designed so you can have the strength of an ant to the strength of a mountain-lifting titan?

This is important for consistency. How many times have you seen a RPG where the first weapon is a sword, the second level has a shotgun, then the third level has a pike? If you don't care about that kind of thing, you can go ahead and skip to the next step, but for some games it really matters

Linear or non-linear?
Take that earlier strength example.

If you can have a scale from 1 to 10 on how much strength a human has. A super strong human (10 STR) does 10 damage, a really weak child (1 STR) does 1 damage. It becomes linear, like this...
Image

Now, let's put humans at a range from 4-7 strength. 10 is a killer robot. 1 is a fly. Because the range is so huge, you need to make it non-linear to suit all the odds, like this...
Image

As you can see from the image, the human strength is insignificant compared to everything above that. And the stuff below 5 STR is so squashed that you can't even see them. That's the problem with picking a huge scale. That's why you should keep to as small a scale as you can. If possible, you want to keep your stuff linear. It's simpler for balance and you don't have to read the complicated Part 2 of this article


Don't start with little details
First, let's start with what you should not do.

I've worked with a few strategy games and the first thing most of them do is write down the stats for the units. I was guilty of that. The problem there is that you have nothing to compare them to. Unless you get them right the first time, you'll be re-doing these later on. Another similar mistake is to write down formulas. This is also something you'll end up redoing.

But Muz, if I don't write numbers I have nothing to compare them to! That's why you start by placing them in a comment like form. Before you do anything, write down what they do, not what they are.

Start with the big picture, then you narrow it down. Keep it in words if possible.. you want to tweak it as late as possible, once you get the big picture.

Poor draft design:
Grunt
20 HP, 10 damage, 3 strength, 2 agility

Better draft:
Grunt
low HP, low damage, medium strength, medium-low agility.

Later on, you may decide that low HP = 17 hp. If you put it in a word processor, you can just find and replace. Use the same concept with formulas.

Not so good draft formula:
Damage = Strength*2+Size-Armor-Defense

Somewhat better draft formula:
Damage is affected heavily by strength, slightly affected by size. Armor will lower damage and so will defense.

My draft formula style:
Damage
+++ Strength
+ Size
- Armor
- Defense


The second part is a lot wordier, which is not good too. So, I put it in symbols. +++ means that it's affected heavily. Heavily might not mean double at all, it could mean 10 times more. Or just 1.5 times.

Another problem with prewritten formulas is that Strength may be from 1 to 10 or 1 to 1000 and you could change this in the future. A preset number would mean you have to change ALL of it to the new scale, and it means a hard to detect bug if you left one out.


Creating a formula
This part will only deal with numbers in linear form. [Linear means anything that goes up constantly; in a line form.] Unless you want to make a really complicated game, you should be fine with only basic arithmetic.

Addition and subtraction
Stick to these if possible.
If the variable makes it increase, add.
If it goes down, subtract.

These have the smallest effect, which is a good thing. But you'll almost always need to multiply or divide them by a constant.

Multiplication and division
These are much stronger. Use them for two reasons:
1. To relate two variables directly to each other, e.g.
2. Multiply or divide by a constant to make a variable have more or less effect.

Linear equation
Remember that equation for a line you learned at school?
y = m*x + c

That helps a lot. Y is the result. X is the variable.
c is the offset. This means how high it is when x is 0. Say, you have a LVL 0 guy, with no skill. c is how much you have him start off with.
m is the multiplier to x. The higher m is, the more effect x will have. If you set m as negative, then if x is higher, y becomes lower.

So, if you have..
Strength = 2*Level + 10
This means that at Level 0, you start with 10 Strength. Every level he goes up, your strength increases by 2.

Dodging = -3*Armor+20
This means that Dodging skill becomes lower the heavier the armor is. With 0 Armor, it starts off at 20, then it goes down by 3 points for every point of armor you have.


Example formulas
Let's say you have some stats: Strength, Agility, Size, etc. You want to determine attack and defense from these.

Attack = Strength + Agility
This is a simple formula, meaning that if strength or agility are higher, attack is more powerful.

Attack = Strength*3 + Agility
This means that strength matters 3 times more than agility does, so a small increase in strength has a bigger effect.

Attack = Strength*Size + Agility
This means that strength is related to size. If both are high, then it becomes much higher. If both are low, then it doesn't affect much.
I'd suggest you avoid doing this, unless you have a good reason to.
If Size = 0, then Strength becomes worthless. You might mean that Size 0 is 'average sized', but it becomes 0!
An even nastier thing is if you divide it. Never divide by 0!

Attack = Strength*(0.5*Size + 3) + Agility
This uses the linear equation mentioned before.
See.. if Size is 0, Strength becomes Strength*3.
(0.5*Size + 3) is only 0 if Size = -6. That way, if Size 0 is average, you'll be fine.


What should the numbers be?
Find the results you want first, then calculate the maximum, minimum and average you want.

Say, if you have an enemy at 100 health.
If you want the player to beat him in 4 hits, make the average damage as 25 (100/4).
If you never want the player to beat him in less than 2 hits, you should aim for maximum to be 99 damage.
It applies similarly to the minimum.

There's a small problem to this approach: You get only a few points. You don't see where it'll usually end up, just where it would normally be. I'll go into more detail for it in Part 2, but for now, you can see the range you'll get.


Keep it simple!!
A final word on this. Just because you're better at doing it now, it doesn't mean you should make it tough. Keep it as simple as you can! Get rid of any variables you don't need. As you can see from the examples above, an extra variable makes things much more complicated. It's easy to make mistakes when you're juggling many variables in your head.