diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp index 807ff345db..42cdf5d838 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()); @@ -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_22.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp index 571181cc28..22be82158a 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,429 @@ -/* 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: Defeated Team Star (Fire). At East Province (Area One) Pokecenter."; +} + +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); + checkpoint_49(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(); + } + } + +} + + +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(); + // 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); + + + + 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..9673fc1cf1 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: Beat Team Star (Fire) +// end: At East Province (Area Two) Pokecenter. +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..9fefaf9470 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" @@ -55,7 +58,216 @@ 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(); + } + } + +} + + +// 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 4855f0afb3..b42a4e3626 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,58 @@ class AutoStory_Segment_23 : public AutoStory_Segment{ ) const override; }; +// start: +// end: +void checkpoint_50( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + 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 +); + 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"