-
Notifications
You must be signed in to change notification settings - Fork 60
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
11 changed files
with
697 additions
and
19 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
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
122 changes: 122 additions & 0 deletions
122
SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.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,122 @@ | ||
/* 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_02.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_02::name() const{ | ||
return "02: First Nemona Battle"; | ||
} | ||
|
||
std::string AutoStory_Segment_02::start_text() const{ | ||
return "Start: Picked the starter."; | ||
} | ||
|
||
std::string AutoStory_Segment_02::end_text() const{ | ||
return "End: Battled Nemona on the beach."; | ||
} | ||
|
||
void AutoStory_Segment_02::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 02: First Nemona Battle", COLOR_ORANGE); | ||
env.console.overlay().add_log("Start Segment 02: First Nemona Battle", COLOR_ORANGE); | ||
|
||
checkpoint_04(env, context, options.notif_status_update); | ||
|
||
context.wait_for_all_requests(); | ||
env.console.log("End Segment 02: First Nemona Battle", COLOR_GREEN); | ||
env.console.overlay().add_log("End Segment 02: First Nemona Battle", COLOR_GREEN); | ||
stats.m_segment++; | ||
env.update_stats(); | ||
|
||
} | ||
|
||
|
||
void checkpoint_04( | ||
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_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 220, 245, 50); | ||
pbf_move_left_joystick(context, 128, 0, 4 * TICKS_PER_SECOND, 1 * TICKS_PER_SECOND); | ||
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 128, 50); | ||
pbf_move_left_joystick(context, 128, 0, 4 * TICKS_PER_SECOND, 1 * TICKS_PER_SECOND); | ||
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 60, 50); | ||
pbf_move_left_joystick(context, 128, 0, 4 * TICKS_PER_SECOND, 2 * TICKS_PER_SECOND); | ||
env.console.log("overworld_navigation: Go to Nemona at the beach."); | ||
overworld_navigation(env.program_info(), env.console, context, NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_SPAM_A, 128, 0, 8); | ||
|
||
context.wait_for_all_requests(); | ||
env.console.overlay().add_log("Found Nemona", COLOR_WHITE); | ||
|
||
context.wait_for_all_requests(); | ||
env.console.log("Starting battle..."); | ||
env.console.overlay().add_log("Starting battle...", COLOR_WHITE); | ||
// TODO: Battle start prompt detection | ||
// can lose this battle, and story will continue | ||
mash_button_till_overworld(env.console, context); | ||
context.wait_for_all_requests(); | ||
env.console.log("Finished battle."); | ||
env.console.overlay().add_log("Finished battle.", COLOR_WHITE); | ||
|
||
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(); | ||
} | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
|
||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_02.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,43 @@ | ||
/* Autostory | ||
* | ||
* From: https://github.com/PokemonAutomation/Arduino-Source | ||
* | ||
*/ | ||
|
||
#ifndef PokemonAutomation_PokemonSV_AutoStory_Segment_02_H | ||
#define PokemonAutomation_PokemonSV_AutoStory_Segment_02_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_02 : 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: Received starter pokemon and changed move order. Cleared autoheal tutorial. | ||
// end: Battled Nemona on the beach. | ||
void checkpoint_04(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update); | ||
|
||
|
||
} | ||
} | ||
} | ||
#endif |
Oops, something went wrong.