diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index 40ce1e56c..a4b77f40a 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -1427,7 +1427,9 @@ file(GLOB MAIN_SOURCES Source/PokemonSV/PokemonSV_Settings.cpp Source/PokemonSV/PokemonSV_Settings.h Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_00.cpp - Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_00.h + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_00.h + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.cpp + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.h Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp diff --git a/SerialPrograms/SerialPrograms.pro b/SerialPrograms/SerialPrograms.pro index f405ca508..6fb8ba213 100644 --- a/SerialPrograms/SerialPrograms.pro +++ b/SerialPrograms/SerialPrograms.pro @@ -713,6 +713,7 @@ SOURCES += \ Source/PokemonSV/PokemonSV_Panels.cpp \ Source/PokemonSV/PokemonSV_Settings.cpp \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_00.cpp \ + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.cpp \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp \ Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.cpp \ @@ -1800,6 +1801,7 @@ HEADERS += \ Source/PokemonSV/PokemonSV_Panels.h \ Source/PokemonSV/PokemonSV_Settings.h \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_00.h \ + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.h \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h \ Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.h \ diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp index e01cf5bb4..35b9e5016 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp @@ -16,7 +16,7 @@ #include "PokemonSwSh/Inference/PokemonSwSh_IvJudgeReader.h" #include "PokemonSV/Programs/PokemonSV_GameEntry.h" #include "PokemonSV_AutoStory_Segment_00.h" -// #include "PokemonSV_AutoStory_Segment_01.h" +#include "PokemonSV_AutoStory_Segment_01.h" // #include "PokemonSV_AutoStory_Segment_02.h" // #include "PokemonSV_AutoStory_Segment_03.h" // #include "PokemonSV_AutoStory_Segment_04.h" @@ -49,7 +49,7 @@ using namespace Pokemon; std::vector> make_autoStory_segment_list(){ std::vector> 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()); @@ -453,14 +453,14 @@ void AutoStory::test_checkpoints( int start, int end, int loop, int start_loop, int end_loop ){ - // EventNotificationOption& notif_status_update = NOTIFICATION_STATUS_UPDATE; - // Language language = LANGUAGE; - // StarterChoice starter_choice = STARTERCHOICE; + EventNotificationOption& notif_status_update = NOTIFICATION_STATUS_UPDATE; + Language language = LANGUAGE; + StarterChoice starter_choice = STARTERCHOICE; std::vector> checkpoint_list; checkpoint_list.push_back([&](){checkpoint_00(env, context);}); - // checkpoint_list.push_back([&](){checkpoint_01(env, context, notif_status_update, language);}); - // checkpoint_list.push_back([&](){checkpoint_02(env, context, notif_status_update);}); - // checkpoint_list.push_back([&](){checkpoint_03(env, context, notif_status_update, language, starter_choice);}); + checkpoint_list.push_back([&](){checkpoint_01(env, context, notif_status_update, language);}); + checkpoint_list.push_back([&](){checkpoint_02(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_03(env, context, notif_status_update, language, starter_choice);}); // checkpoint_list.push_back([&](){checkpoint_04(env, context, notif_status_update);}); // checkpoint_list.push_back([&](){checkpoint_05(env, context, notif_status_update);}); // checkpoint_list.push_back([&](){checkpoint_06(env, context, notif_status_update);}); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index 16e9143b7..7196a80dc 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -150,7 +150,7 @@ void clear_tutorial(ConsoleHandle& console, BotBaseContext& context, uint16_t se void clear_dialog(ConsoleHandle& console, BotBaseContext& context, ClearDialogMode mode, uint16_t seconds_timeout, - std::vector enum_optional_callbacks + std::vector enum_optional_callbacks ){ bool seen_dialog = false; WallClock start = current_time(); @@ -174,32 +174,32 @@ void clear_dialog(ConsoleHandle& console, BotBaseContext& context, context.wait_for_all_requests(); std::vector callbacks; - std::vector enum_all_callbacks{ClearDialogCallback::ADVANCE_DIALOG}; // mandatory callbacks + std::vector enum_all_callbacks{CallbackEnum::ADVANCE_DIALOG}; // mandatory callbacks enum_all_callbacks.insert(enum_all_callbacks.end(), enum_optional_callbacks.begin(), enum_optional_callbacks.end()); // append the mandatory and optional callback vectors together - for (const ClearDialogCallback& enum_callback : enum_all_callbacks){ + for (const CallbackEnum& enum_callback : enum_all_callbacks){ switch(enum_callback){ - case ClearDialogCallback::ADVANCE_DIALOG: + case CallbackEnum::ADVANCE_DIALOG: callbacks.emplace_back(advance_dialog); break; - case ClearDialogCallback::OVERWORLD: + case CallbackEnum::OVERWORLD: callbacks.emplace_back(overworld); break; - case ClearDialogCallback::PROMPT_DIALOG: + case CallbackEnum::PROMPT_DIALOG: callbacks.emplace_back(prompt); break; - case ClearDialogCallback::WHITE_A_BUTTON: + case CallbackEnum::WHITE_A_BUTTON: callbacks.emplace_back(whitebutton); break; - case ClearDialogCallback::DIALOG_ARROW: + case CallbackEnum::DIALOG_ARROW: callbacks.emplace_back(dialog_arrow); break; - case ClearDialogCallback::BATTLE: + case CallbackEnum::BATTLE: callbacks.emplace_back(battle); break; - case ClearDialogCallback::TUTORIAL: + case CallbackEnum::TUTORIAL: callbacks.emplace_back(tutorial); break; - case ClearDialogCallback::BLACK_DIALOG_BOX: + case CallbackEnum::BLACK_DIALOG_BOX: callbacks.emplace_back(black_dialog_box); break; } @@ -233,20 +233,20 @@ void clear_dialog(ConsoleHandle& console, BotBaseContext& context, ); } - ClearDialogCallback enum_callback = enum_all_callbacks[ret]; + CallbackEnum enum_callback = enum_all_callbacks[ret]; switch(enum_callback){ - case ClearDialogCallback::ADVANCE_DIALOG: + case CallbackEnum::ADVANCE_DIALOG: console.log("clear_dialog: Detected advance dialog."); seen_dialog = true; pbf_press_button(context, BUTTON_A, 20, 105); break; - case ClearDialogCallback::OVERWORLD: + case CallbackEnum::OVERWORLD: console.log("clear_dialog: Detected overworld."); if (seen_dialog && mode == ClearDialogMode::STOP_OVERWORLD){ return; } break; - case ClearDialogCallback::PROMPT_DIALOG: + case CallbackEnum::PROMPT_DIALOG: console.log("clear_dialog: Detected prompt."); seen_dialog = true; if (mode == ClearDialogMode::STOP_PROMPT){ @@ -254,7 +254,7 @@ void clear_dialog(ConsoleHandle& console, BotBaseContext& context, } pbf_press_button(context, BUTTON_A, 20, 105); break; - case ClearDialogCallback::WHITE_A_BUTTON: + case CallbackEnum::WHITE_A_BUTTON: console.log("clear_dialog: Detected white A button."); seen_dialog = true; if (mode == ClearDialogMode::STOP_WHITEBUTTON){ @@ -262,22 +262,22 @@ void clear_dialog(ConsoleHandle& console, BotBaseContext& context, } pbf_press_button(context, BUTTON_A, 20, 105); break; - case ClearDialogCallback::DIALOG_ARROW: + case CallbackEnum::DIALOG_ARROW: console.log("clear_dialog: Detected dialog arrow."); seen_dialog = true; pbf_press_button(context, BUTTON_A, 20, 105); break; - case ClearDialogCallback::BATTLE: + case CallbackEnum::BATTLE: console.log("clear_dialog: Detected battle."); if (mode == ClearDialogMode::STOP_BATTLE){ return; } break; - case ClearDialogCallback::TUTORIAL: + case CallbackEnum::TUTORIAL: console.log("clear_dialog: Detected tutorial."); pbf_press_button(context, BUTTON_A, 20, 105); break; - case ClearDialogCallback::BLACK_DIALOG_BOX: + case CallbackEnum::BLACK_DIALOG_BOX: console.log("clear_dialog: Detected black dialog box."); pbf_press_button(context, BUTTON_A, 20, 105); break; @@ -522,7 +522,7 @@ void change_settings(SingleSwitchProgramEnvironment& env, BotBaseContext& contex } pbf_mash_button(context, BUTTON_A, 1 * TICKS_PER_SECOND); - clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 5, {ClearDialogCallback::PROMPT_DIALOG}); + clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 5, {CallbackEnum::PROMPT_DIALOG}); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h index 64557058b..3d3f0952b 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h @@ -46,7 +46,7 @@ enum class ClearDialogMode{ }; -enum class ClearDialogCallback{ +enum class CallbackEnum{ ADVANCE_DIALOG, OVERWORLD, PROMPT_DIALOG, @@ -110,7 +110,7 @@ void clear_tutorial(ConsoleHandle& console, BotBaseContext& context, uint16_t se // also throw exception if dialog is never detected. void clear_dialog(ConsoleHandle& console, BotBaseContext& context, ClearDialogMode mode, uint16_t seconds_timeout = 60, - std::vector optional_callbacks = {} + std::vector optional_callbacks = {} ); // move character with ssf left joystick, as per given x, y, until diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.cpp new file mode 100644 index 000000000..abb617b76 --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.cpp @@ -0,0 +1,301 @@ +/* AutoStory + * + * From: https://github.com/PokemonAutomation/Arduino-Source + * + */ + +#include "CommonFramework/GlobalSettingsPanel.h" +#include "CommonFramework/Exceptions/FatalProgramException.h" +#include "CommonFramework/Exceptions/OperationFailedException.h" +#include "CommonFramework/InferenceInfra/InferenceRoutines.h" +#include "CommonFramework/Notifications/ProgramNotifications.h" +#include "CommonFramework/Tools/StatsTracking.h" +#include "CommonFramework/Tools/VideoResolutionCheck.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "Pokemon/Pokemon_Strings.h" +#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_AutoStoryTools.h" +#include "PokemonSV_AutoStory_Segment_01.h" + +//#include +//using std::cout; +//using std::endl; +//#include +//#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + +using namespace Pokemon; + + + + +std::string AutoStory_Segment_01::name() const{ + return "01: Pick Starter"; +} + + +std::string AutoStory_Segment_01::start_text() const{ + return "Start: Finished cutscene."; +} + +std::string AutoStory_Segment_01::end_text() const{ + return "End: Picked the starter."; +} + +void AutoStory_Segment_01::run_segment(SingleSwitchProgramEnvironment& env, BotBaseContext& context, AutoStoryOptions options) const{ + AutoStoryStats& stats = env.current_stats(); + + context.wait_for_all_requests(); + env.console.log("Start Segment 01: Pick Starter", COLOR_ORANGE); + env.console.overlay().add_log("Start Segment 01: Pick Starter", COLOR_ORANGE); + + checkpoint_01(env, context, options.notif_status_update, options.language); + checkpoint_02(env, context, options.notif_status_update); + checkpoint_03(env, context, options.notif_status_update, options.language, options.starter_choice); + + context.wait_for_all_requests(); + env.console.log("End Segment 02: Pick Starter", COLOR_GREEN); + env.console.overlay().add_log("End Segment 02: Pick Starter", COLOR_GREEN); + stats.m_segment++; + env.update_stats(); + +} + + +void checkpoint_01( + SingleSwitchProgramEnvironment& env, + BotBaseContext& context, + EventNotificationOption& notif_status_update, + Language language +){ +AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; + while (true){ + try{ + if(first_attempt){ + save_game_tutorial(env.program_info(), env.console, context); + 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(); + // set settings + 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); + + break; + }catch(...){ + // (void)e; + first_attempt = false; + 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_02( + SingleSwitchProgramEnvironment& env, + BotBaseContext& context, + EventNotificationOption& notif_status_update +){ + AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; + while (true){ + try{ + if(!first_attempt){ + save_game_tutorial(env.program_info(), env.console, context); + 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(); + env.console.log("Go downstairs, get stopped by Skwovet"); + env.console.overlay().add_log("Go downstairs, get stopped by Skwovet", COLOR_WHITE); + pbf_move_left_joystick(context, 128, 0, 3 * TICKS_PER_SECOND, 20); + pbf_move_left_joystick(context, 0, 128, 3 * TICKS_PER_SECOND, 20); + pbf_move_left_joystick(context, 128, 255, 3 * TICKS_PER_SECOND, 20); + pbf_wait(context, 5 * TICKS_PER_SECOND); + // clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 5, {}); + + context.wait_for_all_requests(); + env.console.log("Go to the kitchen, talk with mom"); + env.console.overlay().add_log("Go to the kitchen, talk with mom", COLOR_WHITE); + pbf_move_left_joystick(context, 128, 255, 2 * TICKS_PER_SECOND, 20); + overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, 0, 128); + + env.console.log("clear_dialog: Talk with Mom."); + clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 5, {}); + + context.wait_for_all_requests(); + env.console.log("Go to the front door, talk with Clavell"); + env.console.overlay().add_log("Go to the front door, talk with Clavell", COLOR_WHITE); + pbf_move_left_joystick(context, 230, 200, 2 * TICKS_PER_SECOND, 20); + overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, 255, 128); + + env.console.log("clear_dialog: Talk with Clavell at front door."); + clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 5, {}); + + context.wait_for_all_requests(); + env.console.log("Go upstairs, dress up"); + env.console.overlay().add_log("Go upstairs, dress up", COLOR_WHITE); + pbf_move_left_joystick(context, 255, 128, 2 * TICKS_PER_SECOND, 20); + pbf_move_left_joystick(context, 185, 10, 1 * TICKS_PER_SECOND, 20); + pbf_move_left_joystick(context, 128, 0, 4 * TICKS_PER_SECOND, 20); + pbf_move_left_joystick(context, 255, 128, 4 * TICKS_PER_SECOND, 20); + pbf_move_left_joystick(context, 110, 200, 3 * TICKS_PER_SECOND, 20); + pbf_move_left_joystick(context, 255, 128, 2 * TICKS_PER_SECOND, 20); + pbf_mash_button(context, BUTTON_A, 20 * TICKS_PER_SECOND); + + context.wait_for_all_requests(); + env.console.log("Go to the living room, talk with Clavell"); + env.console.overlay().add_log("Go to the living room, talk with Clavell", COLOR_WHITE); + pbf_move_left_joystick(context, 0, 0, 3 * TICKS_PER_SECOND, 20); + pbf_move_left_joystick(context, 0, 128, 3 * TICKS_PER_SECOND, 20); + pbf_move_left_joystick(context, 128, 255, 4 * TICKS_PER_SECOND, 20); + overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, 0, 128); + + env.console.log("clear_dialog: Talk with Clavell at living room."); + clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 10, {}); + + context.wait_for_all_requests(); + env.console.log("Go outside, receive Rotom Phone"); + env.console.overlay().add_log("Go outside, receive Rotom Phone", COLOR_WHITE); + overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, 245, 230); + + 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); + + break; + }catch(...){ + 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_03( + SingleSwitchProgramEnvironment& env, + BotBaseContext& context, + EventNotificationOption& notif_status_update, + Language language, + StarterChoice starter_choice +){ + 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; + } + + 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); + + context.wait_for_all_requests(); + env.console.log("Entered Nemona's house"); + mash_button_till_overworld(env.console, context); + context.wait_for_all_requests(); + env.console.log("Picking a starter..."); + switch(starter_choice){ + case StarterChoice::SPRIGATITO: + env.console.log("Picking Sprigatito..."); + pbf_move_left_joystick(context, 75, 0, 80, 20); + break; + case StarterChoice::FUECOCO: + env.console.log("Picking Fuecoco..."); + pbf_move_left_joystick(context, 180, 0, 80, 20); + break; + case StarterChoice::QUAXLY: + env.console.log("Picking Quaxly..."); + pbf_move_left_joystick(context, 128, 0, 80, 20); + break; + } + pbf_press_button(context, BUTTON_A, 20, 105); // choose the starter + env.console.log("clear_dialog: Choose starter. Stop when detect prompt to receive starter."); + clear_dialog(env.console, context, ClearDialogMode::STOP_PROMPT, 20, {CallbackEnum::PROMPT_DIALOG}); + + pbf_press_button(context, BUTTON_A, 20, 105); // accept the pokemon + env.console.log("clear_dialog: Stop when detect prompt to give nickname to starter."); + clear_dialog(env.console, context, ClearDialogMode::STOP_PROMPT, 20, {CallbackEnum::PROMPT_DIALOG}); + + pbf_mash_button(context, BUTTON_B, 100); // Don't give a nickname + env.console.log("clear_dialog: Talk to Nemona and Clavell. Stop when detect overworld."); + clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 20, {CallbackEnum::OVERWORLD}); + + context.wait_for_all_requests(); + env.console.log("Clear auto heal tutorial."); + // Press X until Auto heal tutorial shows up + TutorialWatcher tutorial; + int ret = run_until( + env.console, context, + [](BotBaseContext& context){ + for (int i = 0; i < 10; i++){ + pbf_press_button(context, BUTTON_X, 20, 250); + } + }, + {tutorial} + ); + if (ret < 0){ + throw OperationFailedException( + ErrorReport::SEND_ERROR_REPORT, env.console, + "Stuck trying to clear auto heal tutorial.", + true + ); + } + clear_tutorial(env.console, context); + + env.console.log("Change move order."); + swap_starter_moves(env.program_info(), env.console, context, language); + leave_box_system_to_overworld(env.program_info(), env.console, context); + + break; + }catch(...){ + 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_01.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.h new file mode 100644 index 000000000..10083f33a --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.h @@ -0,0 +1,50 @@ +/* Autostory + * + * From: https://github.com/PokemonAutomation/Arduino-Source + * + */ + +#ifndef PokemonAutomation_PokemonSV_AutoStory_Segment_01_H +#define PokemonAutomation_PokemonSV_AutoStory_Segment_01_H + +#include +#include "Common/Cpp/Options/EnumDropdownOption.h" +#include "CommonFramework/Notifications/EventNotificationsTable.h" +#include "CommonFramework/Options/LanguageOCROption.h" +#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h" +#include "Common/NintendoSwitch/NintendoSwitch_ControllerDefs.h" +#include "PokemonSV/Programs/PokemonSV_Navigation.h" +#include "PokemonSV_AutoStoryTools.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + +class AutoStory_Segment_01 : 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, + BotBaseContext& context, + AutoStoryOptions options) const override; +}; + +// start: stood up from chair. Walked to left side of room. +// end: standing in room. updated settings +void checkpoint_01(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update, Language language); + +// start: standing in room. updated settings +// end: standing in front of power of science NPC. Cleared map tutorial. +void checkpoint_02(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update); + +// start: standing in front of power of science NPC. Cleared map tutorial. +// end: received starter, changed move order +void checkpoint_03(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update, Language language, StarterChoice starter_choice); + + +} +} +} +#endif