Skip to content

Commit 264172f

Browse files
author
Gin
committed
refactor shuttle run
1 parent 9d38edb commit 264172f

File tree

2 files changed

+42
-35
lines changed

2 files changed

+42
-35
lines changed

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

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,18 @@ ShinyHunt_ShuttleRun::ShinyHunt_ShuttleRun()
6060
: DURATION("<b>Duration:</b><br>Run the program this long.", LockMode::UNLOCK_WHILE_RUNNING, "5 h")
6161
, ROUTE("<b>Hunt Route:</b>",
6262
{
63-
{Routes::KLEFKI, "klefki", "Sewers: Klefki"},
64-
{Routes::KLEFKI_INKAY_GOOMY, "klefki_inkay_goomy", "Sewers: Klefki+Inkay+Goomy"},
65-
{Routes::LITWICK, "litwick", "Sewers: Litwick"},
66-
{Routes::SKRELP, "skrelp", "Sewers: Skrelp"},
67-
{Routes::SKRELP_INKAY, "skrelp_inkay", "Sewers: Skrelp+Inkay"},
68-
{Routes::SKRELP_ARIADOS, "skrelp_ariados", "Sewers: Skrelp+Ariados"},
69-
// {Routes::SCRAGGY, "scraggy", "Sewers: Scraggy"},
70-
{Routes::WILD_ZONE_19, "wild_zone_19", "Wild Zone 19"},
63+
{Route::KLEFKI, "klefki", "Sewers: Klefki"},
64+
{Route::KLEFKI_INKAY_GOOMY, "klefki_inkay_goomy", "Sewers: Klefki+Inkay+Goomy"},
65+
{Route::LITWICK, "litwick", "Sewers: Litwick"},
66+
{Route::LITWICK_SKRELP, "litwick_skrelp", "Sewers: Litwick+Skrelp"},
67+
{Route::SKRELP, "skrelp", "Sewers: Skrelp"},
68+
{Route::SKRELP_INKAY, "skrelp_inkay", "Sewers: Skrelp+Inkay"},
69+
{Route::SKRELP_ARIADOS, "skrelp_ariados", "Sewers: Skrelp+Ariados"},
70+
// {Route::SCRAGGY, "scraggy", "Sewers: Scraggy"},
71+
{Route::WILD_ZONE_19, "wild_zone_19", "Wild Zone 19"},
7172
},
7273
LockMode::LOCK_WHILE_RUNNING,
73-
Routes::KLEFKI
74+
Route::KLEFKI
7475
)
7576
, SHINY_DETECTED("Shiny Detected", "", "1000 ms", ShinySoundDetectedAction::NOTIFY_ON_FIRST_ONLY)
7677
, NOTIFICATION_STATUS("Status Update", true, false, std::chrono::seconds(3600))
@@ -115,8 +116,17 @@ void fly_back_to_sewers_entrance(ConsoleHandle& console, ProControllerContext& c
115116
wait_until_overworld(console, context);
116117
}
117118

119+
void run_forward_backward_to_wall(
120+
SingleSwitchProgramEnvironment& env, ProControllerContext& context,
121+
PokemonAutomation::Milliseconds duration
122+
){
123+
ssf_press_button(context, BUTTON_B, 0ms, 500ms, 0ms);
124+
pbf_move_left_joystick(context, 128, 0, duration, 0ms);
125+
pbf_move_left_joystick(context, 128, 255, duration + 500ms, 0ms);
126+
pbf_wait(context, 500ms);
127+
}
128+
118129
void route_klefki(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
119-
context.wait_for_all_requests();
120130
ssf_press_button(context, BUTTON_B, 0ms, 500ms, 0ms);
121131
pbf_move_left_joystick(context, 128, 0, 4900ms, 0ms);
122132
pbf_move_left_joystick(context, 0, 128, 1000ms, 0ms);
@@ -125,7 +135,6 @@ void route_klefki(SingleSwitchProgramEnvironment& env, ProControllerContext& con
125135
}
126136

127137
void route_klefki_inkay_goomy(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
128-
context.wait_for_all_requests();
129138
ssf_press_button(context, BUTTON_B, 0ms, 500ms, 0ms);
130139
pbf_move_left_joystick(context, 128, 0, 8500ms, 0ms);
131140
pbf_move_left_joystick(context, 255, 128, 1300ms, 0ms);
@@ -134,40 +143,33 @@ void route_klefki_inkay_goomy(SingleSwitchProgramEnvironment& env, ProController
134143
}
135144

136145
void route_litwick(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
137-
context.wait_for_all_requests();
138-
ssf_press_button(context, BUTTON_B, 0ms, 500ms, 0ms);
139-
pbf_move_left_joystick(context, 128, 0, 5000ms, 0ms);
140-
pbf_move_left_joystick(context, 128, 255, 5500ms, 0ms);
141-
pbf_wait(context, 500ms);
146+
run_forward_backward_to_wall(env, context, 5s);
147+
}
148+
149+
void route_litwick_skrelp(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
150+
run_forward_backward_to_wall(env, context, 9000ms);
142151
}
143152

144153
void route_skrelp(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
145-
context.wait_for_all_requests();
146154
fly_back_to_sewers_entrance(env.console, context);
147155
pbf_wait(context, 1000ms);
148156
}
149157

150158
void route_skrelp_inkay(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
151-
context.wait_for_all_requests();
152159
ssf_press_button(context, BUTTON_B, 0ms, 500ms, 0ms);
153160
pbf_move_left_joystick(context, 128, 0, 3900ms, 0ms);
154161
fly_back_to_sewers_entrance(env.console, context);
155162
}
156163

157164
void route_skrelp_ariados(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
158-
context.wait_for_all_requests();
159-
ssf_press_button(context, BUTTON_B, 0ms, 500ms, 0ms);
160-
pbf_move_left_joystick(context, 128, 0, 6000ms, 0ms);
161-
pbf_move_left_joystick(context, 128, 255, 6500ms, 0ms);
162-
pbf_wait(context, 500ms);
165+
run_forward_backward_to_wall(env, context, 6s);
163166
}
164167

165168
void route_scraggy(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
166169
//TODO
167170
}
168171

169172
void route_wild_zone_19(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
170-
context.wait_for_all_requests();
171173
if (run_a_straight_path_in_overworld(env.console, context, 0, 80, 6500ms) == 0) {
172174
open_map(env.console, context, false);
173175
pbf_move_left_joystick(context, 0, 128, 100ms, 100ms);
@@ -202,28 +204,31 @@ void ShinyHunt_ShuttleRun::program(SingleSwitchProgramEnvironment& env, ProContr
202204
});
203205
std::function<void(SingleSwitchProgramEnvironment&, ProControllerContext&)> route;
204206
switch (ROUTE) {
205-
case Routes::KLEFKI:
207+
case Route::KLEFKI:
206208
route = route_klefki;
207209
break;
208-
case Routes::KLEFKI_INKAY_GOOMY:
210+
case Route::KLEFKI_INKAY_GOOMY:
209211
route = route_klefki_inkay_goomy;
210212
break;
211-
case Routes::LITWICK:
213+
case Route::LITWICK:
212214
route = route_litwick;
213215
break;
214-
case Routes::SKRELP:
216+
case Route::LITWICK_SKRELP:
217+
route = route_litwick_skrelp;
218+
break;
219+
case Route::SKRELP:
215220
route = route_skrelp;
216221
break;
217-
case Routes::SKRELP_INKAY:
222+
case Route::SKRELP_INKAY:
218223
route = route_skrelp_inkay;
219224
break;
220-
case Routes::SKRELP_ARIADOS:
225+
case Route::SKRELP_ARIADOS:
221226
route = route_skrelp_ariados;
222227
break;
223-
case Routes::SCRAGGY:
228+
case Route::SCRAGGY:
224229
route = route_scraggy;
225230
break;
226-
case Routes::WILD_ZONE_19:
231+
case Route::WILD_ZONE_19:
227232
route = route_wild_zone_19;
228233
break;
229234
default:
@@ -242,8 +247,9 @@ void ShinyHunt_ShuttleRun::program(SingleSwitchProgramEnvironment& env, ProContr
242247
do{
243248
shiny_sound_handler.process_pending(context);
244249
send_program_status_notification(env, NOTIFICATION_STATUS);
245-
stats.resets++;
246250
route(env, context);
251+
context.wait_for_all_requests();
252+
stats.resets++;
247253
env.update_stats();
248254
}while (current_time() < start_time + DURATION.get());
249255
},

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ class ShinyHunt_ShuttleRun : public SingleSwitchProgramInstance {
3434

3535
virtual void program(SingleSwitchProgramEnvironment& env, ProControllerContext& context) override;
3636

37-
enum class Routes{
37+
enum class Route{
3838
KLEFKI,
3939
KLEFKI_INKAY_GOOMY,
4040
LITWICK,
41+
LITWICK_SKRELP,
4142
SKRELP,
4243
SKRELP_INKAY,
4344
SKRELP_ARIADOS,
@@ -51,7 +52,7 @@ class ShinyHunt_ShuttleRun : public SingleSwitchProgramInstance {
5152
private:
5253
PokemonLA::ShinyRequiresAudioText SHINY_REQUIRES_AUDIO;
5354
MillisecondsOption DURATION;
54-
EnumDropdownOption<Routes> ROUTE;
55+
EnumDropdownOption<Route> ROUTE;
5556
ShinySoundDetectedActionOption SHINY_DETECTED;
5657
EventNotificationOption NOTIFICATION_STATUS;
5758
EventNotificationsOption NOTIFICATIONS;

0 commit comments

Comments
 (0)