Skip to content

Commit 863da06

Browse files
author
Gin
committed
improve tower shuttle run.
1 parent 4703a89 commit 863da06

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

SerialPrograms/Source/PokemonLZA/Inference/PokemonLZA_OverworldPartySelectionDetector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class OverworldPartySelectionDetector : public StaticScreenDetector{
7373
class OverworldPartySelectionWatcher : public DetectorToFinder<OverworldPartySelectionDetector>{
7474
public:
7575
OverworldPartySelectionWatcher(
76-
Color color = COLOR_RED,
76+
Color color = COLOR_WHITE,
7777
VideoOverlay* overlay = nullptr,
7878
std::chrono::milliseconds hold_duration = std::chrono::milliseconds(150)
7979
)
@@ -84,7 +84,7 @@ class OverworldPartySelectionWatcher : public DetectorToFinder<OverworldPartySel
8484
class OverworldPartySelectionOverWatcher : public DetectorToFinder<OverworldPartySelectionDetector>{
8585
public:
8686
OverworldPartySelectionOverWatcher(
87-
Color color = COLOR_RED,
87+
Color color = COLOR_WHITE,
8888
VideoOverlay* overlay = nullptr,
8989
std::chrono::milliseconds hold_duration = std::chrono::milliseconds(150)
9090
)

SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_BasicNavigation.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ bool save_game_to_menu(ConsoleHandle& console, ProControllerContext& context){
4242
);
4343
}
4444

45-
OverworldPartySelectionWatcher overworld(COLOR_RED, &console.overlay());
45+
OverworldPartySelectionWatcher overworld(COLOR_WHITE, &console.overlay());
4646
MainMenuWatcher main_menu(COLOR_YELLOW, &console.overlay());
4747
SelectionArrowWatcher save_button(
4848
COLOR_GREEN,
@@ -374,11 +374,12 @@ void wait_until_overworld(
374374
ConsoleHandle& console, ProControllerContext& context,
375375
std::chrono::milliseconds max_wait_time
376376
){
377-
OverworldPartySelectionWatcher overworld;
377+
OverworldPartySelectionWatcher overworld(COLOR_WHITE, &console.overlay(), Milliseconds(100));
378+
DirectionArrowWatcher map_arrow(COLOR_BLUE, std::chrono::milliseconds(50));
378379
int ret = wait_until(
379380
console, context,
380381
max_wait_time,
381-
{overworld}
382+
{overworld, map_arrow}
382383
);
383384
if (ret < 0){
384385
OperationFailedException::fire(
@@ -397,7 +398,7 @@ double get_facing_direction(
397398
ConsoleHandle& console,
398399
ProControllerContext& context
399400
){
400-
DirectionArrowWatcher arrow_watcher(COLOR_YELLOW, std::chrono::milliseconds(100));
401+
DirectionArrowWatcher arrow_watcher(COLOR_YELLOW, std::chrono::milliseconds(50));
401402
int ret = wait_until(
402403
console, context,
403404
std::chrono::seconds(40), // 40 sec to account for possible day/night change
@@ -408,7 +409,7 @@ double get_facing_direction(
408409
console.overlay().add_log("No Minimap Arrow Found", COLOR_RED);
409410
OperationFailedException::fire(
410411
ErrorReport::SEND_ERROR_REPORT,
411-
"get_facing_direction(): Direction arrow on minimap not detected within 1 second",
412+
"get_facing_direction(): Direction arrow on minimap not detected within 40 second",
412413
console
413414
);
414415
}

SerialPrograms/Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_ShuttleRun.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,28 @@ void route_alpha_pidgeot(SingleSwitchProgramEnvironment& env, ProControllerConte
9191
}
9292

9393
void route_wild_zone_3_tower(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
94+
bool been_at_downstairs = false;
95+
bool been_at_upstairs_after_downstairs = false;
96+
9497
for(int i = 0; i < 6; i++){
9598
// if there is no day/night change and no button drop, this loop should only have three iterations
9699
const double direction = get_facing_direction(env.console, context);
97100
const bool face_east = get_angle_between_facing_directions(direction, 90.0) < 10.0;
98101
const bool face_west = get_angle_between_facing_directions(direction, 270.0) < 10.0;
99-
if (i > 0 && (face_east || face_west)){
100-
// we've finished one run of the tower
101-
return;
102+
const bool face_south = get_angle_between_facing_directions(direction, 180.0) < 10.0;
103+
const bool face_north = get_angle_between_facing_directions(direction, 0.0) < 10.0;
104+
if (face_east || face_west){ // we are at downstars
105+
been_at_downstairs = true;
102106
}
103-
104-
if (face_east || get_angle_between_facing_directions(direction, 180.0) < 10.0){
107+
else if (been_at_downstairs){
108+
// we are not at downstairs right now, but we've been to the downstairs, so we
109+
// must be at upstairs
110+
been_at_upstairs_after_downstairs = true;
111+
}
112+
if (face_east || face_south){
105113
// if facing east or south, run backward
106114
pbf_move_left_joystick(context, 128, 255, 500ms, 200ms);
107-
} else if (face_west || get_angle_between_facing_directions(direction, 0.0) < 10.0){
115+
} else if (face_west || face_north){
108116
// if facing west or north, run forward
109117
pbf_move_left_joystick(context, 128, 0, 500ms, 200ms);
110118
} else{
@@ -116,6 +124,11 @@ void route_wild_zone_3_tower(SingleSwitchProgramEnvironment& env, ProControllerC
116124
}
117125
context.wait_for_all_requests();
118126
wait_until_overworld(env.console, context, 50s);
127+
128+
if (been_at_upstairs_after_downstairs){
129+
// we've finished one run of the tower
130+
return;
131+
}
119132
}
120133
}
121134

@@ -158,6 +171,9 @@ void ShinyHunt_ShuttleRun::program(SingleSwitchProgramEnvironment& env, ProContr
158171
env.console, context,
159172
[&](ProControllerContext& context){
160173
do{
174+
const std::string log_msg = "Round " + std::to_string(stats.resets + 1);
175+
env.log(log_msg);
176+
env.console.overlay().add_log(log_msg);
161177
shiny_sound_handler.process_pending(context);
162178
send_program_status_notification(env, NOTIFICATION_STATUS);
163179
route(env, context);

0 commit comments

Comments
 (0)