Skip to content

Commit 09a55f5

Browse files
authored
Update stats reset to use OCR based fast travel (#1083)
* fix stats reset meltan option * update stats reset to use OCR based fast travel
1 parent 3d41596 commit 09a55f5

1 file changed

Lines changed: 27 additions & 15 deletions

File tree

SerialPrograms/Source/PokemonLZA/Programs/NonShinyHunting/PokemonLZA_StatsReset.cpp

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*
55
*/
66

7+
#include "CommonFramework/Exceptions/OperationFailedException.h"
78
#include "CommonFramework/Notifications/ProgramNotifications.h"
89
#include "CommonFramework/ProgramStats/StatsTracking.h"
910
#include "CommonFramework/VideoPipeline/VideoFeed.h"
@@ -20,6 +21,7 @@
2021
#include "PokemonLZA_StatsReset.h"
2122
#include "PokemonLZA/Programs/PokemonLZA_GameEntry.h"
2223
#include "PokemonLZA/Programs/PokemonLZA_BasicNavigation.h"
24+
#include "PokemonLZA/Programs/PokemonLZA_FastTravelNavigation.h"
2325
#include "PokemonLZA/Programs/PokemonLZA_MenuNavigation.h"
2426

2527
namespace PokemonAutomation{
@@ -162,13 +164,19 @@ void StatsReset::program(SingleSwitchProgramEnvironment& env, ProControllerConte
162164
context.wait_for_all_requests();
163165

164166
if (POKEMON == GiftPokemon::FLOETTE || POKEMON == GiftPokemon::MAGEARNA){
165-
// fly to Quasartico, replace with OCR in the future
166-
overworld_to_main_menu(env.console, context);
167-
open_map(env.console, context, false, false);
168-
pbf_move_right_joystick(context, {0, +1}, 500ms, 500ms);
169-
pbf_move_right_joystick(context, {0, +1}, 500ms, 500ms);
170-
pbf_move_left_joystick(context, {-0.609, 0}, 100ms, 500ms);
171-
fly_from_map(env.console, context);
167+
// fly to Quasartico Inc.
168+
FastTravelState travel_status = open_map_and_fly_to(env.console, context, LANGUAGE, Location::QUASARTICO_INC);
169+
if (travel_status != FastTravelState::SUCCESS){
170+
stats.errors++;
171+
env.update_stats();
172+
OperationFailedException::fire(
173+
ErrorReport::SEND_ERROR_REPORT,
174+
"Failed to travel to Quasartico Inc.",
175+
env.console
176+
);
177+
}
178+
context.wait_for(100ms);
179+
env.log("Detected overworld. Fast traveled to Quasartico Inc.");
172180

173181
// move to the door
174182
pbf_move_left_joystick(context, {0, +1}, 8s, 500ms);
@@ -184,14 +192,18 @@ void StatsReset::program(SingleSwitchProgramEnvironment& env, ProControllerConte
184192

185193
if (POKEMON == GiftPokemon::MELTAN || POKEMON == GiftPokemon::MELMETAL){
186194
// fly to Lysandre Café, replace with OCR in the future
187-
overworld_to_main_menu(env.console, context);
188-
open_map(env.console, context, false, false);
189-
pbf_press_button(context, BUTTON_Y, 50ms, 500ms);
190-
pbf_press_dpad(context, DPAD_RIGHT, 50ms, 500ms);
191-
pbf_press_dpad(context, DPAD_RIGHT, 50ms, 500ms);
192-
pbf_press_dpad(context, DPAD_RIGHT, 50ms, 500ms);
193-
pbf_press_dpad(context, DPAD_UP, 50ms, 500ms);
194-
pbf_mash_button(context, BUTTON_A, 5s);
195+
FastTravelState travel_status = open_map_and_fly_to(env.console, context, LANGUAGE, Location::LYSANDRE_CAFE);
196+
if (travel_status != FastTravelState::SUCCESS){
197+
stats.errors++;
198+
env.update_stats();
199+
OperationFailedException::fire(
200+
ErrorReport::SEND_ERROR_REPORT,
201+
"Failed to travel to Lysandre Café",
202+
env.console
203+
);
204+
}
205+
context.wait_for(100ms);
206+
env.log("Detected overworld. Fast traveled to Lysandre Café");
195207

196208
// move to the staircase
197209
pbf_move_left_joystick(context, {-1, -0.05}, 200ms, 500ms);

0 commit comments

Comments
 (0)