Skip to content

Commit 9fc9e7a

Browse files
authored
Autostory: update sequence to clear Pokemon from minimap, for DirectionDetector. (#889)
1 parent ee52a04 commit 9fc9e7a

File tree

5 files changed

+30
-22
lines changed

5 files changed

+30
-22
lines changed

SerialPrograms/Source/PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*
55
*/
66

7+
#include "CommonFramework/Exceptions/OperationFailedException.h"
78
#include "Kernels/Waterfill/Kernels_Waterfill_Types.h"
89
#include "CommonFramework/ImageTypes/ImageViewRGB32.h"
910
#include "CommonFramework/Tools/DebugDumper.h"
@@ -174,8 +175,11 @@ void DirectionDetector::change_direction(
174175
VideoSnapshot screen = stream.video().snapshot();
175176
double current = get_current_direction(stream, screen);
176177
if (current < 0){
177-
stream.log("Unable to detect current direction.");
178-
return;
178+
OperationFailedException::fire(
179+
ErrorReport::SEND_ERROR_REPORT,
180+
"change_direction(): Unable to detect current direction.",
181+
stream
182+
);
179183
}
180184
double target = std::fmod(direction, (2 * PI));
181185

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_26.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,19 @@ void checkpoint_61(
9999
checkpoint_reattempt_loop(env, context, notif_status_update, stats,
100100
[&](size_t attempt_number){
101101

102+
// first, clear Pokemon in Minimap.
103+
env.console.log("Fly to neighbouring Pokecenter, then fly back, to clear any pokemon covering the minimap.");
104+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0});
105+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0});
106+
102107
// marker 1 keep{0.490625, 0.594444} in{0.589583, 0.569444}
103108
place_marker_offset_from_flypoint(env.program_info(), env.console, context,
104109
{ZoomChange::ZOOM_IN, 0, 0, 0},
105110
FlyPoint::POKECENTER,
106111
{0.589583, 0.569444}
107112
);
108-
113+
109114
DirectionDetector direction;
110-
VideoSnapshot snapshot = env.console.video().snapshot();
111-
double current_direction = direction.get_current_direction(env.console, snapshot);
112-
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.
113-
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0});
114-
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0});
115-
}
116115

117116
direction.change_direction(env.program_info(), env.console, context, 0.278620);
118117
pbf_move_left_joystick(context, 128, 0, 400, 50);

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_29.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,19 @@ void checkpoint_71(SingleSwitchProgramEnvironment& env, ProControllerContext& co
103103
checkpoint_reattempt_loop(env, context, notif_status_update, stats,
104104
[&](size_t attempt_number){
105105
DirectionDetector direction;
106-
VideoSnapshot snapshot = env.console.video().snapshot();
107-
double current_direction = direction.get_current_direction(env.console, snapshot);
108-
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.
109-
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 128, 75});
110-
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 255, 128, 75});
111-
}
106+
107+
env.console.log("Fly to neighbouring Pokecenter, then fly back, to clear any pokemon covering the minimap.");
108+
109+
// place down marker as a workaround with an issue with fly_to_overworld_from_map
110+
// 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
111+
place_marker_offset_from_flypoint(env.program_info(), env.console, context,
112+
{ZoomChange::KEEP_ZOOM, 128, 255, 35},
113+
FlyPoint::POKECENTER,
114+
{0.54375, 0.662037}
115+
);
116+
117+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 128, 75});
118+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 255, 128, 75});
112119

113120

114121
direction.change_direction(env.program_info(), env.console, context, 1.536225);

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_30.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void checkpoint_76(SingleSwitchProgramEnvironment& env, ProControllerContext& co
159159
wait_for_overworld(env.program_info(), env.console, context, 30);
160160

161161
// place down marker as a workaround with an issue with fly_to_overworld_from_map
162-
// 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
162+
// 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
163163
place_marker_offset_from_flypoint(env.program_info(), env.console, context,
164164
{ZoomChange::ZOOM_IN, 0, 0, 0},
165165
FlyPoint::POKECENTER,

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_32.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,10 @@ void checkpoint_83(SingleSwitchProgramEnvironment& env, ProControllerContext& co
106106
checkpoint_reattempt_loop(env, context, notif_status_update, stats,
107107
[&](size_t attempt_number){
108108
DirectionDetector direction;
109-
VideoSnapshot snapshot = env.console.video().snapshot();
110-
double current_direction = direction.get_current_direction(env.console, snapshot);
111-
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.
112-
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 128, 0, 150});
113-
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 128, 255, 150});
114-
}
109+
110+
env.console.log("Fly to neighbouring Pokecenter, then fly back, to clear any pokemon covering the minimap.");
111+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 128, 0, 150});
112+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 128, 255, 150});
115113

116114
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 140, 70);
117115

0 commit comments

Comments
 (0)