d8637182aea4e3a29207861c05a7f63706683533
[zzz-pokedex.git] / pokedex / struct / _pokemon_struct.py
1 # encoding: utf8
2 u"""Defines a construct `pokemon_struct`, containing the structure of a single
3 Pokémon saved within a game -- often seen as a .pkm file. This is the same
4 format sent back and forth over the GTS.
5 """
6
7 import datetime
8
9 from construct import *
10
11 # TODO:
12 # - strings should be validated, going both in and out
13 # - strings need to pad themselves when being re-encoded
14 # - strings sometimes need specific padding christ
15 # - date_met is not optional
16 # - some way to be more lenient with junk data, or at least
17 # - higher-level validation; see XXXes below
18 # - personality indirectly influences IVs due to PRNG use
19
20 # The entire gen 4 character table:
21 character_table = {
22 0x0002: u'ぁ',
23 0x0003: u'あ',
24 0x0004: u'ぃ',
25 0x0005: u'い',
26 0x0006: u'ぅ',
27 0x0007: u'う',
28 0x0008: u'ぇ',
29 0x0009: u'え',
30 0x000a: u'ぉ',
31 0x000b: u'お',
32 0x000c: u'か',
33 0x000d: u'が',
34 0x000e: u'き',
35 0x000f: u'ぎ',
36 0x0010: u'く',
37 0x0011: u'ぐ',
38 0x0012: u'け',
39 0x0013: u'げ',
40 0x0014: u'こ',
41 0x0015: u'ご',
42 0x0016: u'さ',
43 0x0017: u'ざ',
44 0x0018: u'し',
45 0x0019: u'じ',
46 0x001a: u'す',
47 0x001b: u'ず',
48 0x001c: u'せ',
49 0x001d: u'ぜ',
50 0x001e: u'そ',
51 0x001f: u'ぞ',
52 0x0020: u'た',
53 0x0021: u'だ',
54 0x0022: u'ち',
55 0x0023: u'ぢ',
56 0x0024: u'っ',
57 0x0025: u'つ',
58 0x0026: u'づ',
59 0x0027: u'て',
60 0x0028: u'で',
61 0x0029: u'と',
62 0x002a: u'ど',
63 0x002b: u'な',
64 0x002c: u'に',
65 0x002d: u'ぬ',
66 0x002e: u'ね',
67 0x002f: u'の',
68 0x0030: u'は',
69 0x0031: u'ば',
70 0x0032: u'ぱ',
71 0x0033: u'ひ',
72 0x0034: u'び',
73 0x0035: u'ぴ',
74 0x0036: u'ふ',
75 0x0037: u'ぶ',
76 0x0038: u'ぷ',
77 0x0039: u'へ',
78 0x003a: u'べ',
79 0x003b: u'ぺ',
80 0x003c: u'ほ',
81 0x003d: u'ぼ',
82 0x003e: u'ぽ',
83 0x003f: u'ま',
84 0x0040: u'み',
85 0x0041: u'む',
86 0x0042: u'め',
87 0x0043: u'も',
88 0x0044: u'ゃ',
89 0x0045: u'や',
90 0x0046: u'ゅ',
91 0x0047: u'ゆ',
92 0x0048: u'ょ',
93 0x0049: u'よ',
94 0x004a: u'ら',
95 0x004b: u'り',
96 0x004c: u'る',
97 0x004d: u'れ',
98 0x004e: u'ろ',
99 0x004f: u'わ',
100 0x0050: u'を',
101 0x0051: u'ん',
102 0x0052: u'ァ',
103 0x0053: u'ア',
104 0x0054: u'ィ',
105 0x0055: u'イ',
106 0x0056: u'ゥ',
107 0x0057: u'ウ',
108 0x0058: u'ェ',
109 0x0059: u'エ',
110 0x005a: u'ォ',
111 0x005b: u'オ',
112 0x005c: u'カ',
113 0x005d: u'ガ',
114 0x005e: u'キ',
115 0x005f: u'ギ',
116 0x0060: u'ク',
117 0x0061: u'グ',
118 0x0062: u'ケ',
119 0x0063: u'ゲ',
120 0x0064: u'コ',
121 0x0065: u'ゴ',
122 0x0066: u'サ',
123 0x0067: u'ザ',
124 0x0068: u'シ',
125 0x0069: u'ジ',
126 0x006a: u'ス',
127 0x006b: u'ズ',
128 0x006c: u'セ',
129 0x006d: u'ゼ',
130 0x006e: u'ソ',
131 0x006f: u'ゾ',
132 0x0070: u'タ',
133 0x0071: u'ダ',
134 0x0072: u'チ',
135 0x0073: u'ヂ',
136 0x0074: u'ッ',
137 0x0075: u'ツ',
138 0x0076: u'ヅ',
139 0x0077: u'テ',
140 0x0078: u'デ',
141 0x0079: u'ト',
142 0x007a: u'ド',
143 0x007b: u'ナ',
144 0x007c: u'ニ',
145 0x007d: u'ヌ',
146 0x007e: u'ネ',
147 0x007f: u'ノ',
148 0x0080: u'ハ',
149 0x0081: u'バ',
150 0x0082: u'パ',
151 0x0083: u'ヒ',
152 0x0084: u'ビ',
153 0x0085: u'ピ',
154 0x0086: u'フ',
155 0x0087: u'ブ',
156 0x0088: u'プ',
157 0x0089: u'ヘ',
158 0x008a: u'ベ',
159 0x008b: u'ペ',
160 0x008c: u'ホ',
161 0x008d: u'ボ',
162 0x008e: u'ポ',
163 0x008f: u'マ',
164 0x0090: u'ミ',
165 0x0091: u'ム',
166 0x0092: u'メ',
167 0x0093: u'モ',
168 0x0094: u'ャ',
169 0x0095: u'ヤ',
170 0x0096: u'ュ',
171 0x0097: u'ユ',
172 0x0098: u'ョ',
173 0x0099: u'ヨ',
174 0x009a: u'ラ',
175 0x009b: u'リ',
176 0x009c: u'ル',
177 0x009d: u'レ',
178 0x009e: u'ロ',
179 0x009f: u'ワ',
180 0x00a0: u'ヲ',
181 0x00a1: u'ン',
182 0x00a2: u'0',
183 0x00a3: u'1',
184 0x00a4: u'2',
185 0x00a5: u'3',
186 0x00a6: u'4',
187 0x00a7: u'5',
188 0x00a8: u'6',
189 0x00a9: u'7',
190 0x00aa: u'8',
191 0x00ab: u'9',
192 0x00ac: u'A',
193 0x00ad: u'B',
194 0x00ae: u'C',
195 0x00af: u'D',
196 0x00b0: u'E',
197 0x00b1: u'F',
198 0x00b2: u'G',
199 0x00b3: u'H',
200 0x00b4: u'I',
201 0x00b5: u'J',
202 0x00b6: u'K',
203 0x00b7: u'L',
204 0x00b8: u'M',
205 0x00b9: u'N',
206 0x00ba: u'O',
207 0x00bb: u'P',
208 0x00bc: u'Q',
209 0x00bd: u'R',
210 0x00be: u'S',
211 0x00bf: u'T',
212 0x00c0: u'U',
213 0x00c1: u'V',
214 0x00c2: u'W',
215 0x00c3: u'X',
216 0x00c4: u'Y',
217 0x00c5: u'Z',
218 0x00c6: u'a',
219 0x00c7: u'b',
220 0x00c8: u'c',
221 0x00c9: u'd',
222 0x00ca: u'e',
223 0x00cb: u'f',
224 0x00cc: u'g',
225 0x00cd: u'h',
226 0x00ce: u'i',
227 0x00cf: u'j',
228 0x00d0: u'k',
229 0x00d1: u'l',
230 0x00d2: u'm',
231 0x00d3: u'n',
232 0x00d4: u'o',
233 0x00d5: u'p',
234 0x00d6: u'q',
235 0x00d7: u'r',
236 0x00d8: u's',
237 0x00d9: u't',
238 0x00da: u'u',
239 0x00db: u'v',
240 0x00dc: u'w',
241 0x00dd: u'x',
242 0x00de: u'y',
243 0x00df: u'z',
244 0x00e0: u'à',
245 0x00e1: u'!',
246 0x00e2: u'?',
247 0x00e3: u'、',
248 0x00e4: u'。',
249 0x00e5: u'…',
250 0x00e6: u'・',
251 0x00e7: u'/',
252 0x00e8: u'「',
253 0x00e9: u'」',
254 0x00ea: u'『',
255 0x00eb: u'』',
256 0x00ec: u'(',
257 0x00ed: u')',
258 0x00ee: u'♂',
259 0x00ef: u'♀',
260 0x00f0: u'+',
261 0x00f1: u'ー',
262 0x00f2: u'×',
263 0x00f3: u'÷',
264 0x00f4: u'=',
265 0x00f5: u'~',
266 0x00f6: u':',
267 0x00f7: u';',
268 0x00f8: u'.',
269 0x00f9: u',',
270 0x00fa: u'♠',
271 0x00fb: u'♣',
272 0x00fc: u'♥',
273 0x00fd: u'♦',
274 0x00fe: u'★',
275 0x00ff: u'◎',
276 0x0100: u'○',
277 0x0101: u'□',
278 0x0102: u'△',
279 0x0103: u'◇',
280 0x0104: u'@',
281 0x0105: u'♪',
282 0x0106: u'%',
283 0x0107: u'☀',
284 0x0108: u'☁',
285 0x0109: u'☂',
286 0x010a: u'☃',
287 0x010f: u'⤴',
288 0x0110: u'⤵',
289 0x0112: u'円',
290 0x0116: u'✉',
291 0x011b: u'←',
292 0x011c: u'↑',
293 0x011d: u'↓',
294 0x011e: u'→',
295 0x0120: u'&',
296 0x0121: u'0',
297 0x0122: u'1',
298 0x0123: u'2',
299 0x0124: u'3',
300 0x0125: u'4',
301 0x0126: u'5',
302 0x0127: u'6',
303 0x0128: u'7',
304 0x0129: u'8',
305 0x012a: u'9',
306 0x012b: u'A',
307 0x012c: u'B',
308 0x012d: u'C',
309 0x012e: u'D',
310 0x012f: u'E',
311 0x0130: u'F',
312 0x0131: u'G',
313 0x0132: u'H',
314 0x0133: u'I',
315 0x0134: u'J',
316 0x0135: u'K',
317 0x0136: u'L',
318 0x0137: u'M',
319 0x0138: u'N',
320 0x0139: u'O',
321 0x013a: u'P',
322 0x013b: u'Q',
323 0x013c: u'R',
324 0x013d: u'S',
325 0x013e: u'T',
326 0x013f: u'U',
327 0x0140: u'V',
328 0x0141: u'W',
329 0x0142: u'X',
330 0x0143: u'Y',
331 0x0144: u'Z',
332 0x0145: u'a',
333 0x0146: u'b',
334 0x0147: u'c',
335 0x0148: u'd',
336 0x0149: u'e',
337 0x014a: u'f',
338 0x014b: u'g',
339 0x014c: u'h',
340 0x014d: u'i',
341 0x014e: u'j',
342 0x014f: u'k',
343 0x0150: u'l',
344 0x0151: u'm',
345 0x0152: u'n',
346 0x0153: u'o',
347 0x0154: u'p',
348 0x0155: u'q',
349 0x0156: u'r',
350 0x0157: u's',
351 0x0158: u't',
352 0x0159: u'u',
353 0x015a: u'v',
354 0x015b: u'w',
355 0x015c: u'x',
356 0x015d: u'y',
357 0x015e: u'z',
358 0x015f: u'À',
359 0x0160: u'Á',
360 0x0161: u'Â',
361 0x0163: u'Ä',
362 0x0166: u'Ç',
363 0x0167: u'È',
364 0x0168: u'É',
365 0x0169: u'Ê',
366 0x016a: u'Ë',
367 0x016b: u'Ì',
368 0x016c: u'Í',
369 0x016d: u'Î',
370 0x016e: u'Ï',
371 0x0170: u'Ñ',
372 0x0171: u'Ò',
373 0x0172: u'Ó',
374 0x0173: u'Ô',
375 0x0175: u'Ö',
376 0x0176: u'×',
377 0x0178: u'Ù',
378 0x0179: u'Ú',
379 0x017a: u'Û',
380 0x017b: u'Ü',
381 0x017e: u'ß',
382 0x017f: u'à',
383 0x0180: u'á',
384 0x0181: u'â',
385 0x0183: u'ä',
386 0x0186: u'ç',
387 0x0187: u'è',
388 0x0188: u'é',
389 0x0189: u'ê',
390 0x018a: u'ë',
391 0x018b: u'ì',
392 0x018c: u'í',
393 0x018d: u'î',
394 0x018e: u'ï',
395 0x0190: u'ñ',
396 0x0191: u'ò',
397 0x0192: u'ó',
398 0x0193: u'ô',
399 0x0195: u'ö',
400 0x0196: u'÷',
401 0x0198: u'ù',
402 0x0199: u'ú',
403 0x019a: u'û',
404 0x019b: u'ü',
405 0x019f: u'Œ',
406 0x01a0: u'œ',
407 0x01a3: u'ª',
408 0x01a4: u'º',
409 0x01a5: u'þ',
410 0x01a6: u'Þ',
411 0x01a7: u'ʳ',
412 0x01a8: u'¥',
413 0x01a9: u'¡',
414 0x01aa: u'¿',
415 0x01ab: u'!',
416 0x01ac: u'?',
417 0x01ad: u',',
418 0x01ae: u'.',
419 0x01af: u'…',
420 0x01b0: u'·',
421 0x01b1: u'/',
422 0x01b2: u'‘',
423 0x01b3: u'\'',
424 0x01b3: u'’',
425 0x01b4: u'“',
426 0x01b5: u'”',
427 0x01b6: u'„',
428 0x01b7: u'«',
429 0x01b8: u'»',
430 0x01b9: u'(',
431 0x01ba: u')',
432 0x01bb: u'♂',
433 0x01bc: u'♀',
434 0x01bd: u'+',
435 0x01be: u'-',
436 0x01bf: u'*',
437 0x01c0: u'#',
438 0x01c1: u'=',
439 0x01c2: u'&',
440 0x01c3: u'~',
441 0x01c4: u':',
442 0x01c5: u';',
443 0x01c6: u'♠',
444 0x01c7: u'♣',
445 0x01c8: u'♥',
446 0x01c9: u'♦',
447 0x01ca: u'★',
448 0x01cb: u'◎',
449 0x01cc: u'○',
450 0x01cd: u'□',
451 0x01ce: u'△',
452 0x01cf: u'◇',
453 0x01d0: u'@',
454 0x01d1: u'♪',
455 0x01d2: u'%',
456 0x01d3: u'☀',
457 0x01d4: u'☁',
458 0x01d5: u'☂',
459 0x01d6: u'☃',
460 0x01db: u'⤴',
461 0x01dc: u'⤵',
462 0x01de: u' ',
463 0xe000: u'\n',
464 0x25bc: u'\f',
465 0x25bd: u'\r',
466 }
467
468 # And the reverse dict, used with str.translate()
469 inverse_character_table = dict()
470 for in_, out in character_table.iteritems():
471 inverse_character_table[ord(out)] = in_
472
473
474 def LittleEndianBitStruct(*args):
475 """Construct's bit structs read a byte at a time in the order they appear,
476 reading each bit from most to least significant. Alas, this doesn't work
477 at all for a 32-bit bit field, because the bytes are 'backwards' in
478 little-endian files.
479
480 So this acts as a bit struct, but reverses the order of bytes before
481 reading/writing, so ALL the bits are read from most to least significant.
482 """
483 return Buffered(
484 BitStruct(*args),
485 encoder=lambda s: s[::-1],
486 decoder=lambda s: s[::-1],
487 resizer=lambda _: _,
488 )
489
490 class PokemonStringAdapter(Adapter):
491 u"""Adapter that encodes/decodes Pokémon-formatted text stored in a regular
492 String struct.
493 """
494 def _decode(self, obj, context):
495 decoded_text = obj.decode('utf16')
496
497 # Real string ends at the \uffff character
498 if u'\uffff' in decoded_text:
499 decoded_text = decoded_text[0:decoded_text.index(u'\uffff')]
500 # XXX save "trash bytes" somewhere..?
501
502 return decoded_text.translate(character_table)
503
504 def _encode(self, obj, context):
505 #padded_text = (obj + u'\xffff' + '\x00' * 12)
506 padded_text = obj
507 decoded_text = padded_text.translate(inverse_character_table)
508 return decoded_text.encode('utf16')
509
510 class DateAdapter(Adapter):
511 """Converts between a three-byte string and a Python date.
512
513 Only dates in 2000 or later will work!
514 """
515 def _decode(self, obj, context):
516 if obj == '\x00\x00\x00':
517 return None
518
519 y, m, d = (ord(byte) for byte in obj)
520 y += 2000
521 return datetime.date(y, m, d)
522
523 def _encode(self, obj, context):
524 if obj is None:
525 return '\x00\x00\x00'
526
527 y, m, d = obj.year - 2000, obj.month, obj.day
528 return ''.join(chr(n) for n in (y, m, d))
529
530 # And here we go.
531 # Docs: http://projectpokemon.org/wiki/Pokemon_NDS_Structure
532 pokemon_struct = Struct('pokemon_struct',
533 # Header
534 ULInt32('personality'), # XXX aughgh http://bulbapedia.bulbagarden.net/wiki/Personality
535 Padding(2),
536 ULInt16('checksum'), # XXX should be checked or calculated
537
538 # Block A
539 ULInt16('national_id'),
540 ULInt16('held_item_id'),
541 ULInt16('original_trainer_id'),
542 ULInt16('original_trainer_secret_id'),
543 ULInt32('exp'),
544 ULInt8('happiness'),
545 ULInt8('ability_id'), # XXX needs to match personality + species
546 BitStruct('markings',
547 Padding(2),
548 Flag('diamond'),
549 Flag('star'),
550 Flag('heart'),
551 Flag('square'),
552 Flag('triangle'),
553 Flag('circle'),
554 ),
555 Enum(
556 ULInt8('original_country'),
557 jp=1,
558 us=2,
559 fr=3,
560 it=4,
561 de=5,
562 es=7,
563 kr=8,
564 ),
565
566 # XXX sum cannot surpass 510
567 ULInt8('effort_hp'),
568 ULInt8('effort_attack'),
569 ULInt8('effort_defense'),
570 ULInt8('effort_speed'),
571 ULInt8('effort_special_attack'),
572 ULInt8('effort_special_defense'),
573
574 ULInt8('contest_cool'),
575 ULInt8('contest_beauty'),
576 ULInt8('contest_cute'),
577 ULInt8('contest_smart'),
578 ULInt8('contest_tough'),
579 ULInt8('contest_sheen'),
580
581 LittleEndianBitStruct('sinnoh_ribbons',
582 Padding(4),
583 Flag('premier_ribbon'),
584 Flag('classic_ribbon'),
585 Flag('carnival_ribbon'),
586 Flag('festival_ribbon'),
587 Flag('blue_ribbon'),
588 Flag('green_ribbon'),
589 Flag('red_ribbon'),
590 Flag('legend_ribbon'),
591 Flag('history_ribbon'),
592 Flag('record_ribbon'),
593 Flag('footprint_ribbon'),
594 Flag('gorgeous_royal_ribbon'),
595 Flag('royal_ribbon'),
596 Flag('gorgeous_ribbon'),
597 Flag('smile_ribbon'),
598 Flag('snooze_ribbon'),
599 Flag('relax_ribbon'),
600 Flag('careless_ribbon'),
601 Flag('downcast_ribbon'),
602 Flag('shock_ribbon'),
603 Flag('alert_ribbon'),
604 Flag('world_ability_ribbon'),
605 Flag('pair_ability_ribbon'),
606 Flag('multi_ability_ribbon'),
607 Flag('double_ability_ribbon'),
608 Flag('great_ability_ribbon'),
609 Flag('ability_ribbon'),
610 Flag('sinnoh_champ_ribbon'),
611 ),
612
613 # Block B
614 ULInt16('move1_id'),
615 ULInt16('move2_id'),
616 ULInt16('move3_id'),
617 ULInt16('move4_id'),
618 ULInt8('move1_pp'),
619 ULInt8('move2_pp'),
620 ULInt8('move3_pp'),
621 ULInt8('move4_pp'),
622 ULInt8('move1_pp_ups'),
623 ULInt8('move2_pp_ups'),
624 ULInt8('move3_pp_ups'),
625 ULInt8('move4_pp_ups'),
626
627 LittleEndianBitStruct('ivs',
628 Flag('is_nicknamed'),
629 Flag('is_egg'),
630 BitField('iv_special_defense', 5),
631 BitField('iv_special_attack', 5),
632 BitField('iv_speed', 5),
633 BitField('iv_defense', 5),
634 BitField('iv_attack', 5),
635 BitField('iv_hp', 5),
636 ),
637 LittleEndianBitStruct('hoenn_ribbons',
638 Flag('world_ribbon'),
639 Flag('earth_ribbon'),
640 Flag('national_ribbon'),
641 Flag('country_ribbon'),
642 Flag('sky_ribbon'),
643 Flag('land_ribbon'),
644 Flag('marine_ribbon'),
645 Flag('effort_ribbon'),
646 Flag('artist_ribbon'),
647 Flag('victory_ribbon'),
648 Flag('winning_ribbon'),
649 Flag('champion_ribbon'),
650 Flag('tough_ribbon_master'),
651 Flag('tough_ribbon_hyper'),
652 Flag('tough_ribbon_super'),
653 Flag('tough_ribbon'),
654 Flag('smart_ribbon_master'),
655 Flag('smart_ribbon_hyper'),
656 Flag('smart_ribbon_super'),
657 Flag('smart_ribbon'),
658 Flag('cute_ribbon_master'),
659 Flag('cute_ribbon_hyper'),
660 Flag('cute_ribbon_super'),
661 Flag('cute_ribbon'),
662 Flag('beauty_ribbon_master'),
663 Flag('beauty_ribbon_hyper'),
664 Flag('beauty_ribbon_super'),
665 Flag('beauty_ribbon'),
666 Flag('cool_ribbon_master'),
667 Flag('cool_ribbon_hyper'),
668 Flag('cool_ribbon_super'),
669 Flag('cool_ribbon'),
670 ),
671 EmbeddedBitStruct(
672 BitField('alternate_form', 5),
673 Enum(BitField('gender', 2),
674 genderless = 2,
675 male = 0,
676 female = 1,
677 ),
678 Flag('fateful_encounter'),
679 ),
680 BitStruct('shining_leaves',
681 Padding(2),
682 Flag('crown'),
683 Flag('leaf5'),
684 Flag('leaf4'),
685 Flag('leaf3'),
686 Flag('leaf2'),
687 Flag('leaf1'),
688 ),
689 Padding(2),
690 ULInt16('pt_egg_location_id'),
691 ULInt16('pt_met_location_id'),
692
693 # Block C
694 PokemonStringAdapter(String('nickname', 22)),
695 Padding(1),
696 Enum(ULInt8('original_version'),
697 sapphire = 1,
698 ruby = 2,
699 emerald = 3,
700 firered = 4,
701 leafgreen = 5,
702 heartgold = 7,
703 soulsilver = 8,
704 diamond = 10,
705 pearl = 11,
706 platinum = 12,
707 orre = 15,
708 ),
709 LittleEndianBitStruct('sinnoh_contest_ribbons',
710 Padding(12),
711 Flag('tough_ribbon_master'),
712 Flag('tough_ribbon_ultra'),
713 Flag('tough_ribbon_great'),
714 Flag('tough_ribbon'),
715 Flag('smart_ribbon_master'),
716 Flag('smart_ribbon_ultra'),
717 Flag('smart_ribbon_great'),
718 Flag('smart_ribbon'),
719 Flag('cute_ribbon_master'),
720 Flag('cute_ribbon_ultra'),
721 Flag('cute_ribbon_great'),
722 Flag('cute_ribbon'),
723 Flag('beauty_ribbon_master'),
724 Flag('beauty_ribbon_ultra'),
725 Flag('beauty_ribbon_great'),
726 Flag('beauty_ribbon'),
727 Flag('cool_ribbon_master'),
728 Flag('cool_ribbon_ultra'),
729 Flag('cool_ribbon_great'),
730 Flag('cool_ribbon'),
731 ),
732 Padding(4),
733
734 # Block D
735 PokemonStringAdapter(String('original_trainer_name', 16)),
736 DateAdapter(String('date_egg_received', 3)),
737 DateAdapter(String('date_met', 3)),
738 ULInt16('dp_egg_location_id'),
739 ULInt16('dp_met_location_id'),
740 ULInt8('pokerus'),
741 ULInt8('dppt_pokeball'),
742 EmbeddedBitStruct(
743 Enum(Flag('original_trainer_gender'),
744 male = False,
745 female = True,
746 ),
747 BitField('met_at_level', 7),
748 ),
749 Enum(ULInt8('encounter_type'),
750 special = 0,
751 grass = 2,
752 dialga_palkia = 4,
753 cave = 5, # or hall of origin
754 water = 7,
755 building = 9,
756 safari_zone = 10,
757 gift = 12,
758 ),
759 ULInt8('hgss_pokeball'),
760 Padding(1),
761 )