@@ -88,7 +88,7 @@ class ShinyHunt_WildZoneEntrance_Descriptor::Stats : public StatsTracker{
8888 , day_changes(m_stats[" Day/Night Changes" ])
8989 {
9090 m_display_order.emplace_back (" Visits" );
91- m_display_order.emplace_back (" Chased" , PreloadSettings::instance (). DEVELOPER_MODE ? ALWAYS_VISIBLE : ALWAYS_HIDDEN );
91+ m_display_order.emplace_back (" Chased" );
9292 m_display_order.emplace_back (" Shiny Sounds" );
9393 m_display_order.emplace_back (" Game Resets" );
9494 m_display_order.emplace_back (" Errors" , HIDDEN_IF_ZERO);
@@ -186,29 +186,6 @@ void go_to_entrance(
186186 env.console .overlay ().add_log (" Detect Entrance" );
187187}
188188
189- // While at the gate in the zone, mash A to leave the zone.
190- // If day/night change happens during this period, the function still returns after
191- // day/night change finishes, but then we don't know if the player character is still
192- // in the wild zone or not.
193- void leave_zone_gate (
194- SingleSwitchProgramEnvironment& env,
195- ProControllerContext& context
196- ){
197- env.log (" Leaving zone gate" );
198- OverworldPartySelectionWatcher overworld_watcher (COLOR_WHITE, &env.console .overlay ());
199- pbf_mash_button (context, BUTTON_A, 1s);
200- context.wait_for_all_requests ();
201- wait_until (
202- env.console , context,
203- std::chrono::seconds (40 ), // wait this long in case day/night change happens
204- {overworld_watcher}
205- );
206- pbf_wait (context, 100ms); // after leaving the gate, the game needs this long time to give back control
207- context.wait_for_all_requests ();
208- env.console .overlay ().add_log (" Left Gate" );
209- env.log (" Finished leaving zone gate" );
210- }
211-
212189
213190void fast_travel_outside_zone (
214191 SingleSwitchProgramEnvironment& env,
@@ -312,27 +289,19 @@ void leave_zone_and_reset_spawns(
312289 map_to_overworld (env.console , context);
313290 }
314291
315- walk_time_in_zone += 2s; // give some extra time
316- env.log (" Escaping" );
317- env.console .overlay ().add_log (" Escaping Back to Entrance" );
318292 stats.chased ++;
319293 env.update_stats ();
320294
295+ walk_time_in_zone += 2s; // give some extra time
296+ env.log (" Escaping" );
297+ env.console .overlay ().add_log (" Escaping Back to Entrance" );
298+
321299 const double starting_angle = get_current_facing_angle (env.console , context);
322300
323- ButtonWatcher buttonA (COLOR_RED, ButtonType::ButtonA, {0.3 , 0.2 , 0.4 , 0.7 }, &env.console .overlay ());
324- OverworldPartySelectionOverWatcher overworld_gone (COLOR_WHITE, &env.console .overlay (), std::chrono::milliseconds (400 ));
325- int ret = run_until<ProControllerContext>(
326- env.console , context,
327- [&walk_time_in_zone](ProControllerContext& context){
328- // running back
329- ssf_press_button (context, BUTTON_B, 0ms, walk_time_in_zone, 0ms);
330- pbf_move_left_joystick (context, 128 , 255 , walk_time_in_zone, 0ms);
331- },
332- {{buttonA, overworld_gone}}
333- );
301+ const ImageFloatBox button_A_box{0.3 , 0.2 , 0.4 , 0.7 };
302+ int ret = run_towards_wild_zone_gate (env.console , context, button_A_box, 128 , 255 , walk_time_in_zone);
334303 switch (ret){
335- case 0 :
304+ case 0 : // Found button A. Reached the gate.
336305 break ;
337306 case 1 :
338307 env.log (" Day/night change happened while escaping" );
@@ -347,7 +316,6 @@ void leave_zone_and_reset_spawns(
347316 env.log (" Facing angle difference after day/night change: " + tostr_fixed (angle_between, 0 ) + " deg, from "
348317 + tostr_fixed (starting_angle, 0 ) + " to " + tostr_fixed (current_facing_angle, 0 ) + " deg" );
349318
350- buttonA.reset_state ();
351319 uint8_t joystick_y = 0 ;
352320 if (angle_between > 150.0 ){
353321 // we are facing towards the gate
@@ -368,17 +336,7 @@ void leave_zone_and_reset_spawns(
368336 }
369337
370338 // Running forward or backward depends on character facing to go back to zone entrance
371- // Since day/night change just happened, we are sure this running sequence won't be interrupted
372- // by day/night change again. So no need to call overworld detector.
373- ret = run_until<ProControllerContext>(
374- env.console , context,
375- [&walk_time_in_zone, &joystick_y](ProControllerContext& context){
376- // running forward
377- ssf_press_button (context, BUTTON_B, 0ms, walk_time_in_zone, 0ms);
378- pbf_move_left_joystick (context, 128 , joystick_y, walk_time_in_zone, 0ms);
379- },
380- {{buttonA}}
381- );
339+ ret = run_towards_wild_zone_gate (env.console , context, button_A_box, 128 , joystick_y, walk_time_in_zone);
382340 if (ret != 0 ){
383341 stats.errors ++;
384342 env.update_stats ();
@@ -415,7 +373,7 @@ void leave_zone_and_reset_spawns(
415373 env.console .overlay ().add_log (" Found Button A. Leaving Zone" );
416374
417375 WallClock start_time = current_time ();
418- leave_zone_gate (env, context);
376+ leave_zone_gate (env. console , context);
419377 WallClock end_time = current_time ();
420378 shiny_sound_handler.process_pending (context);
421379
@@ -460,7 +418,7 @@ void leave_zone_and_reset_spawns(
460418 map_to_overworld (env.console , context);
461419 // Mash A to leave zone gate
462420 env.log (" Mashing A again to leave zone" );
463- leave_zone_gate (env, context);
421+ leave_zone_gate (env. console , context);
464422 // Do a fast travel outside the gate to reset spawns
465423 env.log (" Finally, we should have left the zone" );
466424 fast_travel_outside_zone (env, context, wild_zone, to_max_zoom_level_on_map, std::move (extra_eror_msg));
0 commit comments