aaaaaa123456789

PBR savefile dumper

Sep 26th, 2016
477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.79 KB | None | 0 0
  1. /*
  2.    This program is hereby released to the public domain.
  3.    ~aaaaaa123456789, 2016-09-26
  4.  
  5.    This program requires libeps to be compiled. Download from here:
  6.    https://github.com/TwitchPlaysPokemon/pokerevo/tree/master/utils/libeps
  7. */
  8.  
  9. #include <stdio.h>
  10. #include "libeps.h"
  11.  
  12. unsigned char move_base_PP[] = {
  13.    0, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30,  5, 10, 30, 30, 35, 35, 20, 15,
  14.   20, 20, 15, 20, 30,  5, 25, 15, 15, 15, 25, 20,  5, 35, 15, 20, 20, 20, 15, 30,
  15.   35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, 30, 25, 15, 30, 25,  5, 15, 10,  5,
  16.   20, 20, 20,  5, 35, 20, 20, 20, 20, 20, 15, 25, 15, 10, 40, 25, 10, 35, 30, 15,
  17.   20, 40, 10, 15, 30, 15, 20, 10, 15, 10,  5, 10, 10, 25, 10, 20, 40, 30, 30, 20,
  18.   20, 15, 10, 40, 15, 10, 30, 20, 20, 10, 40, 40, 30, 30, 30, 20, 30, 10, 10, 20,
  19.    5, 10, 30, 20, 20, 20,  5, 15, 10, 20, 15, 15, 35, 20, 15, 10, 20, 30, 15, 40,
  20.   20, 15, 10,  5, 10, 30, 10, 15, 20, 15, 40, 40, 10,  5, 15, 10, 10, 10, 15, 30,
  21.   30, 10, 10, 20, 10,  1,  1, 10, 10, 10,  5, 15, 25, 15, 10, 15, 30,  5, 40, 15,
  22.   10, 25, 10, 30, 10, 20, 10, 10, 10, 10, 10, 20,  5, 40,  5,  5, 15,  5, 10,  5,
  23.   15, 10, 10, 10, 20, 20, 40, 15, 10, 20, 20, 25,  5, 15, 10,  5, 20, 15, 20, 25,
  24.   20,  5, 30,  5, 10, 20, 40,  5, 20, 40, 20, 15, 35, 10,  5,  5,  5, 15,  5, 20,
  25.    5,  5, 15, 20, 10,  5,  5, 15, 15, 15, 15, 10, 10, 10, 20, 10, 10, 10, 10, 15,
  26.   15, 15, 10, 20, 20, 10, 20, 20, 20, 20, 20, 10, 10, 10, 20, 20,  5, 15, 10, 10,
  27.   15, 10, 20,  5,  5, 10, 10, 20,  5, 10, 20, 10, 20, 20, 20,  5,  5, 15, 20, 10,
  28.   15, 20, 15, 10, 10, 15, 10,  5,  5, 10, 15, 10,  5, 20, 25,  5, 40, 10,  5, 40,
  29.   15, 20, 20,  5, 15, 20, 30, 15, 15,  5, 10, 30, 20, 30, 15,  5, 40, 15,  5, 20,
  30.    5, 15, 25, 40, 15, 20, 15, 20, 15, 20, 10, 20, 20,  5,  5, 10,  5, 40, 10, 10,
  31.    5, 10, 10, 15, 10, 20, 30, 30, 10, 20,  5, 10, 10, 15, 10, 10,  5, 15,  5, 10,
  32.   10, 30, 20, 20, 10, 10,  5,  5, 10,  5, 20, 10, 20, 10, 15, 10, 20, 20, 20, 15,
  33.   15, 10, 15, 20, 15, 10, 10, 10, 20,  5, 30,  5, 10, 15, 10, 10,  5, 20, 30, 10,
  34.   30, 15, 15, 15, 15, 30, 10, 20, 15, 10, 10, 20, 15,  5,  5, 15, 15,  5, 10,  5,
  35.   20,  5, 15, 20,  5, 20, 20, 20, 20, 10, 20, 10, 15, 20, 15, 10, 10,  5, 10,  5,
  36.    5, 10,  5,  5, 10,  5,  5,  5
  37. };
  38.  
  39. int main (int argc, char ** argv) {
  40.   void * save;
  41.   void * pokemon;
  42.   int rv = epsf_read_save_from_file((argc > 1) ? argv[1] : "PbrSaveData", &save);
  43.   if (rv) return 1;
  44.   epsf_select_save_slot(save, 1);
  45.   int box, slot, index;
  46.   char name[16];
  47.   unsigned value, expected_PP, real_PP;
  48.   for (box = 0; box <= 18; box ++) for (slot = 1; slot <= (box ? 30 : 6); slot ++) {
  49.     epsf_read_pokemon_from_save(save, box, slot, &pokemon);
  50.     epsf_get_pokemon_name(pokemon, 0, name);
  51.     epsf_get_pokemon_value(pokemon, EPSK_SPECIES_NUMBER, 0, &value);
  52.     if (box)
  53.       printf("Box %d, slot %d - %s\n", box, slot, value ? name : "<empty slot>");
  54.     else
  55.       printf("Party slot %d - %s\n", slot, value ? name : "<empty slot>");
  56.     if (!value) goto done;
  57.     printf("Species #: %u\n", value);
  58.     epsf_get_pokemon_value(pokemon, EPSK_FORM, 0, &value);
  59.     printf("Form: %u\n", value);
  60.     epsf_get_pokemon_value(pokemon, EPSK_GENDER, 0, &value);
  61.     printf("Gender: %u\n", value);
  62.     epsf_get_pokemon_value(pokemon, EPSK_HELD_ITEM, 0, &value);
  63.     printf("Held item: %u\n", value);
  64.     epsf_get_pokemon_value(pokemon, EPSK_ABILITY, 0, &value);
  65.     printf("Ability: %u\n", value);
  66.     epsf_get_pokemon_value(pokemon, EPSK_PERSONALITY_VALUE, 0, &value);
  67.     printf("Nature: %u\n", value % 25);
  68.     epsf_get_pokemon_value(pokemon, EPSK_FRIENDSHIP, 0, &value);
  69.     printf("Happiness: %u\n", value);
  70.     printf("Moves: ");
  71.     for (index = 1; index <= 4; index ++) {
  72.       epsf_get_pokemon_value(pokemon, EPSK_MOVE, index, &value);
  73.       if (!value) continue;
  74.       if (index > 1) printf(", ");
  75.       printf("%u", value);
  76.       expected_PP = move_base_PP[value];
  77.       epsf_get_pokemon_value(pokemon, EPSK_MOVE_PP_UPS, index, &value);
  78.       expected_PP = expected_PP * (value + 5) / 5;
  79.       epsf_get_pokemon_value(pokemon, EPSK_MOVE_PP, index, &real_PP);
  80.       if (real_PP != expected_PP) {
  81.         printf(" (=%u", real_PP);
  82.         if (value) printf("/+%u", value);
  83.         putchar(')');
  84.       } else if (value)
  85.         printf(" (+%u)", value);
  86.     }
  87.     printf("\nIVs/EVs: ");
  88.     for (index = 0; index <= 5; index ++) {
  89.       printf("%s%s ", index ? ", " : "", index[(const char * []) {"HP", "atk", "def", "spe", "spA", "spD"}]);
  90.       epsf_get_pokemon_value(pokemon, EPSK_INDIVIDUAL_VALUE, index, &value);
  91.       printf("%u", value);
  92.       epsf_get_pokemon_value(pokemon, EPSK_EFFORT_VALUE, index, &value);
  93.       printf("/%u", value);
  94.     }
  95.     putchar('\n');
  96.     done:
  97.     epsf_destroy_pokemon(pokemon);
  98.     putchar('\n');
  99.   }
  100.   epsf_destroy_save(save);
  101.   return 0;
  102. }
Add Comment
Please, Sign In to add comment