Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "PokemonSV/Programs/Eggs/PokemonSV_EggRoutines.h"
#include "PokemonSV/Programs/Boxes/PokemonSV_BoxRelease.h"
#include "PokemonSV/Programs/Sandwiches/PokemonSV_SandwichRoutines.h"
#include "PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.h"
#include "PokemonSV_EggAutonomous.h"

namespace PokemonAutomation{
Expand Down Expand Up @@ -736,6 +737,26 @@ void EggAutonomous::save_game(SingleSwitchProgramEnvironment& env, ProController
}
}

void change_settings_egg_program(SingleSwitchProgramEnvironment& env, ProControllerContext& context, Language language){
int8_t options_index = 4;
enter_menu_from_overworld(env.program_info(), env.console, context, options_index, MenuSide::RIGHT);
MenuOption session(env.console, context, language);

std::vector<std::pair<MenuOptionItemEnum, std::vector<MenuOptionToggleEnum>>> options = {
{MenuOptionItemEnum::TEXT_SPEED, {MenuOptionToggleEnum::FAST}},
{MenuOptionItemEnum::SKIP_MOVE_LEARNING, {MenuOptionToggleEnum::ON}},
{MenuOptionItemEnum::GIVE_NICKNAMES, {MenuOptionToggleEnum::OFF}},
{MenuOptionItemEnum::CAMERA_SUPPORT, {MenuOptionToggleEnum::ON}},
{MenuOptionItemEnum::AUTOSAVE, {MenuOptionToggleEnum::OFF}},

};
session.set_options(options);

pbf_mash_button(context, BUTTON_A, 1 * TICKS_PER_SECOND);
clear_dialog(env.console, context, ClearDialogMode::STOP_TIMEOUT, 5, {CallbackEnum::PROMPT_DIALOG});
press_Bs_to_back_to_overworld(env.program_info(), env.console, context);
}


bool EggAutonomous::handle_recoverable_error(
SingleSwitchProgramEnvironment& env, ProControllerContext& context,
Expand Down Expand Up @@ -767,19 +788,23 @@ bool EggAutonomous::handle_recoverable_error(
env.log("Don't reset game to protect it.", COLOR_RED);
return true;
}

std::string fail_message = e.message();
consecutive_failures++;
if (consecutive_failures >= 3){
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"Failed 3 times in the row.",
"Failed 3 times in the row.\n" + fail_message,
env.console
);
}

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

if (e.message().find("collect_eggs_from_basket") != std::string::npos){
change_settings_egg_program(env, context, LANGUAGE);
}

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class EggAutonomous : public SingleSwitchProgramInstance{
bool m_in_critical_to_save_stage = false;
};


void change_settings_egg_program(SingleSwitchProgramEnvironment& env, ProControllerContext& context, Language language);


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,27 +351,65 @@ void collect_eggs_after_sandwich(
// Recall your ride to reduce obstacles.
pbf_press_button(context, BUTTON_PLUS, 20, 105);

#if 0
// this sequence will purposefully fail if Camera support is off.
// If we fail to reach the egg basket, we can then check that Camera support is on.

// Move forward to table
pbf_move_left_joystick(context, 128, 0, 80, 40);
// Move left
pbf_move_left_joystick(context, 0, 128, 40, 40);
// Move forward to pass table
pbf_move_left_joystick(context, 128, 0, 80, 40);
// Move right
pbf_move_left_joystick(context, 255, 128, 40, 85);
// Move back/right to align to basket
pbf_move_left_joystick(context, 240, 255, 40, 40);

// Move closer to the basket, up to the table
pbf_press_button(context, BUTTON_L, 20, 105);
pbf_move_left_joystick(context, 128, 0, 100, 40);

// face away from the table
pbf_press_button(context, BUTTON_L, 20, 105);
pbf_move_left_joystick(context, 128, 255, 10, 40);
#endif

#if 1
// this sequence will work with both Camera Support being Off and On

// Move forward to table
pbf_move_left_joystick(context, 128, 0, 320ms, 480ms);

// Move left
pbf_move_left_joystick(context, 0, 128, 80ms, 480ms);
pbf_press_button(context, BUTTON_L, 120ms, 120ms);
pbf_press_button(context, BUTTON_L, 120ms, 480ms);
pbf_move_left_joystick(context, 128, 0, 320ms, 480ms);

// Move forward to pass table
pbf_move_left_joystick(context, 255, 128, 80ms, 480ms);
pbf_press_button(context, BUTTON_L, 120ms, 120ms);
pbf_move_left_joystick(context, 128, 0, 640ms, 320ms);
pbf_press_button(context, BUTTON_L, 120ms, 480ms);
pbf_move_left_joystick(context, 128, 0, 640ms, 480ms);

// Move right
pbf_move_left_joystick(context, 255, 128, 80ms, 480ms);
pbf_press_button(context, BUTTON_L, 120ms, 120ms);
pbf_move_left_joystick(context, 128, 0, 320ms, 320ms);
pbf_press_button(context, BUTTON_L, 120ms, 480ms);
pbf_move_left_joystick(context, 128, 0, 320ms, 480ms);

// Move back to face basket
pbf_move_left_joystick(context, 255, 128, 80ms, 320ms);
pbf_press_button(context, BUTTON_L, 120ms, 120ms);
pbf_move_left_joystick(context, 128, 0, 160ms, 320ms);
#else
// Turn right to face basket
pbf_move_left_joystick(context, 255, 128, 80ms, 480ms);
pbf_press_button(context, BUTTON_L, 120ms, 480ms);

// Move closer to the basket, up to the table
pbf_move_left_joystick(context, 128, 0, 800ms, 480ms);

// back away from the table, then face forwards towards the basket again
pbf_move_left_joystick(context, 128, 255, 200ms, 480ms);
pbf_move_left_joystick(context, 128, 0, 80ms, 480ms);
pbf_press_button(context, BUTTON_L, 120ms, 480ms);
#endif

#if 0
// Move left
pbf_move_left_joystick(context, 0, 128, 40, 40);
// Move forward to pass table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,8 @@ void run_sandwich_maker(
stream.log("Read nothing on center plate label.");
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"No ingredient found on center plate label.",
"run_sandwich_maker: No ingredient found on center plate label.\n"
"Please make sure that you have set the correct Game Language in the program settings.",
stream,
std::move(screen)
);
Expand Down