View Single Post
Old January 29th, 2013 (04:45 PM).
FBI agent's Avatar
FBI agent
Ally to good, nightmare to you!
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Quote originally posted by Jambo51:
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:

My name forum name is FBI Agent, though you can call me FBI because it's shorter. I ran an ASM request/resource thread feel free to check that out!
Reply With Quote