diff --git a/SerialPrograms/Source/PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.cpp b/SerialPrograms/Source/PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.cpp index 56d5cfb67..9550ea214 100644 --- a/SerialPrograms/Source/PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.cpp +++ b/SerialPrograms/Source/PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.cpp @@ -4,6 +4,7 @@ * */ +#include "CommonFramework/Exceptions/OperationFailedException.h" #include "Kernels/Waterfill/Kernels_Waterfill_Types.h" #include "CommonFramework/ImageTypes/ImageViewRGB32.h" #include "CommonFramework/Tools/DebugDumper.h" @@ -174,8 +175,11 @@ void DirectionDetector::change_direction( VideoSnapshot screen = stream.video().snapshot(); double current = get_current_direction(stream, screen); if (current < 0){ - stream.log("Unable to detect current direction."); - return; + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "change_direction(): Unable to detect current direction.", + stream + ); } double target = std::fmod(direction, (2 * PI)); 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 9d48c1b6e..6c5de9198 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_26.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_26.cpp @@ -99,20 +99,19 @@ void checkpoint_61( checkpoint_reattempt_loop(env, context, notif_status_update, stats, [&](size_t attempt_number){ + // first, clear Pokemon in Minimap. + env.console.log("Fly to neighbouring Pokecenter, then fly back, to 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}); + // marker 1 keep{0.490625, 0.594444} in{0.589583, 0.569444} place_marker_offset_from_flypoint(env.program_info(), env.console, context, {ZoomChange::ZOOM_IN, 0, 0, 0}, FlyPoint::POKECENTER, {0.589583, 0.569444} ); - + 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); 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 a3c7a8ea6..b6ee1e99c 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_29.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_29.cpp @@ -103,12 +103,19 @@ 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}); - } + + env.console.log("Fly to neighbouring Pokecenter, then fly back, to clear any pokemon covering the minimap."); + + // place down marker as a workaround with an issue with fly_to_overworld_from_map + // fly_to_overworld_from_map() will fail since the snowy background on the map will false positive the destinationMenuItemWatcher (MapDestinationMenuDetector at box {0.523000, 0.680000, 0.080000, 0.010000}), which causes the fly to fail + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 128, 255, 35}, + FlyPoint::POKECENTER, + {0.54375, 0.662037} + ); + + 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); 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 f7b3cadbc..d9ecfca10 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_30.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_30.cpp @@ -159,7 +159,7 @@ void checkpoint_76(SingleSwitchProgramEnvironment& env, ProControllerContext& co wait_for_overworld(env.program_info(), env.console, context, 30); // place down marker as a workaround with an issue with fly_to_overworld_from_map - // fly_to_overworld_from_map() will fail since the snowy background on the map will false positive the destinationMenuItemWatcher, which causes the fly to fail + // fly_to_overworld_from_map() will fail since the snowy background on the map will false positive the destinationMenuItemWatcher (MapDestinationMenuDetector at box {0.523000, 0.680000, 0.080000, 0.010000}), which causes the fly to fail place_marker_offset_from_flypoint(env.program_info(), env.console, context, {ZoomChange::ZOOM_IN, 0, 0, 0}, FlyPoint::POKECENTER, 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 c3545f65a..34149f936 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp @@ -106,12 +106,10 @@ 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}); - } + + env.console.log("Fly to neighbouring Pokecenter, then fly back, to 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);