From 5c0f1684d800b90f27fca4586777c882fd79f9ac Mon Sep 17 00:00:00 2001 From: jw098 Date: Sun, 3 Aug 2025 09:44:41 -0700 Subject: [PATCH 1/3] segment 22. beat team star fire --- .../AutoStory/PokemonSV_AutoStory.cpp | 2 +- .../PokemonSV_AutoStory_Segment_22.cpp | 511 ++++++++++++------ .../PokemonSV_AutoStory_Segment_22.h | 118 ++-- .../PokemonSV_AutoStory_Segment_23.cpp | 5 +- .../PokemonSV_AutoStory_Segment_24.cpp | 5 +- 5 files changed, 401 insertions(+), 240 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp index 807ff345db..350dfe9daf 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp @@ -83,7 +83,7 @@ std::vector> make_autoStory_segment_list(){ segment_list.emplace_back(std::make_unique()); segment_list.emplace_back(std::make_unique()); segment_list.emplace_back(std::make_unique()); - // segment_list.emplace_back(std::make_unique()); + segment_list.emplace_back(std::make_unique()); // segment_list.emplace_back(std::make_unique()); // segment_list.emplace_back(std::make_unique()); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp index 571181cc28..da73c123e2 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp @@ -1,178 +1,333 @@ -/* AutoStory - * - * From: https://github.com/PokemonAutomation/ - * - */ - -#include "CommonFramework/Exceptions/OperationFailedException.h" -#include "CommonFramework/VideoPipeline/VideoOverlay.h" -#include "PokemonSV/Programs/PokemonSV_GameEntry.h" -#include "PokemonSV/Programs/PokemonSV_SaveGame.h" -#include "PokemonSV/Programs/PokemonSV_MenuNavigation.h" -#include "PokemonSV_AutoStoryTools.h" -#include "PokemonSV_AutoStory_Segment_22.h" - -//#include -//using std::cout; -//using std::endl; -//#include -//#include - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonSV{ - - - - -std::string AutoStory_Segment_22::name() const{ - return "22: Team Star (Fire): Beat Team Star"; -} - -std::string AutoStory_Segment_22::start_text() const{ - return "Start: At East Province (Area One) Pokecenter."; -} - -std::string AutoStory_Segment_22::end_text() const{ - return "End: "; -} - -void AutoStory_Segment_22::run_segment( - SingleSwitchProgramEnvironment& env, - ProControllerContext& context, - AutoStoryOptions options -) const{ - AutoStoryStats& stats = env.current_stats(); - - stats.m_segment++; - env.update_stats(); - context.wait_for_all_requests(); - env.console.log("Start Segment " + name(), COLOR_ORANGE); - - // checkpoint_(env, context, options.notif_status_update); - - context.wait_for_all_requests(); - env.console.log("End Segment " + name(), COLOR_GREEN); - -} - - -// todo: uncomment checkpoint_save -void checkpoint_47( - SingleSwitchProgramEnvironment& env, - ProControllerContext& context, - EventNotificationOption& notif_status_update -){ - AutoStoryStats& stats = env.current_stats(); - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - // checkpoint_save(env, context, notif_status_update); - first_attempt = false; - }else{ - enter_menu_from_overworld(env.program_info(), env.console, context, -1); - // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. - env.log("Wait 10 seconds."); - context.wait_for(Milliseconds(10 * 1000)); - save_game_from_overworld(env.program_info(), env.console, context); - } - - context.wait_for_all_requests(); - - - - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } - -} - - -// todo: uncomment checkpoint_save -void checkpoint_48( - SingleSwitchProgramEnvironment& env, - ProControllerContext& context, - EventNotificationOption& notif_status_update -){ - AutoStoryStats& stats = env.current_stats(); - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - // checkpoint_save(env, context, notif_status_update); - first_attempt = false; - }else{ - enter_menu_from_overworld(env.program_info(), env.console, context, -1); - // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. - env.log("Wait 10 seconds."); - context.wait_for(Milliseconds(10 * 1000)); - save_game_from_overworld(env.program_info(), env.console, context); - } - - context.wait_for_all_requests(); - - - - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } - -} - - -// todo: uncomment checkpoint_save -void checkpoint_49( - SingleSwitchProgramEnvironment& env, - ProControllerContext& context, - EventNotificationOption& notif_status_update -){ - AutoStoryStats& stats = env.current_stats(); - bool first_attempt = true; - while (true){ - try{ - if (first_attempt){ - // checkpoint_save(env, context, notif_status_update); - first_attempt = false; - }else{ - enter_menu_from_overworld(env.program_info(), env.console, context, -1); - // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. - env.log("Wait 10 seconds."); - context.wait_for(Milliseconds(10 * 1000)); - save_game_from_overworld(env.program_info(), env.console, context); - } - - context.wait_for_all_requests(); - - - - break; - }catch(OperationFailedException&){ - context.wait_for_all_requests(); - env.console.log("Resetting from checkpoint."); - reset_game(env.program_info(), env.console, context); - stats.m_reset++; - env.update_stats(); - } - } - -} - - - - -} -} -} +/* AutoStory + * + * From: https://github.com/PokemonAutomation/Arduino-Source + * + */ + +#include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" +#include "PokemonSV/Inference/Dialogs/PokemonSV_DialogDetector.h" + +#include "CommonFramework/Exceptions/OperationFailedException.h" +#include "CommonTools/Async/InferenceRoutines.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "PokemonSV/Programs/PokemonSV_GameEntry.h" +#include "PokemonSV/Programs/PokemonSV_SaveGame.h" +#include "PokemonSV/Programs/PokemonSV_MenuNavigation.h" +#include "PokemonSV/Programs/PokemonSV_WorldNavigation.h" +#include "PokemonSV_AutoStoryTools.h" +#include "PokemonSV_AutoStory_Segment_22.h" + +//#include +//using std::cout; +//using std::endl; +//#include +//#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + + + + +std::string AutoStory_Segment_22::name() const{ + return "22: Team Star (Fire): Beat Team Star"; +} + +std::string AutoStory_Segment_22::start_text() const{ + return "Start: At East Province (Area One) Pokecenter."; +} + +std::string AutoStory_Segment_22::end_text() const{ + return "End: "; +} + +void AutoStory_Segment_22::run_segment( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + AutoStoryOptions options +) const{ + AutoStoryStats& stats = env.current_stats(); + + stats.m_segment++; + env.update_stats(); + context.wait_for_all_requests(); + env.console.log("Start Segment " + name(), COLOR_ORANGE); + + checkpoint_47(env, context, options.notif_status_update); + checkpoint_48(env, context, options.notif_status_update); + + context.wait_for_all_requests(); + env.console.log("End Segment " + name(), COLOR_GREEN); + +} + + +void checkpoint_47( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update +){ + AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; + while (true){ + try{ + if (first_attempt){ + checkpoint_save(env, context, notif_status_update); + first_attempt = false; + }else{ + enter_menu_from_overworld(env.program_info(), env.console, context, -1); + // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. + env.log("Wait 10 seconds."); + context.wait_for(Milliseconds(10 * 1000)); + save_game_from_overworld(env.program_info(), env.console, context); + } + + context.wait_for_all_requests(); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 110, 100); + + DirectionDetector direction; + direction.change_direction(env.program_info(), env.console, context, 2.06); + pbf_move_left_joystick(context, 128, 0, 200, 100); + + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 60, 20, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 128, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // speak to Clive and Cassiopeia + mash_button_till_overworld(env.console, context, BUTTON_A); + + // move towards Team Star base gate + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 20, 255, 40); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 40, 20, false); + + // battle Team Star Grunt + clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::PROMPT_DIALOG, CallbackEnum::DIALOG_ARROW, CallbackEnum::BATTLE}); + env.console.log("Battle team star grunt."); + run_trainer_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG); + mash_button_till_overworld(env.console, context, BUTTON_A); + + + break; + }catch(OperationFailedException&){ + context.wait_for_all_requests(); + env.console.log("Resetting from checkpoint."); + reset_game(env.program_info(), env.console, context); + stats.m_reset++; + env.update_stats(); + } + } + +} + + +void checkpoint_48( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update +){ + AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; + while (true){ + try{ + if (first_attempt){ + checkpoint_save(env, context, notif_status_update); + first_attempt = false; + }else{ + enter_menu_from_overworld(env.program_info(), env.console, context, -1); + // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. + env.log("Wait 10 seconds."); + context.wait_for(Milliseconds(10 * 1000)); + save_game_from_overworld(env.program_info(), env.console, context); + } + + context.wait_for_all_requests(); + do_action_and_monitor_for_battles(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 240, 50); + walk_forward_while_clear_front_path(env.program_info(), env.console, context, 300); + walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_SPAM_A); + } + ); + clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::OVERWORLD, CallbackEnum::PROMPT_DIALOG, CallbackEnum::TUTORIAL}); + + AdvanceDialogWatcher dialog(COLOR_RED); + int ret = run_until( + env.console, context, + [&](ProControllerContext& context){ + + DirectionDetector direction; + uint16_t seconds_wait = 8; + + direction.change_direction(env.program_info(), env.console, context, 2.50); + pbf_move_left_joystick(context, 128, 0, 300, 50); + pbf_press_button(context, BUTTON_R, 20, 20); + pbf_wait(context, seconds_wait * TICKS_PER_SECOND); + + + direction.change_direction(env.program_info(), env.console, context, 3.54); + pbf_move_left_joystick(context, 128, 0, 300, 50); + pbf_press_button(context, BUTTON_R, 20, 20); + pbf_wait(context, seconds_wait * TICKS_PER_SECOND); + + + direction.change_direction(env.program_info(), env.console, context, 1.76); + pbf_move_left_joystick(context, 128, 0, 300, 50); + pbf_press_button(context, BUTTON_R, 20, 20); + pbf_wait(context, seconds_wait * TICKS_PER_SECOND); + + pbf_move_left_joystick(context, 128, 0, 400, 50); + + + direction.change_direction(env.program_info(), env.console, context, 1.97); + pbf_move_left_joystick(context, 128, 0, 300, 50); + pbf_press_button(context, BUTTON_R, 20, 20); + pbf_wait(context, seconds_wait * TICKS_PER_SECOND); + + direction.change_direction(env.program_info(), env.console, context, 2.60); + pbf_move_left_joystick(context, 128, 0, 400, 50); + pbf_press_button(context, BUTTON_R, 20, 20); + pbf_wait(context, seconds_wait * TICKS_PER_SECOND); + + + direction.change_direction(env.program_info(), env.console, context, 0.19); + pbf_move_left_joystick(context, 128, 0, 400, 50); + + + direction.change_direction(env.program_info(), env.console, context, 0.82); + pbf_move_left_joystick(context, 128, 0, 400, 50); + pbf_press_button(context, BUTTON_R, 20, 20); + pbf_wait(context, seconds_wait * TICKS_PER_SECOND); + + direction.change_direction(env.program_info(), env.console, context, 2.13); + pbf_move_left_joystick(context, 128, 0, 400, 50); + pbf_press_button(context, BUTTON_R, 20, 20); + pbf_wait(context, seconds_wait * TICKS_PER_SECOND); + + + direction.change_direction(env.program_info(), env.console, context, 1.97); + pbf_move_left_joystick(context, 128, 0, 500, 50); + pbf_press_button(context, BUTTON_R, 20, 20); + pbf_wait(context, seconds_wait * TICKS_PER_SECOND); + + direction.change_direction(env.program_info(), env.console, context, 3.02); + pbf_move_left_joystick(context, 128, 0, 400, 50); + + + direction.change_direction(env.program_info(), env.console, context, 3.87); + pbf_move_left_joystick(context, 128, 0, 200, 50); + pbf_press_button(context, BUTTON_R, 20, 20); + pbf_wait(context, seconds_wait * TICKS_PER_SECOND); + + direction.change_direction(env.program_info(), env.console, context, 4.56); + pbf_move_left_joystick(context, 128, 0, 300, 50); + pbf_press_button(context, BUTTON_R, 20, 20); + pbf_wait(context, seconds_wait * TICKS_PER_SECOND); + + direction.change_direction(env.program_info(), env.console, context, 4.98); + pbf_move_left_joystick(context, 128, 0, 400, 50); + + direction.change_direction(env.program_info(), env.console, context, 5.18); + pbf_move_left_joystick(context, 128, 0, 300, 50); + pbf_press_button(context, BUTTON_R, 20, 20); + pbf_wait(context, seconds_wait * TICKS_PER_SECOND); + + direction.change_direction(env.program_info(), env.console, context, 5.66); + pbf_move_left_joystick(context, 128, 0, 400, 50); + pbf_press_button(context, BUTTON_R, 20, 20); + pbf_wait(context, seconds_wait * TICKS_PER_SECOND); + + direction.change_direction(env.program_info(), env.console, context, 5.24); + pbf_move_left_joystick(context, 128, 0, 600, 50); + pbf_press_button(context, BUTTON_R, 20, 20); + pbf_wait(context, seconds_wait * TICKS_PER_SECOND); + + direction.change_direction(env.program_info(), env.console, context, 5.45); + pbf_move_left_joystick(context, 128, 0, 400, 50); + pbf_press_button(context, BUTTON_R, 20, 20); + pbf_wait(context, seconds_wait * TICKS_PER_SECOND); + + + }, + {dialog} + ); + context.wait_for(std::chrono::milliseconds(100)); + if (ret < 0){ + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "checkpoint_48(): Failed to kill 30 pokemon with Let's go.", + env.console + ); + } + clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::BATTLE, CallbackEnum::DIALOG_ARROW}); + env.console.log("Battle the Team Star (Fire) boss."); + run_trainer_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG); + mash_button_till_overworld(env.console, context, BUTTON_A, 360); + + break; + }catch(OperationFailedException&){ + context.wait_for_all_requests(); + env.console.log("Resetting from checkpoint."); + reset_game(env.program_info(), env.console, context); + stats.m_reset++; + env.update_stats(); + } + } + +} + + +// todo: uncomment checkpoint_save +void checkpoint_49( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update +){ + AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; + while (true){ + try{ + if (first_attempt){ + // checkpoint_save(env, context, notif_status_update); + first_attempt = false; + }else{ + enter_menu_from_overworld(env.program_info(), env.console, context, -1); + // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. + env.log("Wait 10 seconds."); + context.wait_for(Milliseconds(10 * 1000)); + save_game_from_overworld(env.program_info(), env.console, context); + } + + context.wait_for_all_requests(); + + + + break; + }catch(OperationFailedException&){ + context.wait_for_all_requests(); + env.console.log("Resetting from checkpoint."); + reset_game(env.program_info(), env.console, context); + stats.m_reset++; + env.update_stats(); + } + } + +} + + + + +} +} +} diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.h index fe55075349..d5c29a97f5 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.h @@ -1,59 +1,59 @@ -/* Autostory - * - * From: https://github.com/PokemonAutomation/ - * - */ - -#ifndef PokemonAutomation_PokemonSV_AutoStory_Segment_22_H -#define PokemonAutomation_PokemonSV_AutoStory_Segment_22_H - -#include "PokemonSV_AutoStoryTools.h" - -namespace PokemonAutomation{ -namespace NintendoSwitch{ -namespace PokemonSV{ - -class AutoStory_Segment_22 : public AutoStory_Segment{ -public: - virtual std::string name() const override; - virtual std::string start_text() const override; - virtual std::string end_text() const override; - virtual void run_segment( - SingleSwitchProgramEnvironment& env, - ProControllerContext& context, - AutoStoryOptions options - ) const override; -}; - - -// start: At East Province (Area One) Pokecenter. -// end: -void checkpoint_47( - SingleSwitchProgramEnvironment& env, - ProControllerContext& context, - EventNotificationOption& notif_status_update -); - -// start: -// end: -void checkpoint_48( - SingleSwitchProgramEnvironment& env, - ProControllerContext& context, - EventNotificationOption& notif_status_update -); - -// start: -// end: -void checkpoint_49( - SingleSwitchProgramEnvironment& env, - ProControllerContext& context, - EventNotificationOption& notif_status_update -); - - - - -} -} -} -#endif +/* Autostory + * + * From: https://github.com/PokemonAutomation/Arduino-Source + * + */ + +#ifndef PokemonAutomation_PokemonSV_AutoStory_Segment_22_H +#define PokemonAutomation_PokemonSV_AutoStory_Segment_22_H + +#include "PokemonSV_AutoStoryTools.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + +class AutoStory_Segment_22 : public AutoStory_Segment{ +public: + virtual std::string name() const override; + virtual std::string start_text() const override; + virtual std::string end_text() const override; + virtual void run_segment( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + AutoStoryOptions options + ) const override; +}; + + +// start: At East Province (Area One) Pokecenter. +// end: At gate of Team Star (Fire) base. +void checkpoint_47( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update +); + +// start: At gate of Team Star (Fire) base. +// end: Beat Team Star (Fire) +void checkpoint_48( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update +); + +// start: +// end: +void checkpoint_49( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update +); + + + + +} +} +} +#endif diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp index df9981ec3d..cf7c6fa6e3 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp @@ -5,9 +5,12 @@ */ #include "CommonFramework/Exceptions/OperationFailedException.h" -#include "CommonFramework/VideoPipeline/VideoOverlay.h" +#include "CommonTools/Async/InferenceRoutines.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" #include "PokemonSV/Programs/PokemonSV_GameEntry.h" #include "PokemonSV/Programs/PokemonSV_SaveGame.h" +#include "PokemonSV/Programs/PokemonSV_MenuNavigation.h" +#include "PokemonSV/Programs/PokemonSV_WorldNavigation.h" #include "PokemonSV_AutoStoryTools.h" #include "PokemonSV_AutoStory_Segment_23.h" diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.cpp index 58e4f047eb..a22655b6e7 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.cpp @@ -5,9 +5,12 @@ */ #include "CommonFramework/Exceptions/OperationFailedException.h" -#include "CommonFramework/VideoPipeline/VideoOverlay.h" +#include "CommonTools/Async/InferenceRoutines.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" #include "PokemonSV/Programs/PokemonSV_GameEntry.h" #include "PokemonSV/Programs/PokemonSV_SaveGame.h" +#include "PokemonSV/Programs/PokemonSV_MenuNavigation.h" +#include "PokemonSV/Programs/PokemonSV_WorldNavigation.h" #include "PokemonSV_AutoStoryTools.h" #include "PokemonSV_AutoStory_Segment_24.h" From 253823479e27e7a609c55b43daefa7751cc5ff68 Mon Sep 17 00:00:00 2001 From: jw098 Date: Mon, 4 Aug 2025 15:59:30 -0700 Subject: [PATCH 2/3] checkpoint 49: team star base to East Province (Area Two) Pokecenter. --- .../PokemonSV_AutoStory_Segment_22.cpp | 102 +++++++++++++++++- .../PokemonSV_AutoStory_Segment_22.h | 4 +- .../PokemonSV_AutoStory_Segment_23.cpp | 35 ++++++ .../PokemonSV_AutoStory_Segment_23.h | 7 ++ 4 files changed, 143 insertions(+), 5 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp index da73c123e2..22be82158a 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp @@ -39,7 +39,7 @@ std::string AutoStory_Segment_22::start_text() const{ } std::string AutoStory_Segment_22::end_text() const{ - return "End: "; + return "End: Defeated Team Star (Fire). At East Province (Area One) Pokecenter."; } void AutoStory_Segment_22::run_segment( @@ -56,6 +56,7 @@ void AutoStory_Segment_22::run_segment( checkpoint_47(env, context, options.notif_status_update); checkpoint_48(env, context, options.notif_status_update); + checkpoint_49(env, context, options.notif_status_update); context.wait_for_all_requests(); env.console.log("End Segment " + name(), COLOR_GREEN); @@ -288,7 +289,6 @@ void checkpoint_48( } -// todo: uncomment checkpoint_save void checkpoint_49( SingleSwitchProgramEnvironment& env, ProControllerContext& context, @@ -299,7 +299,7 @@ void checkpoint_49( while (true){ try{ if (first_attempt){ - // checkpoint_save(env, context, notif_status_update); + checkpoint_save(env, context, notif_status_update); first_attempt = false; }else{ enter_menu_from_overworld(env.program_info(), env.console, context, -1); @@ -310,6 +310,102 @@ void checkpoint_49( } context.wait_for_all_requests(); + // marker 1 + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 255, 128, 30}, + {ZoomChange::ZOOM_IN, 0, 90, 90} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 30, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 128, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // marker 2 + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 128, 0, 30}, + {ZoomChange::ZOOM_IN, 128, 255, 30} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 30, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 255, 128, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // marker 3 + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 255, 180, 50}, + {ZoomChange::ZOOM_IN, 0, 70, 175} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 30, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 255, 128, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // marker 4 + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 255, 180, 50}, + {ZoomChange::ZOOM_IN, 0, 50, 185} + ); + // walk until you run into the wall + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_TIME, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 10, 10, false); + + + // marker 5. put marker on other side of bridge + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::ZOOM_IN, 128, 128, 0}, + {ZoomChange::ZOOM_IN, 128, 0, 10} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 30, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 128, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + + // marker 6. set marker past pokecenter + handle_unexpected_battles(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 255, 30); + }); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_TIME, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 15, 12, 12, false); // can't wrap in handle_when_stationary_in_overworld(), since we expect to be stationary when walking into the pokecenter + + + fly_to_overlapping_flypoint(env.program_info(), env.console, context); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.h index d5c29a97f5..9673fc1cf1 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.h @@ -42,8 +42,8 @@ void checkpoint_48( EventNotificationOption& notif_status_update ); -// start: -// end: +// start: Beat Team Star (Fire) +// end: At East Province (Area Two) Pokecenter. void checkpoint_49( SingleSwitchProgramEnvironment& env, ProControllerContext& context, diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp index cf7c6fa6e3..b09aa35e69 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp @@ -58,6 +58,41 @@ void AutoStory_Segment_23::run_segment( } +// todo: uncomment checkpoint_save +void checkpoint_50( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update +){ + AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; + while (true){ + try{ + if (first_attempt){ + // checkpoint_save(env, context, notif_status_update); + first_attempt = false; + }else{ + enter_menu_from_overworld(env.program_info(), env.console, context, -1); + // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. + env.log("Wait 10 seconds."); + context.wait_for(Milliseconds(10 * 1000)); + save_game_from_overworld(env.program_info(), env.console, context); + } + + context.wait_for_all_requests(); + + break; + }catch(OperationFailedException&){ + context.wait_for_all_requests(); + env.console.log("Resetting from checkpoint."); + reset_game(env.program_info(), env.console, context); + stats.m_reset++; + env.update_stats(); + } + } + +} + } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.h index 4855f0afb3..608331c320 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.h @@ -25,6 +25,13 @@ class AutoStory_Segment_23 : public AutoStory_Segment{ ) const override; }; +// start: +// end: +void checkpoint_50( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update +); From c718388fdc4932439db90d56e068a2da6b2ae09c Mon Sep 17 00:00:00 2001 From: jw098 Date: Mon, 4 Aug 2025 16:08:30 -0700 Subject: [PATCH 3/3] add more blank checkpoints --- .../AutoStory/PokemonSV_AutoStory.cpp | 7 + .../PokemonSV_AutoStory_Segment_23.cpp | 174 ++++++++++++++++++ .../PokemonSV_AutoStory_Segment_23.h | 45 +++++ 3 files changed, 226 insertions(+) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp index 350dfe9daf..42cdf5d838 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp @@ -611,6 +611,13 @@ void AutoStory::test_checkpoints( checkpoint_list.push_back([&](){checkpoint_47(env, context, notif_status_update);}); checkpoint_list.push_back([&](){checkpoint_48(env, context, notif_status_update);}); checkpoint_list.push_back([&](){checkpoint_49(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_50(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_51(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_52(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_53(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_54(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_55(env, context, notif_status_update);}); + for (int checkpoint = start; checkpoint <= end; checkpoint++){ if (checkpoint == 0){ diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp index b09aa35e69..9fefaf9470 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp @@ -94,6 +94,180 @@ void checkpoint_50( } +// todo: uncomment checkpoint_save +void checkpoint_51( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update +){ + AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; + while (true){ + try{ + if (first_attempt){ + // checkpoint_save(env, context, notif_status_update); + first_attempt = false; + }else{ + enter_menu_from_overworld(env.program_info(), env.console, context, -1); + // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. + env.log("Wait 10 seconds."); + context.wait_for(Milliseconds(10 * 1000)); + save_game_from_overworld(env.program_info(), env.console, context); + } + + context.wait_for_all_requests(); + + break; + }catch(OperationFailedException&){ + context.wait_for_all_requests(); + env.console.log("Resetting from checkpoint."); + reset_game(env.program_info(), env.console, context); + stats.m_reset++; + env.update_stats(); + } + } + +} + +// todo: uncomment checkpoint_save +void checkpoint_52( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update +){ + AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; + while (true){ + try{ + if (first_attempt){ + // checkpoint_save(env, context, notif_status_update); + first_attempt = false; + }else{ + enter_menu_from_overworld(env.program_info(), env.console, context, -1); + // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. + env.log("Wait 10 seconds."); + context.wait_for(Milliseconds(10 * 1000)); + save_game_from_overworld(env.program_info(), env.console, context); + } + + context.wait_for_all_requests(); + + break; + }catch(OperationFailedException&){ + context.wait_for_all_requests(); + env.console.log("Resetting from checkpoint."); + reset_game(env.program_info(), env.console, context); + stats.m_reset++; + env.update_stats(); + } + } + +} + +// todo: uncomment checkpoint_save +void checkpoint_53( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update +){ + AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; + while (true){ + try{ + if (first_attempt){ + // checkpoint_save(env, context, notif_status_update); + first_attempt = false; + }else{ + enter_menu_from_overworld(env.program_info(), env.console, context, -1); + // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. + env.log("Wait 10 seconds."); + context.wait_for(Milliseconds(10 * 1000)); + save_game_from_overworld(env.program_info(), env.console, context); + } + + context.wait_for_all_requests(); + + break; + }catch(OperationFailedException&){ + context.wait_for_all_requests(); + env.console.log("Resetting from checkpoint."); + reset_game(env.program_info(), env.console, context); + stats.m_reset++; + env.update_stats(); + } + } + +} + +// todo: uncomment checkpoint_save +void checkpoint_54( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update +){ + AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; + while (true){ + try{ + if (first_attempt){ + // checkpoint_save(env, context, notif_status_update); + first_attempt = false; + }else{ + enter_menu_from_overworld(env.program_info(), env.console, context, -1); + // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. + env.log("Wait 10 seconds."); + context.wait_for(Milliseconds(10 * 1000)); + save_game_from_overworld(env.program_info(), env.console, context); + } + + context.wait_for_all_requests(); + + break; + }catch(OperationFailedException&){ + context.wait_for_all_requests(); + env.console.log("Resetting from checkpoint."); + reset_game(env.program_info(), env.console, context); + stats.m_reset++; + env.update_stats(); + } + } + +} + +// todo: uncomment checkpoint_save +void checkpoint_55( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update +){ + AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; + while (true){ + try{ + if (first_attempt){ + // checkpoint_save(env, context, notif_status_update); + first_attempt = false; + }else{ + enter_menu_from_overworld(env.program_info(), env.console, context, -1); + // we wait 10 seconds then save, so that the initial conditions are slightly different on each reset. + env.log("Wait 10 seconds."); + context.wait_for(Milliseconds(10 * 1000)); + save_game_from_overworld(env.program_info(), env.console, context); + } + + context.wait_for_all_requests(); + + break; + }catch(OperationFailedException&){ + context.wait_for_all_requests(); + env.console.log("Resetting from checkpoint."); + reset_game(env.program_info(), env.console, context); + stats.m_reset++; + env.update_stats(); + } + } + +} } } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.h index 608331c320..b42a4e3626 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.h @@ -33,6 +33,51 @@ void checkpoint_50( EventNotificationOption& notif_status_update ); +// start: +// end: +void checkpoint_51( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update +); + + +// start: +// end: +void checkpoint_52( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update +); + + +// start: +// end: +void checkpoint_53( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update +); + + +// start: +// end: +void checkpoint_54( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update +); + + +// start: +// end: +void checkpoint_55( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + EventNotificationOption& notif_status_update +); + + }