Rsaves/examples/all_pokemon_shiny.pl

39 lines
1.2 KiB
Perl

#!/usr/bin/env perl
use v5.34.1;
use strict;
use warnings;
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/;
use Rsaves::Constants::Ruby::Global qw/$MALE $FEMALE/;
sub start {
my ( @saves_raw, $extra );
( @saves_raw[ 0, 1 ], $extra ) = read_save('ruby.sav');
check_correct_size( @saves_raw, $extra );
my @saves = get_saves(@saves_raw);
my $current_save_index = find_current_save_index(@saves);
my $save = $saves[$current_save_index];
make_all_pokemon_shiny($save);
save_changes( @saves, $extra, 'ruby1.sav' );
}
sub make_all_pokemon_shiny {
my $save = shift;
my $pc = read_pc_storage($save);
for my $box ( $pc->{boxes}->@* ) {
for my $pokemon ( $box->@* ) {
my $substructures = $pokemon->{substructures};
my $substruct0 = find_pokemon_substruct( $substructures, 0 );
if ( $substruct0->{species} ) {
pokemon_set_shiny($pokemon);
}
}
}
save_pc_changes( $save, $pc );
}
start;