Skip to content

Commit de9ca30

Browse files
committed
Improve AutoDA stability.
1 parent 9517287 commit de9ca30

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

SerialPrograms/Source/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_Battle.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,12 @@ StateMachineAction throw_balls(
348348
}
349349

350350
BattleBallReader reader(stream, language);
351-
pbf_press_button(context, BUTTON_A, 10, 125);
351+
pbf_press_button(context, BUTTON_A, 50, 75);
352352
context.wait_for_all_requests();
353353

354354
int16_t balls = move_to_ball(reader, stream, context, ball);
355355
if (balls != 0){
356-
pbf_press_button(context, BUTTON_A, 10, 125);
356+
pbf_mash_button(context, BUTTON_A, 1000ms);
357357
}else{
358358
OperationFailedException::fire(
359359
ErrorReport::NO_ERROR_REPORT,

SerialPrograms/Source/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_PathSelect.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ void run_path_select(
6464
for (uint8_t c = 0; c < slot; c++){
6565
pbf_press_dpad(context, DPAD_RIGHT, 10, 50);
6666
}
67-
pbf_press_button(context, BUTTON_A, 10, TICKS_PER_SECOND);
67+
pbf_mash_button(context, BUTTON_A, 1000ms);
68+
pbf_wait(context, 5000ms);
6869
context.wait_for_all_requests();
6970
}
7071

SerialPrograms/Source/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_ProfessorSwap.cpp

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,54 +44,49 @@ void run_professor_swap(
4444
if (swap){
4545
stream.log("Choosing to swap.", COLOR_PURPLE);
4646
std::lock_guard<std::mutex> lg(runtime.m_delay_lock);
47-
pbf_press_button(context, BUTTON_A, 10, TICKS_PER_SECOND);
47+
pbf_mash_button(context, BUTTON_A, 1000ms);
4848
context.wait_for_all_requests();
4949
}else{
5050
stream.log("Choosing not to swap.", COLOR_PURPLE);
51-
pbf_press_button(context, BUTTON_B, 10, TICKS_PER_SECOND);
51+
pbf_mash_button(context, BUTTON_B, 1000ms);
5252
}
5353
context.wait_for_all_requests();
5454

55-
#if 1
55+
5656
// Wait until we exit the window.
5757
{
5858
BlackScreenWatcher detector;
59-
int result = run_until<ProControllerContext>(
59+
int result = wait_until(
6060
stream, context,
61-
[&](ProControllerContext& context){
62-
pbf_mash_button(context, swap ? BUTTON_A : BUTTON_B, 30 * TICKS_PER_SECOND);
63-
},
64-
{{detector}}
61+
std::chrono::seconds(30),
62+
{detector}
6563
);
6664
if (result < 0){
6765
stream.log("Timed out waiting for black screen.", COLOR_RED);
68-
}else{
69-
stream.log("Found path screen. Reading party...");
66+
return;
7067
}
7168
}
72-
#endif
69+
7370
{
7471
PathScreenDetector detector;
7572
int result = wait_until(
7673
stream, context,
7774
std::chrono::seconds(30),
78-
{{detector}},
75+
{detector},
7976
INFERENCE_RATE
8077
);
8178
if (result < 0){
8279
stream.log("Timed out waiting for path screen.", COLOR_RED);
83-
}else{
84-
stream.log("Found path screen. Reading party...");
80+
return;
8581
}
8682
}
8783

84+
stream.log("Found path screen. Reading party...");
8885
context.wait_for(std::chrono::milliseconds(100));
8986

90-
{
91-
VideoSnapshot screen = stream.video().snapshot();
92-
reader.read_sprites(stream.logger(), state, screen);
93-
reader.read_hp(stream.logger(), state, screen);
94-
}
87+
VideoSnapshot screen = stream.video().snapshot();
88+
reader.read_sprites(stream.logger(), state, screen);
89+
reader.read_hp(stream.logger(), state, screen);
9590
}
9691

9792

0 commit comments

Comments
 (0)