From 0e39a5ee4bfabdd78a454bed3523a598bba27caf Mon Sep 17 00:00:00 2001 From: jw098 Date: Sun, 3 Nov 2024 14:23:58 -0800 Subject: [PATCH] segment 10 --- SerialPrograms/CMakeLists.txt | 4 +- SerialPrograms/SerialPrograms.pro | 2 + .../AutoStory/PokemonSV_AutoStory.cpp | 71 +++-- .../Programs/AutoStory/PokemonSV_AutoStory.h | 4 +- .../PokemonSV_AutoStory_Segment_10.cpp | 292 ++++++++++++++++++ .../PokemonSV_AutoStory_Segment_10.h | 51 +++ 6 files changed, 391 insertions(+), 33 deletions(-) create mode 100644 SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.cpp create mode 100644 SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.h diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index 7735619f33..2a805ace18 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -1453,7 +1453,9 @@ file(GLOB MAIN_SOURCES Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.cpp Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.h Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp - Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.h + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.h + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.cpp + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.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 15d0d0d768..dadf515a3d 100644 --- a/SerialPrograms/SerialPrograms.pro +++ b/SerialPrograms/SerialPrograms.pro @@ -726,6 +726,7 @@ SOURCES += \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.cpp \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp \ + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.cpp \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp \ Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.cpp \ @@ -1826,6 +1827,7 @@ HEADERS += \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.h \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.h \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.h \ + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.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 6929ff7dfd..14e45d3cba 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp @@ -25,7 +25,7 @@ #include "PokemonSV_AutoStory_Segment_07.h" #include "PokemonSV_AutoStory_Segment_08.h" #include "PokemonSV_AutoStory_Segment_09.h" -// #include "PokemonSV_AutoStory_Segment_10.h" +#include "PokemonSV_AutoStory_Segment_10.h" // #include "PokemonSV_AutoStory_Segment_11.h" // #include "PokemonSV_AutoStory_Segment_12.h" // #include "PokemonSV_AutoStory_Segment_13.h" @@ -45,6 +45,8 @@ namespace PokemonSV{ using namespace Pokemon; +static constexpr size_t INDEX_OF_LAST_TUTORIAL_SEGMENT = 9; + std::vector> make_autoStory_segment_list(){ std::vector> segment_list; @@ -58,7 +60,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()); // segment_list.emplace_back(std::make_unique()); @@ -91,7 +93,7 @@ StringSelectDatabase make_tutorial_segments_database(){ StringSelectDatabase ret; const StringSelectDatabase& all_segments = ALL_SEGMENTS_SELECT_DATABASE(); size_t start = 0; - size_t end = all_segments.case_list().size(); // 10. size() is the placeholder value. will be 10 when rest of segments merged. + size_t end = INDEX_OF_LAST_TUTORIAL_SEGMENT + 1; for (size_t i = start; i < end; i++){ const auto& segment = all_segments[i]; ret.add_entry(segment); @@ -107,7 +109,7 @@ const StringSelectDatabase& TUTORIAL_SEGMENTS_SELECT_DATABASE(){ StringSelectDatabase make_mainstory_segments_database(){ StringSelectDatabase ret; const StringSelectDatabase& all_segments = ALL_SEGMENTS_SELECT_DATABASE(); - size_t start = 0; // 10. 0 is the placeholder value. will be 10 when rest of segments merged. + size_t start = INDEX_OF_LAST_TUTORIAL_SEGMENT + 1; size_t end = all_segments.case_list().size(); for (size_t i = start; i < end; i++){ const auto& segment = all_segments[i]; @@ -171,20 +173,20 @@ AutoStory::AutoStory() "End Point:
Program will stop after completing this segment.", TUTORIAL_SEGMENTS_SELECT_DATABASE(), LockMode::UNLOCK_WHILE_RUNNING, - "0" //"9" + "9" ) - // , STARTPOINT_MAINSTORY( - // "Start Point:
Program will start with this segment.", - // MAINSTORY_SEGMENTS_SELECT_DATABASE(), - // LockMode::UNLOCK_WHILE_RUNNING, - // "10" - // ) - // , ENDPOINT_MAINSTORY( - // "End Point:
Program will stop after completing this segment.", - // MAINSTORY_SEGMENTS_SELECT_DATABASE(), - // LockMode::UNLOCK_WHILE_RUNNING, - // "10" - // ) + , STARTPOINT_MAINSTORY( + "Start Point:
Program will start with this segment.", + MAINSTORY_SEGMENTS_SELECT_DATABASE(), + LockMode::UNLOCK_WHILE_RUNNING, + "10" + ) + , ENDPOINT_MAINSTORY( + "End Point:
Program will stop after completing this segment.", + MAINSTORY_SEGMENTS_SELECT_DATABASE(), + LockMode::UNLOCK_WHILE_RUNNING, + "10" + ) , MAINSTORY_NOTE{ "Ensure you have a level 100 Gardevoir with the moves in the following order: Moonblast, Dazzling Gleam, Psychic, Mystical Fire.
" "Refer to the documentation on github for more details." @@ -322,10 +324,10 @@ AutoStory::AutoStory() PA_ADD_OPTION(STORY_SECTION); PA_ADD_OPTION(STARTPOINT_TUTORIAL); PA_ADD_OPTION(MAINSTORY_NOTE); - // PA_ADD_OPTION(STARTPOINT_MAINSTORY); + PA_ADD_OPTION(STARTPOINT_MAINSTORY); PA_ADD_OPTION(START_DESCRIPTION); PA_ADD_OPTION(ENDPOINT_TUTORIAL); - // PA_ADD_OPTION(ENDPOINT_MAINSTORY); + PA_ADD_OPTION(ENDPOINT_MAINSTORY); PA_ADD_OPTION(END_DESCRIPTION); PA_ADD_OPTION(STARTERCHOICE); PA_ADD_OPTION(GO_HOME_WHEN_DONE); @@ -362,8 +364,8 @@ AutoStory::AutoStory() STORY_SECTION.add_listener(*this); STARTPOINT_TUTORIAL.add_listener(*this); ENDPOINT_TUTORIAL.add_listener(*this); - // STARTPOINT_MAINSTORY.add_listener(*this); - // ENDPOINT_MAINSTORY.add_listener(*this); + STARTPOINT_MAINSTORY.add_listener(*this); + ENDPOINT_MAINSTORY.add_listener(*this); ENABLE_TEST_CHECKPOINTS.add_listener(*this); ENABLE_TEST_REALIGN.add_listener(*this); ENABLE_TEST_OVERWORLD_MOVE.add_listener(*this); @@ -380,14 +382,14 @@ void AutoStory::value_changed(void* object){ STARTPOINT_TUTORIAL.set_visibility(ConfigOptionState::ENABLED); ENDPOINT_TUTORIAL.set_visibility(ConfigOptionState::ENABLED); - // STARTPOINT_MAINSTORY.set_visibility(ConfigOptionState::HIDDEN); - // ENDPOINT_MAINSTORY.set_visibility(ConfigOptionState::HIDDEN); + STARTPOINT_MAINSTORY.set_visibility(ConfigOptionState::HIDDEN); + ENDPOINT_MAINSTORY.set_visibility(ConfigOptionState::HIDDEN); }else if (STORY_SECTION == StorySection::MAIN_STORY){ STARTPOINT_TUTORIAL.set_visibility(ConfigOptionState::HIDDEN); ENDPOINT_TUTORIAL.set_visibility(ConfigOptionState::HIDDEN); - // STARTPOINT_MAINSTORY.set_visibility(ConfigOptionState::ENABLED); - // ENDPOINT_MAINSTORY.set_visibility(ConfigOptionState::ENABLED); + STARTPOINT_MAINSTORY.set_visibility(ConfigOptionState::ENABLED); + ENDPOINT_MAINSTORY.set_visibility(ConfigOptionState::ENABLED); } MAINSTORY_NOTE.set_visibility(STORY_SECTION == StorySection::TUTORIAL ? ConfigOptionState::HIDDEN : ConfigOptionState::ENABLED); @@ -478,9 +480,9 @@ void AutoStory::test_checkpoints( checkpoint_list.push_back([&](){checkpoint_18(env, context, notif_status_update);}); checkpoint_list.push_back([&](){checkpoint_19(env, context, notif_status_update);}); checkpoint_list.push_back([&](){checkpoint_20(env, context, notif_status_update);}); - // checkpoint_list.push_back([&](){checkpoint_21(env, context, notif_status_update);}); - // checkpoint_list.push_back([&](){checkpoint_22(env, context, notif_status_update);}); - // checkpoint_list.push_back([&](){checkpoint_23(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_21(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_22(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_23(env, context, notif_status_update);}); // checkpoint_list.push_back([&](){checkpoint_24(env, context, notif_status_update);}); // checkpoint_list.push_back([&](){checkpoint_25(env, context, notif_status_update);}); // checkpoint_list.push_back([&](){checkpoint_26(env, context, notif_status_update);}); @@ -527,7 +529,7 @@ std::string AutoStory::start_segment_description(){ if (STORY_SECTION == StorySection::TUTORIAL){ segment_index = STARTPOINT_TUTORIAL.index(); }else if (STORY_SECTION == StorySection::MAIN_STORY){ - // segment_index = STARTPOINT_MAINSTORY.index() + 10; + segment_index = STARTPOINT_MAINSTORY.index() + (INDEX_OF_LAST_TUTORIAL_SEGMENT + 1); } return ALL_AUTO_STORY_SEGMENT_LIST()[segment_index]->start_text(); } @@ -537,7 +539,7 @@ std::string AutoStory::end_segment_description(){ if (STORY_SECTION == StorySection::TUTORIAL){ segment_index = ENDPOINT_TUTORIAL.index(); }else if (STORY_SECTION == StorySection::MAIN_STORY){ - // segment_index = ENDPOINT_MAINSTORY.index() + 10; + segment_index = ENDPOINT_MAINSTORY.index() + (INDEX_OF_LAST_TUTORIAL_SEGMENT + 1); } return ALL_AUTO_STORY_SEGMENT_LIST()[segment_index]->end_text(); } @@ -552,6 +554,15 @@ void AutoStory::run_autostory(SingleSwitchProgramEnvironment& env, BotBaseContex size_t start = STARTPOINT_TUTORIAL.index(); size_t end = ENDPOINT_TUTORIAL.index(); + + if (STORY_SECTION == StorySection::TUTORIAL){ + start = STARTPOINT_TUTORIAL.index(); + end = ENDPOINT_TUTORIAL.index(); + }else if (STORY_SECTION == StorySection::MAIN_STORY){ + start = (INDEX_OF_LAST_TUTORIAL_SEGMENT + 1) + STARTPOINT_MAINSTORY.index(); + end = (INDEX_OF_LAST_TUTORIAL_SEGMENT + 1) + ENDPOINT_MAINSTORY.index(); + } + for (size_t segment_index = start; segment_index <= end; segment_index++){ ALL_AUTO_STORY_SEGMENT_LIST()[segment_index]->run_segment(env, context, options); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h index a6715346bc..50230698db 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h @@ -71,8 +71,8 @@ class AutoStory : public SingleSwitchProgramInstance, public ConfigOption::Liste StringSelectOption STARTPOINT_TUTORIAL; StringSelectOption ENDPOINT_TUTORIAL; - // StringSelectOption STARTPOINT_MAINSTORY; - // StringSelectOption ENDPOINT_MAINSTORY; + StringSelectOption STARTPOINT_MAINSTORY; + StringSelectOption ENDPOINT_MAINSTORY; StaticTextOption MAINSTORY_NOTE; diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.cpp new file mode 100644 index 0000000000..3df20aa946 --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.cpp @@ -0,0 +1,292 @@ +/* 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 "CommonFramework/Inference/BlackScreenDetector.h" +#include "PokemonSV_AutoStoryTools.h" +#include "PokemonSV_AutoStory_Segment_10.h" + +//#include +//using std::cout; +//using std::endl; +//#include +//#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + +using namespace Pokemon; + + + + +std::string AutoStory_Segment_10::name() const{ + return "10.1: Cortondo Gym - Go to Cortondo city"; +} + +std::string AutoStory_Segment_10::start_text() const{ + return "Start: After the break, with level 100 Gardevoir. At Mesagoza West pokecenter."; +} + +std::string AutoStory_Segment_10::end_text() const{ + return "End: At Cortondo East Pokecenter."; +} + +void AutoStory_Segment_10::run_segment(SingleSwitchProgramEnvironment& env, BotBaseContext& context, AutoStoryOptions options) const{ + AutoStoryStats& stats = env.current_stats(); + + context.wait_for_all_requests(); + env.console.overlay().add_log("Start Segment 10.1: Cortondo Gym - Go to Cortondo city", COLOR_ORANGE); + + checkpoint_21(env, context, options.notif_status_update); + checkpoint_22(env, context, options.notif_status_update); + checkpoint_23(env, context, options.notif_status_update); + + context.wait_for_all_requests(); + env.console.log("End Segment 10.1: Cortondo Gym - Go to Cortondo city", COLOR_GREEN); + stats.m_segment++; + env.update_stats(); + +} + +void checkpoint_21( + 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; + } + fly_to_overlapping_flypoint(env.program_info(), env.console, context); + + context.wait_for_all_requests(); + pbf_press_button(context, BUTTON_L, 20, 20); + // move forward + pbf_move_left_joystick(context, 128, 0, 30, 100); + // get on ride + get_on_ride(env.program_info(), env.console, context); + // turn left + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NO_MARKER, 0, 128, 50); + // move forward + pbf_move_left_joystick(context, 128, 0, 100, 100); + + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 200, 70); + pbf_move_left_joystick(context, 128, 0, 400, 100); + + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 128, 70); + pbf_move_left_joystick(context, 128, 0, 700, 100); + + // turn towards wall + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 128, 0, 50); + pbf_move_left_joystick(context, 128, 0, 200, 100); + // run and jump over wall + pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 100); + + BlackScreenOverWatcher black_screen(COLOR_RED, { 0.2, 0.2, 0.6, 0.6 }); + int ret = wait_until( + env.console, context, + std::chrono::seconds(30), + { black_screen } + ); + if (ret < 0){ + throw OperationFailedException( + ErrorReport::SEND_ERROR_REPORT, env.console, + "checkpoint_21(): Failed to jump the East Mesagoza wall.", + true + ); + } + context.wait_for_all_requests(); + fly_to_overlapping_flypoint(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_22( + 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(); + // section 1 + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::ZOOM_IN, 0, 128, 80}, + {ZoomChange::KEEP_ZOOM, 255, 80, 37} + ); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 40, 20); + + // section 2 + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::ZOOM_IN, 0, 128, 40}, + {ZoomChange::KEEP_ZOOM, 255, 255, 27} + ); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 30, 15); + + // section 3. set marker to pokecenter + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::ZOOM_IN, 128, 128, 0}, + {ZoomChange::KEEP_ZOOM, 128, 128, 0} + ); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 30, 15); + + // section 3. set marker past pokecenter + handle_unexpected_battles(env.program_info(), env.console, context, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 70, 30); + }); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_TIME, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 20, 12, 12); + + fly_to_overlapping_flypoint(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_23( + 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(); + + // section 1 + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 110, 0, 30); + + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10); + + // section 2 + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::ZOOM_IN, 0, 128, 80}, + {ZoomChange::KEEP_ZOOM, 255, 95, 100} + ); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10); + + // section 3 + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::ZOOM_IN, 0, 128, 80}, + {ZoomChange::KEEP_ZOOM, 255, 75, 65} + ); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10); + + // section 4 + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::ZOOM_IN, 0, 128, 50}, + {ZoomChange::KEEP_ZOOM, 255, 180, 17} + ); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 40, 10); + + // section 5. set marker to pokecenter + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::ZOOM_IN, 128, 128, 0}, + {ZoomChange::KEEP_ZOOM, 128, 128, 0} + ); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10); + + // section 6. set marker past pokecenter + handle_unexpected_battles(env.program_info(), env.console, context, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 110, 50); + }); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_TIME, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 15, 12, 12); + + fly_to_overlapping_flypoint(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_10.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.h new file mode 100644 index 0000000000..e87b5d4f44 --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_10.h @@ -0,0 +1,51 @@ +/* Autostory + * + * From: https://github.com/PokemonAutomation/Arduino-Source + * + */ + +#ifndef PokemonAutomation_PokemonSV_AutoStory_Segment_10_H +#define PokemonAutomation_PokemonSV_AutoStory_Segment_10_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_10 : 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: After the break, with level 100 Gardevoir. At Mesagoza West pokecenter. +// end: At Mesagoza West gate flypoint +void checkpoint_21(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update); + +// start: At Mesagoza West gate flypoint +// end: At South Province Area Two Pokecenter. +void checkpoint_22(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update); + +// start: At South Province Area Two Pokecenter. +// end: At Cortondo East Pokecenter +void checkpoint_23(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update); + + +} +} +} +#endif