|
11 | 11 | #include "CommonFramework/ProgramStats/StatsTracking.h" |
12 | 12 | #include "CommonFramework/Notifications/ProgramNotifications.h" |
13 | 13 | #include "CommonFramework/Globals.h" |
14 | | -// #include "CommonFramework/Tools/DebugDumper.h" |
15 | 14 | #include "CommonFramework/VideoPipeline/VideoFeed.h" |
16 | 15 | #include "CommonTools/Async/InferenceRoutines.h" |
17 | 16 | #include "CommonTools/StartupChecks/VideoResolutionCheck.h" |
@@ -168,21 +167,42 @@ void ShinyHunt_WildZoneEntrance::on_config_value_changed(void* object){ |
168 | 167 | // This function is robust against day/night changes. |
169 | 168 | void go_to_entrance( |
170 | 169 | SingleSwitchProgramEnvironment& env, |
171 | | - ProControllerContext& context |
| 170 | + ProControllerContext& context, |
| 171 | + WildZone wildzone |
172 | 172 | ){ |
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 | + } |
186 | 206 | } |
187 | 207 |
|
188 | 208 |
|
@@ -300,8 +320,7 @@ void leave_zone_and_reset_spawns( |
300 | 320 |
|
301 | 321 | const double starting_direction = get_facing_direction(env.console, context); |
302 | 322 |
|
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); |
305 | 324 | switch (ret){ |
306 | 325 | case 0: // Found button A. Reached the gate. |
307 | 326 | break; |
@@ -332,7 +351,7 @@ void leave_zone_and_reset_spawns( |
332 | 351 | } |
333 | 352 |
|
334 | 353 | // 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); |
336 | 355 | if (ret != 0){ |
337 | 356 | stats.errors++; |
338 | 357 | env.update_stats(); |
@@ -428,7 +447,7 @@ void do_one_wild_zone_trip( |
428 | 447 | shiny_sound_handler.process_pending(context); |
429 | 448 |
|
430 | 449 | if (movement_mode >= 1){ |
431 | | - go_to_entrance(env, context); |
| 450 | + go_to_entrance(env, context, wild_zone); |
432 | 451 | context.wait_for_all_requests(); |
433 | 452 | shiny_sound_handler.process_pending(context); |
434 | 453 | } |
|
0 commit comments