Skip to content

Commit 90aedaa

Browse files
authored
FRLG Gift Auto-RNG (#1216)
* gift rng program * fix gender threshold stuff * calibration and other fixes * more small fixes * even more tweaks to resets * fix issue with signedness * rework rng resets * make displayed seed calibrations ints * include cmath * remove copy/paste mistake * another copy/paste fix * add missing targets to check_for_shiny
1 parent a5b3d2d commit 90aedaa

13 files changed

Lines changed: 1020 additions & 84 deletions

SerialPrograms/Source/Pokemon/Pokemon_AdvRng.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ void level_up_observed_pokemon(AdvObservedPokemon& pokemon, const StatReads& new
135135
// returns the appropriate NatureAdjustments for an AdvNature
136136
Pokemon::NatureAdjustments nature_to_adjustment(AdvNature nature);
137137

138+
// returns the appropriate NatureAdjustments for an AdvNature
139+
Pokemon::NatureAdjustments nature_to_adjustment(AdvNature nature);
140+
138141
// returns search filters that correspond with observed stats
139142
AdvRngFilters observation_to_filters(const AdvObservedPokemon& observation, const BaseStats& basestats, AdvRngMethod method = AdvRngMethod::Method1);
140143

SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Navigation.cpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "PokemonFRLG/Inference/Menus/PokemonFRLG_LoadMenuDetector.h"
2727
#include "PokemonFRLG/Inference/Menus/PokemonFRLG_SummaryDetector.h"
2828
#include "PokemonFRLG/Inference/Menus/PokemonFRLG_PartyMenuDetector.h"
29+
#include "PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.h"
2930
#include "PokemonFRLG/Inference/Map/PokemonFRLG_MapDetector.h"
3031
#include "PokemonFRLG/Inference/PokemonFRLG_BattlePokemonDetector.h"
3132
#include "PokemonFRLG/Programs/PokemonFRLG_StartMenuNavigation.h"
@@ -678,6 +679,65 @@ void open_party_menu_from_overworld(ConsoleHandle& console, ProControllerContext
678679
}
679680
}
680681

682+
void open_bag_from_overworld(ConsoleHandle& console, ProControllerContext& context, StartMenuContext menu_context){
683+
uint16_t errors = 0;
684+
bool start_menu_is_open = false;
685+
while (true){
686+
if (errors > 5){
687+
OperationFailedException::fire(
688+
ErrorReport::SEND_ERROR_REPORT,
689+
"open_party_menu_from_overworld(): Failed to open party menu 5 times in a row.",
690+
console
691+
);
692+
}
693+
694+
context.wait_for_all_requests();
695+
if (!start_menu_is_open){
696+
open_start_menu(console, context); // This is unavoidable since we cannot detect the overworld.
697+
start_menu_is_open = true;
698+
}
699+
700+
StartMenuWatcher start_menu(COLOR_RED);
701+
BagWatcher bag(COLOR_RED);
702+
703+
int ret = wait_until(
704+
console, context, 10000ms,
705+
{ start_menu, bag }
706+
);
707+
708+
switch (ret){
709+
case 0:
710+
if (menu_context == StartMenuContext::SAFARI_ZONE){
711+
ret = move_cursor_to_position(console, context, SelectionArrowPositionSafariMenu::BAG);
712+
} else {
713+
ret = move_cursor_to_position(console, context, SelectionArrowPositionStartMenu::BAG);
714+
}
715+
716+
if (ret < 0){
717+
console.log("Failed to navigate to BAG on the start menu.");
718+
errors++;
719+
context.wait_for_all_requests();
720+
pbf_mash_button(context, BUTTON_B, 2000ms);
721+
start_menu_is_open = false;
722+
} else {
723+
console.log("Navigated to BAG on the start menu");
724+
context.wait_for_all_requests();
725+
pbf_press_button(context, BUTTON_A, 200ms, 1300ms);
726+
}
727+
continue;
728+
case 1:
729+
console.log("Bag opened.");
730+
return;
731+
default:
732+
console.log("Failed to open bag.");
733+
errors++;
734+
pbf_mash_button(context, BUTTON_B, 2000ms);
735+
start_menu_is_open = false;
736+
continue;
737+
}
738+
}
739+
}
740+
681741
void use_teleport_from_overworld(ConsoleHandle& console, ProControllerContext& context){
682742
uint16_t errors = 0;
683743

SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Navigation.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ enum class StartMenuContext {
7676
};
7777
void open_party_menu_from_overworld(ConsoleHandle& console, ProControllerContext& context, StartMenuContext menu_context = StartMenuContext::STANDARD);
7878

79+
// Starting from the start menu, a sub-screen of the start menu, or the overworld, navigate to the bag
80+
void open_bag_from_overworld(ConsoleHandle& console, ProControllerContext& context, StartMenuContext menu_context = StartMenuContext::STANDARD);
81+
7982
// Uses Teleport to return to a PokeCenter.
8083
// Assumes that Teleport is usable and the last party member has it learned
8184
void use_teleport_from_overworld(ConsoleHandle& console, ProControllerContext& context);

SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Panels.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "Programs/RngManipulation/PokemonFRLG_RngHelper.h"
2424
#include "Programs/RngManipulation/PokemonFRLG_SidHelper.h"
2525
#include "Programs/RngManipulation/PokemonFRLG_StarterRng.h"
26+
#include "Programs/RngManipulation/PokemonFRLG_GiftRng.h"
2627
#include "Programs/TestPrograms/PokemonFRLG_SoundListener.h"
2728
#include "Programs/TestPrograms/PokemonFRLG_ReadStats.h"
2829
#include "Programs/TestPrograms/PokemonFRLG_ReadBattleLevelUp.h"
@@ -69,6 +70,7 @@ std::vector<PanelEntry> PanelListFactory::make_panels() const{
6970
ret.emplace_back(make_single_switch_program<ItemDuplication_Descriptor, ItemDuplication>());
7071
ret.emplace_back(make_single_switch_program<SidHelper_Descriptor, SidHelper>());
7172
ret.emplace_back(make_single_switch_program<StarterRng_Descriptor, StarterRng>());
73+
ret.emplace_back(make_single_switch_program<GiftRng_Descriptor, GiftRng>());
7274
}
7375

7476
if (PreloadSettings::instance().DEVELOPER_MODE){

SerialPrograms/Source/PokemonFRLG/Programs/RngManipulation/PokemonFRLG_BlindNavigation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ void set_seed_after_delay(ProControllerContext& context, SeedButton SEED_BUTTON,
6262

6363
void load_game_after_delay(ProControllerContext& context, uint64_t CONTINUE_SCREEN_DELAY){
6464
pbf_wait(context, std::chrono::milliseconds(CONTINUE_SCREEN_DELAY - 3000));
65-
pbf_press_button(context, BUTTON_A, 33ms, 1467ms);
65+
pbf_press_button(context, BUTTON_A, 50ms, 1450ms);
6666
// skip recap
67-
pbf_press_button(context, BUTTON_B, 33ms, 2467ms);
67+
pbf_press_button(context, BUTTON_B, 50ms, 2450ms);
6868
// need to later subtract 4000ms from delay to hit desired number of advances
6969
}
7070

0 commit comments

Comments
 (0)