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

From Bulbapedia, the community-driven Pokémon encyclopedia.
Jump to navigationJump to search
m (level)
Line 120: Line 120:


Where G, A, E, and M stand for the substructures: growth, attacks, effort, and Misc. respectively.
Where G, A, E, and M stand for the substructures: growth, attacks, effort, and Misc. respectively.
<!--
Not really necessary.
For simplicity I used a table-lookup procedure to retrieve a single DWORD at a time from a specific data section, which I'll share.
Written in x86 assembly, formatted in MASM:
''pattern'' is (p modulo 24)
''section'' is 0, 1, 2, or 3 corresponding to Growth, Attacks, Effort, and Caught respectively.
<pre>
.data
GDSO_A db 0,0,0,0,0,0
GDSO_B db 1,1,2,3,2,3
GDSO_C db 2,3,1,1,3,2
GDSO_D db 3,2,3,2,1,1
.code
GetDataSectionOffset proc uses ebx pattern:DWORD,section:DWORD
mov eax,pattern
mov ecx,6
xor edx,edx
div ecx
mov ecx,eax
mov eax,section
shl eax,2
add eax,offset gdso_pbgroup
mov eax,DWORD PTR [eax]
shl cl,3 ; x8
shr eax,cl
and eax,11111111b
mov ebx,offset GDSO_A
add ebx,edx
mov edx,12
xlatb
mul edx
ret
gdso_pbgroup db 0,6,6,6 ; DS_GROWTH = 0
db 6,0,12,12 ; DS_ATTACKS = 1
db 12,12,0,18 ; DS_EFFORT = 2
db 18,18,18,0 ; DS_CAUGHT = 3
GetDataSectionOffset endp
</pre>
-->


==Encryption==
==Encryption==
Line 167: Line 126:


=Notes=
=Notes=
==PP bonuses==
The PP bonuses byte stores the number of [[Item#PP Up|PP Up]]s 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==


[[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.
[[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.


==PP bonuses==
==Level caught==


The PP bonuses byte stores the number of [[Item#PP Up|PP Up]]s used for each attack. Two bits per attack, starting with the first attack from the least significant bits upward to the last attack.
Level caught is a 7-bit value, not an 8-bit value like the one found in the [[Pok%C3%A9mon_data_structure_in_the_GBA|main pokemon 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==
==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 6-3 store the [[Poké Ball]] type that the Pokémon was caught in.
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.


==DVs==
==DVs==

Revision as of 20:37, 16 February 2005

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
Species word
Item held word
Experience dword
PP bonuses byte
Happiness byte
??? word
Attacks
Attack 1 word
Attack 2 word
Attack 3 word
Attack 4 word
PP 1 byte
PP 2 byte
PP 3 byte
PP 4 byte
Effort
HP EV byte
Attack EV byte
Defense EV byte
Speed EV byte
Sp. Attack EV byte
Sp. Defense EV byte
Coolness byte
Beauty byte
Cuteness byte
Smartness byte
Toughness byte
Fill byte
Misc.
Pokérus status byte
Location caught byte
Level signed byte
Poké Ball byte
Trainer gender
DVs dword
Ribbons dword

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, then XORing the resulting value with the data (one long value at a time). The same process is used to decrypt the encrypted data. 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 pokemon 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.

DVs

DVs 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.