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

Clarified IV field order. I checked!
(Clarified IV field order. I checked!)
(41 intermediate revisions by 21 users not shown)
Line 1: Line 1:
=Format=
This is the list of Pokémon data substructures in the [[Generation III]] [[Game Boy Advance]] games, [[Pokémon Ruby and Sapphire Versions|Pokémon Ruby, Sapphire]], {{3v2|FireRed|LeafGreen|Emerald}}.
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:


{| align="center" style="border: 1px solid #88a; background: #f8f8ff; padding: 0.5em;" cellspacing="1"
==Format==
|-
A Pokémon's data is slightly more complex than the rest of the  [[Pokémon data structure in Generation III|encapsulating structure]]. It is stored as four distinct substructures, each 12 bytes in length. (The Notes section below explains some of these fields in greater detail.)
! colspan="3" style="text-align: center; background: #ccf;" | '''Growth'''
 
|-
{| cellspacing="3" style="border: 1px solid #88a; padding: 0.5em"
! || size || offset
|- style="background: #ccf;"
|-
! colspan="3" | Growth
| [[List of Pokémon by index number (GBA)|Species]] || word || 0
! colspan="3" | [[Move|Attacks]]
|-
! colspan="3" | [[Effort values|EVs]] & [[Contest condition|Condition]]
| [[List of items by index number|Item held]] || word || 2
! colspan="3" | Miscellaneous
|-
| [[Experience]] || dword || 4
|-
| [[Vitamin#PP Up|PP bonuses]] || byte || 8
|-
| [[Happiness]] || byte || 9
|-
| ??? || word || 10
|}
{| align="center" style="border: 1px solid #88a; background: #f8f8ff; padding: 0.5em;" cellspacing="1"
! colspan="3" style="text-align: center; background: #ccf;" | '''[[Move|Attacks]]'''
|-
! || size || offset
|-
| [[List of moves|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
|}
{| align="center" style="border: 1px solid #88a; background: #f8f8ff; padding: 0.5em;" cellspacing="1"
! colspan="3" style="text-align: center; background: #ccf;" | '''Effort'''
|-
! || size || offset
|-
| HP [[Effort values|EV]] || byte || 0
|-
| Attack EV || byte || 1
|-
| Defense EV || byte || 2
|-
|-
| Speed EV || byte || 3
! || size<br>(bytes) || offset<br>(bytes)
! || size<br>(bytes) || offset<br>(bytes)
! || size<br>(bytes) || offset<br>(bytes)
! || size<br>(bytes) || offset<br>(bytes)
|-
|-
| Sp. Attack EV || byte || 4
| [[List of Pokémon by index number (Generation III)|Species]] || 2 || 0
| [[List of moves|Move]] 1 || 2 || 0
| [[Stats#HP|HP]] EV || 1 || 0
| [[Pokérus]] status || 1 || 0
|-
|-
| Sp. Defense EV || byte || 5
| [[List of items by index number (Generation III)|Item held]] || 2 || 2
| Move 2 || 2 || 2
| [[Stats#Attack|Attack]] EV || 1 || 1
| [[List of locations by index number (Generation III)|Met location]] || 1 || 1
|-
|-
| Coolness || byte || 6
| [[Experience]] || 4 || 4
| Move 3 || 2 || 4
| [[Stats#Defense|Defense]] EV || 1 || 2
| Origins info || 2 || 2
|-
|-
| Beauty || byte || 7
| [[Vitamin#PP Up|PP bonuses]] || 1 || 8
| Move 4 || 2 || 6
| [[Stats#Speed|Speed]] EV || 1 || 3
| [[Individual values|IVs]], {{pkmn|Egg}}, and [[Ability]] || 4 || 4
|-
|-
| Cuteness || byte || 8
| [[Friendship]] || 1 || 9
|-
| {{PP}} 1 || 1 || 8
| Smartness || byte || 9
| [[Stats#Special Attack|Special Attack]] EV || 1 || 4
|-
| [[Ribbons]] and [[Obedience]] || 4 || 8
| Toughness || byte || 10
|-
| Feel || byte || 11
|}
{| align="center" style="border: 1px solid #88a; background: #f8f8ff; padding: 0.5em;" cellspacing="1"
! colspan="3" style="text-align: center; background: #ccf;" | '''Misc.'''
|-
|-
! || size || offset
| ''Unknown'' || 2 || 10
| PP 2 || 1 || 9
| [[Stats#Special Defense|Special Defense]] EV || 1 || 5
|-
|-
| [[Pokérus]] status || byte || 0
| colspan="3" rowspan="2" |
| PP 3 || 1 || 10
| {{OBP|Cool|condition}}ness || 1 || 6
|-
|-
| [[List of locations by index number (GBA)|Location]] caught || byte || 1
| PP 4 || 1 || 11
| {{OBP|Beauty|condition}} || 1 || 7
|-
|-
| Level || signed byte || 2
| colspan="6" rowspan="4" |
| {{OBP|Cute|condition}}ness || 1 || 8
|-
|-
| [[Poké Ball]]<br/>Trainer gender || byte || 3
| {{OBP|Smart|condition}}ness || 1 || 9
|-
|-
| [[DVs]] || dword || 4
| {{OBP|Tough|condition}}ness || 1 || 10
|-
|-
| [[Ribbons]] || dword || 8
| {{DL|Pokéblock|Feel}} || 1 || 11
|}
|}


==Order==
===Substructure 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:
The order of the structures is determined by the [[personality value]] of the Pokémon modulo 24, as shown below, where G, A, E, and M stand for the substructures growth, attacks, EVs and condition, and miscellaneous, respectively.


{| align="center" style="border: 1px solid #88a; background: white; padding: 1px; text-align: center;" cellspacing="1" cellpadding="2"
{| style="margin:auto; border: 1px solid #88a; background: #f8f8ff; padding: 1px; text-align: center;" cellspacing="1" cellpadding="2"
|- style="background: #f8f8ff;"
| width="25%" | 00. GAEM
| width="25%" | 00. GAEM
| width="25%" | 06. AGEM
| width="25%" | 06. AGEM
| width="25%" | 12. EGAM
| width="25%" | 12. EGAM
| width="25%" | 18. MGAE
| width="25%" | 18. MGAE
|- style="background: #f8f8ff;"
|-
| 01. GAME
| 01. GAME
| 07. AGME
| 07. AGME
| 13. EGMA
| 13. EGMA
| 19. MGEA
| 19. MGEA
|- style="background: #f8f8ff;"
|-
| 02. GEAM
| 02. GEAM
| 08. AEGM
| 08. AEGM
| 14. EAGM
| 14. EAGM
| 20. MAGE
| 20. MAGE
|- style="background: #f8f8ff;"
|-
| 03. GEMA
| 03. GEMA
| 09. AEMG
| 09. AEMG
| 15. EAMG
| 15. EAMG
| 21. MAEG
| 21. MAEG
|- style="background: #f8f8ff;"
|-
| 04. GMAE
| 04. GMAE
| 10. AMGE
| 10. AMGE
| 16. EMGA
| 16. EMGA
| 22. MEGA
| 22. MEGA
|- style="background: #f8f8ff;"
|-
| 05. GMEA
| 05. GMEA
| 11. AMEG
| 11. AMEG
Line 124: Line 97:
|}
|}


Where G, A, E, and M stand for the substructures: growth, attacks, effort, and Misc. respectively.
===Encryption===
The four data substructures are stored in an encrypted form. Decrypting the data involves two steps: actually decrypting the data, and validating the decrypted data. To obtain the 32-bit decryption key, the entire [[Original Trainer]] [[Trainer ID number|ID number]] must be {{wp|XOR}}ed with the personality value of the entry. This key can then be used to decrypt the data by XORing it, 32 bits (or 4 bytes) at a time. To validate the checksum given in the encapsulating [[Pokémon data structure in Generation III|Pokémon data structure]], the entirety of the four unencrypted data substructures must be summed into a 16-bit value.


==Encryption==
==Notes==
===PP bonuses===
The PP bonuses byte stores the number of times {{PP}} has been increased for each move in the attacks substructure. Each move has two bits, meaning the PP of each move can be increased 0 to 3 times.
{| style="border: 1px solid #88a; background: #f8f8ff; padding: 0.5em; border-collapse: collapse; margin: 0 0 0.5em 0.5em" cellpadding=2
! Bits || Move
|-
| 0-1 || Move 1
|-
| 2-3 || Move 2
|-
| 4-5 || Move 3
|-
| 6-7 || Move 4
|}


The entire data structure is encrypted by XORing the entire Trainer ID with the personality value, after that you 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 [http://en.wikipedia.org/wiki/Xor XOR]. The correct checksum is found by summing the original values, not the encrypted values.
===Pokérus status===
[[Pokérus]] status is stored in a single byte, with the upper and lower halves representing distinct values.
{| style="border: 1px solid #88a; background: #f8f8ff; padding: 0.5em; border-collapse: collapse; margin: 0 0 0.5em 0.5em" cellpadding=2
! Bits || Interpretation
|-
| 0-3 || Days left until Pokérus is cured
|-
| 4-7 || Pokérus "strain"
|}
Any value from 0 to 15 is valid for the strain, with 0 indicating that the Pokémon does not have Pokérus at all. The number of days can be any value from 0 to 4, although for some "strains", some of those higher values [[Pokérus#Strains|are also invalid]]. If any bit is set in the "strain" and the number of days is at 0, the Pokémon has been "cured" of Pokérus, as indicated by a small black dot on the Pokémon's status screen.


=Notes=
===Origins===
==PP bonuses==
''Trainer gender'' tells the game how to color the name of the Pokémon's [[Original Trainer]] on the Pokémon's status screen. If ''Level met'' is 0, it is interpreted as the Pokémon having been hatched from an {{pkmn|Egg}}; however, the games only differentiate a hatched Pokémon from other Pokémon if its current Trainer is the Pokémon's Original Trainer. If a hatched Pokémon is traded, its origin text on the status screen is displayed just like a caught Pokémon's and will not say "Hatched" or "Egg".
{| style="border: 1px solid #88a; padding: 0.5em" cellpadding=2 cellspacing=3
|- style="background: #ccf;"
! colspan=2 | Trainer gender || colspan=2 | Poké Ball caught in || colspan=2 | Game of origin || colspan=2 | Level met
|- style="text-align:center"
| colspan=2 | ''Bit 15'' || colspan=2 | ''Bits 11 - 14'' || colspan=2 | ''Bits 7 - 10'' || colspan=2 | ''Bits 0 - 6''
|-
! Value || Gender || Value || Ball || Value || Game || Value || Interpretation
|-
| 0 || style="color:#{{blue color}}" | '''Male''' || 1 || {{bag|Master Ball}}[[Master Ball]] || 0 || {{pkmn|Colosseum Bonus Disc}} || 0 || Hatched
|-
| 1 || style="color:#{{red color}}" | '''Female''' || 2 || {{bag|Ultra Ball}}{{ball|Ultra}} || 1 || '''{{color2|{{sapphire color}}|Pokémon Ruby and Sapphire Versions|Sapphire}}''' || >0 || Caught or other
|-
| rowspan=10 colspan=2 | || 3 || {{bag|Great Ball}}{{ball|Great}} || 2 || '''{{color2|{{ruby color}}|Pokémon Ruby and Sapphire Versions|Ruby}}'''
|-
| 4 || {{bag|Poké Ball}}{{ball|Poké}} || 3 || '''{{color2|{{emerald color}}|Pokémon Emerald Version|Emerald}}'''
|-
| 5 || {{bag|Safari Ball}}{{ball|Safari}} || 4 || '''{{color2|{{firered color}}|Pokémon FireRed and LeafGreen Versions|FireRed}}'''
|-
| 6 || {{bag|Net Ball}}{{ball|Net}} || 5 || '''{{color2|{{leafgreen color}}|Pokémon FireRed and LeafGreen Versions|LeafGreen}}'''
|-
| 7 || {{bag|Dive Ball}}{{ball|Dive}} || 15 || '''{{color2|{{colo color}}|Pokémon Colosseum|Colosseum}}''' or '''{{color2|{{xd color}}|Pokémon XD: Gale of Darkness|XD}}'''
|-
| 8 || {{bag|Nest Ball}}{{ball|Nest}}
|-
| 9 || {{bag|Repeat Ball}}{{ball|Repeat}}
|-
| 10 || {{bag|Timer Ball}}{{ball|Timer}}
|-
| 11 || {{bag|Luxury Ball}}{{ball|Luxury}}
|-
| 12 || {{bag|Premier Ball}}{{ball|Premier}}
|}


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.
===IVs, Egg, and Ability===
[[Individual values|IVs]] for each of the [[stats]] from HP to Special Defense take up the first 30 bits of this field, each IV taking 5 bits. Bit 30 is a 1 if the Pokémon is still an Egg or 0 otherwise. Bit 31 indicates the [[Ability]] the Pokémon has: 0 indicates its first Ability, while 1 indicates its second Ability (if it has one). The indices in the following table are from the left: bit 0 is the most significant, and bit 31 is the least significant of the 32 consecutive bits.
{| style="border: 1px solid #88a; background: #f8f8ff; padding: 0.5em; border-collapse: collapse; margin: 0 0 0.5em 0.5em" cellpadding=2
! Bits || Stat
|-
| 0-4 || HP
|-
| 5-9 || Attack
|-
| 10-14 || Defense
|-
| 15-19 || Speed
|-
| 20-24 || Special Attack
|-
| 25-29 || Special Defense
|-
| 30 || Egg?
|-
| 31 || Ability
|}


==Pokérus status==
===Ribbons and Obedience===
For most of the [[Ribbon]]s, a value of 0 indicates that the Pokémon does not have the Ribbon while 1 indicates that it does. For the {{pkmn|Contest}} Ribbons, the values 1 to 4 indicate that the Pokémon has the Ribbon or Ribbons for (respectively) the Normal, Super, Hyper, and Master Ranks of that Contest.


[[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.
The last 6 possible spots for Ribbons are variable. The data identifying what Ribbons these spots correspond to is stored elsewhere. The full list of possibilities for these can be seen [[List of Ribbons in the games#Generation III|here]]. The only two of these special Ribbons that remain reliably obtainable are those {{DL|List of Ribbons in the games|National Ribbon|for purifying a Shadow Pokémon}} and {{DL|List of Ribbons in the games|Earth Ribbon|for beating Mt. Battle}}.
{| style="border: 1px solid #88a; background: #f8f8ff; padding: 0.5em; border-collapse: collapse; margin: 0 0 0.5em 0.5em" cellpadding=2
! Bits || Ribbon
|-
| 0-2 || {{DL|List of Ribbons in the games|Cool Ribbon|Cool}}
|-
| 3-5 || {{DL|List of Ribbons in the games|Beauty Ribbon|Beauty}}
|-
| 6-8 || {{DL|List of Ribbons in the games|Cute Ribbon|Cute}}
|-
| 9-11 || {{DL|List of Ribbons in the games|Smart Ribbon|Smart}}
|-
| 12-14 || {{DL|List of Ribbons in the games|Tough Ribbon|Tough}}
|-
| 15 || {{DL|List of Ribbons in the games|Champion Ribbon|Champion}}
|-
| 16 || {{DL|List of Ribbons in the games|Winning Ribbon|Winning}}
|-
| 17 || {{DL|List of Ribbons in the games|Victory Ribbon|Victory}}
|-
| 18 || {{DL|List of Ribbons in the games|Artist Ribbon|Artist}}
|-
| 19 || {{DL|List of Ribbons in the games|Effort Ribbon|Effort}}
|-
| 20 || Special 1
|-
| 21 || Special 2
|-
| 22 || Special 3
|-
| 23 || Special 4
|-
| 24 || Special 5
|-
| 26<!--According to http://www.ppnstudio.com/maker/PokemonMakerHelp.txt , 26 (with a gap from the previous) is correct...--> || Special 6
|}


==Level caught==
The last bit of this field, bit 31, determines the [[obedience]] of {{p|Mew}} and {{p|Deoxys}}. If this bit is not set, Mew and Deoxys cannot be traded to or from Pokémon FireRed, LeafGreen, or Emerald, and will always disobey the player in battle in those games (except in link battles). If this bit is set on a Pokémon that is transferred to a later generation, the Pokémon will be treated as having had a [[fateful encounter]].<ref>[https://web.archive.org/web/20110426023742/http://upokecenter.com/games/rs/guides/notes.php#15BB2A7E2 Pokémon Ruby, Sapphire, and Emerald - Various Notes (Upokecenter via the Internet Archive)]</ref>


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 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.
==See also==
 
* [[Pokémon data structure in the GBA]]
==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.
==Links==
* [http://www.ppnstudio.com/maker/PokemonMakerHelp.txt PokemonMakerV4x Help and 80 bytes Make a Pokémon]


==DVs==
==References==
 
<references/>
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.
 
==See also==
* [[Pokémon data structure in the GBA]]


[[Category:Structures]]
{{data structure}}<br>
[[Category:Game mechanics]]
{{Project Games notice|data structure}}
78

edits