Skip to content

Commit 98543ca

Browse files
authored
Autostory: Advanced mode. Finer control over start/end points. (#738)
* Autostory refactor. create Checkpoint classes. Create Checkpoints database. * add checkpoint class, until checkpoint 20 * add checkpoint selection to UI * add rest of checkpoints * more UI adjustments * run_autostory with checkpoints instead of segments, when in advanced mode
1 parent 2a0b135 commit 98543ca

File tree

74 files changed

+2053
-156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+2053
-156
lines changed

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

Lines changed: 331 additions & 31 deletions
Large diffs are not rendered by default.

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class AutoStory : public SingleSwitchProgramInstance, public ConfigOption::Liste
5252

5353
size_t get_start_segment_index();
5454
size_t get_end_segment_index();
55+
size_t get_start_checkpoint_index();
56+
size_t get_end_checkpoint_index();
5557

5658
void run_autostory(SingleSwitchProgramEnvironment& env, ProControllerContext& context);
5759

@@ -60,6 +62,8 @@ class AutoStory : public SingleSwitchProgramInstance, public ConfigOption::Liste
6062

6163
std::string start_segment_description();
6264
std::string end_segment_description();
65+
std::string start_checkpoint_description();
66+
std::string end_checkpoint_description();
6367

6468
private:
6569
OCR::LanguageOCROption LANGUAGE;
@@ -77,15 +81,26 @@ class AutoStory : public SingleSwitchProgramInstance, public ConfigOption::Liste
7781
StringSelectOption STARTPOINT_MAINSTORY;
7882
StringSelectOption ENDPOINT_MAINSTORY;
7983

84+
StringSelectOption START_CHECKPOINT_TUTORIAL;
85+
StringSelectOption END_CHECKPOINT_TUTORIAL;
86+
87+
StringSelectOption START_CHECKPOINT_MAINSTORY;
88+
StringSelectOption END_CHECKPOINT_MAINSTORY;
89+
8090
StaticTextOption SETUP_NOTE;
8191
StaticTextOption MAINSTORY_NOTE;
8292

8393
StaticTextOption START_DESCRIPTION;
8494
StaticTextOption END_DESCRIPTION;
8595

96+
StaticTextOption START_CHECKPOINT_DESCRIPTION;
97+
StaticTextOption END_CHECKPOINT_DESCRIPTION;
98+
8699

87100
EnumDropdownOption<StarterChoice> STARTERCHOICE;
88101

102+
BooleanCheckBoxOption ENABLE_ADVANCED_MODE;
103+
89104
GoHomeWhenDoneOption GO_HOME_WHEN_DONE;
90105

91106
EventNotificationOption NOTIFICATION_STATUS_UPDATE;

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

Lines changed: 92 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -486,13 +486,7 @@ void swap_starter_moves(SingleSwitchProgramEnvironment& env, ProControllerContex
486486

487487
}
488488

489-
490-
void change_settings_prior_to_autostory(
491-
SingleSwitchProgramEnvironment& env, ProControllerContext& context,
492-
size_t current_segment_num,
493-
Language language
494-
){
495-
489+
void change_settings_prior_to_autostory_segment_mode(SingleSwitchProgramEnvironment& env, ProControllerContext& context, size_t current_segment_num, Language language){
496490
// get index of `Options` in the Main Menu, which depends on where you are in Autostory
497491
int8_t options_index;
498492
std::string assumption_text = "";
@@ -555,6 +549,97 @@ void change_settings_prior_to_autostory(
555549
env.console.log("change_settings_prior_to_autostory: " + assumption_text + " The index of \"Options\" in the Menu is " + std::to_string(options_index) + ".");
556550

557551
bool has_minimap = current_segment_num >= 2; // the minimap only shows up in segment 2 and beyond
552+
change_settings_prior_to_autostory(env, context, options_index, has_minimap, language);
553+
}
554+
555+
void change_settings_prior_to_autostory_checkpoint_mode(SingleSwitchProgramEnvironment& env, ProControllerContext& context, size_t current_checkpoint_num, Language language){
556+
// get index of `Options` in the Main Menu, which depends on where you are in Autostory
557+
int8_t options_index;
558+
std::string assumption_text = "";
559+
switch(current_checkpoint_num){
560+
case 0:
561+
return; // can't change settings in the intro cutscene
562+
case 1:
563+
case 2:
564+
// after Intro cutscene done, in room
565+
// Menu
566+
// - Options
567+
// - Save
568+
options_index = 0;
569+
assumption_text = "We assume 'Bag' is not yet unlocked.";
570+
break;
571+
case 3:
572+
case 4:
573+
// Menu
574+
// - Bag --> unlocked after picked up bag/hat in room. Segment 01, checkpoint 02
575+
// - Options
576+
// - Save
577+
options_index = 1;
578+
assumption_text = "We assume 'Boxes' is not yet unlocked.";
579+
break;
580+
case 5:
581+
case 6:
582+
case 7:
583+
case 8:
584+
case 9:
585+
case 10:
586+
case 11:
587+
// Menu
588+
// - Bag
589+
// - Boxes --> unlocked after battling Nemona and receiving Pokedex app. Segment 02, checkpoint 04
590+
// - Options
591+
// - Save
592+
options_index = 2;
593+
assumption_text = "We assume 'Poke Portal' is not yet unlocked.";
594+
break;
595+
case 12:
596+
case 13:
597+
case 14:
598+
case 15:
599+
case 16:
600+
case 17:
601+
case 18:
602+
case 19:
603+
case 20:
604+
// Menu
605+
// - Bag
606+
// - Boxes
607+
// - Poke Portal --> unlocked after arriving at Los Platos and talking to Nemona. Segment 06, checkpoint 11
608+
// - Options
609+
// - Save
610+
options_index = 3;
611+
assumption_text = "We assume 'Picnic' is not yet unlocked.";
612+
break;
613+
default:
614+
if(current_checkpoint_num <= 20){
615+
throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "change_settings_prior_to_autostory_checkpoint_mode: current_checkpoint_num should be greater than 20.");
616+
}
617+
618+
// Menu
619+
// - Bag
620+
// - Boxes
621+
// - Picnic --> unlocked after finishing tutorial. Segment 09, checkpoint 20
622+
// - Poke Portal
623+
// - Options
624+
// - Save
625+
options_index = 4;
626+
assumption_text = "We assume that the tutorial is done, and all menu items are unlocked.";
627+
break;
628+
}
629+
630+
env.console.log("change_settings_prior_to_autostory: " + assumption_text + " The index of \"Options\" in the Menu is " + std::to_string(options_index) + ".");
631+
632+
bool has_minimap = current_checkpoint_num >= 3; // the minimap only shows up in checkpoint 3 and beyond
633+
change_settings_prior_to_autostory(env, context, options_index, has_minimap, language);
634+
}
635+
636+
637+
void change_settings_prior_to_autostory(
638+
SingleSwitchProgramEnvironment& env, ProControllerContext& context,
639+
int options_index,
640+
bool has_minimap,
641+
Language language
642+
){
558643

559644
enter_menu_from_overworld(env.program_info(), env.console, context, options_index, MenuSide::RIGHT, has_minimap);
560645
change_settings(env, context, language);

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,19 @@ class AutoStory_Segment {
9595
AutoStoryStats& stats) const = 0;
9696
};
9797

98+
class AutoStory_Checkpoint {
99+
public:
100+
virtual ~AutoStory_Checkpoint() = default;
101+
virtual std::string name() const = 0;
102+
virtual std::string start_text() const = 0;
103+
virtual std::string end_text() const = 0;
104+
virtual void run_checkpoint(
105+
SingleSwitchProgramEnvironment& env,
106+
ProControllerContext& context,
107+
AutoStoryOptions options,
108+
AutoStoryStats& stats) const = 0;
109+
};
110+
98111

99112
// press A to clear tutorial screens
100113
// throw exception if tutorial screen never detected
@@ -262,12 +275,15 @@ void get_off_ride(const ProgramInfo& info, VideoStream& stream, ProControllerCon
262275

263276
void get_on_or_off_ride(const ProgramInfo& info, VideoStream& stream, ProControllerContext& context, bool get_on);
264277

278+
void change_settings_prior_to_autostory_segment_mode(SingleSwitchProgramEnvironment& env, ProControllerContext& context, size_t current_segment_num, Language language);
279+
void change_settings_prior_to_autostory_checkpoint_mode(SingleSwitchProgramEnvironment& env, ProControllerContext& context, size_t current_checkpoint_num, Language language);
265280

266281
// change the settings prior to Autostory
267282
// Assumes that `current_segment` represents where we currently are in the story.
268283
void change_settings_prior_to_autostory(
269284
SingleSwitchProgramEnvironment& env, ProControllerContext& context,
270-
size_t current_segment_num,
285+
int options_index,
286+
bool has_minimap,
271287
Language language
272288
);
273289

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,20 @@ void AutoStory_Segment_00::run_segment(
4242
) const{
4343

4444
context.wait_for_all_requests();
45-
env.console.log("Start Segment 00: Intro Cutscene", COLOR_ORANGE);
45+
env.console.log("Start Segment " + name(), COLOR_ORANGE);
4646

47-
checkpoint_00(env, context);
47+
AutoStory_Checkpoint_00().run_checkpoint(env, context, options, stats);
4848

4949
context.wait_for_all_requests();
50-
env.console.log("End Segment 00: Intro Cutscene", COLOR_GREEN);
50+
env.console.log("End Segment " + name(), COLOR_GREEN);
5151
}
5252

53+
std::string AutoStory_Checkpoint_00::name() const{ return "000 - " + AutoStory_Segment_00().name(); }
54+
std::string AutoStory_Checkpoint_00::start_text() const{ return "After selecting character name, style and the cutscene has started.";}
55+
std::string AutoStory_Checkpoint_00::end_text() const{ return "Done cutscene. Stood up from chair. Walked to left side of room.";}
56+
void AutoStory_Checkpoint_00::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{
57+
checkpoint_00(env, context);
58+
}
5359

5460
void checkpoint_00(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
5561

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ class AutoStory_Segment_00 : public AutoStory_Segment{
2626
) const override;
2727
};
2828

29+
class AutoStory_Checkpoint_00 : public AutoStory_Checkpoint{
30+
public:
31+
virtual std::string name() const override;
32+
virtual std::string start_text() const override;
33+
virtual std::string end_text() const override;
34+
virtual void run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const override;
35+
};
36+
37+
2938
// start: after selecting character name, style and the cutscene has started
3039
// end: stood up from chair. Walked to left side of room.
3140
void checkpoint_00(SingleSwitchProgramEnvironment& env, ProControllerContext& context);

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

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,36 @@ void AutoStory_Segment_01::run_segment(
5656
stats.m_segment++;
5757
env.update_stats();
5858
context.wait_for_all_requests();
59-
env.console.log("Start Segment 01: Pick Starter", COLOR_ORANGE);
59+
env.console.log("Start Segment " + name(), COLOR_ORANGE);
6060

61+
AutoStory_Checkpoint_01().run_checkpoint(env, context, options, stats);
62+
AutoStory_Checkpoint_02().run_checkpoint(env, context, options, stats);
63+
AutoStory_Checkpoint_03().run_checkpoint(env, context, options, stats);
64+
65+
context.wait_for_all_requests();
66+
env.console.log("End Segment " + name(), COLOR_GREEN);
67+
68+
}
69+
70+
std::string AutoStory_Checkpoint_01::name() const{ return "001 - " + AutoStory_Segment_01().name(); }
71+
std::string AutoStory_Checkpoint_01::start_text() const{ return "Done cutscene. Stood up from chair. Walked to left side of room.";}
72+
std::string AutoStory_Checkpoint_01::end_text() const{ return "Standing in room. Updated settings";}
73+
void AutoStory_Checkpoint_01::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{
6174
checkpoint_01(env, context, options.notif_status_update, stats, options.language);
62-
checkpoint_02(env, context, options.notif_status_update, stats);
63-
checkpoint_03(env, context, options.notif_status_update, stats, options.language, options.starter_choice);
75+
}
6476

65-
context.wait_for_all_requests();
66-
env.console.log("End Segment 01: Pick Starter", COLOR_GREEN);
77+
std::string AutoStory_Checkpoint_02::name() const{ return "002 - " + AutoStory_Segment_01().name(); }
78+
std::string AutoStory_Checkpoint_02::start_text() const{ return AutoStory_Checkpoint_01().end_text();}
79+
std::string AutoStory_Checkpoint_02::end_text() const{ return "Standing in front of the 'power of science' NPC. Cleared map tutorial.";}
80+
void AutoStory_Checkpoint_02::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{
81+
checkpoint_02(env, context, options.notif_status_update, stats);
82+
}
6783

84+
std::string AutoStory_Checkpoint_03::name() const{ return "003 - " + AutoStory_Segment_01().name(); }
85+
std::string AutoStory_Checkpoint_03::start_text() const{ return AutoStory_Checkpoint_02().end_text();}
86+
std::string AutoStory_Checkpoint_03::end_text() const{ return "Received starter Pokemon. Changed move order. Cleared autoheal tutorial.";}
87+
void AutoStory_Checkpoint_03::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{
88+
checkpoint_03(env, context, options.notif_status_update, stats, options.language, options.starter_choice);
6889
}
6990

7091

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,31 @@ class AutoStory_Segment_01 : public AutoStory_Segment{
2626
) const override;
2727
};
2828

29+
class AutoStory_Checkpoint_01 : public AutoStory_Checkpoint{
30+
public:
31+
virtual std::string name() const override;
32+
virtual std::string start_text() const override;
33+
virtual std::string end_text() const override;
34+
virtual void run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const override;
35+
};
36+
37+
class AutoStory_Checkpoint_02 : public AutoStory_Checkpoint{
38+
public:
39+
virtual std::string name() const override;
40+
virtual std::string start_text() const override;
41+
virtual std::string end_text() const override;
42+
virtual void run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const override;
43+
};
44+
45+
46+
class AutoStory_Checkpoint_03 : public AutoStory_Checkpoint{
47+
public:
48+
virtual std::string name() const override;
49+
virtual std::string start_text() const override;
50+
virtual std::string end_text() const override;
51+
virtual void run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const override;
52+
};
53+
2954
// start: stood up from chair. Walked to left side of room.
3055
// end: standing in room. updated settings
3156
void checkpoint_01(

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,21 @@ void AutoStory_Segment_02::run_segment(
5151
stats.m_segment++;
5252
env.update_stats();
5353
context.wait_for_all_requests();
54-
env.console.log("Start Segment 02: First Nemona Battle", COLOR_ORANGE);
54+
env.console.log("Start Segment " + name(), COLOR_ORANGE);
5555

56-
checkpoint_04(env, context, options.notif_status_update, stats);
56+
AutoStory_Checkpoint_04().run_checkpoint(env, context, options, stats);
5757

5858
context.wait_for_all_requests();
59-
env.console.log("End Segment 02: First Nemona Battle", COLOR_GREEN);
59+
env.console.log("End Segment " + name(), COLOR_GREEN);
60+
61+
}
6062

63+
64+
std::string AutoStory_Checkpoint_04::name() const{ return "004 - " + AutoStory_Segment_02().name(); }
65+
std::string AutoStory_Checkpoint_04::start_text() const{ return "Received starter Pokemon. Changed move order. Cleared autoheal tutorial.";}
66+
std::string AutoStory_Checkpoint_04::end_text() const{ return "Battled Nemona on the beach.";}
67+
void AutoStory_Checkpoint_04::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{
68+
checkpoint_04(env, context, options.notif_status_update, stats);
6169
}
6270

6371

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ class AutoStory_Segment_02 : public AutoStory_Segment{
2626
) const override;
2727
};
2828

29+
class AutoStory_Checkpoint_04 : public AutoStory_Checkpoint{
30+
public:
31+
virtual std::string name() const override;
32+
virtual std::string start_text() const override;
33+
virtual std::string end_text() const override;
34+
virtual void run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const override;
35+
};
36+
2937

3038
// start: Received starter pokemon and changed move order. Cleared autoheal tutorial.
3139
// end: Battled Nemona on the beach.

0 commit comments

Comments
 (0)