www.pojo.com
  

Grimer Eyes

5.4.00 

Recent investigation into the Z80 code that runs the Pokemon GameBoy game has revealed a lot of useful information.  Most notably is the main formula that runs the combat engine of Pokemon Red/Blue/Yellow and Pokemon Stadium.  As in all games, Damage from an attack is a calculation based on stats, and frequently including a random variability.  Pokemon is no different.  Extracted from the Z80 code, this is the formula to determine how much damage your Pokemon does:

[[[[[[2*A/5 +2] *B*C/D] /50] +2] *X*Y/10] *Z/255]

A = Attacker’s Level

B = Attacker’s Attack or Special (Depending on type of attack)

C = Strength of Attack

D = Defender’s Defense or Special (Depending on type of attack)

X = 1.5 if type of attack matches attacker’s type, otherwise X = 1

Y = 20 if defender is weak to attack
       5 if defender is resistant to attack
       0 if attack has no effect on defender (i.e. normal attack on ghost)
       10 in all other cases

Z = Random number from 217 to 255

Important note about the formula, sections enclosed in []’s must have normal mathmatetical rules run within them, but the final value must be rounded down to the closest integer.

So:  [2 * 2 / 5 + 2] becomes [2.8] which then becomes 2 before you can proceed with the rest of the formula.

A full example:

My Level 2 Rattata with an attack of 12, uses Tackle (Strength 35) against a Pidgey (Defense of 15).  The Random number for Z was 223...

[[[[[[2 * 2 / 5 + 2] * 12 * 35 / 15] / 50] + 2] * 1 * 10 / 10] * 223 / 255]

[[[[[[2.8] * 12 * 35 / 15] / 50] + 2] * 1 * 10 / 10] * 223 / 255]

[[[[[2 * 12 * 35 / 15] / 50] + 2] * 1 * 10 / 10] * 223 / 255]

[[[[[56] / 50] + 2] * 1 * 10 / 10] * 223 / 255]

[[[[1.12] + 2] * 1 * 10 / 10] * 223 / 255]

[[[1 + 2] * 1 * 10 / 10] * 223 / 255]

[[3 * 1 * 10 / 10] * 223 / 255]

[[3] * 223 / 255]

[3 * 223 / 255]

[2.6235294118]

2

The final result is my Tackle did 2 points of damage.  Well, what do you expect from a Level 2 Rattata?  ;)

- Bret Larwick

www.pojo.com