Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autostory segment 01 #488

Merged
merged 1 commit into from
Oct 3, 2024
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
4 changes: 3 additions & 1 deletion SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,9 @@ file(GLOB MAIN_SOURCES
Source/PokemonSV/PokemonSV_Settings.cpp
Source/PokemonSV/PokemonSV_Settings.h
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_00.cpp
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_00.h
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_00.h
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.cpp
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.h
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp
Expand Down
2 changes: 2 additions & 0 deletions SerialPrograms/SerialPrograms.pro
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ SOURCES += \
Source/PokemonSV/PokemonSV_Panels.cpp \
Source/PokemonSV/PokemonSV_Settings.cpp \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_00.cpp \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.cpp \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp \
Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.cpp \
Expand Down Expand Up @@ -1800,6 +1801,7 @@ HEADERS += \
Source/PokemonSV/PokemonSV_Panels.h \
Source/PokemonSV/PokemonSV_Settings.h \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_00.h \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_01.h \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h \
Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.h \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "PokemonSwSh/Inference/PokemonSwSh_IvJudgeReader.h"
#include "PokemonSV/Programs/PokemonSV_GameEntry.h"
#include "PokemonSV_AutoStory_Segment_00.h"
// #include "PokemonSV_AutoStory_Segment_01.h"
#include "PokemonSV_AutoStory_Segment_01.h"
// #include "PokemonSV_AutoStory_Segment_02.h"
// #include "PokemonSV_AutoStory_Segment_03.h"
// #include "PokemonSV_AutoStory_Segment_04.h"
Expand Down Expand Up @@ -49,7 +49,7 @@ using namespace Pokemon;
std::vector<std::unique_ptr<AutoStory_Segment>> make_autoStory_segment_list(){
std::vector<std::unique_ptr<AutoStory_Segment>> segment_list;
segment_list.emplace_back(std::make_unique<AutoStory_Segment_00>());
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_01>());
segment_list.emplace_back(std::make_unique<AutoStory_Segment_01>());
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_02>());
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_03>());
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_04>());
Expand Down Expand Up @@ -453,14 +453,14 @@ void AutoStory::test_checkpoints(
int start, int end,
int loop, int start_loop, int end_loop
){
// EventNotificationOption& notif_status_update = NOTIFICATION_STATUS_UPDATE;
// Language language = LANGUAGE;
// StarterChoice starter_choice = STARTERCHOICE;
EventNotificationOption& notif_status_update = NOTIFICATION_STATUS_UPDATE;
Language language = LANGUAGE;
StarterChoice starter_choice = STARTERCHOICE;
std::vector<std::function<void()>> checkpoint_list;
checkpoint_list.push_back([&](){checkpoint_00(env, context);});
// checkpoint_list.push_back([&](){checkpoint_01(env, context, notif_status_update, language);});
// checkpoint_list.push_back([&](){checkpoint_02(env, context, notif_status_update);});
// checkpoint_list.push_back([&](){checkpoint_03(env, context, notif_status_update, language, starter_choice);});
checkpoint_list.push_back([&](){checkpoint_01(env, context, notif_status_update, language);});
checkpoint_list.push_back([&](){checkpoint_02(env, context, notif_status_update);});
checkpoint_list.push_back([&](){checkpoint_03(env, context, notif_status_update, language, starter_choice);});
// checkpoint_list.push_back([&](){checkpoint_04(env, context, notif_status_update);});
// checkpoint_list.push_back([&](){checkpoint_05(env, context, notif_status_update);});
// checkpoint_list.push_back([&](){checkpoint_06(env, context, notif_status_update);});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void clear_tutorial(ConsoleHandle& console, BotBaseContext& context, uint16_t se

void clear_dialog(ConsoleHandle& console, BotBaseContext& context,
ClearDialogMode mode, uint16_t seconds_timeout,
std::vector<ClearDialogCallback> enum_optional_callbacks
std::vector<CallbackEnum> enum_optional_callbacks
){
bool seen_dialog = false;
WallClock start = current_time();
Expand All @@ -174,32 +174,32 @@ void clear_dialog(ConsoleHandle& console, BotBaseContext& context,
context.wait_for_all_requests();

std::vector<PeriodicInferenceCallback> callbacks;
std::vector<ClearDialogCallback> enum_all_callbacks{ClearDialogCallback::ADVANCE_DIALOG}; // mandatory callbacks
std::vector<CallbackEnum> enum_all_callbacks{CallbackEnum::ADVANCE_DIALOG}; // mandatory callbacks
enum_all_callbacks.insert(enum_all_callbacks.end(), enum_optional_callbacks.begin(), enum_optional_callbacks.end()); // append the mandatory and optional callback vectors together
for (const ClearDialogCallback& enum_callback : enum_all_callbacks){
for (const CallbackEnum& enum_callback : enum_all_callbacks){
switch(enum_callback){
case ClearDialogCallback::ADVANCE_DIALOG:
case CallbackEnum::ADVANCE_DIALOG:
callbacks.emplace_back(advance_dialog);
break;
case ClearDialogCallback::OVERWORLD:
case CallbackEnum::OVERWORLD:
callbacks.emplace_back(overworld);
break;
case ClearDialogCallback::PROMPT_DIALOG:
case CallbackEnum::PROMPT_DIALOG:
callbacks.emplace_back(prompt);
break;
case ClearDialogCallback::WHITE_A_BUTTON:
case CallbackEnum::WHITE_A_BUTTON:
callbacks.emplace_back(whitebutton);
break;
case ClearDialogCallback::DIALOG_ARROW:
case CallbackEnum::DIALOG_ARROW:
callbacks.emplace_back(dialog_arrow);
break;
case ClearDialogCallback::BATTLE:
case CallbackEnum::BATTLE:
callbacks.emplace_back(battle);
break;
case ClearDialogCallback::TUTORIAL:
case CallbackEnum::TUTORIAL:
callbacks.emplace_back(tutorial);
break;
case ClearDialogCallback::BLACK_DIALOG_BOX:
case CallbackEnum::BLACK_DIALOG_BOX:
callbacks.emplace_back(black_dialog_box);
break;
}
Expand Down Expand Up @@ -233,51 +233,51 @@ void clear_dialog(ConsoleHandle& console, BotBaseContext& context,
);
}

ClearDialogCallback enum_callback = enum_all_callbacks[ret];
CallbackEnum enum_callback = enum_all_callbacks[ret];
switch(enum_callback){
case ClearDialogCallback::ADVANCE_DIALOG:
case CallbackEnum::ADVANCE_DIALOG:
console.log("clear_dialog: Detected advance dialog.");
seen_dialog = true;
pbf_press_button(context, BUTTON_A, 20, 105);
break;
case ClearDialogCallback::OVERWORLD:
case CallbackEnum::OVERWORLD:
console.log("clear_dialog: Detected overworld.");
if (seen_dialog && mode == ClearDialogMode::STOP_OVERWORLD){
return;
}
break;
case ClearDialogCallback::PROMPT_DIALOG:
case CallbackEnum::PROMPT_DIALOG:
console.log("clear_dialog: Detected prompt.");
seen_dialog = true;
if (mode == ClearDialogMode::STOP_PROMPT){
return;
}
pbf_press_button(context, BUTTON_A, 20, 105);
break;
case ClearDialogCallback::WHITE_A_BUTTON:
case CallbackEnum::WHITE_A_BUTTON:
console.log("clear_dialog: Detected white A button.");
seen_dialog = true;
if (mode == ClearDialogMode::STOP_WHITEBUTTON){
return;
}
pbf_press_button(context, BUTTON_A, 20, 105);
break;
case ClearDialogCallback::DIALOG_ARROW:
case CallbackEnum::DIALOG_ARROW:
console.log("clear_dialog: Detected dialog arrow.");
seen_dialog = true;
pbf_press_button(context, BUTTON_A, 20, 105);
break;
case ClearDialogCallback::BATTLE:
case CallbackEnum::BATTLE:
console.log("clear_dialog: Detected battle.");
if (mode == ClearDialogMode::STOP_BATTLE){
return;
}
break;
case ClearDialogCallback::TUTORIAL:
case CallbackEnum::TUTORIAL:
console.log("clear_dialog: Detected tutorial.");
pbf_press_button(context, BUTTON_A, 20, 105);
break;
case ClearDialogCallback::BLACK_DIALOG_BOX:
case CallbackEnum::BLACK_DIALOG_BOX:
console.log("clear_dialog: Detected black dialog box.");
pbf_press_button(context, BUTTON_A, 20, 105);
break;
Expand Down Expand Up @@ -522,7 +522,7 @@ void change_settings(SingleSwitchProgramEnvironment& env, BotBaseContext& contex
}

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

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ enum class ClearDialogMode{
};


enum class ClearDialogCallback{
enum class CallbackEnum{
ADVANCE_DIALOG,
OVERWORLD,
PROMPT_DIALOG,
Expand Down Expand Up @@ -110,7 +110,7 @@ void clear_tutorial(ConsoleHandle& console, BotBaseContext& context, uint16_t se
// also throw exception if dialog is never detected.
void clear_dialog(ConsoleHandle& console, BotBaseContext& context,
ClearDialogMode mode, uint16_t seconds_timeout = 60,
std::vector<ClearDialogCallback> optional_callbacks = {}
std::vector<CallbackEnum> optional_callbacks = {}
);

// move character with ssf left joystick, as per given x, y, until
Expand Down
Loading
Loading