Continuing on from part 1, I will talk about about what are known in gaming as ‘modifiers’ . They are known by various names like weapon modifiers, armour bonuses, to-hit bonuses, weight penalty, and so on.

Game mechanics, under the hood of most role playing games, involves around defining the ‘final value’ of some object or action. This ‘final value’ is often based on a ‘base value’ which is then translated by a ‘modifier’. These may seem like useless abstractions, but in fact help reduce the complexity of the development of the game, and make it easier to make changes later. All very important when you are a team of one.

So, in picture form:

This is a little vague, but some examples should clarify things…

### Base Value

The base value is a numerical quantity (usually an integer) for something. Things like how much damage a sword does, or a character’s agility, using the examples above. The base value can be a fixed value (like agility) or a randomly generated value (weapon damage can randomly vary between a range of values e.g swords can inflict 1-6 points damage). There are more complex scenarios on how the modifier can affect the base value (like affecting the minimum damage only, or the addition of extra effects like adding poisoning to a sword attack), but I will ignore those for now.

### Modifier

The modifier is an offset value which is applied to the base value, with some sort of mathematical operator (addition ,multiplication, logarithmic, and so on). I will stick to addition for now, because I have a formula for modifier which works well enough for now. In future, the mathematical operators can be expanded to anything required (like multiplication, or go crazy with polynomials).

For now, I have decided on using a single type of equation to create modifiers which are added to the base value. Dredging up long forgotten math lectures from my hindbrain, I am going with what is known as a hyperbolic function ( I started with a hyperbolic sinh function, and took it from there).

I picked this because it an ‘S’ (sigmoid) shaped curve, which means than for most modifiers, only very low or high values make a real difference to the modifier. So using the effect of strength on sword damage as an example, only very high strength will make a **big** difference to damage, with most values only adding modest benefits. Similarly very low strength significantly reduces damage, as the modifier is negative.

Here is the modifier formula, after a nifty WordPress plugin rendered it for me.

where:

is a value of an attribute like agility or strength (between 1 and 20)**A**and**c1, c2, offset,**are ‘translation’ factors which move and squeeze the curve around to the values I want. Ignore them for now, unless you are into that sort of thing.**scal****e**

This formula gives a real valued result, which I round up and down to an integer for convenience.

#### An Example – The Effect of Strength on Weapon Damage

Using the formula with values: * c1*=1.5,

*=2.2,*

**c2***= 1 to 20,*

**A***=6, and*

**offset***=5*

**scale**Strength | Modifier Exact Value | Weapon Damage Modifier |
---|---|---|

1 | -1.53 | -2 |

2 | -1.16 | -1 |

3 | -0.82 | -1 |

4 | -0.52 | -1 |

5 | -0.25 | 0 |

6 | 0 | 0 |

7 | 0.2 | 0 |

8 | 0.44 | 0 |

9 | 0.65 | 0 |

10 | 0.85 | 0 |

11 | 1.04 | 1 |

12 | 1.23 | 1 |

13 | 1.43 | 1 |

14 | 1.62 | 1 |

15 | 1.83 | 1 |

16 | 2.04 | 2 |

17 | 2.26 | 2 |

18 | 2.49 | 2 |

19 | 2.74 | 2 |

20 | 3 | 3 |

From the table above, you can see that for most strength values, the effect on weapon damage is modest. By adjusting the parameters, I could do things like:

- flatten the curve even more (so strength plays less of a role on weapon damage)
- increase the maximum values for extreme strength or weakness and so on
- Update this in real time (e.g a spell which reduces the effect of strength)

### What’s Next

I have enough now to knock up a demo engine with some monsters fighting it out to the death. I’ll start now.

**Update 15th April, 2014:**** **Here is a tiny game which shows the engine in action.