diff --git a/examples/modifyJorgeTeam.pl b/examples/modifyJorgeTeam.pl index 4ef7795..1abbcea 100644 --- a/examples/modifyJorgeTeam.pl +++ b/examples/modifyJorgeTeam.pl @@ -7,7 +7,7 @@ use warnings; use feature 'signatures'; use Rsaves - qw/read_save check_correct_size get_saves find_current_save_index check_correct_size find_pokemon_substruct change_gender read_pc_storage save_pc_changes enable_eon_ticket save_changes pokemon_set_shiny read_pkm_file_box enable_mirage_island_for_pokemon parse_version_name pokemon_fill_pp/; + qw/read_save check_correct_size get_saves find_current_save_index check_correct_size find_pokemon_substruct change_gender read_pc_storage save_pc_changes enable_eon_ticket save_changes pokemon_set_shiny read_pkm_file_box enable_mirage_island_for_pokemon parse_version_name pokemon_fill_pp to_3rd_encoding translate_3rd_encoding/; use Rsaves::Constants::Global qw/$MOVE_SPIKES $MOVE_DRILL_PECK $MOVE_HIDDEN_POWER $MOVE_TAUNT $MOVE_THUNDERBOLT $MOVE_ROAR $MOVE_THUNDER_WAVE $ITEM_LEFTOVERS $MOVE_DRAGON_DANCE $MOVE_ROCK_SLIDE $MOVE_EARTHQUAKE $MOVE_TAUNT $MOVE_FLAMETHROWER $MOVE_WILL_O_WISP $MOVE_HYDRO_PUMP $MOVE_ICE_BEAM $MOVE_FOCUS_PUNCH/; @@ -48,13 +48,11 @@ sub start { } sub modifyMudkip ($pokemon) { - print Data::Dumper::Dumper $pokemon; $pokemon->{personality} = 0x6BB2770A; + $pokemon->{nickname} = to_3rd_encoding('Kumena'); my $ivs_egg_status_and_ability = $pokemon->{substructures}[3]{ivs_egg_status_and_ability}; - say _hihalf_u32( $pokemon->{otid} ); - say _lowhalf_u32( $pokemon->{otid} ); my $ability = $ivs_egg_status_and_ability >> 31 & 1; my $egg = $ivs_egg_status_and_ability >> 30 & 1; my $iv_special_defense = $ivs_egg_status_and_ability >> 25 & 0x1F; @@ -93,17 +91,13 @@ sub modifyMudkip ($pokemon) { $pokemon->{substructures}[1]{movements}[2] = $MOVE_ICE_BEAM; $pokemon->{substructures}[1]{movements}[3] = $MOVE_FOCUS_PUNCH; $pokemon->{substructures}[0]{held_item} = $ITEM_LEFTOVERS; - print Data::Dumper::Dumper $pokemon; } sub modifyMoltres ($pokemon) { - print Data::Dumper::Dumper $pokemon; $pokemon->{personality} = 0x336E4D34; my $ivs_egg_status_and_ability = $pokemon->{substructures}[3]{ivs_egg_status_and_ability}; - say _hihalf_u32( $pokemon->{otid} ); - say _lowhalf_u32( $pokemon->{otid} ); my $ability = $ivs_egg_status_and_ability >> 31 & 1; my $egg = $ivs_egg_status_and_ability >> 30 & 1; my $iv_special_defense = $ivs_egg_status_and_ability >> 25 & 0x1F; @@ -142,7 +136,6 @@ sub modifyMoltres ($pokemon) { $pokemon->{substructures}[1]{movements}[2] = $MOVE_WILL_O_WISP; $pokemon->{substructures}[1]{movements}[3] = $MOVE_ROAR; $pokemon->{substructures}[0]{held_item} = $ITEM_LEFTOVERS; - print Data::Dumper::Dumper $pokemon; } sub _hihalf_u32 { diff --git a/lib/Rsaves.pm b/lib/Rsaves.pm index 27e8bd0..72b732f 100644 --- a/lib/Rsaves.pm +++ b/lib/Rsaves.pm @@ -29,7 +29,7 @@ our @EXPORT_OK = ( read_pkm_file_box calculate_shiny_personality pokemon_set_shiny get_first_super_data set_first_super_data enable_rematch_main_legendary check_flag_id enable_mirage_island_for_pokemon parse_version_name - enable_deoxys_firered match_again_rival_firered_cerulean pokemon_fill_pp/ + enable_deoxys_firered match_again_rival_firered_cerulean pokemon_fill_pp to_3rd_encoding translate_3rd_encoding/ ); my $SAVE_SIZE = 57344; @@ -271,7 +271,15 @@ sub _write_pokemon_fh { } print $fh pack 'V', $pokemon->{personality}; print $fh pack 'V', $pokemon->{otid}; - print $fh $pokemon->{nickname}; + my $nickname = $pokemon->{nickname}; + if (length $nickname < 10) { + $nickname .= chr(0xff); + my $to_add = 10 - length $nickname; + for (my $i = 0; $i < $to_add; $i++) { + $nickname .= chr(int(rand(256))); + } + } + print $fh $nickname; print $fh pack 'C', $pokemon->{language}; print $fh pack 'C', $pokemon->{flags_eggs}; print $fh $pokemon->{ot_name}; @@ -449,7 +457,7 @@ sub _write_pokemon_substruct_fh { my %translate_encoding_table; my %translate_real_table; { - my $counter = hex 'BB'; + my $counter = 0xBB; for my $char ( 'A' .. 'Z', 'a' .. 'z' ) { $translate_encoding_table{ chr($counter) } = $char; $translate_real_table{$char} = chr($counter); @@ -461,7 +469,7 @@ sub _write_pokemon_substruct_fh { $translate_encoding_table{ chr(0xB6) } = '♀'; } - sub _to_3rd_encoding { + sub to_3rd_encoding { my $text = shift; my @chars = split '', $text; my $return_text = ''; @@ -471,7 +479,7 @@ sub _write_pokemon_substruct_fh { return $return_text; } - sub _translate_3rd_encoding { + sub translate_3rd_encoding { my $text = shift; my @chars = split '', $text; my $return_text = ''; diff --git a/mudkip.sav b/mudkip.sav index 87cb7cb..e3e77f6 100644 Binary files a/mudkip.sav and b/mudkip.sav differ