Turn-Based Battle - Damage Calculations

11

Index

Features on these Courses

Attached Files

The following files have been attached to this tutorial:

.c3p

tb-battledamagecalc.c3p

Download now 169.66 KB
.c3p

tb-battledamageeq.c3p

Download now 171.48 KB

Stats

4,205 visits, 7,190 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 30 Mar, 2021.
.C3P

tb-battledamageeq.c3p

Download now 171.48 KB

On the first page of this tutorial, we briefly touched on the fact that Pokemon uses a rather complex calculation to calculate the damage of a move in a given turn. The calculation takes into account a lot of factors to create a robust damage system.

Ignoring the modifier for now (we'll tackle that later) the equation can be broken down as follows:

Level is the current level of the attacking Pokemon

Power is the power level of the move the attacking Pokemon is using

A is the attack stat of the attacking Pokemon (using the physical or special attack stat value depending on the move being used)

D is the defence stat of the defending Pokemon (again, using the physical or special defence stat value depending on the move being used)

So, even before we get onto the modifier, there are four factors on top of the arbitrary numbers included in the calculation that can affect damage output. (I'm sure they're not actually arbitrary, but I am not privy to the methods behind developing this equation!) It should also be noted that A and D are both affected by in-battle moves which alter a target's stats. So, if for example, the attacker's attack stat was lowered, A would be the lowered value rather than the base value.

At this point, to recreate this, without multiple team members or moves to choose from, this can be done using the instance variables attached to our combatant objects. We will need to add new Power and Level instance variables to use in the equation.

Ultimately, it's down to you how your game handles damage and it's worth developing your own stat and damage systems that work for you. But for the sake of demonstration, we'll implement the base part of the Pokemon equation. Modifiers will come later.

First of all, with any equation you need to build into Construct, Iā€™d recommend making sure you have it written out in full somewhere so you can easily break it down and transfer it into an expression.

The above equation becomes this in expression form:

You'll notice there is a new variable in this equation ā€“ DamageModifier. This is set using a new function and sets up the project to be able to handle more complex modifiers if needed. For this example, we've just moved the random element into the modifier function.

Once you wade through the vast number of brackets at the beginning of the expression string, it's actually relatively easy to see where each bit of the equation sits in the string. And if you build up the string following the BODMAS Order of Operations (we use BODMAS here in the UK, but other mnemonics are used around the world) it's not quite so daunting to recreate the equation.

  • 0 Comments

Want to leave a comment? Login or Register an account!