Skip to content

Commit 86a1461

Browse files
author
Gin
committed
fix wild zone 1 entranc3
1 parent e37cdce commit 86a1461

File tree

4 files changed

+41
-24
lines changed

4 files changed

+41
-24
lines changed

SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_BasicNavigation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,10 @@ bool leave_zone_gate(ConsoleHandle& console, ProControllerContext& context){
464464

465465
int run_towards_wild_zone_gate(
466466
ConsoleHandle& console, ProControllerContext& context,
467-
const ImageFloatBox& button_A_box,
468467
uint8_t run_direction_x, uint8_t run_direction_y,
469468
PokemonAutomation::Milliseconds run_time
470469
){
470+
const ImageFloatBox button_A_box{0.3, 0.2, 0.4, 0.7};
471471
ButtonWatcher buttonA(COLOR_RED, ButtonType::ButtonA, button_A_box, &console.overlay());
472472
OverworldPartySelectionOverWatcher overworld_gone(COLOR_WHITE, &console.overlay(), std::chrono::milliseconds(400));
473473
const int ret = run_until<ProControllerContext>(

SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_BasicNavigation.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ bool leave_zone_gate(ConsoleHandle& console, ProControllerContext& context);
117117
// or get stuck by terrain or obstacle on the way
118118
int run_towards_wild_zone_gate(
119119
ConsoleHandle& console, ProControllerContext& context,
120-
const ImageFloatBox& button_A_box,
121120
uint8_t run_direction_x, uint8_t run_direction_y,
122121
Milliseconds run_time
123122
);

SerialPrograms/Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_WildZoneCafe.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ void do_one_cafe_trip(
178178
break;
179179
}
180180

181-
const ImageFloatBox button_A_box{0.3, 0.2, 0.4, 0.7};
182-
int ret = run_towards_wild_zone_gate(env.console, context, button_A_box, move_x, move_y, Seconds(10));
181+
int ret = run_towards_wild_zone_gate(env.console, context, move_x, move_y, Seconds(10));
183182
switch (ret){
184183
case 0: // Found button A. Reached the gate.
185184
break;
@@ -197,7 +196,7 @@ void do_one_cafe_trip(
197196
env.console.overlay().add_log("Running Forward");
198197
}
199198
// Running forward or backward depends on character facing to go back to zone entrance
200-
ret = run_towards_wild_zone_gate(env.console, context, button_A_box, move_x, move_y, Seconds(10));
199+
ret = run_towards_wild_zone_gate(env.console, context, move_x, move_y, Seconds(10));
201200
if (ret != 0){
202201
stats.errors++;
203202
env.update_stats();

SerialPrograms/Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_WildZoneEntrance.cpp

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "CommonFramework/ProgramStats/StatsTracking.h"
1212
#include "CommonFramework/Notifications/ProgramNotifications.h"
1313
#include "CommonFramework/Globals.h"
14-
// #include "CommonFramework/Tools/DebugDumper.h"
1514
#include "CommonFramework/VideoPipeline/VideoFeed.h"
1615
#include "CommonTools/Async/InferenceRoutines.h"
1716
#include "CommonTools/StartupChecks/VideoResolutionCheck.h"
@@ -168,21 +167,42 @@ void ShinyHunt_WildZoneEntrance::on_config_value_changed(void* object){
168167
// This function is robust against day/night changes.
169168
void go_to_entrance(
170169
SingleSwitchProgramEnvironment& env,
171-
ProControllerContext& context
170+
ProControllerContext& context,
171+
WildZone wildzone
172172
){
173-
ButtonWatcher buttonA(COLOR_RED, ButtonType::ButtonA, {0.3, 0.2, 0.4, 0.7}, &env.console.overlay());
174-
run_until<ProControllerContext>(
175-
env.console, context,
176-
[](ProControllerContext& context){
177-
for (int c = 0; c < 30; c++){
178-
ssf_press_button(context, BUTTON_B, 0ms, 2s, 0ms);
179-
pbf_move_left_joystick(context, 128, 0, 2s, 200ms);
180-
}
181-
},
182-
{{buttonA}}
183-
);
184-
env.log("Detected button A. At Wild Zone gate.");
185-
env.console.overlay().add_log("Detect Entrance");
173+
double starting_direction = 0;
174+
uint8_t joystick_x = 128;
175+
if (wildzone == WildZone::WILD_ZONE_1){
176+
// The fast travel point of Wild Zone 1 does not face the zone entrance directly. We need
177+
// to turn a little bit to the right
178+
starting_direction = get_facing_direction(env.console, context);
179+
joystick_x = 145;
180+
}
181+
int ret = run_towards_wild_zone_gate(env.console, context, joystick_x, 0, 10s);
182+
switch(ret){
183+
case 0: // detected button A. Reached gate
184+
break;
185+
case 1: // day/night change happened.
186+
if (wildzone == WildZone::WILD_ZONE_1 &&
187+
get_angle_between_facing_directions(starting_direction, get_facing_direction(env.console, context)) > 2.5){
188+
joystick_x = 128; // we've already turned. Just need to go forward to enter the zone
189+
}
190+
ret = run_towards_wild_zone_gate(env.console, context, joystick_x, 0, 10s);
191+
if (ret != 0){
192+
OperationFailedException::fire(
193+
ErrorReport::SEND_ERROR_REPORT,
194+
"go_to_entrance(): Cannot reach gate from outside after day/night change.",
195+
env.console
196+
);
197+
}
198+
break;
199+
default:
200+
OperationFailedException::fire(
201+
ErrorReport::SEND_ERROR_REPORT,
202+
"go_to_entrance(): Cannot reach gate from outside.",
203+
env.console
204+
);
205+
}
186206
}
187207

188208

@@ -300,8 +320,7 @@ void leave_zone_and_reset_spawns(
300320

301321
const double starting_direction = get_facing_direction(env.console, context);
302322

303-
const ImageFloatBox button_A_box{0.3, 0.2, 0.4, 0.7};
304-
int ret = run_towards_wild_zone_gate(env.console, context, button_A_box, 128, 255, walk_time_in_zone);
323+
int ret = run_towards_wild_zone_gate(env.console, context, 128, 255, walk_time_in_zone);
305324
switch (ret){
306325
case 0: // Found button A. Reached the gate.
307326
break;
@@ -332,7 +351,7 @@ void leave_zone_and_reset_spawns(
332351
}
333352

334353
// Running forward or backward depends on character facing to go back to zone entrance
335-
ret = run_towards_wild_zone_gate(env.console, context, button_A_box, 128, joystick_y, walk_time_in_zone);
354+
ret = run_towards_wild_zone_gate(env.console, context, 128, joystick_y, walk_time_in_zone);
336355
if (ret != 0){
337356
stats.errors++;
338357
env.update_stats();
@@ -428,7 +447,7 @@ void do_one_wild_zone_trip(
428447
shiny_sound_handler.process_pending(context);
429448

430449
if (movement_mode >= 1){
431-
go_to_entrance(env, context);
450+
go_to_entrance(env, context, wild_zone);
432451
context.wait_for_all_requests();
433452
shiny_sound_handler.process_pending(context);
434453
}

0 commit comments

Comments
 (0)