-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
686 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
225 changes: 225 additions & 0 deletions
225
SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_08.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.