As I try to create the formula to calculate the damage an ability will inflict upon an enemy, I feel like Matt Damon in “Good Will Hunting”.

In my previous 3 games, I kept it pretty simple. There was some base damage modifier that was multiplied by the level of the character. Let’s take for example, the Last Resort (LR) ability, Stramadonian Fire. It does 10 points of damage per level of the user. At level 3 (when LR’s are unlocked), you’ll do 30 points of damage. At level 5, you’ll do 50. Pretty simple and straightforward. This, however, never took into account the magic and/or fire resistance of the target. It never took into account the target’s level.

This time around, I want to take many more thing into consideration. For the user, that would be:

  • Level
  • Magic attribute (still in prototype, could possibly change to something else, or possibly a composite of multiple attributes)
  • Any items/buffs that modify different parts of the calculation
  • Base damage

For the target(s), it would be:

  • Level
  • Magic/elemental spell resistance attribute (this does not exist at the moment)
  • Any items/buffs that would modify parts of the calculation (especially the aforementioned resistance attribute)

Now, one of the key things for me is to make a universal calculation, which will cut down on lots of code. For instance, let’s say the formula ends up being something like so:

STRAMADONIAN FIRE 

((Base Power * (Magic Attribute + Item and Buff Modifiers) * User Level) – ((Enemy Spell Resistance + Item and Buff Modifiers) * Enemy Level))

This is very simplistic, as I’m really just making this up on the fly for the purposes of this blog. But let’s say this was the formula to determine the damage. At this point, the “Base Power” could just be stored in the ability.json file, along with all the other applicable attributes that are needed. This really cuts down on the code I have to write, which in the end, cuts down on potential bugs.

And in the special case that a particular spell shouldn’t use this calculator, I can just override the functionality.

I imagine as development continues, I’ll iterate over this and add/remove a bunch of things. But for a starting point, I’m quite happy.

Till tomorrow…