Pokémon data substructures (Generation III): Difference between revisions

From Bulbapedia, the community-driven Pokémon encyclopedia.
Jump to navigationJump to search
Line 145: Line 145:
===Game of origin===
===Game of origin===


Since the most significant bit reported in level caught and bits 0-2 of Pokeball/Trainer gender are not needed to store that data, they instead together report the game which the Pokémon came from:
Since the most significant bit reported in level caught and bits 0-2 of Poké Ball/Trainer gender are not needed to store that data, they instead together report the game which the Pokémon came from:


XXXXXYYY: is Poké Ball/Trainer gender.
XXXXXYYY: is Poké Ball/Trainer gender.

Revision as of 21:46, 14 August 2012

This is the list of Pokémon data substructures in the Generation III Game Boy Advance games, Pokémon Ruby, Sapphire, FireRed, LeafGreen, and Emerald.

Format

A Pokémon's data is slightly more complex than the rest of the structure. It is stored as four substructures, each 12 bytes in length:

Growth
size offset
Species word 0
Item held word 2
Experience dword 4
PP bonuses byte 8
Friendship byte 9
??? word 10
Attacks
size offset
Attack 1 word 0
Attack 2 word 2
Attack 3 word 4
Attack 4 word 6
PP 1 byte 8
PP 2 byte 9
PP 3 byte 10
PP 4 byte 11
Effort
size offset
HP EV byte 0
Attack EV byte 1
Defense EV byte 2
Speed EV byte 3
Sp. Attack EV byte 4
Sp. Defense EV byte 5
Coolness byte 6
Beauty byte 7
Cuteness byte 8
Smartness byte 9
Toughness byte 10
Feel byte 11
Misc.
size offset
Pokérus status byte 0
Location caught byte 1
Level caught signed byte 2
Poké Ball
Trainer gender
byte 3
IVs dword 4
Ribbons dword 8

Order

The order of the structures is determined by the personality value of the Pokémon. The order is determined by the value modulo 24:

00. GAEM 06. AGEM 12. EGAM 18. MGAE
01. GAME 07. AGME 13. EGMA 19. MGEA
02. GEAM 08. AEGM 14. EAGM 20. MAGE
03. GEMA 09. AEMG 15. EAMG 21. MAEG
04. GMAE 10. AMGE 16. EMGA 22. MEGA
05. GMEA 11. AMEG 17. EMAG 23. MEAG

Where G, A, E, and M stand for the substructures: growth, attacks, effort, and Misc. respectively.

Encryption

The entire data structure is encrypted by XORing the entire Trainer ID with the personality value, after that the player will get a 4 bytes value, then XORing the resulting value with the data (one long value at a time, p/s: one long value here refer to 4 bytes). The same process is used to decrypt the encrypted data, for detail check on use of xor. The correct checksum is found by summing the original values, not the encrypted values.

Notes

PP bonuses

The PP bonuses byte stores the number of PP Ups used for each attack. Two bits per attack, starting with the first attack from the least significant bits upward to the last attack.

Pokérus status

Pokérus status is stored in a single byte. The lower 4 bits represents the number of units of time left until the virus wears away. If any bit in the upper 4 bits is set, the Pokémon is immune to Pokérus, indicated a small black dot appears on the Pokémon's status screen. Both values are completely random when caught, leading to the fact that not all Pokémon contract the virus for the same amount of time and some are able to catch it again.

Level caught

Level caught is a 7-bit value, not an 8-bit value like the one found in the main Pokémon structure. Therefore, it can be treated as a signed value, but when it is reported only the magnitude is included, limiting it to the range of 1-127. This range does not include zero because setting this value to zero causes the game to produce the "Level 5 (egg)" message instead of the regular "Level # (met)" message.

Poké Ball / Trainer gender

The gender of the Trainer that caught a Pokémon is stored in the data section, and is determined by the most significant bit of this byte. Bits 3-6 store the Poké Ball type that the Pokémon was caught in.

Game of origin

Since the most significant bit reported in level caught and bits 0-2 of Poké Ball/Trainer gender are not needed to store that data, they instead together report the game which the Pokémon came from:

XXXXXYYY: is Poké Ball/Trainer gender.

ZTTTTTTT: is Level.

then YYYZ will record the game in which the Pokémon originated.

convert YYYZ to dec and compare:

IVs

IVs are stored pretty logically. Starting from the least significant bit, each stat from HP to Special Defense takes up 5 bits, leaving the uppermost 2 bits zeroed.

See also


Data structure in the Pokémon games
Generation I Pokémon speciesPokémonPoké MartCharacter encodingSave
Generation II Pokémon speciesPokémonTrainerCharacter encoding (Korean) • Save
Generation III Pokémon species (Pokémon evolutionPokédexType chart)
Pokémon (substructures) • MoveContestContest moveItem
Trainer TowerBattle FrontierCharacter encodingSave
Generation IV Pokémon species (Pokémon evolutionLearnsets)
PokémonSaveCharacter encoding
Generation V-present Character encoding
TCG GB and GB2 Character encoding


Project Games logo.png This data structure article is part of Project Games, a Bulbapedia project that aims to write comprehensive articles on the Pokémon games.