Skip to content

Commit 24ff362

Browse files
authored
Merge pull request #633 from jw098/autostory
Autostory fixes
2 parents d6dac64 + b2fbe76 commit 24ff362

27 files changed

+89
-53
lines changed

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

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ AutoStory::AutoStory()
187187
, STARTPOINT_TUTORIAL(
188188
"<b>Start Point:</b><br>Program will start with this segment.",
189189
TUTORIAL_SEGMENTS_SELECT_DATABASE(),
190-
LockMode::UNLOCK_WHILE_RUNNING,
190+
LockMode::LOCK_WHILE_RUNNING,
191191
"0"
192192
)
193193
, ENDPOINT_TUTORIAL(
@@ -679,26 +679,39 @@ std::string AutoStory::end_segment_description(){
679679
return ALL_AUTO_STORY_SEGMENT_LIST()[segment_index]->end_text();
680680
}
681681

682+
size_t AutoStory::get_start_segment_index(){
683+
size_t start = 0;
682684

683-
void AutoStory::run_autostory(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
684-
AutoStoryOptions options{
685-
LANGUAGE,
686-
STARTERCHOICE,
687-
NOTIFICATION_STATUS_UPDATE
688-
};
685+
if (STORY_SECTION == StorySection::TUTORIAL){
686+
start = STARTPOINT_TUTORIAL.index();
687+
}else if (STORY_SECTION == StorySection::MAIN_STORY){
688+
start = (INDEX_OF_LAST_TUTORIAL_SEGMENT + 1) + STARTPOINT_MAINSTORY.index();
689+
}
690+
691+
return start;
692+
}
689693

690-
size_t start = STARTPOINT_TUTORIAL.index();
691-
size_t end = ENDPOINT_TUTORIAL.index();
694+
size_t AutoStory::get_end_segment_index(){
695+
size_t end = 0;
692696

693697
if (STORY_SECTION == StorySection::TUTORIAL){
694-
start = STARTPOINT_TUTORIAL.index();
695698
end = ENDPOINT_TUTORIAL.index();
696699
}else if (STORY_SECTION == StorySection::MAIN_STORY){
697-
start = (INDEX_OF_LAST_TUTORIAL_SEGMENT + 1) + STARTPOINT_MAINSTORY.index();
698700
end = (INDEX_OF_LAST_TUTORIAL_SEGMENT + 1) + ENDPOINT_MAINSTORY.index();
699701
}
702+
703+
return end;
704+
}
705+
706+
707+
void AutoStory::run_autostory(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
708+
AutoStoryOptions options{
709+
LANGUAGE,
710+
STARTERCHOICE,
711+
NOTIFICATION_STATUS_UPDATE
712+
};
700713

701-
for (size_t segment_index = start; segment_index <= end; segment_index++){
714+
for (size_t segment_index = get_start_segment_index(); segment_index <= get_end_segment_index(); segment_index++){
702715
ALL_AUTO_STORY_SEGMENT_LIST()[segment_index]->run_segment(env, context, options);
703716
}
704717
}
@@ -777,7 +790,7 @@ void AutoStory::program(SingleSwitchProgramEnvironment& env, ProControllerContex
777790

778791
// Set settings. to ensure autosave is off.
779792
if (CHANGE_SETTINGS){
780-
change_settings_prior_to_autostory(env, context, STARTPOINT_TUTORIAL.index(), LANGUAGE);
793+
change_settings_prior_to_autostory(env, context, get_start_segment_index(), LANGUAGE);
781794
}
782795

783796
run_autostory(env, context);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ class AutoStory : public SingleSwitchProgramInstance, public ConfigOption::Liste
5050
int loop, int start_loop, int end_loop
5151
);
5252

53+
size_t get_start_segment_index();
54+
size_t get_end_segment_index();
55+
5356
void run_autostory(SingleSwitchProgramEnvironment& env, ProControllerContext& context);
5457

5558
private:

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

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -583,29 +583,65 @@ void change_settings_prior_to_autostory(
583583
size_t current_segment_num,
584584
Language language
585585
){
586-
if (current_segment_num == 0){ // can't change settings in the intro cutscene
587-
return;
588-
}
589586

590587
// get index of `Options` in the Main Menu, which depends on where you are in Autostory
591588
int8_t options_index;
592589
switch(current_segment_num){
593590
case 0:
591+
return; // can't change settings in the intro cutscene
592+
case 1:
593+
// after Intro cutscene done, in room
594+
// Menu
595+
// - Options
596+
// - Save
594597
options_index = 0;
595598
break;
596-
case 1:
599+
case 2:
600+
// Menu
601+
// - Bag --> unlocked after picked up bag/hat in room. Segment 01, checkpoint 02
602+
// - Options
603+
// - Save
597604
options_index = 1;
598605
break;
606+
case 3:
607+
case 4:
608+
case 5:
609+
case 6:
610+
// Menu
611+
// - Bag
612+
// - Boxes --> unlocked after battling Nemona and receiving Pokedex app. Segment 02, checkpoint 04
613+
// - Options
614+
// - Save
615+
options_index = 2;
616+
break;
617+
case 7:
618+
case 8:
619+
case 9:
620+
// Menu
621+
// - Bag
622+
// - Boxes
623+
// - Poke Portal --> unlocked after arriving at Los Platos and talking to Nemona. Segment 06, checkpoint 11
624+
// - Options
625+
// - Save
626+
options_index = 3;
627+
break;
599628
default:
600-
options_index = 2;
629+
// Menu
630+
// - Bag
631+
// - Boxes
632+
// - Picnic --> unlocked after finishing tutorial. Segment 09, checkpoint 20
633+
// - Poke Portal
634+
// - Options
635+
// - Save
636+
options_index = 4;
601637
break;
602638
}
603639

604-
bool has_minimap = current_segment_num > 1; // the minimap only shows up in segment 2 and beyond
640+
bool has_minimap = current_segment_num >= 2; // the minimap only shows up in segment 2 and beyond
605641

606642
enter_menu_from_overworld(env.program_info(), env.console, context, options_index, MenuSide::RIGHT, has_minimap);
607643
change_settings(env, context, language);
608-
if(has_minimap){
644+
if(!has_minimap){
609645
pbf_mash_button(context, BUTTON_B, 2 * TICKS_PER_SECOND);
610646
}else{
611647
press_Bs_to_back_to_overworld(env.program_info(), env.console, context);

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,11 @@ void AutoStory_Segment_00::run_segment(
4343

4444
context.wait_for_all_requests();
4545
env.console.log("Start Segment 00: Intro Cutscene", COLOR_ORANGE);
46-
env.console.overlay().add_log("Start Segment 00: Intro Cutscene", COLOR_ORANGE);
4746

4847
checkpoint_00(env, context);
4948

5049
context.wait_for_all_requests();
5150
env.console.log("End Segment 00: Intro Cutscene", COLOR_GREEN);
52-
env.console.overlay().add_log("End Segment 00: Intro Cutscene", COLOR_GREEN);
5351
stats.m_segment++;
5452
env.update_stats();
5553
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,13 @@ void AutoStory_Segment_01::run_segment(
5555

5656
context.wait_for_all_requests();
5757
env.console.log("Start Segment 01: Pick Starter", COLOR_ORANGE);
58-
env.console.overlay().add_log("Start Segment 01: Pick Starter", COLOR_ORANGE);
5958

6059
checkpoint_01(env, context, options.notif_status_update, options.language);
6160
checkpoint_02(env, context, options.notif_status_update);
6261
checkpoint_03(env, context, options.notif_status_update, options.language, options.starter_choice);
6362

6463
context.wait_for_all_requests();
65-
env.console.log("End Segment 02: Pick Starter", COLOR_GREEN);
66-
env.console.overlay().add_log("End Segment 02: Pick Starter", COLOR_GREEN);
64+
env.console.log("End Segment 01: Pick Starter", COLOR_GREEN);
6765
stats.m_segment++;
6866
env.update_stats();
6967

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,11 @@ void AutoStory_Segment_02::run_segment(
5050

5151
context.wait_for_all_requests();
5252
env.console.log("Start Segment 02: First Nemona Battle", COLOR_ORANGE);
53-
env.console.overlay().add_log("Start Segment 02: First Nemona Battle", COLOR_ORANGE);
5453

5554
checkpoint_04(env, context, options.notif_status_update);
5655

5756
context.wait_for_all_requests();
5857
env.console.log("End Segment 02: First Nemona Battle", COLOR_GREEN);
59-
env.console.overlay().add_log("End Segment 02: First Nemona Battle", COLOR_GREEN);
6058
stats.m_segment++;
6159
env.update_stats();
6260

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,13 @@ void AutoStory_Segment_03::run_segment(SingleSwitchProgramEnvironment& env, ProC
4545

4646
context.wait_for_all_requests();
4747
env.console.log("Start Segment 03: Catch Tutorial", COLOR_ORANGE);
48-
env.console.overlay().add_log("Start Segment 03: Catch Tutorial", COLOR_ORANGE);
4948

5049
checkpoint_05(env, context, options.notif_status_update);
5150
checkpoint_06(env, context, options.notif_status_update);
5251
checkpoint_07(env, context, options.notif_status_update);
5352

5453
context.wait_for_all_requests();
5554
env.console.log("End Segment 03: Catch Tutorial", COLOR_GREEN);
56-
env.console.overlay().add_log("End Segment 03: Catch Tutorial", COLOR_GREEN);
5755
stats.m_segment++;
5856
env.update_stats();
5957

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,11 @@ void AutoStory_Segment_04::run_segment(
5151

5252
context.wait_for_all_requests();
5353
env.console.log("Start Segment 04: Rescue Legendary", COLOR_ORANGE);
54-
env.console.overlay().add_log("Start Segment 04: Rescue Legendary", COLOR_ORANGE);
5554

5655
checkpoint_08(env, context, options.notif_status_update);
5756

5857
context.wait_for_all_requests();
5958
env.console.log("End Segment 04: Rescue Legendary", COLOR_GREEN);
60-
env.console.overlay().add_log("End Segment 04: Rescue Legendary", COLOR_GREEN);
6159
stats.m_segment++;
6260
env.update_stats();
6361

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,12 @@ void AutoStory_Segment_05::run_segment(
4949

5050
context.wait_for_all_requests();
5151
env.console.log("Start Segment 05: First Arven Battle", COLOR_ORANGE);
52-
env.console.overlay().add_log("Start Segment 05: First Arven Battle", COLOR_ORANGE);
5352

5453
checkpoint_09(env, context, options.notif_status_update);
5554
checkpoint_10(env, context, options.notif_status_update);
5655

5756
context.wait_for_all_requests();
5857
env.console.log("End Segment 05: First Arven Battle", COLOR_GREEN);
59-
env.console.overlay().add_log("End Segment 05: First Arven Battle", COLOR_GREEN);
6058
stats.m_segment++;
6159
env.update_stats();
6260

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,11 @@ void AutoStory_Segment_06::run_segment(
4848

4949
context.wait_for_all_requests();
5050
env.console.log("Start Segment 06: Go to Los Platos", COLOR_ORANGE);
51-
env.console.overlay().add_log("Start Segment 06: Go to Los Platos", COLOR_ORANGE);
5251

5352
checkpoint_11(env, context, options.notif_status_update);
5453

5554
context.wait_for_all_requests();
5655
env.console.log("End Segment 06: Go to Los Platos", COLOR_GREEN);
57-
env.console.overlay().add_log("End Segment 06: Go to Los Platos", COLOR_GREEN);
5856
stats.m_segment++;
5957
env.update_stats();
6058

0 commit comments

Comments
 (0)