Skip to content

Commit d513dbc

Browse files
committed
Autostory: add pre-check to confrim minimap is unlocked.
1 parent 76ce307 commit d513dbc

4 files changed

Lines changed: 31 additions & 0 deletions

File tree

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,12 @@ AutoStory::AutoStory()
525525
LockMode::UNLOCK_WHILE_RUNNING,
526526
true
527527
)
528+
, ENSURE_MINIMAP_UNLOCKED(
529+
"<b>Pre-check: Ensure the minimap is unlocked:</b><br>"
530+
"This is to ensure the minimap is unlocked. We use it to detect our direction.",
531+
LockMode::UNLOCK_WHILE_RUNNING,
532+
true
533+
)
528534
, GO_HOME_WHEN_DONE(true)
529535
, NOTIFICATION_STATUS_UPDATE("Status Update", true, false, std::chrono::seconds(30))
530536
, NOTIFICATIONS({
@@ -764,6 +770,7 @@ AutoStory::AutoStory()
764770
PA_ADD_OPTION(CHANGE_SETTINGS);
765771
PA_ADD_OPTION(ENSURE_TIME_UNSYNCED);
766772
PA_ADD_OPTION(ENSURE_CORRECT_MOVES);
773+
PA_ADD_OPTION(ENSURE_MINIMAP_UNLOCKED);
767774

768775
PA_ADD_OPTION(NOTIFICATIONS);
769776

@@ -1316,6 +1323,11 @@ void AutoStory::program(SingleSwitchProgramEnvironment& env, ProControllerContex
13161323
confirm_lead_pokemon_moves(env, context, LANGUAGE);
13171324
}
13181325

1326+
if (ENSURE_MINIMAP_UNLOCKED && STORY_SECTION == StorySection::MAIN_STORY){
1327+
env.console.log("Ensure the minimap is unlocked.");
1328+
confirm_minimap_unlocked(env, context);
1329+
}
1330+
13191331
run_autostory(env, context);
13201332

13211333
send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH);

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class AutoStory : public SingleSwitchProgramInstance, public ConfigOption::Liste
104104
BooleanCheckBoxOption CHANGE_SETTINGS;
105105
BooleanCheckBoxOption ENSURE_TIME_UNSYNCED;
106106
BooleanCheckBoxOption ENSURE_CORRECT_MOVES;
107+
BooleanCheckBoxOption ENSURE_MINIMAP_UNLOCKED;
107108

108109
GoHomeWhenDoneOption GO_HOME_WHEN_DONE;
109110

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,22 @@ void confirm_lead_pokemon_moves(SingleSwitchProgramEnvironment& env, ProControll
551551

552552
}
553553

554+
void confirm_minimap_unlocked(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
555+
DirectionDetector direction;
556+
try{
557+
direction.change_direction(env.program_info(), env.console, context, 3.02);
558+
pbf_press_button(context, BUTTON_L, 200ms, 200ms);
559+
}catch(OperationFailedException&){
560+
OperationFailedException::fire(
561+
ErrorReport::SEND_ERROR_REPORT,
562+
"confirm_minimap_unlocked(): Unable to confirm that the minimap is unlocked. Likely because the direction cannot be detected. "
563+
"If you manually confirm that the minimap is unlocked, you can disable this precheck in the program setting \"Pre-check: Ensure the minimap is unlocked\".",
564+
env.console
565+
);
566+
}
567+
568+
}
569+
554570
void change_settings_prior_to_autostory_segment_mode(SingleSwitchProgramEnvironment& env, ProControllerContext& context, size_t current_segment_num, Language language){
555571
// get index of `Options` in the Main Menu, which depends on where you are in Autostory
556572
int8_t options_index;

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ void swap_starter_moves(SingleSwitchProgramEnvironment& env, ProControllerContex
185185
// start and end in the overworld
186186
void confirm_lead_pokemon_moves(SingleSwitchProgramEnvironment& env, ProControllerContext& context, Language language);
187187

188+
void confirm_minimap_unlocked(SingleSwitchProgramEnvironment& env, ProControllerContext& context);
189+
188190
// run the given `action`. if detect a battle, stop the action, and throw exception
189191
void do_action_and_monitor_for_battles(
190192
const ProgramInfo& info,

0 commit comments

Comments
 (0)