diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp index a2eeaf1a0..c1e4f11eb 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp @@ -135,7 +135,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()); } return segment_list; }; @@ -311,7 +311,7 @@ std::vector> make_autoStory_checkpoint_lis checkpoint_list.emplace_back(std::make_unique()); checkpoint_list.emplace_back(std::make_unique()); checkpoint_list.emplace_back(std::make_unique()); - // checkpoint_list.emplace_back(std::make_unique()); + checkpoint_list.emplace_back(std::make_unique()); // checkpoint_list.emplace_back(std::make_unique()); } @@ -479,8 +479,9 @@ AutoStory::AutoStory() } , MAINSTORY_NOTE{ "Ensure you have a level 100 Gardevoir with the moves in the following order: Moonblast, Mystical Fire, Psychic, Misty Terrain." - "Ensure PP is maxed out. Ensure Modest nature with max Special Attack and Speed EVs, with max IVs.
" - "Also, make sure you have two other strong pokemon (e.g. level 100 Talonflames)
" + "Ensure PP is maxed out (Moonblast should have 24 PP). Ensure Modest nature with max Special Attack and Speed EVs, with max IVs. " + "After vitamins, mint and hypertraining, the stats should be as follows: HP 277, Attack [doesn't matter], Defense 167, Speed 259, Sp. Def 266, Sp. Atk 383.
" + "Also, make sure you have two other strong pokemon (e.g. level 100 Talonflames), ideally with a strong first move (e.g. Acrobatics for Talonflame).
" "Refer to the documentation on github for more details." } , START_DESCRIPTION( @@ -1053,7 +1054,7 @@ void AutoStory::test_checkpoints( checkpoint_list.push_back([&](){checkpoint_101(env, context, notif_status_update, stats);}); checkpoint_list.push_back([&](){checkpoint_102(env, context, notif_status_update, stats);}); checkpoint_list.push_back([&](){checkpoint_103(env, context, notif_status_update, stats);}); - // checkpoint_list.push_back([&](){checkpoint_104(env, context, notif_status_update, stats);}); + checkpoint_list.push_back([&](){checkpoint_104(env, context, notif_status_update, stats);}); // checkpoint_list.push_back([&](){checkpoint_105(env, context, notif_status_update, stats);}); @@ -1303,7 +1304,7 @@ void AutoStory::test_code(SingleSwitchProgramEnvironment& env, ProControllerCont // move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "tree-tera", 0.294444); // move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-tera", 0.604688); - + return; } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index 1c52ff681..5c9695953 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -79,7 +79,8 @@ void clear_tutorial(VideoStream& stream, ProControllerContext& context, uint16_t void clear_dialog(VideoStream& stream, ProControllerContext& context, ClearDialogMode mode, uint16_t seconds_timeout, - std::vector enum_optional_callbacks + std::vector enum_optional_callbacks, + bool press_A ){ bool seen_dialog = false; WallClock start = current_time(); @@ -148,12 +149,12 @@ void clear_dialog(VideoStream& stream, ProControllerContext& context, stream, context, [&](ProControllerContext& context){ - if (mode == ClearDialogMode::STOP_TIMEOUT){ + if (mode == ClearDialogMode::STOP_TIMEOUT || !press_A){ context.wait_for(Seconds(seconds_timeout)); - }else{ // press A every 8 seconds, until we time out. - auto button_press_period = Seconds(8); + }else{ // press A every 25 seconds, until we time out. + auto button_press_period = Seconds(25); while (true){ - if (current_time() - start_inference + button_press_period > Seconds(seconds_timeout)){ + if (current_time() - start_inference > Seconds(seconds_timeout)){ break; } context.wait_for(button_press_period); @@ -208,6 +209,9 @@ void clear_dialog(VideoStream& stream, ProControllerContext& context, case CallbackEnum::DIALOG_ARROW: stream.log("clear_dialog: Detected dialog arrow."); seen_dialog = true; + if (mode == ClearDialogMode::STOP_BATTLE_DIALOG_ARROW){ + return; + } pbf_press_button(context, BUTTON_A, 20, 105); break; case CallbackEnum::BATTLE: @@ -358,9 +362,9 @@ void overworld_navigation( if (movement_mode == NavigationMovementMode::CLEAR_WITH_LETS_GO){ walk_forward_while_clear_front_path(info, stream, context, forward_ticks, y); }else{ - ssf_press_left_joystick(context, x, y, 0, seconds_realign * TICKS_PER_SECOND); + ssf_press_left_joystick(context, x, y, 0ms, Seconds(seconds_realign)); if (movement_mode == NavigationMovementMode::DIRECTIONAL_ONLY){ - pbf_wait(context, seconds_realign * TICKS_PER_SECOND); + pbf_wait(context, Seconds(seconds_realign)); } else if (movement_mode == NavigationMovementMode::DIRECTIONAL_SPAM_A){ for (size_t j = 0; j < 5 * seconds_realign; j++){ pbf_press_button(context, BUTTON_A, 20, 5); @@ -1059,9 +1063,9 @@ void press_A_until_dialog( int ret = run_until( stream, context, [seconds_between_button_presses](ProControllerContext& context){ - pbf_wait(context, seconds_between_button_presses * TICKS_PER_SECOND); // avoiding pressing A if dialog already present + pbf_wait(context, Seconds(seconds_between_button_presses)); // avoiding pressing A if dialog already present for (size_t c = 0; c < 10; c++){ - pbf_press_button(context, BUTTON_A, 20, seconds_between_button_presses * TICKS_PER_SECOND); + pbf_press_button(context, BUTTON_A, 20*8ms, Seconds(seconds_between_button_presses)); } }, {advance_dialog} diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h index 7d1081368..a75bc0d4e 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h @@ -45,6 +45,7 @@ enum class ClearDialogMode{ STOP_TIMEOUT, STOP_BATTLE, STOP_TUTORIAL, + STOP_BATTLE_DIALOG_ARROW, }; @@ -123,9 +124,11 @@ void clear_tutorial(VideoStream& stream, ProControllerContext& context, uint16_t // stop depending on ClearDialogMode: stop when detect overworld, or dialog prompt, or A button prompt. Or if times out // throw exception if times out, unless this is the intended stop condition. // also throw exception if dialog is never detected. +// NOTE: seconds_timeout is rounded up to a multiple of 25, unless press_A is false or ClearDialogMode == STOP_TIMEOUT void clear_dialog(VideoStream& stream, ProControllerContext& context, - ClearDialogMode mode, uint16_t seconds_timeout = 60, - std::vector optional_callbacks = {} + ClearDialogMode mode, uint16_t seconds_timeout = 75, + std::vector optional_callbacks = {}, + bool press_A = true ); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp index 4ceb778ea..e16c17379 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp @@ -211,10 +211,10 @@ void checkpoint_18( pbf_mash_button(context, BUTTON_A, 6 * TICKS_PER_SECOND); env.console.log("Talk to Clavell in his office, and the professor."); - // clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 25, - // {CallbackEnum::PROMPT_DIALOG}); // max time between dialog: 17s. set timeout to 25 seconds for buffer. - // // mash A to get through the Random A press that you need. when the professor shows you area zero. - // pbf_mash_button(context, BUTTON_A, 3 * TICKS_PER_SECOND); + clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 25, + {CallbackEnum::PROMPT_DIALOG}); // max time between dialog: 17s. set timeout to 25 seconds for buffer. + // mash A to get through the Random A press that you need. when the professor shows you area zero. + pbf_mash_button(context, BUTTON_A, 3 * TICKS_PER_SECOND); clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::OVERWORLD, CallbackEnum::PROMPT_DIALOG}); @@ -280,11 +280,11 @@ void checkpoint_20( walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 60, 128, 0); env.console.log("Talk to Nemona, Arven, Cassiopeia."); - // clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 16, - // {CallbackEnum::PROMPT_DIALOG, CallbackEnum::BLACK_DIALOG_BOX}); // max time between dialog: 11 + clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 16, + {CallbackEnum::PROMPT_DIALOG, CallbackEnum::BLACK_DIALOG_BOX}); // max time between dialog: 11 - // // mash A to get through the Random A press that you need. when the Nemona shows you a Poke Gym. - // pbf_mash_button(context, BUTTON_A, 250); + // mash A to get through the Random A press that you need. when the Nemona shows you a Poke Gym. + pbf_mash_button(context, BUTTON_A, 250); clear_dialog(env.console, context, ClearDialogMode::STOP_TUTORIAL, 20, {CallbackEnum::TUTORIAL, CallbackEnum::PROMPT_DIALOG, CallbackEnum::BLACK_DIALOG_BOX}); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_11.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_11.cpp index 7962f1c42..1d55a0779 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_11.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_11.cpp @@ -4,6 +4,8 @@ * */ +#include "CommonFramework/VideoPipeline/VideoFeed.h" + #include "CommonTools/Async/InferenceRoutines.h" #include "NintendoSwitch/NintendoSwitch_Settings.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" @@ -113,6 +115,13 @@ void checkpoint_24( [&](size_t attempt_number){ context.wait_for_all_requests(); DirectionDetector direction; + VideoSnapshot snapshot = env.console.video().snapshot(); + double current_direction = direction.get_current_direction(env.console, snapshot); + if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap. + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0}); + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0}); + } + do_action_and_monitor_for_battles(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ direction.change_direction(env.program_info(), env.console, context, 2.71); @@ -188,6 +197,8 @@ void checkpoint_25( // section 3 DirectionDetector direction; + // we just hope the minimap Direction isn't covered + direction.change_direction(env.program_info(), env.console, context, 6.0); pbf_move_left_joystick(context, 128, 0, 700, 100); @@ -292,6 +303,8 @@ void checkpoint_26( // section 1b. realign using fence corner DirectionDetector direction; + // we just hope the minimap Direction isn't covered + direction.change_direction(env.program_info(), env.console, context, 2.74); pbf_move_left_joystick(context, 128, 0, 200, 50); direction.change_direction(env.program_info(), env.console, context, 4.328); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_12.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_12.cpp index 46f0103a8..38b80d2f0 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_12.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_12.cpp @@ -4,6 +4,8 @@ * */ +#include "CommonFramework/VideoPipeline/VideoFeed.h" + #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonFramework/VideoPipeline/VideoOverlay.h" #include "CommonTools/Async/InferenceRoutines.h" @@ -83,6 +85,13 @@ void checkpoint_28( [&](size_t attempt_number){ context.wait_for_all_requests(); DirectionDetector direction; + VideoSnapshot snapshot = env.console.video().snapshot(); + double current_direction = direction.get_current_direction(env.console, snapshot); + if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap. + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0}); + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0}); + } + do_action_and_monitor_for_battles(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ direction.change_direction(env.program_info(), env.console, context, 2.71); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_13.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_13.cpp index 390308af9..7cc19fccf 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_13.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_13.cpp @@ -83,9 +83,17 @@ void checkpoint_29( realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 70, 0, 60); - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 30, 15, false); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 30, 15, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 255, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); // align for long stretch 1, part 2 realign_player_from_landmark( @@ -94,9 +102,17 @@ void checkpoint_29( {ZoomChange::KEEP_ZOOM, 80, 0, 75} ); - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 12, 12, false); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 24, 12, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 255, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); // align for long stretch 1, part 3 @@ -106,9 +122,17 @@ void checkpoint_29( {ZoomChange::KEEP_ZOOM, 95, 0, 115} ); - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 36, 12, false); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 36, 12, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 255, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); // align for long stretch 2 realign_player_from_landmark( @@ -117,9 +141,17 @@ void checkpoint_29( {ZoomChange::KEEP_ZOOM, 0, 105, 65} ); - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 45, 15, false); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 45, 15, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 255, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); // align for long stretch 3, part 1 realign_player_from_landmark( @@ -129,9 +161,17 @@ void checkpoint_29( ); - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 20, 10, false); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 255, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); // align for long stretch 3, part 2 realign_player_from_landmark( @@ -141,9 +181,17 @@ void checkpoint_29( ); - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 30, 10, false); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 30, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 255, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); // align for long stretch 3, part 3 realign_player_from_landmark( @@ -153,27 +201,57 @@ void checkpoint_29( ); - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 30, 10, false); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 30, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 255, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); - // align for long stretch 3, part 4 - realign_player_from_landmark( - env.program_info(), env.console, context, - {ZoomChange::ZOOM_IN, 0, 128, 100}, - {ZoomChange::KEEP_ZOOM, 255, 67, 85} //{ZoomChange::KEEP_ZOOM, 255, 70, 90} + // // align for long stretch 3, part 4 + // realign_player_from_landmark( + // env.program_info(), env.console, context, + // {ZoomChange::ZOOM_IN, 0, 128, 100}, + // {ZoomChange::KEEP_ZOOM, 255, 67, 85} //{ZoomChange::KEEP_ZOOM, 255, 70, 90} + // ); + + //align for long stretch 3, part 4. just prior to bridge. {0.339062, 0.612037} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 0}, + FlyPoint::POKECENTER, + {0.339062, 0.612037} ); - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 36, 12, false); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 36, 12, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 255, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); - // align to cross bridge - realign_player_from_landmark( - env.program_info(), env.console, context, - {ZoomChange::ZOOM_IN, 0, 128, 90}, - {ZoomChange::KEEP_ZOOM, 255, 35, 67} + // // align to cross bridge + // realign_player_from_landmark( + // env.program_info(), env.console, context, + // {ZoomChange::ZOOM_IN, 0, 128, 90}, + // {ZoomChange::KEEP_ZOOM, 255, 35, 67} + // ); + + // align to cross bridge {0.385937, 0.615741} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 0}, + FlyPoint::POKECENTER, + {0.385937, 0.615741} ); @@ -198,11 +276,19 @@ void checkpoint_29( }catch(OperationFailedException&){ // try again if fall into water pbf_mash_button(context, BUTTON_A, 250); + // // walk back to start position before bridge + // realign_player_from_landmark( + // env.program_info(), env.console, context, + // {ZoomChange::ZOOM_IN, 255, 255, 180}, + // {ZoomChange::KEEP_ZOOM, 33, 0, 175} + // ); + // walk back to start position before bridge - realign_player_from_landmark( - env.program_info(), env.console, context, - {ZoomChange::ZOOM_IN, 255, 255, 180}, - {ZoomChange::KEEP_ZOOM, 33, 0, 175} + // {0.310937, 0.580556} {0.310937, 0.589815} {0.310937, 0.584259} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 0}, + FlyPoint::POKECENTER, + {0.310937, 0.584259} ); overworld_navigation(env.program_info(), env.console, context, @@ -210,11 +296,18 @@ void checkpoint_29( 128, 0, 20, 20, false); - // align to cross bridge - realign_player_from_landmark( - env.program_info(), env.console, context, - {ZoomChange::ZOOM_IN, 0, 128, 90}, - {ZoomChange::KEEP_ZOOM, 255, 35, 67} + // // align to cross bridge + // realign_player_from_landmark( + // env.program_info(), env.console, context, + // {ZoomChange::ZOOM_IN, 0, 128, 90}, + // {ZoomChange::KEEP_ZOOM, 255, 35, 67} + // ); + + // align to cross bridge {0.385937, 0.615741} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 0}, + FlyPoint::POKECENTER, + {0.385937, 0.615741} ); @@ -238,9 +331,18 @@ void checkpoint_29( ); - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 20, 10, false); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 255, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + // align for post-bridge section 2 realign_player_from_landmark( @@ -250,9 +352,17 @@ void checkpoint_29( ); - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 20, 10, false); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 255, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); // align for post-bridge section 3. move up towards tree realign_player_from_landmark( @@ -262,9 +372,17 @@ void checkpoint_29( ); - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 20, 10, false); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 255, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); // align for post-bridge section 4 realign_player_from_landmark( @@ -274,9 +392,17 @@ void checkpoint_29( ); - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 20, 10, false); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 20, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 255, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); @@ -288,9 +414,17 @@ void checkpoint_29( ); - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 30, 10, false); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 30, 10, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 255, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); // align for post-bridge section 6. set marker past pokecenter diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.cpp index 98f48a6d2..09e43fda2 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_15.cpp @@ -4,6 +4,8 @@ * */ +#include "CommonFramework/VideoPipeline/VideoFeed.h" + #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonFramework/VideoPipeline/VideoOverlay.h" #include "CommonTools/Async/InferenceRoutines.h" @@ -147,6 +149,17 @@ void checkpoint_32( run_trainer_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG); clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::OVERWORLD, CallbackEnum::BLACK_DIALOG_BOX}); + context.wait_for_all_requests(); + VideoSnapshot snapshot = env.console.video().snapshot(); + DirectionDetector direction; + double current_direction = direction.get_current_direction(env.console, snapshot); + if (current_direction == -1){ // if unable to detect current direction, reset. We need to be able to detect the direction for the next checkpoint. + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "Unable to detect direction. Reset.", + env.console + ); + } }); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.cpp index 118c98363..e6ea0c254 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.cpp @@ -4,6 +4,8 @@ * */ +#include "CommonFramework/VideoPipeline/VideoFeed.h" + #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonFramework/VideoPipeline/VideoOverlay.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" @@ -86,6 +88,13 @@ void checkpoint_35( [&](size_t attempt_number){ context.wait_for_all_requests(); DirectionDetector direction; + VideoSnapshot snapshot = env.console.video().snapshot(); + double current_direction = direction.get_current_direction(env.console, snapshot); + if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap. + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0}); + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0}); + } + do_action_and_monitor_for_battles(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ direction.change_direction(env.program_info(), env.console, context, 0.3491); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.cpp index 22d7ab07e..c0faf7b4f 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.cpp @@ -4,6 +4,8 @@ * */ +#include "CommonFramework/VideoPipeline/VideoFeed.h" + #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonFramework/VideoPipeline/VideoOverlay.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" @@ -86,6 +88,13 @@ void checkpoint_37( [&](size_t attempt_number){ context.wait_for_all_requests(); DirectionDetector direction; + VideoSnapshot snapshot = env.console.video().snapshot(); + double current_direction = direction.get_current_direction(env.console, snapshot); + if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap. + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::ZOOM_OUT, 255, 128, 50}); + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::ZOOM_OUT, 0, 128, 80}); + } + do_action_and_monitor_for_battles(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 255, 50); @@ -129,6 +138,8 @@ void checkpoint_38( context.wait_for_all_requests(); move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 255, 180, 170}); DirectionDetector direction; + // recently flew a significant distance, so minimap should be clear of Pokemon + do_action_and_monitor_for_battles(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ direction.change_direction(env.program_info(), env.console, context, 0.3491); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.cpp index c5605a117..5b873b0c6 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.cpp @@ -91,6 +91,7 @@ void checkpoint_39( context.wait_for_all_requests(); DirectionDetector direction; + // recently flew a significant distance, so minimap should be clear of Pokemon // section 1 do_action_and_monitor_for_battles(env.program_info(), env.console, context, @@ -256,6 +257,8 @@ void checkpoint_40( realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 180, 90); DirectionDetector direction; + // recently flew a significant distance, so minimap should be clear of Pokemon + direction.change_direction(env.program_info(), env.console, context, 5.60); get_on_ride(env.program_info(), env.console, context); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.cpp index a92166c23..7bce5d6da 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.cpp @@ -4,6 +4,8 @@ * */ +#include "CommonFramework/VideoPipeline/VideoFeed.h" + #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonFramework/VideoPipeline/VideoOverlay.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" @@ -92,6 +94,13 @@ void checkpoint_41( // section 1 DirectionDetector direction; + VideoSnapshot snapshot = env.console.video().snapshot(); + double current_direction = direction.get_current_direction(env.console, snapshot); + if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap. + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 128, 60}); + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 255, 128, 60}); + } + direction.change_direction(env.program_info(), env.console, context, 0.14); do_action_and_monitor_for_battles(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.cpp index 409b55ae9..e004c405f 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.cpp @@ -4,6 +4,8 @@ * */ +#include "CommonFramework/VideoPipeline/VideoFeed.h" + #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonFramework/VideoPipeline/VideoOverlay.h" #include "CommonTools/Async/InferenceRoutines.h" @@ -111,6 +113,13 @@ void checkpoint_43( realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 128, 50); DirectionDetector direction; + VideoSnapshot snapshot = env.console.video().snapshot(); + double current_direction = direction.get_current_direction(env.console, snapshot); + if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap. + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0}); + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 128, 30}); + } + do_action_and_monitor_for_battles(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ direction.change_direction(env.program_info(), env.console, context, 6.198); @@ -550,7 +559,7 @@ void checkpoint_46( // wait for overworld after leaving Gym wait_for_overworld(env.program_info(), env.console, context, 30); - // fly to Porto Marinada pokecenter + // fly to Artazon east pokecenter move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::ZOOM_IN, 255, 128, 50}); // section 1. set marker to pokecenter diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.cpp index 7c7b01034..a2debed3f 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.cpp @@ -5,6 +5,7 @@ */ #include "PokemonSV/Inference/Dialogs/PokemonSV_DialogDetector.h" #include "CommonTools/Async/InferenceRoutines.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" #include "CommonFramework/Exceptions/OperationFailedException.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" @@ -98,6 +99,13 @@ void checkpoint_47( realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 110, 100); DirectionDetector direction; + VideoSnapshot snapshot = env.console.video().snapshot(); + double current_direction = direction.get_current_direction(env.console, snapshot); + if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap. + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 128, 255, 50}); + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 128, 0, 50}); + } + direction.change_direction(env.program_info(), env.console, context, 2.06); pbf_move_left_joystick(context, 128, 0, 200, 100); @@ -129,6 +137,18 @@ void checkpoint_47( run_trainer_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG); mash_button_till_overworld(env.console, context, BUTTON_A); + + context.wait_for_all_requests(); + VideoSnapshot snapshot2 = env.console.video().snapshot(); + double current_direction2 = direction.get_current_direction(env.console, snapshot2); + if (current_direction2 == -1){ // if unable to detect current direction, reset. We need to be able to detect the direction for the next checkpoint. + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "Unable to detect direction. Reset.", + env.console + ); + } + }); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp index a25f2d117..37e594305 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp @@ -4,10 +4,10 @@ * */ -#include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" #include "PokemonSV/Inference/PokemonSV_WhiteTriangleDetector.h" #include "PokemonSV/Inference/Battles/PokemonSV_NormalBattleMenus.h" #include "CommonTools/Async/InferenceRoutines.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" #include "CommonFramework/Exceptions/OperationFailedException.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" @@ -111,6 +111,13 @@ void checkpoint_50( realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 60, 50); DirectionDetector direction; + VideoSnapshot snapshot = env.console.video().snapshot(); + double current_direction = direction.get_current_direction(env.console, snapshot); + if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap. + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 255, 255, 70}); + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 70}); + } + direction.change_direction(env.program_info(), env.console, context, 0); pbf_move_left_joystick(context, 128, 0, 150, 100); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp index 57c7d986f..e4bbc78ec 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp @@ -80,6 +80,7 @@ void checkpoint_54( [&](size_t attempt_number){ DirectionDetector direction; + // recently flew to this pokecenter, so no need to worry about failing to detect direction direction.change_direction(env.program_info(), env.console, context, 1.341); pbf_move_left_joystick(context, 128, 0, 450, 100); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.cpp index a3609f359..0b57db11d 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.cpp @@ -4,6 +4,7 @@ * */ #include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonTools/Async/InferenceRoutines.h" @@ -102,6 +103,13 @@ void checkpoint_55( DirectionDetector direction; + VideoSnapshot snapshot = env.console.video().snapshot(); + double current_direction = direction.get_current_direction(env.console, snapshot); + if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap. + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 255, 128, 50}); + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 128, 50}, FlyPoint::FAST_TRAVEL); + } + direction.change_direction(env.program_info(), env.console, context, 3.909067); pbf_move_left_joystick(context, 128, 0, 1000, 100); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_25.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_25.cpp index e5b18606e..7e907d1fe 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_25.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_25.cpp @@ -6,6 +6,7 @@ #include "PokemonSV/Inference/Dialogs/PokemonSV_DialogDetector.h" #include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonTools/Async/InferenceRoutines.h" @@ -164,6 +165,18 @@ void checkpoint_58( run_trainer_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG); mash_button_till_overworld(env.console, context, BUTTON_A); + context.wait_for_all_requests(); + VideoSnapshot snapshot = env.console.video().snapshot(); + DirectionDetector direction; + double current_direction = direction.get_current_direction(env.console, snapshot); + if (current_direction == -1){ // if unable to detect current direction, reset. We need to be able to detect the direction for the next checkpoint. + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "Unable to detect direction. Reset.", + env.console + ); + } + }); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_26.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_26.cpp index 6e37c695e..9d48c1b6e 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_26.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_26.cpp @@ -5,6 +5,7 @@ */ #include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonTools/Async/InferenceRoutines.h" @@ -106,6 +107,13 @@ void checkpoint_61( ); DirectionDetector direction; + VideoSnapshot snapshot = env.console.video().snapshot(); + double current_direction = direction.get_current_direction(env.console, snapshot); + if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap. + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0}); + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0}); + } + direction.change_direction(env.program_info(), env.console, context, 0.278620); pbf_move_left_joystick(context, 128, 0, 400, 50); @@ -167,6 +175,14 @@ void checkpoint_62( pbf_press_button(context, BUTTON_L, 50, 50); DirectionDetector direction; + context.wait_for_all_requests(); + VideoSnapshot snapshot = env.console.video().snapshot(); + double current_direction = direction.get_current_direction(env.console, snapshot); + if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap. + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0}); + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0}); + } + direction.change_direction(env.program_info(), env.console, context, 1.971173); pbf_move_left_joystick(context, 128, 0, 600, 50); @@ -200,7 +216,7 @@ void checkpoint_62( // lemon pbf_press_dpad(context, DPAD_DOWN, 13, 20); pbf_press_button(context, BUTTON_A, 50, 50); - clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::OVERWORLD}); + clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::OVERWORLD}, false); pbf_mash_button(context, BUTTON_A, 1000ms); @@ -208,8 +224,8 @@ void checkpoint_62( env.console.log("Battle Normal Gym leader."); run_trainer_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG); - // clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 60); - // pbf_mash_button(context, BUTTON_A, 1000ms); + clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 60); + pbf_mash_button(context, BUTTON_A, 1000ms); env.console.log("Finish up with Larry, then speak to Geeta and Nemona."); clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::WHITE_A_BUTTON, CallbackEnum::PROMPT_DIALOG, CallbackEnum::BATTLE, CallbackEnum:: DIALOG_ARROW}); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_27.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_27.cpp index ebd4a719a..505a3f008 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_27.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_27.cpp @@ -5,6 +5,7 @@ */ #include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonTools/Async/InferenceRoutines.h" @@ -143,6 +144,13 @@ void move_from_glaseado_mountain_to_casseroya_watchtower3(SingleSwitchProgramEnv context.wait_for_all_requests(); DirectionDetector direction; + VideoSnapshot snapshot = env.console.video().snapshot(); + double current_direction = direction.get_current_direction(env.console, snapshot); + if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap. + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::ZOOM_OUT, 100, 255, 60}); + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::ZOOM_OUT, 128, 0, 60}); + } + direction.change_direction(env.program_info(), env.console, context, 1.448679); pbf_move_left_joystick(context, 128, 0, 200, 50); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_28.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_28.cpp index ee9e1d287..5bc78fac9 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_28.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_28.cpp @@ -5,6 +5,7 @@ */ #include "PokemonSV/Inference/Dialogs/PokemonSV_DialogDetector.h" #include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonTools/Async/InferenceRoutines.h" @@ -96,6 +97,13 @@ void checkpoint_68(SingleSwitchProgramEnvironment& env, ProControllerContext& co realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 128, 255, 50); DirectionDetector direction; + VideoSnapshot snapshot = env.console.video().snapshot(); + double current_direction = direction.get_current_direction(env.console, snapshot); + if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap. + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 128, 255, 50}); + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 128, 0, 50}); + } + direction.change_direction(env.program_info(), env.console, context, 0.696613); pbf_move_left_joystick(context, 128, 0, 200, 50); @@ -135,6 +143,17 @@ void checkpoint_68(SingleSwitchProgramEnvironment& env, ProControllerContext& co env.console.log("Battle Mr. Harrington."); run_trainer_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG); mash_button_till_overworld(env.console, context, BUTTON_A); + + context.wait_for_all_requests(); + VideoSnapshot snapshot2 = env.console.video().snapshot(); + double current_direction2 = direction.get_current_direction(env.console, snapshot2); + if (current_direction2 == -1){ // if unable to detect current direction, reset. We need to be able to detect the direction for the next checkpoint. + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "Unable to detect direction. Reset.", + env.console + ); + } }); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_29.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_29.cpp index de352e3a6..a3c7a8ea6 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_29.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_29.cpp @@ -5,6 +5,7 @@ */ #include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonTools/Async/InferenceRoutines.h" @@ -102,6 +103,13 @@ void checkpoint_71(SingleSwitchProgramEnvironment& env, ProControllerContext& co checkpoint_reattempt_loop(env, context, notif_status_update, stats, [&](size_t attempt_number){ DirectionDetector direction; + VideoSnapshot snapshot = env.console.video().snapshot(); + double current_direction = direction.get_current_direction(env.console, snapshot); + if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap. + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 128, 75}); + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 255, 128, 75}); + } + direction.change_direction(env.program_info(), env.console, context, 1.536225); pbf_move_left_joystick(context, 128, 0, 500, 50); @@ -151,6 +159,7 @@ void checkpoint_72(SingleSwitchProgramEnvironment& env, ProControllerContext& co wait_for_overworld(env.program_info(), env.console, context, 30); DirectionDetector direction; + // we just hope the minimap Direction isn't covered direction.change_direction(env.program_info(), env.console, context, 2.462858); // 2.496149 // 2.479418 walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_SPAM_A, 20); @@ -177,6 +186,7 @@ void checkpoint_73(SingleSwitchProgramEnvironment& env, ProControllerContext& co [&](size_t attempt_number){ DirectionDetector direction; + // we just hope the minimap Direction isn't covered direction.change_direction(env.program_info(), env.console, context, 5.478851); handle_when_stationary_in_overworld(env.program_info(), env.console, context, @@ -189,7 +199,7 @@ void checkpoint_73(SingleSwitchProgramEnvironment& env, ProControllerContext& co } ); - mash_button_till_overworld(env.console, context, BUTTON_A, 360); + mash_button_till_overworld(env.console, context, BUTTON_A, 360); // fight the Ghost Gym }); } @@ -215,6 +225,7 @@ void checkpoint_74(SingleSwitchProgramEnvironment& env, ProControllerContext& co void move_from_montenevera_to_glaseado_gym(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ DirectionDetector direction; + // we just hope the minimap Direction isn't covered direction.change_direction(env.program_info(), env.console, context, 1.255489); pbf_move_left_joystick(context, 128, 0, 400, 50); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_30.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_30.cpp index 13237f508..f7b3cadbc 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_30.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_30.cpp @@ -6,6 +6,7 @@ #include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" #include "PokemonSV/Inference/Overworld/PokemonSV_NoMinimapDetector.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonTools/Async/InferenceRoutines.h" @@ -95,6 +96,13 @@ void checkpoint_75(SingleSwitchProgramEnvironment& env, ProControllerContext& co [&](size_t attempt_number){ DirectionDetector direction; + VideoSnapshot snapshot = env.console.video().snapshot(); + double current_direction = direction.get_current_direction(env.console, snapshot); + if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap. + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 128, 0, 50}); + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 128, 255, 50}); + } + do_action_and_monitor_for_battles(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ // move marker away so it doesn't block the North symbol @@ -162,6 +170,7 @@ void checkpoint_76(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::ZOOM_IN, 255, 0, 40}, FlyPoint::POKECENTER); DirectionDetector direction; + // we just hope the minimap Direction isn't covered do_action_and_monitor_for_battles(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_31.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_31.cpp index 32ce7da59..a47c63deb 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_31.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_31.cpp @@ -6,6 +6,7 @@ #include "PokemonSV/Inference/Dialogs/PokemonSV_DialogDetector.h" #include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonTools/Async/InferenceRoutines.h" @@ -131,6 +132,14 @@ void checkpoint_81(SingleSwitchProgramEnvironment& env, ProControllerContext& co void move_from_north_province_area_one_to_fighting_base(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ DirectionDetector direction; + VideoSnapshot snapshot = env.console.video().snapshot(); + double current_direction = direction.get_current_direction(env.console, snapshot); + if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap. + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 128, 100}); + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 255, 128, 100}); + } + + do_action_and_monitor_for_battles(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ @@ -314,6 +323,18 @@ void beat_team_star_fighting1(SingleSwitchProgramEnvironment& env, ProController run_trainer_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG); mash_button_till_overworld(env.console, context, BUTTON_A); + context.wait_for_all_requests(); + VideoSnapshot snapshot = env.console.video().snapshot(); + DirectionDetector direction; + double current_direction = direction.get_current_direction(env.console, snapshot); + if (current_direction == -1){ // if unable to detect current direction, reset. We need to be able to detect the direction for the next checkpoint. + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "Unable to detect direction. Reset.", + env.console + ); + } + diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp index 144485e1e..c3545f65a 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp @@ -6,6 +6,7 @@ #include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h" #include "PokemonSV/Programs/Farming/PokemonSV_ESPTraining.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonTools/Async/InferenceRoutines.h" @@ -105,6 +106,12 @@ void checkpoint_83(SingleSwitchProgramEnvironment& env, ProControllerContext& co checkpoint_reattempt_loop(env, context, notif_status_update, stats, [&](size_t attempt_number){ DirectionDetector direction; + VideoSnapshot snapshot = env.console.video().snapshot(); + double current_direction = direction.get_current_direction(env.console, snapshot); + if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap. + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 128, 0, 150}); + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 128, 255, 150}); + } realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 140, 70); @@ -177,6 +184,7 @@ void checkpoint_84(SingleSwitchProgramEnvironment& env, ProControllerContext& co wait_for_overworld(env.program_info(), env.console, context, 30); DirectionDetector direction; + // we just hope the minimap Direction isn't covered direction.change_direction(env.program_info(), env.console, context, 4.413989); pbf_move_left_joystick(context, 128, 0, 180, 50); @@ -264,6 +272,7 @@ void checkpoint_84(SingleSwitchProgramEnvironment& env, ProControllerContext& co void move_from_west_province_area_one_north_to_alfornada(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ context.wait_for_all_requests(); DirectionDetector direction; + // recently flew here, so Minimap should be clear of Pokemon. and we should have no issues detecting direction. do_action_and_monitor_for_battles(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_33.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_33.cpp index d593f90b1..93e081b31 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_33.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_33.cpp @@ -138,6 +138,7 @@ void checkpoint_86(SingleSwitchProgramEnvironment& env, ProControllerContext& co realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 128, 50); DirectionDetector direction; + // minimap should be clear of Pokemon within Mesagoza direction.change_direction(env.program_info(), env.console, context, 1.222127); pbf_move_left_joystick(context, 128, 0, 1100, 50); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_40.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_40.cpp index c6a7f74fd..edc90ab6a 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_40.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_40.cpp @@ -4,6 +4,9 @@ * */ +#include "PokemonSV/Programs/Battles/PokemonSV_SinglesBattler.h" +#include "PokemonSV/Inference/PokemonSV_TutorialDetector.h" + #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonTools/Async/InferenceRoutines.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" @@ -74,15 +77,105 @@ void AutoStory_Checkpoint_104::run_checkpoint(SingleSwitchProgramEnvironment& en // } void checkpoint_104(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ - // checkpoint_reattempt_loop(env, context, notif_status_update, stats, - // [&](size_t attempt_number){ - - - // }); + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + + pbf_press_button(context, BUTTON_L, 30, 10); + pbf_move_left_joystick(context, 128, 0, 400, 50); + pbf_move_left_joystick(context, 0, 128, 130, 50); + walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_SPAM_A, 10); + + // now in elevator + mash_button_till_overworld(env.console, context, BUTTON_A); + + pbf_move_left_joystick(context, 255, 128, 70, 50); + + // talk to the AI professor + walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_SPAM_A, 10); + mash_button_till_overworld(env.console, context, BUTTON_A); + + // put the book in the machine + pbf_press_button(context, BUTTON_L, 30, 10); + walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_SPAM_A, 10); + + + clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 120, {CallbackEnum::BATTLE, CallbackEnum::PROMPT_DIALOG, CallbackEnum::DIALOG_ARROW}); + + + env.console.log("Battle AI Professor."); + SinglesMoveEntry move1{SinglesMoveType::Move1, false}; // Moonblast + SinglesMoveEntry move3{SinglesMoveType::Move3, false}; // Psychic + + + std::vector move_table1 = {move3, move1}; + bool terastallized = false; + // start with Psychic to defeat Iron Moth for Violet, which quad resists Moonblast. + bool is_won = run_pokemon(env.console, context, move_table1, true, terastallized); + if (!is_won){// throw exception if we lose + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "Failed to beat the AI Professor. Reset.", + env.console + ); + } + + + clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE_DIALOG_ARROW, 120, {CallbackEnum::DIALOG_ARROW}, false); + + pbf_mash_button(context, BUTTON_A, 50); + + + wait_for_gradient_arrow(env.program_info(), env.console, context, {0.75, 0.62, 0.05, 0.35}, 30); + + pbf_press_dpad(context, DPAD_DOWN, 13, 20); + pbf_mash_button(context, BUTTON_A, 20); + + pbf_wait(context, 1000ms); + pbf_press_dpad(context, DPAD_UP, 13, 20); + pbf_mash_button(context, BUTTON_A, 500); + + env.console.log("Battle AI Professor's Koraidon/Miraidon."); + SinglesMoveEntry move4{SinglesMoveType::Move4, false}; // Koraidon/Miraidon: Tera Blast + SinglesMoveEntry move4_tera{SinglesMoveType::Move4, true}; // Koraidon/Miraidon: Tera Blast + std::vector move_table2 = {move4, move4, move4, move4, move4, move4_tera}; + is_won = run_pokemon(env.console, context, move_table2, true, terastallized); + if (!is_won){// throw exception if we lose + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "Failed to beat the AI Professor, round 2. This shouldn't be possible. Reset.", + env.console + ); + } + + mash_button_till_overworld(env.console, context, BUTTON_A, 800); + + env.console.log("Clear Koraidon/Miraidon form change tutorial."); + // Press X until tutorial shows up + TutorialWatcher tutorial; + int ret = run_until( + env.console, context, + [](ProControllerContext& context){ + for (int i = 0; i < 10; i++){ + pbf_press_button(context, BUTTON_X, 20, 250); + } + }, + {tutorial} + ); + if (ret < 0){ + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "Stuck trying to clear the Koraidon/Miraidon form change tutorial.", + env.console + ); + } + clear_tutorial(env.console, context); + + + }); } -void checkpoint_105(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ -} +// void checkpoint_105(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ +// } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_40.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_40.h index 440a701aa..fb4a9e1ff 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_40.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_40.h @@ -48,9 +48,9 @@ class AutoStory_Checkpoint_104 : public AutoStory_Checkpoint{ // end: Battled the AI Professor. Completed the game. void checkpoint_104(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); -// start: -// end: -void checkpoint_105(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); +// // start: +// // end: +// void checkpoint_105(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); diff --git a/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_MenuNavigation.cpp b/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_MenuNavigation.cpp index 0e280150f..630d6bd5c 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_MenuNavigation.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_MenuNavigation.cpp @@ -143,9 +143,9 @@ void press_Bs_to_back_to_overworld(const ProgramInfo& info, VideoStream& stream, int ret = run_until( stream, context, [seconds_between_b_presses](ProControllerContext& context){ - pbf_wait(context, seconds_between_b_presses * TICKS_PER_SECOND); // avoiding pressing B if already in overworld + pbf_wait(context, Seconds(seconds_between_b_presses)); // avoiding pressing B if already in overworld for (size_t c = 0; c < 10; c++){ - pbf_press_button(context, BUTTON_B, 20, seconds_between_b_presses * TICKS_PER_SECOND); + pbf_press_button(context, BUTTON_B, 20*8ms, Seconds(seconds_between_b_presses)); } }, {overworld, battle} @@ -460,8 +460,8 @@ void mash_button_till_overworld( int ret = run_until( stream, context, [button, seconds_run](ProControllerContext& context){ - ssf_mash1_button(context, button, seconds_run * TICKS_PER_SECOND); - pbf_wait(context, seconds_run * TICKS_PER_SECOND); + ssf_mash1_button(context, button, Seconds(seconds_run)); + // pbf_wait(context, Seconds(seconds_run)); }, {overworld} );