aaaaaa123456789 icon

PBR savefile dumper

aaaaaa123456789 | PRO | 09/26/16 08:20:45 AM UTC | 0 ⭐ | 832 👁️ | Never ⏰ | []
C |

4.79 KB

|

None

|

0 👍

/

0 👎

/*
   This program is hereby released to the public domain.
   ~aaaaaa123456789, 2016-09-26
 
   This program requires libeps to be compiled. Download from here:
   https://github.com/TwitchPlaysPokemon/pokerevo/tree/master/utils/libeps
*/
 
#include <stdio.h>
#include "libeps.h"
 
unsigned char move_base_PP[] = {
   0, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30,  5, 10, 30, 30, 35, 35, 20, 15,
  20, 20, 15, 20, 30,  5, 25, 15, 15, 15, 25, 20,  5, 35, 15, 20, 20, 20, 15, 30,
  35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, 30, 25, 15, 30, 25,  5, 15, 10,  5,
  20, 20, 20,  5, 35, 20, 20, 20, 20, 20, 15, 25, 15, 10, 40, 25, 10, 35, 30, 15,
  20, 40, 10, 15, 30, 15, 20, 10, 15, 10,  5, 10, 10, 25, 10, 20, 40, 30, 30, 20,
  20, 15, 10, 40, 15, 10, 30, 20, 20, 10, 40, 40, 30, 30, 30, 20, 30, 10, 10, 20,
   5, 10, 30, 20, 20, 20,  5, 15, 10, 20, 15, 15, 35, 20, 15, 10, 20, 30, 15, 40,
  20, 15, 10,  5, 10, 30, 10, 15, 20, 15, 40, 40, 10,  5, 15, 10, 10, 10, 15, 30,
  30, 10, 10, 20, 10,  1,  1, 10, 10, 10,  5, 15, 25, 15, 10, 15, 30,  5, 40, 15,
  10, 25, 10, 30, 10, 20, 10, 10, 10, 10, 10, 20,  5, 40,  5,  5, 15,  5, 10,  5,
  15, 10, 10, 10, 20, 20, 40, 15, 10, 20, 20, 25,  5, 15, 10,  5, 20, 15, 20, 25,
  20,  5, 30,  5, 10, 20, 40,  5, 20, 40, 20, 15, 35, 10,  5,  5,  5, 15,  5, 20,
   5,  5, 15, 20, 10,  5,  5, 15, 15, 15, 15, 10, 10, 10, 20, 10, 10, 10, 10, 15,
  15, 15, 10, 20, 20, 10, 20, 20, 20, 20, 20, 10, 10, 10, 20, 20,  5, 15, 10, 10,
  15, 10, 20,  5,  5, 10, 10, 20,  5, 10, 20, 10, 20, 20, 20,  5,  5, 15, 20, 10,
  15, 20, 15, 10, 10, 15, 10,  5,  5, 10, 15, 10,  5, 20, 25,  5, 40, 10,  5, 40,
  15, 20, 20,  5, 15, 20, 30, 15, 15,  5, 10, 30, 20, 30, 15,  5, 40, 15,  5, 20,
   5, 15, 25, 40, 15, 20, 15, 20, 15, 20, 10, 20, 20,  5,  5, 10,  5, 40, 10, 10,
   5, 10, 10, 15, 10, 20, 30, 30, 10, 20,  5, 10, 10, 15, 10, 10,  5, 15,  5, 10, 
  10, 30, 20, 20, 10, 10,  5,  5, 10,  5, 20, 10, 20, 10, 15, 10, 20, 20, 20, 15,
  15, 10, 15, 20, 15, 10, 10, 10, 20,  5, 30,  5, 10, 15, 10, 10,  5, 20, 30, 10,
  30, 15, 15, 15, 15, 30, 10, 20, 15, 10, 10, 20, 15,  5,  5, 15, 15,  5, 10,  5,
  20,  5, 15, 20,  5, 20, 20, 20, 20, 10, 20, 10, 15, 20, 15, 10, 10,  5, 10,  5,
   5, 10,  5,  5, 10,  5,  5,  5
};
 
int main (int argc, char ** argv) {
  void * save;
  void * pokemon;
  int rv = epsf_read_save_from_file((argc > 1) ? argv[1] : "PbrSaveData", &save);
  if (rv) return 1;
  epsf_select_save_slot(save, 1);
  int box, slot, index;
  char name[16];
  unsigned value, expected_PP, real_PP;
  for (box = 0; box <= 18; box ++) for (slot = 1; slot <= (box ? 30 : 6); slot ++) {
    epsf_read_pokemon_from_save(save, box, slot, &pokemon);
    epsf_get_pokemon_name(pokemon, 0, name);
    epsf_get_pokemon_value(pokemon, EPSK_SPECIES_NUMBER, 0, &value);
    if (box)
      printf("Box %d, slot %d - %s\n", box, slot, value ? name : "<empty slot>");
    else
      printf("Party slot %d - %s\n", slot, value ? name : "<empty slot>");
    if (!value) goto done;
    printf("Species #: %u\n", value);
    epsf_get_pokemon_value(pokemon, EPSK_FORM, 0, &value);
    printf("Form: %u\n", value);
    epsf_get_pokemon_value(pokemon, EPSK_GENDER, 0, &value);
    printf("Gender: %u\n", value);
    epsf_get_pokemon_value(pokemon, EPSK_HELD_ITEM, 0, &value);
    printf("Held item: %u\n", value);
    epsf_get_pokemon_value(pokemon, EPSK_ABILITY, 0, &value);
    printf("Ability: %u\n", value);
    epsf_get_pokemon_value(pokemon, EPSK_PERSONALITY_VALUE, 0, &value);
    printf("Nature: %u\n", value % 25);
    epsf_get_pokemon_value(pokemon, EPSK_FRIENDSHIP, 0, &value);
    printf("Happiness: %u\n", value);
    printf("Moves: ");
    for (index = 1; index <= 4; index ++) {
      epsf_get_pokemon_value(pokemon, EPSK_MOVE, index, &value);
      if (!value) continue;
      if (index > 1) printf(", ");
      printf("%u", value);
      expected_PP = move_base_PP[value];
      epsf_get_pokemon_value(pokemon, EPSK_MOVE_PP_UPS, index, &value);
      expected_PP = expected_PP * (value + 5) / 5;
      epsf_get_pokemon_value(pokemon, EPSK_MOVE_PP, index, &real_PP);
      if (real_PP != expected_PP) {
        printf(" (=%u", real_PP);
        if (value) printf("/+%u", value);
        putchar(')');
      } else if (value)
        printf(" (+%u)", value);
    }
    printf("\nIVs/EVs: ");
    for (index = 0; index <= 5; index ++) {
      printf("%s%s ", index ? ", " : "", index[(const char * []) {"HP", "atk", "def", "spe", "spA", "spD"}]);
      epsf_get_pokemon_value(pokemon, EPSK_INDIVIDUAL_VALUE, index, &value);
      printf("%u", value);
      epsf_get_pokemon_value(pokemon, EPSK_EFFORT_VALUE, index, &value);
      printf("/%u", value);
    }
    putchar('\n');
    done:
    epsf_destroy_pokemon(pokemon);
    putchar('\n');
  }
  epsf_destroy_save(save);
  return 0;
}

Comments