Going back to the Pokemon Calculation, the modifier adds in a load of other effects to change the damage output of an attack. They include things like effects due to weather, how many targets a move will hit, attack bonuses, critical hits and the random element we talked about in the last section. If a particular modifier is not in effect, it has a value of 1 so it doesn't change the overall calculation.
In the example from the Damage Calculation tutorial, we simply moved the random expression to the Damage Modifier function, instead of being in the main calculation.
In this tutorial, we're going to expand this function to work with an array. It can then be used for both the player and the opponent's damage modifier calculations thanks to a parameter. The array will store the stats for the two combatants as well as any modifiers the system needs to use – in this example there will be two in use: a Standard modifier and a Critical Chance. In the array, the standard modifier value is the actual value used in the modifier calculation, whereas the Critical Chance value is used to store the number used in the random number check to trigger a critical hit.
To go with the Critical Hit check, there is a CriticalHit Boolean to track if a critical hit has been triggered and a global constant number CRITMODIFIER to store the modifier value for the boost in critical hit damage.