From 7a2a69228b5d2eb8fafc6965f20cdd9ebf4c6871 Mon Sep 17 00:00:00 2001 From: jw098 Date: Wed, 16 Oct 2024 21:23:43 -0700 Subject: [PATCH] segments 05 to 07 --- SerialPrograms/CMakeLists.txt | 8 +- SerialPrograms/SerialPrograms.pro | 6 + .../AutoStory/PokemonSV_AutoStory.cpp | 20 +-- .../PokemonSV_AutoStory_Segment_05.cpp | 156 ++++++++++++++++++ .../PokemonSV_AutoStory_Segment_05.h | 46 ++++++ .../PokemonSV_AutoStory_Segment_06.cpp | 123 ++++++++++++++ .../PokemonSV_AutoStory_Segment_06.h | 42 +++++ .../PokemonSV_AutoStory_Segment_07.cpp | 148 +++++++++++++++++ .../PokemonSV_AutoStory_Segment_07.h | 42 +++++ 9 files changed, 580 insertions(+), 11 deletions(-) create mode 100644 SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp create mode 100644 SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.h create mode 100644 SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp create mode 100644 SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.h create mode 100644 SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp create mode 100644 SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.h diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index 93baf08ba..58e3ef831 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -1437,7 +1437,13 @@ file(GLOB MAIN_SOURCES Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.cpp Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.h Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.cpp - Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.h + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.h + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.h + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.h + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.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 6521d31b6..fa3d40c2a 100644 --- a/SerialPrograms/SerialPrograms.pro +++ b/SerialPrograms/SerialPrograms.pro @@ -718,6 +718,9 @@ SOURCES += \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.cpp \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.cpp \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.cpp \ + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp \ + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp \ + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp \ Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.cpp \ @@ -1810,6 +1813,9 @@ HEADERS += \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.h \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_03.h \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.h \ + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.h \ + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.h \ + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.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 5481137af..05adf0c91 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp @@ -20,9 +20,9 @@ #include "PokemonSV_AutoStory_Segment_02.h" #include "PokemonSV_AutoStory_Segment_03.h" #include "PokemonSV_AutoStory_Segment_04.h" -// #include "PokemonSV_AutoStory_Segment_05.h" -// #include "PokemonSV_AutoStory_Segment_06.h" -// #include "PokemonSV_AutoStory_Segment_07.h" +#include "PokemonSV_AutoStory_Segment_05.h" +#include "PokemonSV_AutoStory_Segment_06.h" +#include "PokemonSV_AutoStory_Segment_07.h" // #include "PokemonSV_AutoStory_Segment_08.h" // #include "PokemonSV_AutoStory_Segment_09.h" // #include "PokemonSV_AutoStory_Segment_10.h" @@ -53,9 +53,9 @@ 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()); + 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()); @@ -466,10 +466,10 @@ void AutoStory::test_checkpoints( checkpoint_list.push_back([&](){checkpoint_06(env, context, notif_status_update);}); checkpoint_list.push_back([&](){checkpoint_07(env, context, notif_status_update);}); checkpoint_list.push_back([&](){checkpoint_08(env, context, notif_status_update);}); - // checkpoint_list.push_back([&](){checkpoint_09(env, context, notif_status_update);}); - // checkpoint_list.push_back([&](){checkpoint_10(env, context, notif_status_update);}); - // checkpoint_list.push_back([&](){checkpoint_11(env, context, notif_status_update);}); - // checkpoint_list.push_back([&](){checkpoint_12(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_09(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_10(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_11(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_12(env, context, notif_status_update);}); // checkpoint_list.push_back([&](){checkpoint_13(env, context, notif_status_update);}); // checkpoint_list.push_back([&](){checkpoint_14(env, context, notif_status_update);}); // checkpoint_list.push_back([&](){checkpoint_15(env, context, notif_status_update);}); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp new file mode 100644 index 000000000..746319ee6 --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp @@ -0,0 +1,156 @@ +/* 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_05.h" + +//#include +//using std::cout; +//using std::endl; +//#include +//#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + +using namespace Pokemon; + + + + +std::string AutoStory_Segment_05::name() const{ + return "05: First Arven Battle"; +} + +std::string AutoStory_Segment_05::start_text() const{ + return "Start: Saved the Legendary. Escaped from the Houndoom cave."; +} + +std::string AutoStory_Segment_05::end_text() const{ + return "End: Battled Arven, received Legendary's Pokeball. Talked to Nemona at Lighthouse."; +} + +void AutoStory_Segment_05::run_segment(SingleSwitchProgramEnvironment& env, BotBaseContext& context, AutoStoryOptions options) const{ + AutoStoryStats& stats = env.current_stats(); + + context.wait_for_all_requests(); + env.console.log("Start Segment 05: First Arven Battle", COLOR_ORANGE); + env.console.overlay().add_log("Start Segment 05: First Arven Battle", COLOR_ORANGE); + + checkpoint_09(env, context, options.notif_status_update); + checkpoint_10(env, context, options.notif_status_update); + + context.wait_for_all_requests(); + env.console.log("End Segment 05: First Arven Battle", COLOR_GREEN); + env.console.overlay().add_log("End Segment 05: First Arven Battle", COLOR_GREEN); + stats.m_segment++; + env.update_stats(); + +} + + +void checkpoint_09( + SingleSwitchProgramEnvironment& env, + BotBaseContext& 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; + } + context.wait_for_all_requests(); + + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 230, 120, 100); + env.console.log("overworld_navigation: Go to Arven at the tower."); + overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, 128, 0, true, true); + + context.wait_for_all_requests(); + env.console.log("Found Arven"); + env.console.overlay().add_log("Found Arven", COLOR_WHITE); + // can lose battle, and story will still continue + mash_button_till_overworld(env.console, context, BUTTON_A); + context.wait_for_all_requests(); + env.console.log("Receive legendary ball"); + env.console.overlay().add_log("Receive legendary ball", COLOR_WHITE); + + 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_10( + SingleSwitchProgramEnvironment& env, + BotBaseContext& 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; + } + context.wait_for_all_requests(); + env.console.log("Lighthouse view"); + env.console.overlay().add_log("Lighthouse view", COLOR_WHITE); + do_action_and_monitor_for_battles(env.program_info(), env.console, context, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + realign_player(env.program_info(), console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 230, 110, 100); + pbf_move_left_joystick(context, 128, 0, 6 * TICKS_PER_SECOND, 8 * TICKS_PER_SECOND); + pbf_move_left_joystick(context, 128, 0, 4 * TICKS_PER_SECOND, 20); + pbf_move_left_joystick(context, 255, 128, 15, 20); + pbf_press_button(context, BUTTON_L, 20, 20); + pbf_move_left_joystick(context, 128, 0, 7 * TICKS_PER_SECOND, 20); + } + ); + + env.console.log("overworld_navigation: Go to Nemona on the lighthouse."); + overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_SPAM_A, 128, 0, 20, true, true); + + mash_button_till_overworld(env.console, context, BUTTON_A); + + 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_05.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.h new file mode 100644 index 000000000..5890905d4 --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.h @@ -0,0 +1,46 @@ +/* Autostory + * + * From: https://github.com/PokemonAutomation/Arduino-Source + * + */ + +#ifndef PokemonAutomation_PokemonSV_AutoStory_Segment_05_H +#define PokemonAutomation_PokemonSV_AutoStory_Segment_05_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_05 : 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: Rescued Koraidon/Miraidon and escaped from the Houndoom Cave. +// end: Battled Arven and received Legendary's Pokeball. +void checkpoint_09(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update); + +// start: Battled Arven and received Legendary's Pokeball. +// end: Talked to Nemona at the Lighthouse. +void checkpoint_10(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update); + +} +} +} +#endif diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp new file mode 100644 index 000000000..3b6d63cf8 --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp @@ -0,0 +1,123 @@ +/* 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_06.h" + +//#include +//using std::cout; +//using std::endl; +//#include +//#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + +using namespace Pokemon; + + + + +std::string AutoStory_Segment_06::name() const{ + return "06: Go to Los Platos"; +} + +std::string AutoStory_Segment_06::start_text() const{ + return "Start: Battled Arven, received Legendary's Pokeball. Talked to Nemona at Lighthouse."; +} + +std::string AutoStory_Segment_06::end_text() const{ + return "End: At Los Platos Pokecenter."; +} + +void AutoStory_Segment_06::run_segment(SingleSwitchProgramEnvironment& env, BotBaseContext& context, AutoStoryOptions options) const{ + AutoStoryStats& stats = env.current_stats(); + + context.wait_for_all_requests(); + env.console.log("Start Segment 06: Go to Los Platos", COLOR_ORANGE); + env.console.overlay().add_log("Start Segment 06: Go to Los Platos", COLOR_ORANGE); + + checkpoint_11(env, context, options.notif_status_update); + + context.wait_for_all_requests(); + env.console.log("End Segment 06: Go to Los Platos", COLOR_GREEN); + env.console.overlay().add_log("End Segment 06: Go to Los Platos", COLOR_GREEN); + stats.m_segment++; + env.update_stats(); + +} + + + +void checkpoint_11( + SingleSwitchProgramEnvironment& env, + BotBaseContext& 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; + } + + context.wait_for_all_requests(); + do_action_and_monitor_for_battles(env.program_info(), env.console, context, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + realign_player(info, console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 100, 210, 100); + pbf_move_left_joystick(context, 128, 0, 187, 20); + pbf_move_left_joystick(context, 0, 128, 30, 8 * TICKS_PER_SECOND); + pbf_move_left_joystick(context, 128, 0, 1 * TICKS_PER_SECOND, 2 * TICKS_PER_SECOND); + + realign_player(info, console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 100, 60, 200); + } + ); + + env.console.log("overworld_navigation: Go to Los Platos."); + overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, 128, 0, 75, true, true); + + env.console.log("clear_dialog: Talk with Nemona at Los Platos. Clear Let's go tutorial. Stop when detect overworld."); + clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::TUTORIAL, CallbackEnum::OVERWORLD}); + + context.wait_for_all_requests(); + + env.console.log("Reached Los Platos"); + env.console.overlay().add_log("Reached Los Platos", COLOR_WHITE); + + 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_06.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.h new file mode 100644 index 000000000..18a1cfeb5 --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.h @@ -0,0 +1,42 @@ +/* Autostory + * + * From: https://github.com/PokemonAutomation/Arduino-Source + * + */ + +#ifndef PokemonAutomation_PokemonSV_AutoStory_Segment_06_H +#define PokemonAutomation_PokemonSV_AutoStory_Segment_06_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_06 : 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: Talked to Nemona at the Lighthouse. +// end: Arrived at Los Platos pokecenter. Cleared Let's go tutorial. +void checkpoint_11(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update); + +} +} +} +#endif diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp new file mode 100644 index 000000000..248df8785 --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp @@ -0,0 +1,148 @@ +/* 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_07.h" + +//#include +//using std::cout; +//using std::endl; +//#include +//#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + +using namespace Pokemon; + + + + +std::string AutoStory_Segment_07::name() const{ + return "07: Go to Mesagoza South"; +} + +std::string AutoStory_Segment_07::start_text() const{ + return "Start: At Los Platos Pokecenter."; +} + +std::string AutoStory_Segment_07::end_text() const{ + return "End: At Mesagoza South Pokecenter."; +} + +void AutoStory_Segment_07::run_segment(SingleSwitchProgramEnvironment& env, BotBaseContext& context, AutoStoryOptions options) const{ + AutoStoryStats& stats = env.current_stats(); + + context.wait_for_all_requests(); + env.console.log("Start Segment 07: Go to Mesagoza South", COLOR_ORANGE); + env.console.overlay().add_log("Start Segment 07: Go to Mesagoza South", COLOR_ORANGE); + + checkpoint_12(env, context, options.notif_status_update); + + // // Mystery Gift, delete later + // enter_menu_from_overworld(env.program_info(), env.console, context, 2); + // pbf_press_button(context, BUTTON_A, 20, 4 * TICKS_PER_SECOND); + // pbf_press_dpad(context, DPAD_UP, 20, 105); + // pbf_press_button(context, BUTTON_A, 20, 4 * TICKS_PER_SECOND); + // pbf_press_dpad(context, DPAD_DOWN, 20, 105); + // pbf_press_button(context, BUTTON_A, 20, 4 * TICKS_PER_SECOND); + // pbf_press_button(context, BUTTON_A, 20, 10 * TICKS_PER_SECOND); + // clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 10); + + context.wait_for_all_requests(); + env.console.log("End Segment 07: Go to Mesagoza South", COLOR_GREEN); + env.console.overlay().add_log("End Segment 07: Go to Mesagoza South", COLOR_GREEN); + stats.m_segment++; + env.update_stats(); + +} + +void checkpoint_12( + SingleSwitchProgramEnvironment& env, + BotBaseContext& context, + EventNotificationOption& notif_status_update +){ + // reset rate: ~25%. 12 resets out of 52. + // resets due to: getting attacked by wild pokemon, either from behind, + // or when lead pokemon not strong enough to clear them with Let's go + AutoStoryStats& stats = env.current_stats(); + bool first_attempt = true; + while (true){ + try{ + do_action_and_monitor_for_battles(env.program_info(), env.console, context, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + + if (first_attempt){ + checkpoint_save(env, context, notif_status_update); + first_attempt = false; + } + + context.wait_for_all_requests(); + + fly_to_overlapping_flypoint(info, env.console, context); + + // re-orient camera + pbf_press_button(context, BUTTON_L, 20, 20); + + walk_forward_while_clear_front_path(info, env.console, context, 35); + realign_player(info, env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 128, 0, 100); + walk_forward_while_clear_front_path(info, env.console, context, 500); + realign_player(info, env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 100, 0, 120); + walk_forward_while_clear_front_path(info, env.console, context, 2000); + realign_player(info, env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 0, 120); + walk_forward_while_clear_front_path(info, env.console, context, 1250); + + // check we're not still at the Los Platos Pokecenter. + confirm_no_overlapping_flypoint(info, env.console, context); + + // not stuck at Los Platos Pokecenter + pbf_press_button(context, BUTTON_B, 20, 1 * TICKS_PER_SECOND); + pbf_press_button(context, BUTTON_B, 20, 1 * TICKS_PER_SECOND); + press_Bs_to_back_to_overworld(info, env.console, context, 7); + + realign_player(info, env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 80, 0, 100); + walk_forward_while_clear_front_path(info, env.console, context, 1500); + realign_player(info, env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 30, 0, 50); + walk_forward_while_clear_front_path(info, env.console, context, 1000); + + heal_at_pokecenter(info, env.console, context); + + } + ); + + env.console.log("Reached Mesagoza (South) Pokecenter."); + + 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_07.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.h new file mode 100644 index 000000000..3b651a2a2 --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.h @@ -0,0 +1,42 @@ +/* Autostory + * + * From: https://github.com/PokemonAutomation/Arduino-Source + * + */ + +#ifndef PokemonAutomation_PokemonSV_AutoStory_Segment_07_H +#define PokemonAutomation_PokemonSV_AutoStory_Segment_07_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_07 : 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: Arrived at Los Platos pokecenter. Cleared Let's go tutorial. +// end: Arrived at Mesagoza (South) Pokecenter +void checkpoint_12(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update); + +} +} +} +#endif