Skip to content

Commit 9f09490

Browse files
authored
Merge pull request #672 from jw098/egg
SV Egg Auto: update path to egg basket. works with both Camera Support On and Off
2 parents 4101a0f + c791b25 commit 9f09490

File tree

4 files changed

+78
-14
lines changed

4 files changed

+78
-14
lines changed

SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.cpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "PokemonSV/Programs/Eggs/PokemonSV_EggRoutines.h"
3030
#include "PokemonSV/Programs/Boxes/PokemonSV_BoxRelease.h"
3131
#include "PokemonSV/Programs/Sandwiches/PokemonSV_SandwichRoutines.h"
32+
#include "PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.h"
3233
#include "PokemonSV_EggAutonomous.h"
3334

3435
namespace PokemonAutomation{
@@ -736,6 +737,26 @@ void EggAutonomous::save_game(SingleSwitchProgramEnvironment& env, ProController
736737
}
737738
}
738739

740+
void change_settings_egg_program(SingleSwitchProgramEnvironment& env, ProControllerContext& context, Language language){
741+
int8_t options_index = 4;
742+
enter_menu_from_overworld(env.program_info(), env.console, context, options_index, MenuSide::RIGHT);
743+
MenuOption session(env.console, context, language);
744+
745+
std::vector<std::pair<MenuOptionItemEnum, std::vector<MenuOptionToggleEnum>>> options = {
746+
{MenuOptionItemEnum::TEXT_SPEED, {MenuOptionToggleEnum::FAST}},
747+
{MenuOptionItemEnum::SKIP_MOVE_LEARNING, {MenuOptionToggleEnum::ON}},
748+
{MenuOptionItemEnum::GIVE_NICKNAMES, {MenuOptionToggleEnum::OFF}},
749+
{MenuOptionItemEnum::CAMERA_SUPPORT, {MenuOptionToggleEnum::ON}},
750+
{MenuOptionItemEnum::AUTOSAVE, {MenuOptionToggleEnum::OFF}},
751+
752+
};
753+
session.set_options(options);
754+
755+
pbf_mash_button(context, BUTTON_A, 1 * TICKS_PER_SECOND);
756+
clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 5, {CallbackEnum::PROMPT_DIALOG});
757+
press_Bs_to_back_to_overworld(env.program_info(), env.console, context);
758+
}
759+
739760

740761
bool EggAutonomous::handle_recoverable_error(
741762
SingleSwitchProgramEnvironment& env, ProControllerContext& context,
@@ -767,19 +788,23 @@ bool EggAutonomous::handle_recoverable_error(
767788
env.log("Don't reset game to protect it.", COLOR_RED);
768789
return true;
769790
}
770-
791+
std::string fail_message = e.message();
771792
consecutive_failures++;
772793
if (consecutive_failures >= 3){
773794
OperationFailedException::fire(
774795
ErrorReport::SEND_ERROR_REPORT,
775-
"Failed 3 times in the row.",
796+
"Failed 3 times in the row.\n" + fail_message,
776797
env.console
777798
);
778799
}
779800

780801
env.log("Reset game to handle recoverable error");
781802
reset_game(env.program_info(), env.console, context);
782803

804+
if (e.message().find("collect_eggs_from_basket") != std::string::npos){
805+
change_settings_egg_program(env, context, LANGUAGE);
806+
}
807+
783808
return false;
784809
}
785810

SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class EggAutonomous : public SingleSwitchProgramInstance{
126126
bool m_in_critical_to_save_stage = false;
127127
};
128128

129-
129+
void change_settings_egg_program(SingleSwitchProgramEnvironment& env, ProControllerContext& context, Language language);
130130

131131

132132
}

SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggRoutines.cpp

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -351,27 +351,65 @@ void collect_eggs_after_sandwich(
351351
// Recall your ride to reduce obstacles.
352352
pbf_press_button(context, BUTTON_PLUS, 20, 105);
353353

354+
#if 0
355+
// this sequence will purposefully fail if Camera support is off.
356+
// If we fail to reach the egg basket, we can then check that Camera support is on.
357+
358+
// Move forward to table
359+
pbf_move_left_joystick(context, 128, 0, 80, 40);
360+
// Move left
361+
pbf_move_left_joystick(context, 0, 128, 40, 40);
362+
// Move forward to pass table
363+
pbf_move_left_joystick(context, 128, 0, 80, 40);
364+
// Move right
365+
pbf_move_left_joystick(context, 255, 128, 40, 85);
366+
// Move back/right to align to basket
367+
pbf_move_left_joystick(context, 240, 255, 40, 40);
368+
369+
// Move closer to the basket, up to the table
370+
pbf_press_button(context, BUTTON_L, 20, 105);
371+
pbf_move_left_joystick(context, 128, 0, 100, 40);
372+
373+
// face away from the table
374+
pbf_press_button(context, BUTTON_L, 20, 105);
375+
pbf_move_left_joystick(context, 128, 255, 10, 40);
376+
#endif
377+
354378
#if 1
379+
// this sequence will work with both Camera Support being Off and On
380+
381+
// Move forward to table
382+
pbf_move_left_joystick(context, 128, 0, 320ms, 480ms);
383+
355384
// Move left
356385
pbf_move_left_joystick(context, 0, 128, 80ms, 480ms);
357-
pbf_press_button(context, BUTTON_L, 120ms, 120ms);
386+
pbf_press_button(context, BUTTON_L, 120ms, 480ms);
358387
pbf_move_left_joystick(context, 128, 0, 320ms, 480ms);
359388

360389
// Move forward to pass table
361390
pbf_move_left_joystick(context, 255, 128, 80ms, 480ms);
362-
pbf_press_button(context, BUTTON_L, 120ms, 120ms);
363-
pbf_move_left_joystick(context, 128, 0, 640ms, 320ms);
391+
pbf_press_button(context, BUTTON_L, 120ms, 480ms);
392+
pbf_move_left_joystick(context, 128, 0, 640ms, 480ms);
364393

365394
// Move right
366395
pbf_move_left_joystick(context, 255, 128, 80ms, 480ms);
367-
pbf_press_button(context, BUTTON_L, 120ms, 120ms);
368-
pbf_move_left_joystick(context, 128, 0, 320ms, 320ms);
396+
pbf_press_button(context, BUTTON_L, 120ms, 480ms);
397+
pbf_move_left_joystick(context, 128, 0, 320ms, 480ms);
369398

370-
// Move back to face basket
371-
pbf_move_left_joystick(context, 255, 128, 80ms, 320ms);
372-
pbf_press_button(context, BUTTON_L, 120ms, 120ms);
373-
pbf_move_left_joystick(context, 128, 0, 160ms, 320ms);
374-
#else
399+
// Turn right to face basket
400+
pbf_move_left_joystick(context, 255, 128, 80ms, 480ms);
401+
pbf_press_button(context, BUTTON_L, 120ms, 480ms);
402+
403+
// Move closer to the basket, up to the table
404+
pbf_move_left_joystick(context, 128, 0, 800ms, 480ms);
405+
406+
// back away from the table, then face forwards towards the basket again
407+
pbf_move_left_joystick(context, 128, 255, 200ms, 480ms);
408+
pbf_move_left_joystick(context, 128, 0, 80ms, 480ms);
409+
pbf_press_button(context, BUTTON_L, 120ms, 480ms);
410+
#endif
411+
412+
#if 0
375413
// Move left
376414
pbf_move_left_joystick(context, 0, 128, 40, 40);
377415
// Move forward to pass table

SerialPrograms/Source/PokemonSV/Programs/Sandwiches/PokemonSV_SandwichRoutines.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,8 @@ void run_sandwich_maker(
11051105
stream.log("Read nothing on center plate label.");
11061106
OperationFailedException::fire(
11071107
ErrorReport::SEND_ERROR_REPORT,
1108-
"No ingredient found on center plate label.",
1108+
"run_sandwich_maker: No ingredient found on center plate label.\n"
1109+
"Please make sure that you have set the correct Game Language in the program settings.",
11091110
stream,
11101111
std::move(screen)
11111112
);

0 commit comments

Comments
 (0)