View Single Post
Old January 29th, 2013 (4:45 PM).
FBI's Avatar
FBI FBI is offline
Free supporter
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 1,867
Originally Posted by Jambo51 View Post
So, last night, I worked out how type effectiveness is done in FireRed. You'll be pleased to know that it's relatively simple. Firstly, the method of storage:

[Attack type - 1 byte][Target Type - 1 Byte][Effectiveness value - 1 Byte]
This data is stored at 0x24F050.

There are several of these, kept in an array which ends with a 0xFE value. The game loops over each entry in the array, checking if the attack type matches the used attack's type, and if it does, then checks the Target Type against the 2 types of the targeted Pokémon.

If either type matches, it loads the effectiveness byte and branches off to another routine which takes care of physically making the attack super effective/not effective. The type effectiveness values are as follows:

Note, these are in hex
00 - Has No effect (Eg, Ghost on Normal)
05 - 50% effectiveness
14 - 200% Effectiveness
I don't know why they used these values, but that's what they are nonetheless. What you may gleam from these values, however, is that, unless explicitly told otherwise, the game treats all moves as normal effectiveness on any type.

If neither type matches, it jumps to the loop counter, increments it and continues checking until it hits that magical 0xFE value.

However, the way it is implemented leaves something to be desired as it is very slow (looping over several entries), and taking up more space than needed, both in terms of code and data. It's obviously wasteful in so far as it continues to check even after having already found both effectiveness values, as well as the wasteful nature of the loop in and of itself.
Related thread:
Reply With Quote