Skip to content

Commit cb24ace

Browse files
authored
Autostory: Area Zero Station 3 (#856)
* checkpoint_98: station 3 navigation routine * checkpoint_99: enter station 3 * cleanup * minior changes to station 3 nav routine
1 parent c79b388 commit cb24ace

File tree

4 files changed

+301
-25
lines changed

4 files changed

+301
-25
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ std::vector<std::unique_ptr<AutoStory_Segment>> make_autoStory_segment_list(){
129129
if (PreloadSettings::instance().DEVELOPER_MODE){
130130
segment_list.emplace_back(std::make_unique<AutoStory_Segment_35>());
131131
segment_list.emplace_back(std::make_unique<AutoStory_Segment_36>());
132-
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_37>());
132+
segment_list.emplace_back(std::make_unique<AutoStory_Segment_37>());
133133
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_38>());
134134
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_39>());
135135
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_40>());

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

Lines changed: 259 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ namespace PokemonSV{
2828

2929

3030
std::string AutoStory_Segment_37::name() const{
31-
return "";
31+
return "37: Area Zero Station 3";
3232
}
3333

3434
std::string AutoStory_Segment_37::start_text() const{
35-
return "Start: ";
35+
return "Start: Inside Area Zero Station 2. Deactivated the locks.";
3636
}
3737

3838
std::string AutoStory_Segment_37::end_text() const{
39-
return "End: ";
39+
return "End: Inside Area Zero Station 3. Deactivated the locks.";
4040
}
4141

4242
void AutoStory_Segment_37::run_segment(
@@ -61,15 +61,15 @@ void AutoStory_Segment_37::run_segment(
6161
}
6262

6363
std::string AutoStory_Checkpoint_98::name() const{ return "098 - " + AutoStory_Segment_37().name(); }
64-
std::string AutoStory_Checkpoint_98::start_text() const{ return "";}
65-
std::string AutoStory_Checkpoint_98::end_text() const{ return "";}
64+
std::string AutoStory_Checkpoint_98::start_text() const{ return "Inside Area Zero Station 2. Deactivated the locks.";}
65+
std::string AutoStory_Checkpoint_98::end_text() const{ return "Outside Area Zero Station 3. Defeated Great Tusk/Iron Treads.";}
6666
void AutoStory_Checkpoint_98::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{
6767
checkpoint_98(env, context, options.notif_status_update, stats);
6868
}
6969

7070
std::string AutoStory_Checkpoint_99::name() const{ return "099 - " + AutoStory_Segment_37().name(); }
71-
std::string AutoStory_Checkpoint_99::start_text() const{ return "";}
72-
std::string AutoStory_Checkpoint_99::end_text() const{ return "";}
71+
std::string AutoStory_Checkpoint_99::start_text() const{ return AutoStory_Checkpoint_98().end_text();}
72+
std::string AutoStory_Checkpoint_99::end_text() const{ return "Inside Area Zero Station 3. Deactivated the locks.";}
7373
void AutoStory_Checkpoint_99::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{
7474
checkpoint_99(env, context, options.notif_status_update, stats);
7575
}
@@ -78,41 +78,280 @@ void checkpoint_98(SingleSwitchProgramEnvironment& env, ProControllerContext& co
7878
checkpoint_reattempt_loop(env, context, notif_status_update, stats,
7979
[&](size_t attempt_number){
8080

81-
82-
#if 0
83-
// align to rock.
84-
// center before:
85-
// center after:
86-
move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock", 0.000,
81+
YOLOv5Detector yolo_detector(RESOURCE_PATH() + "PokemonSV/YOLO/A0-station-3.onnx");
82+
83+
pbf_move_left_joystick(context, 128, 255, 200, 100);
84+
walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 10, 255, 128);
85+
clear_dialog(env.console, context, ClearDialogMode::STOP_PROMPT, 60, {CallbackEnum::PROMPT_DIALOG});
86+
pbf_press_dpad(context, DPAD_DOWN, 13, 20);
87+
88+
pbf_mash_button(context, BUTTON_A, 50);
89+
wait_for_overworld(env.program_info(), env.console, context, 30);
90+
91+
92+
93+
// arrived at research station 1
94+
95+
pbf_move_left_joystick(context, 0, 255, 500, 100);
96+
pbf_wait(context, 3 * TICKS_PER_SECOND);
97+
// wait for overworld after leaving research station
98+
wait_for_overworld(env.program_info(), env.console, context, 30);
99+
100+
101+
// left research station 1
102+
103+
104+
// align to rock-3-0.
105+
// center before: center-y: 0.618056 center-x: 0.260156
106+
// center after: center-y: 0.248611 center-x: 0.452344
107+
move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-3-0", 0.248611,
108+
[&](){
109+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
110+
move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3-0", 0.260156); // x-position of target object prior to camera move
111+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
112+
}
113+
);
114+
move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-3-0", 0.452344,
115+
[&](){
116+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
117+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
118+
}
119+
);
120+
121+
// move forward until rock-3-0 not detected
122+
move_forward_until_yolo_object_not_detected(env, context, yolo_detector, "rock-3-0",
123+
2,
124+
[&](){
125+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
126+
move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3-0", 0.452344);
127+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
128+
}
129+
);
130+
131+
132+
pbf_press_button(context, BUTTON_L, 240ms, 100ms);
133+
134+
move_camera_until_yolo_object_detected(env, context, yolo_detector, "waterfall-3-1", 0, 100);
135+
136+
137+
138+
// align to waterfall-3-1.
139+
// center before: y:0.22 x: 0.31
140+
// center after: center-y: 0.220833 center-x: 0.754687
141+
move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "waterfall-3-1", 0.220833,
87142
[&](){
88143
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
89-
move_player_to_realign_via_yolo(env, context, yolo_detector, "rock", 0.000); // x-position of target object prior to camera move
144+
move_player_to_realign_via_yolo(env, context, yolo_detector, "waterfall-3-1", 0.31); // x-position of target object prior to camera move
90145
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
91146
}
92147
);
93-
move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock", 0.000,
148+
move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "waterfall-3-1", 0.754687,
94149
[&](){
95150
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
96151
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
97152
}
98153
);
99154

100-
// move towards rock until box:
101-
move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock",
102-
0.000, 0.000,
155+
// walk off the cliff
156+
157+
158+
// move forward until we see rock-3-1
159+
move_forward_until_yolo_object_detected(env, context, yolo_detector, "rock-3-1",
160+
[&](){
161+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
162+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
163+
pbf_press_button(context, BUTTON_L, 240ms, 100ms);
164+
move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "waterfall-3-1", 0.754687,
165+
[&](){
166+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
167+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
168+
}
169+
);
170+
},
171+
30
172+
);
173+
174+
175+
176+
// align to rock-3-1.
177+
// center before: center-y: 0.538889 center-x: 0.384375
178+
// center after: center-y: 0.295833 center-x: 0.577344
179+
move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-3-1", 0.295833,
180+
[&](){
181+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
182+
move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3-1", 0.4); // x-position of target object prior to camera move
183+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
184+
}
185+
);
186+
move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-3-1", 0.577344,
187+
[&](){
188+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
189+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
190+
}
191+
);
192+
193+
// move forward until rock-3-1 not detected
194+
move_forward_until_yolo_object_not_detected(env, context, yolo_detector, "rock-3-1",
195+
1,
103196
[&](){
104197
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
105-
move_player_to_realign_via_yolo(env, context, yolo_detector, "rock", 0.000); // realign to target X
198+
move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3-1", 0.577344);
106199
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
107200
}
108201
);
109202

110-
#endif
203+
// align to tree-3-1.
204+
// center before: center-y: 0.189 center-x: 0.21
205+
// center after: center-y: 0.318056 center-x: 0.522656
206+
move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "tree-3-1", 0.318056,
207+
[&](){
208+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
209+
move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-3-1", 0.3); // x-position of target object prior to camera move
210+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
211+
}
212+
);
213+
move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-3-1", 0.5,
214+
[&](){
215+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
216+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
217+
}
218+
);
219+
220+
// move towards tree-3-1 until box: {0.428125, 0.000000, 0.118750, 0.305556}
221+
move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "tree-3-1",
222+
0.118, 0.2,
223+
[&](){
224+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
225+
move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-3-1", 0.000); // realign to target X
226+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
227+
}
228+
);
229+
230+
// align to tree-3-1.
231+
// center before: center-y: 0.150000 center-x: 0.517969
232+
// center after: center-y: 0.151389 center-x: 0.358594
233+
move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "tree-3-1", 0.151389,
234+
[&](){
235+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
236+
move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-3-1", 0.5); // x-position of target object prior to camera move
237+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
238+
}
239+
);
240+
move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-3-1", 0.358594,
241+
[&](){
242+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
243+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
244+
}
245+
);
246+
247+
// move forward until tree-3-1 not detected
248+
move_forward_until_yolo_object_not_detected(env, context, yolo_detector, "tree-3-1",
249+
1,
250+
[&](){
251+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
252+
move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-3-1", 0.5);
253+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
254+
}
255+
);
256+
257+
258+
259+
pbf_move_right_joystick(context, 128, 255, 200, 0);
260+
move_camera_until_yolo_object_detected(env, context, yolo_detector, "beyond-cliff-3", 255, 30);
261+
262+
move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "beyond-cliff-3", 0.5,
263+
[&](){
264+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
265+
pbf_move_right_joystick(context, 128, 255, 200, 0);
266+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
267+
}
268+
);
269+
270+
// move towards beyond-cliff-3 until it takes up most of screen
271+
move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "beyond-cliff-3",
272+
0.5, 0.9,
273+
[&](){
274+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
275+
pbf_move_right_joystick(context, 128, 255, 200, 0);
276+
277+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
278+
}
279+
);
280+
281+
// walked off cliff. now move backwards
282+
283+
pbf_move_left_joystick(context, 128, 255, 800, 50); // move forward to align with camera
284+
285+
pbf_press_button(context, BUTTON_L, 240ms, 100ms);
286+
287+
move_camera_until_yolo_object_detected(env, context, yolo_detector, "station-3", 0, 100);
288+
289+
290+
move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "station-3", 0.5,
291+
[&](){
292+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
293+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
294+
}
295+
);
296+
297+
298+
do_action_until_dialog(env.program_info(), env.console, context,
299+
[&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
300+
move_player_forward(env, context, 20,
301+
[&](){
302+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
303+
move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "station-3", 0.5,
304+
[&](){
305+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
306+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
307+
}
308+
);
309+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
310+
}
311+
);
312+
}
313+
);
314+
315+
316+
clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::BATTLE});
317+
run_trainer_double_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG);
318+
mash_button_till_overworld(env.console, context, BUTTON_A);
111319

112320
});
113321
}
114322

115323
void checkpoint_99(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){
324+
checkpoint_reattempt_loop(env, context, notif_status_update, stats,
325+
[&](size_t attempt_number){
326+
327+
YOLOv5Detector yolo_detector(RESOURCE_PATH() + "PokemonSV/YOLO/station-door-1.onnx"); // we can reuse the detector for station door 1.
328+
329+
do_action_until_dialog(env.program_info(), env.console, context,
330+
[&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
331+
pbf_press_button(context, BUTTON_R, 160ms, 0ms);
332+
move_player_forward(env, context, 20,
333+
[&](){
334+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
335+
move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "station-door-1", 0.5,
336+
[&](){
337+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
338+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
339+
}
340+
);
341+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
342+
}
343+
);
344+
}
345+
);
346+
347+
mash_button_till_overworld(env.console, context, BUTTON_A); // black dialog
348+
349+
// disable Lock at Station 3
350+
walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_SPAM_A, 20);
351+
mash_button_till_overworld(env.console, context, BUTTON_A); // black dialog, prompt
352+
353+
354+
});
116355
}
117356

118357

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_37.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ class AutoStory_Checkpoint_99 : public AutoStory_Checkpoint{
4343
};
4444

4545

46-
// start:
47-
// end:
46+
// start: Inside Area Zero Station 2. Deactivated the locks.
47+
// end: Outside Area Zero Station 3. Defeated Great Tusk/Iron Treads.
4848
void checkpoint_98(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats);
4949

50-
// start:
51-
// end:
50+
// start: Outside Area Zero Station 3. Defeated Great Tusk/Iron Treads.
51+
// end: Inside Area Zero Station 3. Deactivated the locks.
5252
void checkpoint_99(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats);
5353

5454

0 commit comments

Comments
 (0)