2323#include " PokemonLZA/Programs/PokemonLZA_BasicNavigation.h"
2424#include " PokemonLZA/Programs/PokemonLZA_FastTravelNavigation.h"
2525#include " PokemonLZA/Programs/PokemonLZA_MenuNavigation.h"
26+ #include " PokemonLZA/Programs/PokemonLZA_TrainerBattle.h"
2627
2728namespace PokemonAutomation {
2829namespace NintendoSwitch {
@@ -80,6 +81,7 @@ StatsReset::StatsReset()
8081 {GiftPokemon::MELTAN, " meltan" , " Meltan" },
8182 {GiftPokemon::MELMETAL, " melmetal" , " Melmetal" },
8283 {GiftPokemon::VOLCANION," volcanion" ," Volcanion" },
84+ {GiftPokemon::HOOPA, " hoopa" , " Hoopa" },
8385 },
8486 LockMode::LOCK_WHILE_RUNNING,
8587 GiftPokemon::FLOETTE
@@ -134,6 +136,7 @@ StatsReset::StatsReset()
134136 PA_ADD_OPTION (SCROLL_RELEASE);
135137 PA_ADD_OPTION (POST_THROW_WAIT);
136138 PA_ADD_OPTION (DOWN_SCROLLS);
139+ PA_ADD_OPTION (BATTLE_AI);
137140 PA_ADD_OPTION (HP);
138141 PA_ADD_OPTION (ATTACK);
139142 PA_ADD_OPTION (DEFENSE);
@@ -154,13 +157,16 @@ StatsReset::~StatsReset(){
154157void StatsReset::on_config_value_changed (void * object){
155158 ConfigOptionState state_ball = (POKEMON == GiftPokemon::GENESECT || POKEMON == GiftPokemon::MELTAN || POKEMON == GiftPokemon::VOLCANION)
156159 ? ConfigOptionState::ENABLED : ConfigOptionState::HIDDEN;
157- ConfigOptionState state_donut = (POKEMON == GiftPokemon::GENESECT || POKEMON == GiftPokemon::MELMETAL)
160+ ConfigOptionState state_donut = (POKEMON == GiftPokemon::GENESECT || POKEMON == GiftPokemon::MELMETAL || POKEMON == GiftPokemon::HOOPA )
158161 ? ConfigOptionState::ENABLED : ConfigOptionState::HIDDEN;
162+ ConfigOptionState state_battle = (POKEMON == GiftPokemon::HOOPA)
163+ ? ConfigOptionState::ENABLED : ConfigOptionState::HIDDEN;
159164 RIGHT_SCROLLS.set_visibility (state_ball);
160165 SCROLL_HOLD.set_visibility (state_ball);
161166 SCROLL_RELEASE.set_visibility (state_ball);
162167 POST_THROW_WAIT.set_visibility (state_ball);
163168 DOWN_SCROLLS.set_visibility (state_donut);
169+ BATTLE_AI.set_visibility (state_battle);
164170}
165171
166172void StatsReset::enter_portal (SingleSwitchProgramEnvironment& env, ProControllerContext& context){
@@ -441,6 +447,122 @@ void StatsReset::program(SingleSwitchProgramEnvironment& env, ProControllerConte
441447 pbf_mash_button (context, BUTTON_A, 20s);
442448 }
443449
450+ if (POKEMON == GiftPokemon::HOOPA){
451+ // fly to cafe soleil
452+ FastTravelState travel_status = open_map_and_fly_to (env.console , context, LANGUAGE, Location::CAFE_SOLEIL);
453+ if (travel_status != FastTravelState::SUCCESS){
454+ stats.errors ++;
455+ env.update_stats ();
456+ OperationFailedException::fire (
457+ ErrorReport::SEND_ERROR_REPORT,
458+ " Failed to travel to Café Soleil" ,
459+ env.console
460+ );
461+ }
462+ context.wait_for (100ms);
463+ env.log (" Detected overworld. Fast traveled to Café Soleil" );
464+
465+ // run to holovator
466+ pbf_move_left_joystick (context, {1 , 0.12 }, 200ms, 500ms);
467+ pbf_press_button (context, BUTTON_L, 50ms, 500ms);
468+ ssf_press_button (context, BUTTON_B, 0ms, 1s, 0ms);
469+ pbf_move_left_joystick (context, {0 , 1 }, 6500ms, 500ms);
470+ pbf_mash_button (context, BUTTON_A, 1s);
471+ context.wait_for_all_requests ();
472+ wait_until_overworld (env.console , context);
473+
474+ // run to the right of roof
475+ pbf_press_button (context, BUTTON_Y, 100ms, 1s);
476+ pbf_move_left_joystick (context, {1 , 0.12 }, 200ms, 500ms);
477+ for (int i = 0 ; i < 6 ; ++i){
478+ pbf_press_button (context, BUTTON_Y, 100ms, 1s);
479+ }
480+
481+ ssf_press_button (context, BUTTON_B, 0ms, 1s, 0ms);
482+ pbf_move_left_joystick (context, {1 , 0.12 }, 1s, 500ms);
483+
484+ // run forward to the ladder
485+ pbf_move_left_joystick (context, {0 , 1 }, 200ms, 500ms);
486+ for (int i = 0 ; i < 5 ; ++i){
487+ pbf_press_button (context, BUTTON_Y, 100ms, 1s);
488+ }
489+
490+ ssf_press_button (context, BUTTON_B, 0ms, 1s, 0ms);
491+ pbf_move_left_joystick (context, {0 , 1 }, 1s, 500ms);
492+
493+ pbf_press_button (context, BUTTON_Y, 100ms, 1s);
494+ pbf_press_button (context, BUTTON_Y, 100ms, 1s);
495+
496+ ssf_press_button (context, BUTTON_B, 0ms, 1s, 0ms);
497+ pbf_move_left_joystick (context, {-0.2 , 1 }, 4s, 0ms);
498+ ssf_press_button (context, BUTTON_B, 0ms, 1s, 0ms);
499+ pbf_move_left_joystick (context, {-0.8 , 1 }, 1500ms, 500ms);
500+
501+ // climb ladder
502+ pbf_mash_button (context, BUTTON_A, 500ms);
503+ pbf_move_left_joystick (context, {0 , 1 }, 8s, 1500ms);
504+
505+ ssf_press_button (context, BUTTON_B, 0ms, 1s, 0ms);
506+ pbf_move_left_joystick (context, {-1 , 0 }, 2s, 500ms);
507+
508+ enter_portal (env, context);
509+ context.wait_for (100ms);
510+
511+ // run toward hoopa to start battle
512+ ssf_press_button (context, BUTTON_B, 0ms, 1s, 0ms);
513+ pbf_move_left_joystick (context, {0 , +1 }, 8s, 0ms);
514+
515+ RunFromBattleWatcher battle_menu (COLOR_GREEN, &env.console .overlay (), 10ms);
516+ OverworldPartySelectionWatcher overworld (COLOR_WHITE, &env.console .overlay (), 100ms);
517+ TrainerBattleState battle_state (BATTLE_AI);
518+ context.wait_for_all_requests ();
519+ bool has_error = false ;
520+ while (true ){
521+ int ret = run_until<ProControllerContext>(
522+ env.console , context,
523+ [](ProControllerContext& context){
524+ pbf_mash_button (context, BUTTON_B, 120s);
525+ },
526+ {
527+ battle_menu,
528+ overworld,
529+ }
530+ );
531+
532+ switch (ret){
533+ case 0 :
534+ env.log (" Detected battle menu." );
535+ if (!battle_state.attempt_one_attack (env, env.console , context)){
536+ pbf_press_button (context, BUTTON_UP, 500ms, 1s);
537+ }
538+ continue ;
539+ case 1 :
540+ env.log (" Detected overworld." );
541+ break ;
542+ default :
543+ has_error = true ;
544+ break ;
545+ }
546+ break ;
547+ }
548+ if (has_error){
549+ stats.errors ++;
550+ env.log (" Error during battle." , COLOR_RED);
551+ // fail safely and start over
552+ go_home (env.console , context);
553+ reset_game_from_home (env, env.console , context, true );
554+ continue ;
555+ }
556+ context.wait_for (100ms);
557+ // run toward hoopa to catch
558+ ssf_press_button (context, BUTTON_B, 0ms, 2s, 0ms);
559+ pbf_move_left_joystick (context, {0.05 , +1 }, 1500ms, 0ms);
560+ pbf_mash_button (context, BUTTON_A, 1s);
561+ // incase did not run
562+ pbf_move_left_joystick (context, {0.05 , +1 }, 500ms, 0ms);
563+ pbf_mash_button (context, BUTTON_A, 1s);
564+ }
565+
444566 context.wait_for_all_requests ();
445567 {
446568 BlackScreenOverWatcher detector;
@@ -453,6 +575,8 @@ void StatsReset::program(SingleSwitchProgramEnvironment& env, ProControllerConte
453575 pbf_mash_button (context, BUTTON_A, 60s);
454576 }else if (POKEMON == GiftPokemon::MAGEARNA){
455577 pbf_mash_button (context, BUTTON_A, 60s);
578+ }else if (POKEMON == GiftPokemon::HOOPA) {
579+ pbf_mash_button (context, BUTTON_A, 120s);
456580 }else {
457581 pbf_mash_button (context, BUTTON_A, 30s);
458582 }
0 commit comments