Skip to content
3 changes: 3 additions & 0 deletions SerialPrograms/Source/Pokemon/Pokemon_AdvRng.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ void level_up_observed_pokemon(AdvObservedPokemon& pokemon, const StatReads& new
// returns the appropriate NatureAdjustments for an AdvNature
Pokemon::NatureAdjustments nature_to_adjustment(AdvNature nature);

// returns the appropriate NatureAdjustments for an AdvNature
Pokemon::NatureAdjustments nature_to_adjustment(AdvNature nature);

// returns search filters that correspond with observed stats
AdvRngFilters observation_to_filters(const AdvObservedPokemon& observation, const BaseStats& basestats, AdvRngMethod method = AdvRngMethod::Method1);

Expand Down
60 changes: 60 additions & 0 deletions SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "PokemonFRLG/Inference/Menus/PokemonFRLG_LoadMenuDetector.h"
#include "PokemonFRLG/Inference/Menus/PokemonFRLG_SummaryDetector.h"
#include "PokemonFRLG/Inference/Menus/PokemonFRLG_PartyMenuDetector.h"
#include "PokemonFRLG/Inference/Menus/PokemonFRLG_BagDetector.h"
#include "PokemonFRLG/Inference/Map/PokemonFRLG_MapDetector.h"
#include "PokemonFRLG/Inference/PokemonFRLG_BattlePokemonDetector.h"
#include "PokemonFRLG/Programs/PokemonFRLG_StartMenuNavigation.h"
Expand Down Expand Up @@ -678,6 +679,65 @@ void open_party_menu_from_overworld(ConsoleHandle& console, ProControllerContext
}
}

void open_bag_from_overworld(ConsoleHandle& console, ProControllerContext& context, StartMenuContext menu_context){
uint16_t errors = 0;
bool start_menu_is_open = false;
while (true){
if (errors > 5){
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"open_party_menu_from_overworld(): Failed to open party menu 5 times in a row.",
console
);
}

context.wait_for_all_requests();
if (!start_menu_is_open){
open_start_menu(console, context); // This is unavoidable since we cannot detect the overworld.
start_menu_is_open = true;
}

StartMenuWatcher start_menu(COLOR_RED);
BagWatcher bag(COLOR_RED);

int ret = wait_until(
console, context, 10000ms,
{ start_menu, bag }
);

switch (ret){
case 0:
if (menu_context == StartMenuContext::SAFARI_ZONE){
ret = move_cursor_to_position(console, context, SelectionArrowPositionSafariMenu::BAG);
} else {
ret = move_cursor_to_position(console, context, SelectionArrowPositionStartMenu::BAG);
}

if (ret < 0){
console.log("Failed to navigate to BAG on the start menu.");
errors++;
context.wait_for_all_requests();
pbf_mash_button(context, BUTTON_B, 2000ms);
start_menu_is_open = false;
} else {
console.log("Navigated to BAG on the start menu");
context.wait_for_all_requests();
pbf_press_button(context, BUTTON_A, 200ms, 1300ms);
}
continue;
case 1:
console.log("Bag opened.");
return;
default:
console.log("Failed to open bag.");
errors++;
pbf_mash_button(context, BUTTON_B, 2000ms);
start_menu_is_open = false;
continue;
}
}
}

void use_teleport_from_overworld(ConsoleHandle& console, ProControllerContext& context){
uint16_t errors = 0;

Expand Down
3 changes: 3 additions & 0 deletions SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Navigation.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ enum class StartMenuContext {
};
void open_party_menu_from_overworld(ConsoleHandle& console, ProControllerContext& context, StartMenuContext menu_context = StartMenuContext::STANDARD);

// Starting from the start menu, a sub-screen of the start menu, or the overworld, navigate to the bag
void open_bag_from_overworld(ConsoleHandle& console, ProControllerContext& context, StartMenuContext menu_context = StartMenuContext::STANDARD);

// Uses Teleport to return to a PokeCenter.
// Assumes that Teleport is usable and the last party member has it learned
void use_teleport_from_overworld(ConsoleHandle& console, ProControllerContext& context);
Expand Down
2 changes: 2 additions & 0 deletions SerialPrograms/Source/PokemonFRLG/PokemonFRLG_Panels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "Programs/RngManipulation/PokemonFRLG_RngHelper.h"
#include "Programs/RngManipulation/PokemonFRLG_SidHelper.h"
#include "Programs/RngManipulation/PokemonFRLG_StarterRng.h"
#include "Programs/RngManipulation/PokemonFRLG_GiftRng.h"
#include "Programs/TestPrograms/PokemonFRLG_SoundListener.h"
#include "Programs/TestPrograms/PokemonFRLG_ReadStats.h"
#include "Programs/TestPrograms/PokemonFRLG_ReadBattleLevelUp.h"
Expand Down Expand Up @@ -69,6 +70,7 @@ std::vector<PanelEntry> PanelListFactory::make_panels() const{
ret.emplace_back(make_single_switch_program<ItemDuplication_Descriptor, ItemDuplication>());
ret.emplace_back(make_single_switch_program<SidHelper_Descriptor, SidHelper>());
ret.emplace_back(make_single_switch_program<StarterRng_Descriptor, StarterRng>());
ret.emplace_back(make_single_switch_program<GiftRng_Descriptor, GiftRng>());
}

if (PreloadSettings::instance().DEVELOPER_MODE){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ void set_seed_after_delay(ProControllerContext& context, SeedButton SEED_BUTTON,

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

Expand Down
Loading