Skip to content

Commit f5f0fdb

Browse files
author
Gin
committed
Add tower shuttle run
1 parent 3d3cd66 commit f5f0fdb

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "CommonFramework/Exceptions/OperationFailedException.h"
88
#include "CommonFramework/ProgramStats/StatsTracking.h"
99
#include "CommonFramework/Notifications/ProgramNotifications.h"
10+
#include "Common/Cpp/PrettyPrint.h"
1011
#include "CommonFramework/VideoPipeline/VideoOverlay.h"
1112
#include "CommonTools/Async/InferenceRoutines.h"
1213
#include "CommonTools/VisualDetectors/BlackScreenDetector.h"
@@ -62,6 +63,7 @@ ShinyHunt_ShuttleRun::ShinyHunt_ShuttleRun()
6263
{
6364
// {Route::SCRAGGY, "scraggy", "Sewers: Scraggy"},
6465
{Route::WILD_ZONE_19, "wild_zone_19", "Wild Zone 19"},
66+
{Route::WILD_ZONE_3_TOWER, "wild_zone_3_tower", "Wild Zone 3 Tower"},
6567
},
6668
LockMode::LOCK_WHILE_RUNNING,
6769
Route::WILD_ZONE_19
@@ -105,6 +107,35 @@ void route_wild_zone_19(SingleSwitchProgramEnvironment& env, ProControllerContex
105107
wait_until_overworld(env.console, context, 50s);
106108
}
107109

110+
void route_wild_zone_3_tower(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
111+
for(int i = 0; i < 6; i++){
112+
// if there is no day/night change and no button drop, this loop should only have three iterations
113+
const double direction = get_facing_direction(env.console, context);
114+
const bool face_east = get_angle_between_facing_directions(direction, 90.0) < 10.0;
115+
const bool face_west = get_angle_between_facing_directions(direction, 270.0) < 10.0;
116+
if (i > 0 && (face_east || face_west)){
117+
// we've finished one run of the tower
118+
return;
119+
}
120+
121+
if (face_east || get_angle_between_facing_directions(direction, 180.0) < 10.0){
122+
// if facing east or south, run backward
123+
pbf_move_left_joystick(context, 128, 255, 500ms, 200ms);
124+
} else if (face_west || get_angle_between_facing_directions(direction, 0.0) < 10.0){
125+
// if facing west or north, run forward
126+
pbf_move_left_joystick(context, 128, 0, 500ms, 200ms);
127+
} else{
128+
OperationFailedException::fire(
129+
ErrorReport::SEND_ERROR_REPORT,
130+
"route_wild_zone_3_tower: unexpected facing direction: " + PokemonAutomation::tostr_fixed(direction, 0) + " deg",
131+
env.console
132+
);
133+
}
134+
context.wait_for_all_requests();
135+
wait_until_overworld(env.console, context, 50s);
136+
}
137+
}
138+
108139
} // namespace
109140

110141
void ShinyHunt_ShuttleRun::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
@@ -130,6 +161,9 @@ void ShinyHunt_ShuttleRun::program(SingleSwitchProgramEnvironment& env, ProContr
130161
case Route::WILD_ZONE_19:
131162
route = route_wild_zone_19;
132163
break;
164+
case Route:: WILD_ZONE_3_TOWER:
165+
route = route_wild_zone_3_tower;
166+
break;
133167
default:
134168
OperationFailedException::fire(
135169
ErrorReport::SEND_ERROR_REPORT,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class ShinyHunt_ShuttleRun : public SingleSwitchProgramInstance {
3939
WILD_ZONE_19,
4040
FIRE_STARTERS,
4141
DRATINI,
42+
WILD_ZONE_3_TOWER,
4243
CUSTOMISED_MACRO = 255,
4344
};
4445

0 commit comments

Comments
 (0)