diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index 188f320fe..e99ece0f0 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -1467,6 +1467,10 @@ file(GLOB MAIN_SOURCES Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_13.h Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_14.cpp Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_14.h + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.cpp + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.h + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.cpp + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.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 25e11c809..2f3f2ea26 100644 --- a/SerialPrograms/SerialPrograms.pro +++ b/SerialPrograms/SerialPrograms.pro @@ -733,6 +733,8 @@ SOURCES += \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_12.cpp \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_13.cpp \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_14.cpp \ + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.cpp \ + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.cpp \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp \ Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.cpp \ @@ -1840,6 +1842,8 @@ HEADERS += \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_12.h \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_13.h \ Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_14.h \ + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.h \ + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.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 f3ab5a483..2c18d9e99 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp @@ -35,8 +35,8 @@ #include "PokemonSV_AutoStory_Segment_12.h" #include "PokemonSV_AutoStory_Segment_13.h" #include "PokemonSV_AutoStory_Segment_14.h" -// #include "PokemonSV_AutoStory_Segment_15.h" -// #include "PokemonSV_AutoStory_Segment_16.h" +#include "PokemonSV_AutoStory_Segment_15.h" +#include "PokemonSV_AutoStory_Segment_16.h" // #include "PokemonSV_AutoStory_Segment_17.h" // #include "PokemonSV_AutoStory_Segment_18.h" // #include "PokemonSV_AutoStory_Segment_19.h" @@ -79,8 +79,8 @@ 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()); @@ -593,13 +593,13 @@ void AutoStory::test_checkpoints( checkpoint_list.push_back([&](){checkpoint_27(env, context, notif_status_update);}); checkpoint_list.push_back([&](){checkpoint_28(env, context, notif_status_update);}); checkpoint_list.push_back([&](){checkpoint_29(env, context, notif_status_update);}); - // checkpoint_list.push_back([&](){checkpoint_30(env, context, notif_status_update);}); - // checkpoint_list.push_back([&](){checkpoint_31(env, context, notif_status_update);}); - // checkpoint_list.push_back([&](){checkpoint_32(env, context, notif_status_update);}); - // checkpoint_list.push_back([&](){checkpoint_33(env, context, notif_status_update);}); - // checkpoint_list.push_back([&](){checkpoint_34(env, context, notif_status_update);}); - // checkpoint_list.push_back([&](){checkpoint_35(env, context, notif_status_update);}); - // checkpoint_list.push_back([&](){checkpoint_36(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_30(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_31(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_32(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_33(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_34(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_35(env, context, notif_status_update);}); + checkpoint_list.push_back([&](){checkpoint_36(env, context, notif_status_update);}); // checkpoint_list.push_back([&](){checkpoint_37(env, context, notif_status_update);}); // checkpoint_list.push_back([&](){checkpoint_38(env, context, notif_status_update);}); // checkpoint_list.push_back([&](){checkpoint_39(env, context, notif_status_update);}); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.cpp new file mode 100644 index 000000000..0f08e6954 --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.cpp @@ -0,0 +1,346 @@ +/* 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/Inference/Dialogs/PokemonSV_DialogDetector.h" +#include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" +#include "PokemonSV_AutoStoryTools.h" +#include "PokemonSV_AutoStory_Segment_15.h" + +//#include +//using std::cout; +//using std::endl; +//#include +//#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + +using namespace Pokemon; + + + + +std::string AutoStory_Segment_15::name() const{ + return "12: Team Star (Dark)"; +} + +std::string AutoStory_Segment_15::start_text() const{ + return "Start: Defeated Bombirder. At West Province Area One North Pokecenter."; +} + +std::string AutoStory_Segment_15::end_text() const{ + return "End: Defeated Team Star (Dark). At Cascarrafa (West) Pokecenter."; +} + +void AutoStory_Segment_15::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 12: Team Star (Dark)", COLOR_ORANGE); + + checkpoint_32(env, context, options.notif_status_update); + checkpoint_33(env, context, options.notif_status_update); + checkpoint_34(env, context, options.notif_status_update); + + + context.wait_for_all_requests(); + env.console.log("End Segment 12: Team Star (Dark)", COLOR_GREEN); + stats.m_segment++; + env.update_stats(); + +} + + + +void checkpoint_32( + 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, 50, 0, 25); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10, false); + + // section 2 + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 255, 0, 80}, + {ZoomChange::ZOOM_IN, 5, 230, 145} + ); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10, false); + + // section 3 + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 255, 0, 60}, + {ZoomChange::ZOOM_IN, 5, 205, 100} + ); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10, false); + + // section 4 + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::ZOOM_IN, 128, 255, 40}, + {ZoomChange::KEEP_ZOOM, 255, 0, 110} + ); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10, false); + + mash_button_till_overworld(env.console, context, BUTTON_A, 360); + + // section 5 + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 255, 50); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 30, 30, false); + + // battle team star grunts + clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::BATTLE, CallbackEnum::PROMPT_DIALOG, CallbackEnum::DIALOG_ARROW}); + run_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG); + clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::OVERWORLD, CallbackEnum::BLACK_DIALOG_BOX}); + + + 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_33( + 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(); + + // enter the base + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 255, 50); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_SPAM_A, + 128, 0, 20, 20, false); + + 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, + [&](BotBaseContext& context){ + + DirectionDetector direction; + int seconds_wait = 6; + + pbf_move_left_joystick(context, 128, 0, 250, 100); + direction.change_direction(env.program_info(), env.console, context, 3); + pbf_move_left_joystick(context, 128, 0, 10, 100); + 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.1); + pbf_move_left_joystick(context, 128, 0, 750, 100); + 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.04); + pbf_move_left_joystick(context, 128, 0, 250, 100); + pbf_press_button(context, BUTTON_R, 20, 20); + pbf_wait(context, seconds_wait * TICKS_PER_SECOND); + + pbf_move_left_joystick(context, 128, 0, 500, 100); + direction.change_direction(env.program_info(), env.console, context, 5.39); + pbf_move_left_joystick(context, 128, 0, 10, 100); + 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.076); + pbf_move_left_joystick(context, 128, 0, 500, 100); + pbf_press_button(context, BUTTON_R, 20, 20); + pbf_wait(context, seconds_wait * TICKS_PER_SECOND); + + pbf_move_left_joystick(context, 128, 0, 250, 100); + direction.change_direction(env.program_info(), env.console, context, 4.800); + pbf_move_left_joystick(context, 128, 0, 250, 100); + pbf_press_button(context, BUTTON_R, 20, 20); + pbf_wait(context, seconds_wait * TICKS_PER_SECOND); + + pbf_move_left_joystick(context, 128, 0, 500, 100); + 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.32); + pbf_move_left_joystick(context, 128, 0, 250, 100); + 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, 6.16); + pbf_move_left_joystick(context, 128, 0, 250, 100); + 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.541); + pbf_move_left_joystick(context, 128, 0, 500, 100); + 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.41); + pbf_move_left_joystick(context, 128, 0, 350, 100); + 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.34); + pbf_move_left_joystick(context, 128, 0, 250, 100); + 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.556); + pbf_move_left_joystick(context, 128, 0, 500, 100); + 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){ + throw OperationFailedException( + ErrorReport::SEND_ERROR_REPORT, env.console, + "checkpoint_33(): Failed to kill 30 pokemon with Let's go.", + true + ); + } + clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::BATTLE, CallbackEnum::DIALOG_ARROW}); + run_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG, {}, true); + mash_button_till_overworld(env.console, context, BUTTON_A, 360); + + + 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_34( + 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::KEEP_ZOOM, 0, 128, 40}, + {ZoomChange::ZOOM_IN, 230, 0, 100} + ); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 40, 10, false); + + // section 2 + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 255, 100, 30}, + {ZoomChange::ZOOM_IN, 0, 240, 40} + ); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10, false); + + // section 3. set marker to pokecenter + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 0}, + {ZoomChange::ZOOM_IN, 0, 0, 0} + ); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10, false); + + // section 4. set marker past pokecenter + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 40, 100); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_TIME, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 15, 12, 12, false); + + 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_15.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.h new file mode 100644 index 000000000..90b6ad7ac --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.h @@ -0,0 +1,53 @@ +/* Autostory + * + * From: https://github.com/PokemonAutomation/Arduino-Source + * + */ + +#ifndef PokemonAutomation_PokemonSV_AutoStory_Segment_15_H +#define PokemonAutomation_PokemonSV_AutoStory_Segment_15_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_15 : 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: At West Province Area One North Pokecenter +// end: Defeated Team Star (Dark) grunts at base entrance +void checkpoint_32(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update); + +// start: Defeated Team star dark grunts at base entrance +// end: Defeated Team Star (Dark) boss +void checkpoint_33(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update); + +// start: Defeated Team Star (Dark) boss +// end: At Cascarrafa (West) Pokecenter. +void checkpoint_34(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update); + + + +} +} +} +#endif diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.cpp new file mode 100644 index 000000000..cca408902 --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.cpp @@ -0,0 +1,201 @@ +/* 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/Overworld/PokemonSV_OverworldDetector.h" +#include "PokemonSV_AutoStoryTools.h" +#include "PokemonSV_AutoStory_Segment_16.h" + +//#include +//using std::cout; +//using std::endl; +//#include +//#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + +using namespace Pokemon; + + + + +std::string AutoStory_Segment_16::name() const{ + return "13.1: Cascarrafa Gym (Water): Get Kofu's wallet"; +} + +std::string AutoStory_Segment_16::start_text() const{ + return "Start: Defeated Team Star (Dark). At Cascarrafa (West) Pokecenter."; +} + +std::string AutoStory_Segment_16::end_text() const{ + return "End: Received Kofu's wallet. At Porto Marinada Pokecenter."; +} + +void AutoStory_Segment_16::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 13.1: Cascarrafa Gym (Water): Get Kofu's wallet", COLOR_ORANGE); + + checkpoint_35(env, context, options.notif_status_update); + checkpoint_36(env, context, options.notif_status_update); + + context.wait_for_all_requests(); + env.console.log("End Segment 13.1: Cascarrafa Gym (Water): Get Kofu's wallet", COLOR_GREEN); + stats.m_segment++; + env.update_stats(); + +} + + +void checkpoint_35( + 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(); + DirectionDetector direction; + do_action_and_monitor_for_battles(env.program_info(), env.console, context, + [&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ + direction.change_direction(env.program_info(), env.console, context, 0.3491); + pbf_move_left_joystick(context, 128, 0, 400, 100); + direction.change_direction(env.program_info(), env.console, context, 5.075911); + pbf_move_left_joystick(context, 128, 0, 525, 100); + }); + + direction.change_direction(env.program_info(), env.console, context, 3.771252); + get_on_ride(env.program_info(), env.console, context); + // walk towards elevator + pbf_move_left_joystick(context, 128, 0, 700, 100); + // jump to ensure you get on elevator + pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 200); + pbf_wait(context, 3 * TICKS_PER_SECOND); + // wait for overworld to reappear after stepping off elevator + wait_for_overworld(env.program_info(), env.console, context, 30); + + pbf_move_left_joystick(context, 128, 0, 120, 100); + direction.change_direction(env.program_info(), env.console, context, 5.11); + walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 20); + 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(); + } + } + +} + +void checkpoint_36( + 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(); + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::ZOOM_IN, 100, 0, 80}); + + // section 1 + // warning: can't reliably set the marker when in Cascarrafa, possibly due to too many NPCs. worse when sandstorm is up. + // what happens is that the program doesn't reliably push the cursor as much as it should + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 135, 410); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 60, 20, false); + // talk to Arven over phone + mash_button_till_overworld(env.console, context, BUTTON_A, 360); + + // section 2 + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 80}, + {ZoomChange::ZOOM_IN, 255, 255, 110} + ); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 60, 20, false); + + // section 3 + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 40}, + {ZoomChange::ZOOM_IN, 255, 128, 45} + ); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 30, 10, false); + + // cutscene with Kofu looking at flowers + mash_button_till_overworld(env.console, context, BUTTON_A, 360); + + // section 4. set marker to pokecenter + realign_player_from_landmark( + env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 0}, + {ZoomChange::ZOOM_IN, 0, 0, 0} + ); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10, false); + + // section 5. set marker past pokecenter + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 100, 30); + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_TIME, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 15, 12, 12, false); + + 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_16.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.h new file mode 100644 index 000000000..8bb97c9e4 --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.h @@ -0,0 +1,50 @@ +/* Autostory + * + * From: https://github.com/PokemonAutomation/Arduino-Source + * + */ + +#ifndef PokemonAutomation_PokemonSV_AutoStory_Segment_16_H +#define PokemonAutomation_PokemonSV_AutoStory_Segment_16_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_16 : 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: At Cascarrafa (West) Pokecenter. +// end: At Cascarrafa Gym. Received Kofu's wallet. +void checkpoint_35(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update); + +// start: At Cascarrafa Gym. Received Kofu's wallet. +// end: At Porto Marinada Pokecenter. +void checkpoint_36(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update); + + + + + +} +} +} +#endif