From acdb930f00b15e0b274086e39c9206ba7ba6d122 Mon Sep 17 00:00:00 2001 From: jw098 Date: Sun, 1 Dec 2024 12:30:46 -0800 Subject: [PATCH] update autostory segments and DialogArrowDetector (#514) --- .../Dialogs/PokemonSV_DialogArrowDetector.cpp | 23 +++--- .../Dialogs/PokemonSV_DialogArrowDetector.h | 1 + .../Overworld/PokemonSV_DirectionDetector.cpp | 2 +- .../AutoStory/PokemonSV_AutoStoryTools.cpp | 22 ++++-- .../AutoStory/PokemonSV_AutoStoryTools.h | 7 +- .../PokemonSV_AutoStory_Segment_01.cpp | 23 +++--- .../PokemonSV_AutoStory_Segment_02.cpp | 21 ++--- .../PokemonSV_AutoStory_Segment_03.cpp | 34 +++++--- .../PokemonSV_AutoStory_Segment_04.cpp | 56 +++++++------ .../PokemonSV_AutoStory_Segment_05.cpp | 24 ++++-- .../PokemonSV_AutoStory_Segment_06.cpp | 13 +++- .../PokemonSV_AutoStory_Segment_07.cpp | 78 +++++++++---------- .../PokemonSV_AutoStory_Segment_09.cpp | 8 +- .../PokemonSV_AutoStory_Segment_10.cpp | 60 ++++++++++---- .../Programs/PokemonSV_Navigation.cpp | 7 +- .../PokemonSV/Programs/PokemonSV_SaveGame.cpp | 3 + 16 files changed, 232 insertions(+), 150 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Inference/Dialogs/PokemonSV_DialogArrowDetector.cpp b/SerialPrograms/Source/PokemonSV/Inference/Dialogs/PokemonSV_DialogArrowDetector.cpp index 2f32f785d..c6bb8eb74 100644 --- a/SerialPrograms/Source/PokemonSV/Inference/Dialogs/PokemonSV_DialogArrowDetector.cpp +++ b/SerialPrograms/Source/PokemonSV/Inference/Dialogs/PokemonSV_DialogArrowDetector.cpp @@ -16,9 +16,9 @@ #include "CommonFramework/ImageMatch/ExactImageMatcher.h" #include "PokemonSV_DialogArrowDetector.h" -// #include -// using std::cout; -// using std::endl; +#include +using std::cout; +using std::endl; namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -188,19 +188,24 @@ void DialogArrowWatcher::make_overlays(VideoOverlaySet& items) const{ // - every time the arrow is above top_line, increment m_num_oscillation_above_top_line. // - likewise for m_num_oscillation_below_bottom_line // - we alternate between looking for the arrow being above top_line vs below bottom_line -// - reset counts whenever the dialog arrow is not detected +// - reset counts whenever the dialog arrow has not been detected for 10 frames consecutively bool DialogArrowWatcher::process_frame(const ImageViewRGB32& frame, WallClock timestamp){ std::pair arrow_location = m_detector.locate_dialog_arrow(frame); double y_location = arrow_location.second; // cout << std::to_string(y_location) << endl; if (y_location < 0){ // dialog arrow not detected - // reset oscillation counts - m_num_oscillation_above_top_line = 0; - m_num_oscillation_below_bottom_line = 0; - return false; + m_num_no_detection++; + if (m_num_no_detection > 10){ + // reset oscillation counts + m_num_oscillation_above_top_line = 0; + m_num_oscillation_below_bottom_line = 0; + } + return false; + }else{ + m_num_no_detection = 0; } - + if (m_num_oscillation_above_top_line >= 5 && m_num_oscillation_below_bottom_line >= 5){ // we have had 5 oscillations above and below the top and bottom line respectively return true; diff --git a/SerialPrograms/Source/PokemonSV/Inference/Dialogs/PokemonSV_DialogArrowDetector.h b/SerialPrograms/Source/PokemonSV/Inference/Dialogs/PokemonSV_DialogArrowDetector.h index 6c2f242e8..4fae2412b 100644 --- a/SerialPrograms/Source/PokemonSV/Inference/Dialogs/PokemonSV_DialogArrowDetector.h +++ b/SerialPrograms/Source/PokemonSV/Inference/Dialogs/PokemonSV_DialogArrowDetector.h @@ -55,6 +55,7 @@ class DialogArrowWatcher : public VisualInferenceCallback{ double m_bottom_line; uint16_t m_num_oscillation_above_top_line; uint16_t m_num_oscillation_below_bottom_line; + uint16_t m_num_no_detection; // FixedLimitVector m_arrows; }; diff --git a/SerialPrograms/Source/PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.cpp b/SerialPrograms/Source/PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.cpp index 9bb74b3fe..10c4b0457 100644 --- a/SerialPrograms/Source/PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.cpp +++ b/SerialPrograms/Source/PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.cpp @@ -215,7 +215,7 @@ void DirectionDetector::change_direction( } is_minimap_definitely_unlocked = true; - if (abs_diff < 0.01){ + if (abs_diff < 0.0105){ // return when we're close enough to the target return; } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index 75591bc34..149fc5e3e 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -489,8 +489,8 @@ void overworld_navigation( context.wait_for_all_requests(); try { realign_player(info, console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - if (!confirm_marker_present(info, console, context)){ - // if marker not present, don't keep walking forward. + if (stop_condition == NavigationStopCondition::STOP_MARKER && !confirm_marker_present(info, console, context)){ + // if marker not present when using marker based navigation, don't keep walking forward. return; } @@ -632,7 +632,7 @@ void change_settings(SingleSwitchProgramEnvironment& env, BotBaseContext& contex {MenuOptionItemEnum::GIVE_NICKNAMES, {MenuOptionToggleEnum::OFF}}, {MenuOptionItemEnum::VERTICAL_CAMERA_CONTROLS, {MenuOptionToggleEnum::REGULAR, MenuOptionToggleEnum::NORMAL}}, {MenuOptionItemEnum::HORIZONTAL_CAMERA_CONTROLS, {MenuOptionToggleEnum::REGULAR, MenuOptionToggleEnum::NORMAL}}, - {MenuOptionItemEnum::CAMERA_SUPPORT, {MenuOptionToggleEnum::ON}}, + {MenuOptionItemEnum::CAMERA_SUPPORT, {MenuOptionToggleEnum::OFF}}, {MenuOptionItemEnum::CAMERA_INTERPOLATION, {MenuOptionToggleEnum::NORMAL, MenuOptionToggleEnum::AVERAGE}}, {MenuOptionItemEnum::CAMERA_DISTANCE, {MenuOptionToggleEnum::CLOSE}}, {MenuOptionItemEnum::AUTOSAVE, {MenuOptionToggleEnum::OFF}}, @@ -650,7 +650,7 @@ void change_settings(SingleSwitchProgramEnvironment& env, BotBaseContext& contex config_option(context, 1); // Give Nicknames: Off config_option(context, 0); // Vertical Camera Controls: Regular config_option(context, 0); // Horiztontal Camera Controls: Regular - config_option(context, 0); // Camera Support: On + config_option(context, 1); // Camera Support: Off config_option(context, 0); // Camera Interpolation: Normal config_option(context, 0); // Camera Distance: Close config_option(context, 1); // Autosave: Off @@ -853,7 +853,7 @@ void press_A_until_dialog(const ProgramInfo& info, ConsoleHandle& console, BotBa } } -bool check_ride_active(const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ +bool is_ride_active(const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ while (true){ try { // open main menu @@ -879,14 +879,22 @@ bool check_ride_active(const ProgramInfo& info, ConsoleHandle& console, BotBaseC } void get_on_ride(const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + get_on_or_off_ride(info, console, context, true); +} + +void get_off_ride(const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + get_on_or_off_ride(info, console, context, false); +} + +void get_on_or_off_ride(const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context, bool get_on){ pbf_press_button(context, BUTTON_PLUS, 20, 20); WallClock start = current_time(); - while (!check_ride_active(info, console, context)){ + while (get_on != is_ride_active(info, console, context)){ if (current_time() - start > std::chrono::minutes(3)){ throw OperationFailedException( ErrorReport::SEND_ERROR_REPORT, console, - "get_on_ride(): Failed to get on ride after 3 minutes.", + "get_on_or_off_ride(): Failed to get on/off ride after 3 minutes.", true ); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h index 8823ab86d..21bc10d85 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h @@ -230,10 +230,15 @@ void wait_for_overworld( void press_A_until_dialog(const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context, uint16_t seconds_between_button_presses); -bool check_ride_active(const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context); +// return true if ride is active. i.e. if you are on your ride +bool is_ride_active(const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context); void get_on_ride(const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context); +void get_off_ride(const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context); + +void get_on_or_off_ride(const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context, bool get_on); + // change the settings prior to Autostory // Assumes that `current_segment` represents where we currently are in the story. diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.cpp index abb617b76..03c324d25 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.cpp @@ -17,6 +17,7 @@ #include "PokemonSV/Programs/PokemonSV_GameEntry.h" #include "PokemonSV/Programs/PokemonSV_SaveGame.h" #include "PokemonSV/Inference/PokemonSV_TutorialDetector.h" +#include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" #include "PokemonSV_AutoStoryTools.h" #include "PokemonSV_AutoStory_Segment_01.h" @@ -83,7 +84,6 @@ AutoStoryStats& stats = env.current_stats(); stats.m_checkpoint++; env.update_stats(); send_program_status_notification(env, notif_status_update, "Saved at checkpoint."); - first_attempt = false; } context.wait_for_all_requests(); @@ -91,6 +91,7 @@ AutoStoryStats& stats = env.current_stats(); enter_menu_from_overworld(env.program_info(), env.console, context, 0, MenuSide::RIGHT, false); change_settings(env, context, language, first_attempt); pbf_mash_button(context, BUTTON_B, 2 * TICKS_PER_SECOND); + context.wait_for_all_requests(); break; }catch(...){ @@ -114,7 +115,7 @@ void checkpoint_02( bool first_attempt = true; while (true){ try{ - if(!first_attempt){ + if(first_attempt){ save_game_tutorial(env.program_info(), env.console, context); stats.m_checkpoint++; env.update_stats(); @@ -179,14 +180,8 @@ void checkpoint_02( env.console.log("clear_dialog: Talk with Clavell outside. Receive Rotom phone. Stop when detect overworld."); clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::OVERWORLD, CallbackEnum::WHITE_A_BUTTON}); - context.wait_for_all_requests(); - env.console.log("Bump into power of science NPC"); - // console.overlay().add_log("Bump into power of science NPC", COLOR_WHITE); - pbf_move_left_joystick(context, 128, 0, 33 * TICKS_PER_SECOND, 20); - context.wait_for_all_requests(); env.console.log("Clear map tutorial"); - // console.overlay().add_log("Clear map tutorial", COLOR_WHITE); open_map_from_overworld(env.program_info(), env.console, context, true); leave_phone_to_overworld(env.program_info(), env.console, context); @@ -218,11 +213,13 @@ void checkpoint_03( } context.wait_for_all_requests(); - - pbf_move_left_joystick(context, 255, 0, 1 * TICKS_PER_SECOND, 20); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 156, 1 * TICKS_PER_SECOND); - env.console.log("overworld_navigation(): Go to Nemona's house."); - overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, 128, 0); + DirectionDetector direction; + direction.change_direction(env.program_info(), env.console, context, 4.62); + pbf_move_left_joystick(context, 128, 0, 3600, 50); + pbf_move_left_joystick(context, 0, 128, 30, 50); + + direction.change_direction(env.program_info(), env.console, context, 4.62); + walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 20); context.wait_for_all_requests(); env.console.log("Entered Nemona's house"); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.cpp index 9dc1a1ee2..0a22ddda6 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.cpp @@ -17,6 +17,7 @@ #include "PokemonSV/Programs/PokemonSV_GameEntry.h" #include "PokemonSV/Programs/PokemonSV_SaveGame.h" #include "PokemonSV/Inference/PokemonSV_TutorialDetector.h" +#include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" #include "PokemonSV_AutoStoryTools.h" #include "PokemonSV_AutoStory_Segment_02.h" @@ -80,27 +81,21 @@ void checkpoint_04( } context.wait_for_all_requests(); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 220, 245, 50); - pbf_move_left_joystick(context, 128, 0, 4 * TICKS_PER_SECOND, 1 * TICKS_PER_SECOND); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 128, 50); - pbf_move_left_joystick(context, 128, 0, 4 * TICKS_PER_SECOND, 1 * TICKS_PER_SECOND); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 60, 50); - pbf_move_left_joystick(context, 128, 0, 4 * TICKS_PER_SECOND, 2 * TICKS_PER_SECOND); - env.console.log("overworld_navigation: Go to Nemona at the beach."); - overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_SPAM_A, 128, 0, 8); - - context.wait_for_all_requests(); - env.console.overlay().add_log("Found Nemona", COLOR_WHITE); + DirectionDetector direction; + direction.change_direction(env.program_info(), env.console, context, 3.72); + pbf_move_left_joystick(context, 128, 0, 400, 50); + direction.change_direction(env.program_info(), env.console, context, 4.55); + pbf_move_left_joystick(context, 128, 0, 600, 50); + direction.change_direction(env.program_info(), env.console, context, 5.27); + walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_SPAM_A, 20); context.wait_for_all_requests(); env.console.log("Starting battle..."); - env.console.overlay().add_log("Starting battle...", COLOR_WHITE); // TODO: Battle start prompt detection // can lose this battle, and story will continue mash_button_till_overworld(env.console, context); context.wait_for_all_requests(); env.console.log("Finished battle."); - env.console.overlay().add_log("Finished battle.", COLOR_WHITE); break; }catch(...){ diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.cpp index 9d3badf0e..0c83c0af4 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.cpp @@ -16,7 +16,7 @@ #include "PokemonSwSh/Inference/PokemonSwSh_IvJudgeReader.h" #include "PokemonSV/Programs/PokemonSV_GameEntry.h" #include "PokemonSV/Programs/PokemonSV_SaveGame.h" -#include "PokemonSV/Inference/PokemonSV_TutorialDetector.h" +#include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" #include "PokemonSV_AutoStoryTools.h" #include "PokemonSV_AutoStory_Segment_03.h" @@ -82,11 +82,11 @@ void checkpoint_05( } context.wait_for_all_requests(); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 40, 160, 60); - pbf_move_left_joystick(context, 128, 0, 7 * TICKS_PER_SECOND, 20); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 40, 84, 60); - env.console.log("overworld_navigation: Go to mom at the gate."); - overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, 128, 0, 20); + DirectionDetector direction; + direction.change_direction(env.program_info(), env.console, context, 1.92); + pbf_move_left_joystick(context, 128, 0, 7 * TICKS_PER_SECOND, 50); + direction.change_direction(env.program_info(), env.console, context, 1.13); + walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 20); context.wait_for_all_requests(); env.console.log("Get mom's sandwich"); @@ -123,7 +123,7 @@ void checkpoint_06( pbf_move_left_joystick(context, 128, 0, 6 * TICKS_PER_SECOND, 20); realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 110, 10, 60); env.console.log("overworld_navigation: Go to Nemona."); - overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, 128, 0, 20); + overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, 128, 0, 20, 20, true, true); context.wait_for_all_requests(); env.console.log("clear_dialog: Talk with Nemona to start catch tutorial. Stop when detect battle."); @@ -171,11 +171,25 @@ void checkpoint_07( env.console.log("Move to cliff"); env.console.overlay().add_log("Move to cliff", COLOR_WHITE); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 240, 60, 80); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 70, 100); env.console.log("overworld_navigation: Go to cliff."); - overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, 116, 0, 72, 24, true, true); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_TIME, NavigationMovementMode::DIRECTIONAL_ONLY, + 135, 0, 24, 12, true, true); + + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 128, 0, 80); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 24, 12, true, true); + }, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + pbf_move_left_joystick(context, 0, 128, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); - env.console.log("clear_dialog: Talk to Nemona at the cliff. Stop when detect overworld."); clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::OVERWORLD}); context.wait_for_all_requests(); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.cpp index b944e0393..67cbd85b3 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.cpp @@ -81,13 +81,16 @@ void checkpoint_08( realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 230, 70, 100); env.console.log("overworld_navigation: Go to cliff."); - overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, 128, 0, true, true); + overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, 128, 0, 30, 30, true, true); - env.console.log("clear_dialog: Look over the injured Miraidon/Koraidon on the beach. Fall down the cliff"); - clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 30, {}); - // long animation - env.console.log("overworld_navigation: Go to Legendary pokemon laying on the beach."); - overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, 128, 0, 30, true, true); + env.console.log("Look over the injured Miraidon/Koraidon on the beach."); + clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 5, {}); + env.console.log("Fall down the cliff."); + pbf_wait(context, 20 * TICKS_PER_SECOND); // long animation + context.wait_for_all_requests(); + clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 10, {}); + env.console.log("Go to Legendary pokemon laying on the beach."); + walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_SPAM_A, 30); env.console.log("clear_dialog: Offer Miraidon/Koraidon a sandwich."); clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 10, {}); @@ -120,9 +123,10 @@ void checkpoint_08( // only press A when the sandwich is selected pbf_mash_button(context, BUTTON_A, 100); - env.console.log("clear_dialog: Miraidon/Koraidon gets up and walks to cave entrance."); - clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 35, {}); - // long animation + env.console.log("Miraidon/Koraidon eats the sandwich."); + clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 25, {}); + env.console.log("Miraidon/Koraidon gets up and walks to cave entrance."); // long animation + clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 10, {}); // First Nemona cave conversation context.wait_for_all_requests(); @@ -130,15 +134,15 @@ void checkpoint_08( env.console.overlay().add_log("Enter cave", COLOR_WHITE); do_action_and_monitor_for_battles(env.program_info(), env.console, context, [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ - pbf_move_left_joystick(context, 128, 20, 10 * TICKS_PER_SECOND, 20); - pbf_move_left_joystick(context, 150, 20, 1 * TICKS_PER_SECOND, 20); - pbf_move_left_joystick(context, 128, 20, 8 * TICKS_PER_SECOND, 20); - pbf_move_left_joystick(context, 150, 20, 2 * TICKS_PER_SECOND, 20); + pbf_move_left_joystick(context, 128, 0, 600, 50); + realign_player(env.program_info(), console, context, PlayerRealignMode::REALIGN_NO_MARKER, 150, 20, 20); + pbf_move_left_joystick(context, 128, 0, 1000, 50); + realign_player(env.program_info(), console, context, PlayerRealignMode::REALIGN_NO_MARKER, 160, 20, 20); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 20, true, true); } - ); - - env.console.log("overworld_navigation: Go to cave."); - overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, 128, 20, 10, true, true); + ); env.console.log("clear_dialog: Talk to Nemona yelling down, while you're down in the cave."); clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 10, {CallbackEnum::PROMPT_DIALOG}); @@ -157,14 +161,20 @@ void checkpoint_08( context.wait_for_all_requests(); console.log("Houndour wave"); console.overlay().add_log("Houndour wave", COLOR_WHITE); - pbf_move_left_joystick(context, 140, 20, 4 * TICKS_PER_SECOND, 2 * TICKS_PER_SECOND); - realign_player(env.program_info(), console, context, PlayerRealignMode::REALIGN_NO_MARKER, 220, 15, 30); - pbf_move_left_joystick(context, 128, 20, 5 * TICKS_PER_SECOND, 2 * TICKS_PER_SECOND); + // walk to room entrance + realign_player(env.program_info(), console, context, PlayerRealignMode::REALIGN_NO_MARKER, 150, 15, 30); + pbf_move_left_joystick(context, 128, 20, 4 * TICKS_PER_SECOND, 2 * TICKS_PER_SECOND); + + realign_player(env.program_info(), console, context, PlayerRealignMode::REALIGN_NO_MARKER, 210, 15, 30); + pbf_move_left_joystick(context, 128, 20, 3 * TICKS_PER_SECOND, 2 * TICKS_PER_SECOND); + pbf_move_left_joystick(context, 128, 20, 2 * TICKS_PER_SECOND, 2 * TICKS_PER_SECOND); pbf_move_left_joystick(context, 128, 20, 6 * TICKS_PER_SECOND, 2 * TICKS_PER_SECOND); - realign_player(env.program_info(), console, context, PlayerRealignMode::REALIGN_NO_MARKER, 220, 25, 20); + + realign_player(env.program_info(), console, context, PlayerRealignMode::REALIGN_NO_MARKER, 200, 25, 20); pbf_move_left_joystick(context, 128, 20, 4 * TICKS_PER_SECOND, 2 * TICKS_PER_SECOND); pbf_move_left_joystick(context, 128, 20, 4 * TICKS_PER_SECOND, 2 * TICKS_PER_SECOND); - realign_player(env.program_info(), console, context, PlayerRealignMode::REALIGN_NO_MARKER, 220, 25, 25); + + realign_player(env.program_info(), console, context, PlayerRealignMode::REALIGN_NO_MARKER, 210, 25, 25); pbf_move_left_joystick(context, 128, 20, 6 * TICKS_PER_SECOND, 20 * TICKS_PER_SECOND); // Houndoom encounter @@ -181,7 +191,7 @@ void checkpoint_08( ); env.console.log("overworld_navigation: Go to Houndoom."); - overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, 128, 20, 40, true, true); + overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, 128, 0, 20, 20, true, true); mash_button_till_overworld(env.console, context, BUTTON_A); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp index 746319ee6..321cb6ec2 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp @@ -16,7 +16,7 @@ #include "PokemonSwSh/Inference/PokemonSwSh_IvJudgeReader.h" #include "PokemonSV/Programs/PokemonSV_GameEntry.h" #include "PokemonSV/Programs/PokemonSV_SaveGame.h" -#include "PokemonSV/Inference/PokemonSV_TutorialDetector.h" +#include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" #include "PokemonSV_AutoStoryTools.h" #include "PokemonSV_AutoStory_Segment_05.h" @@ -81,9 +81,20 @@ void checkpoint_09( } context.wait_for_all_requests(); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 230, 120, 100); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 110, 50); env.console.log("overworld_navigation: Go to Arven at the tower."); - overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, 128, 0, true, true); + + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 60, 30, true, true); + }, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + pbf_move_left_joystick(context, 0, 128, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); context.wait_for_all_requests(); env.console.log("Found Arven"); @@ -126,14 +137,13 @@ void checkpoint_10( realign_player(env.program_info(), console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 230, 110, 100); pbf_move_left_joystick(context, 128, 0, 6 * TICKS_PER_SECOND, 8 * TICKS_PER_SECOND); pbf_move_left_joystick(context, 128, 0, 4 * TICKS_PER_SECOND, 20); - pbf_move_left_joystick(context, 255, 128, 15, 20); - pbf_press_button(context, BUTTON_L, 20, 20); - pbf_move_left_joystick(context, 128, 0, 7 * TICKS_PER_SECOND, 20); } ); + DirectionDetector direction; + direction.change_direction(env.program_info(), env.console, context, 5.41); env.console.log("overworld_navigation: Go to Nemona on the lighthouse."); - overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_SPAM_A, 128, 0, 20, true, true); + overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_SPAM_A, 128, 0, 20, 20, true, true); mash_button_till_overworld(env.console, context, BUTTON_A); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp index 3b6d63cf8..eeac83171 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp @@ -93,7 +93,18 @@ void checkpoint_11( ); env.console.log("overworld_navigation: Go to Los Platos."); - overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, 128, 0, 75, true, true); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 75, 75, true, true); + }, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + pbf_move_left_joystick(context, 0, 128, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + env.console.log("clear_dialog: Talk with Nemona at Los Platos. Clear Let's go tutorial. Stop when detect overworld."); clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::TUTORIAL, CallbackEnum::OVERWORLD}); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp index 1f338783b..0f66d818d 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp @@ -16,7 +16,7 @@ #include "PokemonSwSh/Inference/PokemonSwSh_IvJudgeReader.h" #include "PokemonSV/Programs/PokemonSV_GameEntry.h" #include "PokemonSV/Programs/PokemonSV_SaveGame.h" -#include "PokemonSV/Inference/PokemonSV_TutorialDetector.h" +#include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" #include "PokemonSV_AutoStoryTools.h" #include "PokemonSV_AutoStory_Segment_07.h" @@ -86,48 +86,42 @@ void checkpoint_12( bool first_attempt = true; while (true){ try{ - do_action_and_monitor_for_battles(env.program_info(), env.console, context, - [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + if (first_attempt){ + checkpoint_save(env, context, notif_status_update); + first_attempt = false; + } - if (first_attempt){ - checkpoint_save(env, context, notif_status_update); - first_attempt = false; - } - - context.wait_for_all_requests(); - - fly_to_overlapping_flypoint(info, env.console, context); - - // re-orient camera - pbf_press_button(context, BUTTON_L, 20, 20); - - walk_forward_while_clear_front_path(info, env.console, context, 35); - realign_player(info, env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 128, 0, 100); - walk_forward_while_clear_front_path(info, env.console, context, 500); - realign_player(info, env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 100, 0, 120); - walk_forward_while_clear_front_path(info, env.console, context, 2000); - realign_player(info, env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 0, 120); - walk_forward_while_clear_front_path(info, env.console, context, 1250); - - // check we're not still at the Los Platos Pokecenter. - confirm_no_overlapping_flypoint(info, env.console, context); - - // not stuck at Los Platos Pokecenter - pbf_press_button(context, BUTTON_B, 20, 1 * TICKS_PER_SECOND); - pbf_press_button(context, BUTTON_B, 20, 1 * TICKS_PER_SECOND); - press_Bs_to_back_to_overworld(info, env.console, context, 7); - - realign_player(info, env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 80, 0, 100); - walk_forward_while_clear_front_path(info, env.console, context, 1500); - realign_player(info, env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 30, 0, 50); - walk_forward_while_clear_front_path(info, env.console, context, 1000); - - fly_to_overlapping_flypoint(info, env.console, context); - - // heal_at_pokecenter(info, env.console, context); - - } - ); + fly_to_overlapping_flypoint(env.program_info(), env.console, context); + context.wait_for_all_requests(); + + // re-orient camera + pbf_press_button(context, BUTTON_L, 20, 20); + do_action_and_monitor_for_battles(env.program_info(), env.console, context, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + walk_forward_while_clear_front_path(env.program_info(), env.console, context, 35); + + // place the marker elsewhere + realign_player(info, env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 128, 50); + + DirectionDetector direction; + direction.change_direction(info, env.console, context, 0); + walk_forward_while_clear_front_path(info, env.console, context, 3300, 0, 125, 125); + + // check we're not still at the Los Platos Pokecenter. + confirm_no_overlapping_flypoint(info, env.console, context); + // not stuck at Los Platos Pokecenter + pbf_press_button(context, BUTTON_B, 20, 1 * TICKS_PER_SECOND); + pbf_press_button(context, BUTTON_B, 20, 1 * TICKS_PER_SECOND); + press_Bs_to_back_to_overworld(info, env.console, context, 7); + + direction.change_direction(info, env.console, context, 0.29); + walk_forward_while_clear_front_path(info, env.console, context, 1200, 0, 125, 125); + direction.change_direction(info, env.console, context, 0.61); + walk_forward_while_clear_front_path(info, env.console, context, 1200, 0, 125, 125); + + fly_to_overlapping_flypoint(info, env.console, context); + } + ); env.console.log("Reached Mesagoza (South) Pokecenter."); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp index bb1e302da..fedcbf65a 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp @@ -100,9 +100,9 @@ void checkpoint_16( context.wait_for_all_requests(); // walk forward - pbf_move_left_joystick(context, 128, 0, 300, 100); + pbf_move_left_joystick(context, 128, 0, 600, 100); // turn left - pbf_move_left_joystick(context, 0, 128, 50, 100); + pbf_move_left_joystick(context, 0, 128, 20, 100); // talk to Arven. stop at overworld. need prompt, overworld, white button A. and book? env.console.log("Talk with Arven. Receive Titan questline (Path of Legends)."); @@ -138,7 +138,7 @@ void checkpoint_17( context.wait_for_all_requests(); // walk backwards until dialog - walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 20, 255); + walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 20, 128, 255); env.console.log("Talk with Cassiopeia."); mash_button_till_overworld(env.console, context, BUTTON_A, 360); @@ -290,7 +290,7 @@ void checkpoint_20( env.console.log("Leave dorm for schoolyard."); mash_button_till_overworld(env.console, context, BUTTON_A, 360); - walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 60, 0); + walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 60, 128, 0); env.console.log("Talk to Nemona, Arven, Cassiopeia."); clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 16, diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.cpp index 3df20aa94..ac56cac5e 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.cpp @@ -228,9 +228,17 @@ void checkpoint_23( {ZoomChange::ZOOM_IN, 0, 128, 80}, {ZoomChange::KEEP_ZOOM, 255, 95, 100} ); - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 20, 10); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10); + }, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + pbf_move_left_joystick(context, 255, 128, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); // section 3 realign_player_from_landmark( @@ -238,9 +246,17 @@ void checkpoint_23( {ZoomChange::ZOOM_IN, 0, 128, 80}, {ZoomChange::KEEP_ZOOM, 255, 75, 65} ); - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 20, 10); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10); + }, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + pbf_move_left_joystick(context, 255, 128, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); // section 4 realign_player_from_landmark( @@ -248,9 +264,17 @@ void checkpoint_23( {ZoomChange::ZOOM_IN, 0, 128, 50}, {ZoomChange::KEEP_ZOOM, 255, 180, 17} ); - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 40, 10); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 40, 10); + }, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + pbf_move_left_joystick(context, 255, 128, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); // section 5. set marker to pokecenter realign_player_from_landmark( @@ -258,18 +282,26 @@ void checkpoint_23( {ZoomChange::ZOOM_IN, 128, 128, 0}, {ZoomChange::KEEP_ZOOM, 128, 128, 0} ); - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 20, 10); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10); + }, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + pbf_move_left_joystick(context, 255, 128, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); // section 6. set marker past pokecenter handle_unexpected_battles(env.program_info(), env.console, context, [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 110, 50); - }); + }); overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_TIME, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 15, 12, 12); + 128, 15, 12, 12); fly_to_overlapping_flypoint(env.program_info(), env.console, context); diff --git a/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_Navigation.cpp b/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_Navigation.cpp index a7ecd00e3..38f6d3599 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_Navigation.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_Navigation.cpp @@ -895,7 +895,6 @@ void mash_button_till_overworld( uint16_t button, uint16_t seconds_run ){ OverworldWatcher overworld(console, COLOR_CYAN); - NormalBattleMenuWatcher battle(COLOR_BLUE); context.wait_for_all_requests(); int ret = run_until( @@ -904,12 +903,10 @@ void mash_button_till_overworld( ssf_mash1_button(context, button, seconds_run * TICKS_PER_SECOND); pbf_wait(context, seconds_run * TICKS_PER_SECOND); }, - {overworld, battle} + {overworld} ); - if (ret == 1){ - run_battle_press_A(console, context, BattleStopCondition::STOP_OVERWORLD); - }else if (ret < 0){ + if (ret < 0){ throw OperationFailedException( ErrorReport::SEND_ERROR_REPORT, console, "mash_button_till_overworld(): Timed out, no recognized state found.", diff --git a/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_SaveGame.cpp b/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_SaveGame.cpp index fb2c8383e..af3e56a16 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_SaveGame.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_SaveGame.cpp @@ -107,12 +107,15 @@ void save_game_from_menu_or_overworld( void save_game_tutorial(const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + console.log("Save game from tutorial. Open the menu."); + context.wait_for_all_requests(); // open the menu. MainMenuWatcher menu(COLOR_RED); int ret0 = run_until( console, context, [](BotBaseContext& context){ + pbf_wait(context, 500); // avoiding pressing X if menu already open for (size_t i = 0; i < 10; i++){ pbf_press_button(context, BUTTON_X, 20, 500); }