From ee35490d6b6cd3d021b538520d0a907c95628cfe Mon Sep 17 00:00:00 2001 From: Alexander Yee Date: Tue, 10 Nov 2026 21:05:50 -0800 Subject: [PATCH] Do a full cursor reset if we fail to pick a move too many times. Context: https://discord.com/channels/695809740428673034/711649658220314635/1569625802880843978 Reported by: arosmian --- .../Program/PokemonSwSh_MaxLair_Run_Battle.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_Battle.cpp b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_Battle.cpp index ba8dcd4059..3685caa3a5 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_Battle.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSwSh/MaxLair/Program/PokemonSwSh_MaxLair_Run_Battle.cpp @@ -239,7 +239,7 @@ StateMachineAction run_move_select( bool all_moves_blocked = false; - while (true){ + for (size_t attempts = 0;; attempts++){ stream.log("Selecting move..."); if (cheer_only){ @@ -254,7 +254,10 @@ StateMachineAction run_move_select( inferred, player_index ); - stream.log("Choosing move " + std::to_string((int)move.first) + (move.second ? " (dmax)." : "."), COLOR_PURPLE); + stream.log( + "Choosing move " + std::to_string((int)move.first) + (move.second ? " (dmax)." : "."), + COLOR_PURPLE + ); if (player.can_dmax && move.second){ pbf_press_dpad(context, DPAD_LEFT, 80ms, 400ms); @@ -318,6 +321,14 @@ StateMachineAction run_move_select( // Reset position. pbf_mash_button(context, BUTTON_B, 2000ms); + if (attempts >= 5){ + stream.log( + "Failed to select a move after 5 attempts. Performing full cursor reset...", + COLOR_RED + ); + pbf_press_dpad(context, DPAD_RIGHT, 2000ms, 0ms); + pbf_press_dpad(context, DPAD_UP, 2000ms, 0ms); + } pbf_press_button(context, BUTTON_A, 160ms, 1000ms); pbf_press_dpad(context, DPAD_RIGHT, 2000ms, 0ms); pbf_press_dpad(context, DPAD_UP, 2000ms, 0ms);