Adding code to enable the mirage island.

This commit is contained in:
sergiotarxz 2023-01-30 22:32:58 +01:00
parent 88527cd148
commit 5ca3a85937
2 changed files with 42 additions and 2 deletions

View File

@ -0,0 +1,27 @@
#!/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 enable_mirage_island_for_pokemon/;
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];
# Sightly more complex for other flags, take a look to enable_eon_ticket to see how it works.
my $pc = read_pc_storage($save);
my $pokemon = $pc->{boxes}[0][4];
enable_mirage_island_for_pokemon($save, $pokemon);
save_changes( @saves, $extra, 'ruby1.sav' );
}
start;

View File

@ -8,7 +8,7 @@ use warnings;
use Data::Dumper;
use Rsaves::Constants::Ruby::Flags qw/$FLAG_SYS_HAS_EON_TICKET $FLAG_LEGENDARY_BATTLE_COMPLETED $FLAG_HIDE_LEGEND_MON_CAVE_OF_ORIGIN/;
use Rsaves::Constants::Ruby::Vars qw/$VAR_CAVE_OF_ORIGIN_B4F_STATE $VARS_START/;
use Rsaves::Constants::Ruby::Vars qw/$VAR_CAVE_OF_ORIGIN_B4F_STATE $VARS_START $VAR_MIRAGE_RND_H/;
use Exporter;
@ -20,7 +20,7 @@ our @EXPORT_OK = (
find_current_save_index check_correct_size find_pokemon_substruct
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/
check_flag_id enable_mirage_island_for_pokemon/
);
my $SAVE_SIZE = 57344;
@ -750,6 +750,19 @@ sub enable_eon_ticket {
set_first_super_data( $save, $superdata );
}
sub enable_mirage_island_for_pokemon {
my $save = shift;
my $pokemon = shift;
my $superdata = get_first_super_data($save);
my $personality = $pokemon->{personality};
my $substruct0 = find_pokemon_substruct($pokemon->{substructures}, 0);
say $substruct0->{species};
printf "%x\n", $personality & 0xffff;
set_var($save, $superdata, $VAR_MIRAGE_RND_H, $personality & 0xffff);
set_first_super_data ( $save, $superdata );
}
sub enable_rematch_main_legendary {
my $save = shift;
my $superdata = get_first_super_data($save);