Skip to content

Commit

Permalink
segments 8 to 9
Browse files Browse the repository at this point in the history
  • Loading branch information
jw098 committed Oct 26, 2024
1 parent 9c21821 commit 4c63618
Show file tree
Hide file tree
Showing 7 changed files with 686 additions and 15 deletions.
6 changes: 5 additions & 1 deletion SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,11 @@ file(GLOB MAIN_SOURCES
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.h
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.h
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.h
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.cpp
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.h
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.cpp
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.h
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp
Expand Down
8 changes: 6 additions & 2 deletions SerialPrograms/SerialPrograms.pro
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,9 @@ SOURCES += \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.cpp \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.cpp \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.cpp \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.cpp \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.cpp \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.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 @@ -1815,7 +1817,9 @@ HEADERS += \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_04.h \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_05.h \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_06.h \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.h \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_07.h \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.h \
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_09.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 @@ -23,8 +23,8 @@
#include "PokemonSV_AutoStory_Segment_05.h"
#include "PokemonSV_AutoStory_Segment_06.h"
#include "PokemonSV_AutoStory_Segment_07.h"
// #include "PokemonSV_AutoStory_Segment_08.h"
// #include "PokemonSV_AutoStory_Segment_09.h"
#include "PokemonSV_AutoStory_Segment_08.h"
#include "PokemonSV_AutoStory_Segment_09.h"
// #include "PokemonSV_AutoStory_Segment_10.h"
// #include "PokemonSV_AutoStory_Segment_11.h"
// #include "PokemonSV_AutoStory_Segment_12.h"
Expand Down Expand Up @@ -56,8 +56,8 @@ std::vector<std::unique_ptr<AutoStory_Segment>> make_autoStory_segment_list(){
segment_list.emplace_back(std::make_unique<AutoStory_Segment_05>());
segment_list.emplace_back(std::make_unique<AutoStory_Segment_06>());
segment_list.emplace_back(std::make_unique<AutoStory_Segment_07>());
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_08>());
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_09>());
segment_list.emplace_back(std::make_unique<AutoStory_Segment_08>());
segment_list.emplace_back(std::make_unique<AutoStory_Segment_09>());
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_10>());
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_11>());
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_12>());
Expand Down Expand Up @@ -470,14 +470,14 @@ void AutoStory::test_checkpoints(
checkpoint_list.push_back([&](){checkpoint_10(env, context, notif_status_update);});
checkpoint_list.push_back([&](){checkpoint_11(env, context, notif_status_update);});
checkpoint_list.push_back([&](){checkpoint_12(env, context, notif_status_update);});
// checkpoint_list.push_back([&](){checkpoint_13(env, context, notif_status_update);});
// checkpoint_list.push_back([&](){checkpoint_14(env, context, notif_status_update);});
// checkpoint_list.push_back([&](){checkpoint_15(env, context, notif_status_update);});
// checkpoint_list.push_back([&](){checkpoint_16(env, context, notif_status_update);});
// checkpoint_list.push_back([&](){checkpoint_17(env, context, notif_status_update);});
// checkpoint_list.push_back([&](){checkpoint_18(env, context, notif_status_update);});
// checkpoint_list.push_back([&](){checkpoint_19(env, context, notif_status_update);});
// checkpoint_list.push_back([&](){checkpoint_20(env, context, notif_status_update);});
checkpoint_list.push_back([&](){checkpoint_13(env, context, notif_status_update);});
checkpoint_list.push_back([&](){checkpoint_14(env, context, notif_status_update);});
checkpoint_list.push_back([&](){checkpoint_15(env, context, notif_status_update);});
checkpoint_list.push_back([&](){checkpoint_16(env, context, notif_status_update);});
checkpoint_list.push_back([&](){checkpoint_17(env, context, notif_status_update);});
checkpoint_list.push_back([&](){checkpoint_18(env, context, notif_status_update);});
checkpoint_list.push_back([&](){checkpoint_19(env, context, notif_status_update);});
checkpoint_list.push_back([&](){checkpoint_20(env, context, notif_status_update);});
// checkpoint_list.push_back([&](){checkpoint_21(env, context, notif_status_update);});
// checkpoint_list.push_back([&](){checkpoint_22(env, context, notif_status_update);});
// checkpoint_list.push_back([&](){checkpoint_23(env, context, notif_status_update);});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
/* AutoStory
*
* From: https://github.com/PokemonAutomation/Arduino-Source
*
*/

#include "CommonFramework/GlobalSettingsPanel.h"
#include "CommonFramework/Exceptions/FatalProgramException.h"
#include "CommonFramework/Exceptions/OperationFailedException.h"
#include "CommonFramework/InferenceInfra/InferenceRoutines.h"
#include "CommonFramework/Notifications/ProgramNotifications.h"
#include "CommonFramework/Tools/StatsTracking.h"
#include "CommonFramework/Tools/VideoResolutionCheck.h"
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
#include "Pokemon/Pokemon_Strings.h"
#include "PokemonSwSh/Inference/PokemonSwSh_IvJudgeReader.h"
#include "PokemonSV/Programs/PokemonSV_GameEntry.h"
#include "PokemonSV/Programs/PokemonSV_SaveGame.h"
#include "PokemonSV/Inference/PokemonSV_TutorialDetector.h"
#include "PokemonSV_AutoStoryTools.h"
#include "PokemonSV_AutoStory_Segment_08.h"

//#include <iostream>
//using std::cout;
//using std::endl;
//#include <unordered_map>
//#include <algorithm>

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonSV{

using namespace Pokemon;




std::string AutoStory_Segment_08::name() const{
return "08: Beat Team Star and arrive at School";
}

std::string AutoStory_Segment_08::start_text() const{
return "Start: At Mesagoza South Pokecenter.";
}

std::string AutoStory_Segment_08::end_text() const{
return "End: Battled Team Star, talked to Jacq, standing in classroom.";
}

void AutoStory_Segment_08::run_segment(SingleSwitchProgramEnvironment& env, BotBaseContext& context, AutoStoryOptions options) const{
AutoStoryStats& stats = env.current_stats<AutoStoryStats>();

context.wait_for_all_requests();
env.console.log("Start Segment 08: Beat Team Star and arrive at School", COLOR_ORANGE);

checkpoint_13(env, context, options.notif_status_update);
checkpoint_14(env, context, options.notif_status_update);
checkpoint_15(env, context, options.notif_status_update);


context.wait_for_all_requests();
env.console.log("End Segment 08: Beat Team Star and arrive at School", COLOR_GREEN);
stats.m_segment++;
env.update_stats();

}


void checkpoint_13(
SingleSwitchProgramEnvironment& env,
BotBaseContext& context,
EventNotificationOption& notif_status_update
){
// reset rate: 0%. 0 resets out of 70.
AutoStoryStats& stats = env.current_stats<AutoStoryStats>();
bool first_attempt = true;
while (true){
try{
do_action_and_monitor_for_battles(env.program_info(), env.console, context,
[&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){

if (first_attempt){
checkpoint_save(env, context, notif_status_update);
first_attempt = false;
}

fly_to_overlapping_flypoint(info, env.console, context);

context.wait_for_all_requests();
realign_player(info, env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 80, 50);
walk_forward_while_clear_front_path(info, env.console, context, 500);
walk_forward_until_dialog(info, env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 30);
});

env.console.log("clear_dialog: Talk with Nemona at Mesagoza gate. Stop when detect battle.");
clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60,
{CallbackEnum::PROMPT_DIALOG, CallbackEnum::DIALOG_ARROW, CallbackEnum::BATTLE});

env.console.log("run_battle_press_A: Battle with Nemona at Mesagoza gate. Stop when detect dialog.");
// story continues even if you lose
run_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG);

env.console.log("clear_dialog: Talk with Nemona within Mesagoza. Stop when detect overworld.");
clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60,
{CallbackEnum::OVERWORLD, CallbackEnum::PROMPT_DIALOG, CallbackEnum::WHITE_A_BUTTON});


break;
}catch(...){
context.wait_for_all_requests();
env.console.log("Resetting from checkpoint.");
reset_game(env.program_info(), env.console, context);
stats.m_reset++;
env.update_stats();
}
}

}

void checkpoint_14(
SingleSwitchProgramEnvironment& env,
BotBaseContext& context,
EventNotificationOption& notif_status_update
){
AutoStoryStats& stats = env.current_stats<AutoStoryStats>();
bool first_attempt = true;
while (true){
try{
if (first_attempt){
checkpoint_save(env, context, notif_status_update);
first_attempt = false;
}
context.wait_for_all_requests();
// realign diagonally to the left
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 80, 0, 100);
// walk forward so you're off center
pbf_move_left_joystick(context, 128, 0, 100, 100);
// realign going straight
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 128, 0, 100);
// walk forward, while still off center
pbf_move_left_joystick(context, 128, 0, 2000, 100);
// realign diagonally to the right
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 178, 0, 100);
// walk forward so you're closer to the center
pbf_move_left_joystick(context, 128, 0, 150, 100);
// realign going straight
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 128, 0, 100);
// walk forward until hit dialog at top of stairs
walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 60);
// clear dialog until battle. with prompt, battle
env.console.log("clear_dialog: Talk with Team Star at the top of the stairs. Stop when detect battle.");
clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::PROMPT_DIALOG, CallbackEnum::BATTLE, CallbackEnum::DIALOG_ARROW});
// run battle until dialog
env.console.log("run_battle_press_A: Battle with Team Star grunt 1. Stop when detect dialog.");
run_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG, {}, true);
// clear dialog until battle, with prompt, white button, tutorial, battle
env.console.log("clear_dialog: Talk with Team Star and Nemona. Receive Tera orb. Stop when detect battle.");
clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60,
{CallbackEnum::PROMPT_DIALOG, CallbackEnum::WHITE_A_BUTTON, CallbackEnum::TUTORIAL, CallbackEnum::BATTLE, CallbackEnum::DIALOG_ARROW});
// run battle until dialog
env.console.log("run_battle_press_A: Battle with Team Star grunt 2. Stop when detect dialog.");
run_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG, {}, true);
// clear dialog until overworld
clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::OVERWORLD});

break;
}catch(...){
context.wait_for_all_requests();
env.console.log("Resetting from checkpoint.");
reset_game(env.program_info(), env.console, context);
stats.m_reset++;
env.update_stats();
}
}

}

void checkpoint_15(
SingleSwitchProgramEnvironment& env,
BotBaseContext& context,
EventNotificationOption& notif_status_update
){
AutoStoryStats& stats = env.current_stats<AutoStoryStats>();
bool first_attempt = true;
while (true){
try{
if (first_attempt){
checkpoint_save(env, context, notif_status_update);
first_attempt = false;
}
context.wait_for_all_requests();
// realign diagonally to the right
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 178, 0, 100);
// walk forward so you're closer to the center
pbf_move_left_joystick(context, 128, 0, 100, 100);
// realign going straight
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 128, 0, 100);
// walk forward up stairs
pbf_move_left_joystick(context, 128, 0, 1000, 100);
// realign going straight
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER);
// walk forward until hit dialog inside the school
walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 60);

env.console.log("clear_dialog: Talk with Nemona, Clavell, and Jacq inside the school. Stop when detect overworld.");
clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60,
{CallbackEnum::PROMPT_DIALOG, CallbackEnum::OVERWORLD});

break;
}catch(...){
context.wait_for_all_requests();
env.console.log("Resetting from checkpoint.");
reset_game(env.program_info(), env.console, context);
stats.m_reset++;
env.update_stats();
}
}

}



}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* Autostory
*
* From: https://github.com/PokemonAutomation/Arduino-Source
*
*/

#ifndef PokemonAutomation_PokemonSV_AutoStory_Segment_08_H
#define PokemonAutomation_PokemonSV_AutoStory_Segment_08_H

#include <functional>
#include "Common/Cpp/Options/EnumDropdownOption.h"
#include "CommonFramework/Notifications/EventNotificationsTable.h"
#include "CommonFramework/Options/LanguageOCROption.h"
#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h"
#include "Common/NintendoSwitch/NintendoSwitch_ControllerDefs.h"
#include "PokemonSV/Programs/PokemonSV_Navigation.h"
#include "PokemonSV_AutoStoryTools.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonSV{

class AutoStory_Segment_08 : public AutoStory_Segment{
public:
virtual std::string name() const override;
virtual std::string start_text() const override;
virtual std::string end_text() const override;
virtual void run_segment(
SingleSwitchProgramEnvironment& env,
BotBaseContext& context,
AutoStoryOptions options) const override;
};

// start: Arrived at Mesagoza (South) Pokecenter
// end: Battled Nemona at Mesagoza gate. Entered Mesagoza.
void checkpoint_13(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update);

// start: Battled Nemona at Mesagoza gate. Entered Mesagoza.
// end: Battled Team Star at school entrance.
void checkpoint_14(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update);

// start: Battled Team Star at school entrance.
// end: Talked to Jacq in classroom. Standing in classroom.
void checkpoint_15(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update);



}
}
}
#endif
Loading

0 comments on commit 4c63618

Please sign in to comment.