Skip to content

Commit 05f1fc8

Browse files
author
Gin
committed
Fix battle control interfering with dialog
1 parent fefa804 commit 05f1fc8

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

SerialPrograms/Source/PokemonLZA/Programs/Farming/PokemonLZA_JacintheInfiniteFarmer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ bool JacintheInfiniteFarmer::talk_to_jacinthe(SingleSwitchProgramEnvironment& en
237237
case 3:
238238
env.log("Detected black screen.");
239239
env.console.overlay().add_log("Transition to Battle");
240+
// mash B for 10 sec to clear up any pre-battle transparency dialog
241+
pbf_mash_button(context, BUTTON_B, 10s);
242+
context.wait_for_all_requests();
243+
env.console.overlay().add_log("Cleared Transparent Dialog");
240244
// battle starts
241245
return false;
242246

@@ -265,7 +269,8 @@ void JacintheInfiniteFarmer::run_round(SingleSwitchProgramEnvironment& env, ProC
265269
env.console, context,
266270
[&](ProControllerContext& context){
267271
while (current_time() - start < 30min){
268-
attempt_one_attack(env, context, MOVE_AI, USE_PLUS_MOVES);
272+
const bool allow_button_B_press = false;
273+
attempt_one_attack(env, context, MOVE_AI, USE_PLUS_MOVES, allow_button_B_press);
269274
}
270275
},
271276
{

SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_TrainerBattle.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace PokemonLZA{
2121

2222
bool attempt_one_attack(
2323
SingleSwitchProgramEnvironment& env, ProControllerContext& context,
24-
bool use_move_ai, bool use_plus_moves
24+
bool use_move_ai, bool use_plus_moves, bool allow_button_B_press
2525
){
2626
if (!use_move_ai){
2727
ssf_press_button(context, BUTTON_ZL, 160ms, 800ms, 200ms);
@@ -31,7 +31,9 @@ bool attempt_one_attack(
3131
}
3232
pbf_press_button(context, BUTTON_X, 80ms, 24ms);
3333
pbf_press_button(context, BUTTON_Y, 80ms, 24ms);
34-
pbf_press_button(context, BUTTON_B, 80ms, 24ms);
34+
if (allow_button_B_press){
35+
pbf_press_button(context, BUTTON_B, 80ms, 24ms);
36+
}
3537
return true;
3638
}
3739

@@ -55,7 +57,11 @@ bool attempt_one_attack(
5557
command.stop_session_and_rethrow();
5658
context.wait_for(250ms);
5759
// No move effectiveness symbol found
58-
pbf_press_button(context, BUTTON_B, 160ms, 80ms);
60+
if (allow_button_B_press){
61+
// It could be the game is in a transparent pre-battle dialog,
62+
// press B to clear it.
63+
pbf_press_button(context, BUTTON_B, 160ms, 80ms);
64+
}
5965
return false;
6066
}
6167

SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_TrainerBattle.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,21 @@ namespace PokemonLZA{
2121

2222

2323
// Try to lock onto an opponent pokemon and launch an attack.
24-
// - use_move_ai: if True, select move based on type effectiveness. Otherwise, select the top,
25-
// left then bottom move in quick succession to ensure at least one of the three moves are launched
26-
// despite potential move cooldown.
24+
// - use_move_ai: if True, select move based on type effectiveness. Otherwise, select the top, left
25+
// then bottom (if allow_button_B_press) move in quick succession to ensure at least one of the moves
26+
// are launched despite potential move cooldown.
2727
// - use_plus_moves: if True, press + to launch plus moves.
28+
// - allow_button_B_press: if true, allow the AI mode to press B if it cannot detect move effectiveness
29+
// symbols and allow the non-AI mode to use the bottom move. This lets the function clear any pre-battle
30+
// transparent dialog window it encounters.
31+
// If false, the AI mode will do nothing when move effectiveness symbols are not detected and the
32+
// non-AI mode will never select the bottom move. This ensures the function won't interfere with
33+
// detecting flat white dialog windows but it will be external code's responsibility to clear
34+
// pre-battle transparent dialog windows.
2835
bool attempt_one_attack(
2936
SingleSwitchProgramEnvironment& env, ProControllerContext& context,
30-
bool use_move_ai, bool use_plus_moves
37+
bool use_move_ai, bool use_plus_moves,
38+
bool allow_button_B_press = true
3139
);
3240

3341
}

0 commit comments

Comments
 (0)