Skip to content

Commit 5f9748f

Browse files
committed
draft checkpoint_102: navigation to zero lab.
1 parent 30c75e3 commit 5f9748f

File tree

5 files changed

+182
-24
lines changed

5 files changed

+182
-24
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ std::vector<std::unique_ptr<AutoStory_Segment>> make_autoStory_segment_list(){
134134
segment_list.emplace_back(std::make_unique<AutoStory_Segment_36>());
135135
segment_list.emplace_back(std::make_unique<AutoStory_Segment_37>());
136136
segment_list.emplace_back(std::make_unique<AutoStory_Segment_38>());
137-
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_39>());
137+
segment_list.emplace_back(std::make_unique<AutoStory_Segment_39>());
138138
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_40>());
139139
}
140140
return segment_list;
@@ -309,8 +309,8 @@ std::vector<std::unique_ptr<AutoStory_Checkpoint>> make_autoStory_checkpoint_lis
309309
checkpoint_list.emplace_back(std::make_unique<AutoStory_Checkpoint_99>());
310310
checkpoint_list.emplace_back(std::make_unique<AutoStory_Checkpoint_100>());
311311
checkpoint_list.emplace_back(std::make_unique<AutoStory_Checkpoint_101>());
312-
// checkpoint_list.emplace_back(std::make_unique<AutoStory_Checkpoint_102>());
313-
// checkpoint_list.emplace_back(std::make_unique<AutoStory_Checkpoint_103>());
312+
checkpoint_list.emplace_back(std::make_unique<AutoStory_Checkpoint_102>());
313+
checkpoint_list.emplace_back(std::make_unique<AutoStory_Checkpoint_103>());
314314
// checkpoint_list.emplace_back(std::make_unique<AutoStory_Checkpoint_104>());
315315
// checkpoint_list.emplace_back(std::make_unique<AutoStory_Checkpoint_105>());
316316

@@ -1051,8 +1051,8 @@ void AutoStory::test_checkpoints(
10511051
checkpoint_list.push_back([&](){checkpoint_99(env, context, notif_status_update, stats);});
10521052
checkpoint_list.push_back([&](){checkpoint_100(env, context, notif_status_update, stats);});
10531053
checkpoint_list.push_back([&](){checkpoint_101(env, context, notif_status_update, stats);});
1054-
// checkpoint_list.push_back([&](){checkpoint_102(env, context, notif_status_update, stats);});
1055-
// checkpoint_list.push_back([&](){checkpoint_103(env, context, notif_status_update, stats);});
1054+
checkpoint_list.push_back([&](){checkpoint_102(env, context, notif_status_update, stats);});
1055+
checkpoint_list.push_back([&](){checkpoint_103(env, context, notif_status_update, stats);});
10561056
// checkpoint_list.push_back([&](){checkpoint_104(env, context, notif_status_update, stats);});
10571057
// checkpoint_list.push_back([&](){checkpoint_105(env, context, notif_status_update, stats);});
10581058

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1459,6 +1459,7 @@ void move_player_forward(
14591459
uint8_t num_rounds,
14601460
std::function<void()>&& recovery_action,
14611461
bool use_lets_go,
1462+
bool mash_A,
14621463
uint16_t forward_ticks,
14631464
uint8_t y,
14641465
uint16_t delay_after_forward_move,
@@ -1471,7 +1472,12 @@ void move_player_forward(
14711472
do_action_and_monitor_for_battles_early(env.program_info(), env.console, context,
14721473
[&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
14731474
if (!use_lets_go){
1474-
pbf_move_left_joystick(context, 128, y, forward_ticks, 0);
1475+
// pbf_move_left_joystick(context, 128, y, forward_ticks, 0);
1476+
ssf_press_left_joystick(context, 128, 0, 0, 100, 0);
1477+
1478+
if (mash_A){ // mashing A and Let's go aren't compatible. you end up talking to your Let's go pokemon if you mash A.
1479+
pbf_mash_button(context, BUTTON_A, forward_ticks);
1480+
}
14751481
}else{
14761482
pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go);
14771483
pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,12 +382,14 @@ void checkpoint_reattempt_loop_tutorial(
382382

383383
// walk forward forward_ticks. repeat this for num_rounds.
384384
// if detect battle, kill the Pokemon. then continue. If we run into a battle, this round is considered to be done and will not be repeated.
385+
// NOTE: mashing A and Let's go aren't compatible. you end up talking to your Let's go pokemon if you mash A.
385386
void move_player_forward(
386387
SingleSwitchProgramEnvironment& env,
387388
ProControllerContext& context,
388389
uint8_t num_rounds,
389390
std::function<void()>&& recovery_action,
390391
bool use_lets_go = false,
392+
bool mash_A = false,
391393
uint16_t forward_ticks = 100,
392394
uint8_t y = 0,
393395
uint16_t delay_after_forward_move = 50,

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

Lines changed: 159 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,18 @@ void AutoStory_Segment_39::run_segment(
6060
}
6161

6262
std::string AutoStory_Checkpoint_102::name() const{ return "0102 - " + AutoStory_Segment_39().name(); }
63-
std::string AutoStory_Checkpoint_102::start_text() const{ return "";}
64-
std::string AutoStory_Checkpoint_102::end_text() const{ return "";}
63+
std::string AutoStory_Checkpoint_102::start_text() const{ return "Inside Area Zero Station 4. Deactivated the locks.";}
64+
std::string AutoStory_Checkpoint_102::end_text() const{ return "Opened Zero lab. Defeated Paradox Pokemon.";}
6565
void AutoStory_Checkpoint_102::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{
6666
checkpoint_102(env, context, options.notif_status_update, stats);
6767
}
6868

69-
// std::string AutoStory_Checkpoint_103::name() const{ return "0103 - " + AutoStory_Segment_3().name(); }
70-
// std::string AutoStory_Checkpoint_103::start_text() const{ return "";}
71-
// std::string AutoStory_Checkpoint_103::end_text() const{ return "";}
72-
// void AutoStory_Checkpoint_103::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{
73-
// checkpoint_103(env, context, options.notif_status_update, stats);
74-
// }
69+
std::string AutoStory_Checkpoint_103::name() const{ return "0103 - " + AutoStory_Segment_39().name(); }
70+
std::string AutoStory_Checkpoint_103::start_text() const{ return AutoStory_Checkpoint_102().end_text();}
71+
std::string AutoStory_Checkpoint_103::end_text() const{ return "";}
72+
void AutoStory_Checkpoint_103::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{
73+
checkpoint_103(env, context, options.notif_status_update, stats);
74+
}
7575

7676
// std::string AutoStory_Checkpoint_104::name() const{ return "0104 - " + AutoStory_Segment_3().name(); }
7777
// std::string AutoStory_Checkpoint_104::start_text() const{ return "";}
@@ -91,7 +91,157 @@ void checkpoint_102(SingleSwitchProgramEnvironment& env, ProControllerContext& c
9191
// checkpoint_reattempt_loop(env, context, notif_status_update, stats,
9292
// [&](size_t attempt_number){
9393

94-
// YOLOv5Detector yolo_detector(RESOURCE_PATH() + "PokemonSV/YOLO/A0-station-4b.onnx");
94+
YOLOv5Detector yolo_detector(RESOURCE_PATH() + "PokemonSV/YOLO/A0-lab.onnx");
95+
96+
#if 0
97+
#endif
98+
99+
pbf_move_left_joystick(context, 128, 255, 200, 100);
100+
walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 10, 255, 128);
101+
clear_dialog(env.console, context, ClearDialogMode::STOP_PROMPT, 60, {CallbackEnum::PROMPT_DIALOG});
102+
pbf_press_dpad(context, DPAD_DOWN, 13, 20);
103+
pbf_press_dpad(context, DPAD_DOWN, 13, 20);
104+
105+
// go to Station 2
106+
pbf_mash_button(context, BUTTON_A, 50);
107+
wait_for_overworld(env.program_info(), env.console, context, 30);
108+
109+
// heal at the bed
110+
pbf_move_left_joystick(context, 128, 0, 300, 100);
111+
walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_SPAM_A, 10, 255, 128);
112+
clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::PROMPT_DIALOG, CallbackEnum::OVERWORLD});
113+
114+
// leave Station 2
115+
pbf_move_left_joystick(context, 50, 255, 130, 20);
116+
117+
pbf_move_left_joystick(context, 128, 255, 500, 100);
118+
pbf_wait(context, 3 * TICKS_PER_SECOND);
119+
// wait for overworld after leaving research station
120+
wait_for_overworld(env.program_info(), env.console, context, 30);
121+
122+
pbf_move_right_joystick(context, 180, 128, 30, 0); // adjust camera so rock isn't at edge of screen.
123+
124+
125+
// align to rock-5-1.
126+
// center before: y: x:
127+
// center after: center-y: 0.347222 center-x: 0.664844
128+
move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-5-1", 0.347222,
129+
[&](){
130+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
131+
move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-5-1", 0.5000); // x-position of target object prior to camera move
132+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
133+
}
134+
);
135+
move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-5-1", 0.664844,
136+
[&](){
137+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
138+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
139+
}
140+
);
141+
142+
// move forward until we see rock-5-2
143+
move_player_until_yolo_object_detected(env, context, yolo_detector, "rock-5-2",
144+
[&](){
145+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
146+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
147+
},
148+
30
149+
);
150+
151+
// align to rock-5-2.
152+
// center before: y: x:
153+
// center after: center-y: 0.158333 center-x: 0.568750
154+
move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-5-2", 0.158333,
155+
[&](){
156+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
157+
move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-5-2", 0.5000); // x-position of target object prior to camera move
158+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
159+
}
160+
);
161+
move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-5-2", 0.568750,
162+
[&](){
163+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
164+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
165+
}
166+
);
167+
168+
// move towards rock-5-2 until box: (0.2535, 0.25) OR (0.34, 0.375)
169+
move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock-5-2",
170+
0.25, 0.3,
171+
[&](){
172+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
173+
move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-5-2", 0.000); // realign to target X
174+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
175+
}
176+
);
177+
178+
pbf_move_right_joystick(context, 128, 255, 200, 0);
179+
move_camera_until_yolo_object_detected(env, context, yolo_detector, "beyond-cliff-5", 0, 30);
180+
181+
move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "beyond-cliff-5", 0.5,
182+
[&](){
183+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
184+
pbf_move_right_joystick(context, 128, 255, 200, 0);
185+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
186+
}
187+
);
188+
189+
// move towards beyond-cliff-5 until it takes up most of screen
190+
move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "beyond-cliff-5",
191+
0.5, 0.9,
192+
[&](){
193+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
194+
pbf_move_right_joystick(context, 128, 255, 200, 0);
195+
196+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
197+
}
198+
);
199+
200+
// walked off cliff. now move backwards
201+
walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 60, 128, 255); // move backwards until dialog detected
202+
203+
204+
mash_button_till_overworld(env.console, context, BUTTON_A);
205+
206+
207+
208+
// align to gate-panel.
209+
// center before: y: x:
210+
// center after: center-y: 0.295833 center-x: 0.517969
211+
move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "gate-panel", 0.295833,
212+
[&](){
213+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
214+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
215+
}
216+
);
217+
move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "gate-panel", 0.5,
218+
[&](){
219+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
220+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
221+
}
222+
);
223+
224+
do_action_until_dialog(env.program_info(), env.console, context,
225+
[&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
226+
move_player_forward(env, context, 10,
227+
[&](){
228+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
229+
move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "gate-panel", 0.5,
230+
[&](){
231+
run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD);
232+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
233+
}
234+
);
235+
pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera
236+
},
237+
false,
238+
true
239+
);
240+
}
241+
);
242+
243+
244+
// clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::BATTLE});
95245

96246
#if 0
97247
// align to rock.

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ class AutoStory_Checkpoint_102 : public AutoStory_Checkpoint{
3434
virtual void run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const override;
3535
};
3636

37-
// class AutoStory_Checkpoint_103 : public AutoStory_Checkpoint{
38-
// public:
39-
// virtual std::string name() const override;
40-
// virtual std::string start_text() const override;
41-
// virtual std::string end_text() const override;
42-
// virtual void run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const override;
43-
// };
37+
class AutoStory_Checkpoint_103 : public AutoStory_Checkpoint{
38+
public:
39+
virtual std::string name() const override;
40+
virtual std::string start_text() const override;
41+
virtual std::string end_text() const override;
42+
virtual void run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const override;
43+
};
4444

4545
// class AutoStory_Checkpoint_104 : public AutoStory_Checkpoint{
4646
// public:
@@ -61,10 +61,10 @@ class AutoStory_Checkpoint_102 : public AutoStory_Checkpoint{
6161

6262

6363
// start: Inside Area Zero Station 4. Deactivated the locks.
64-
// end:
64+
// end: Opened Zero lab. Defeated Paradox Pokemon.
6565
void checkpoint_102(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats);
6666

67-
// start:
67+
// start: Opened Zero lab. Defeated Paradox Pokemon.
6868
// end:
6969
void checkpoint_103(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats);
7070

0 commit comments

Comments
 (0)