-
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
6 changed files
with
676 additions
and
0 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
195 changes: 195 additions & 0 deletions
195
SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.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,195 @@ | ||
/* 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/Overworld/PokemonSV_DirectionDetector.h" | ||
#include "PokemonSV/Inference/Overworld/PokemonSV_OverworldDetector.h" | ||
#include "PokemonSV_AutoStoryTools.h" | ||
#include "PokemonSV_AutoStory_Segment_17.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_17::name() const{ | ||
return "13.2: Cascarrafa Gym (Water): Gym challenge and Gym battle"; | ||
} | ||
|
||
std::string AutoStory_Segment_17::start_text() const{ | ||
return "Start: Received Kofu's wallet. At Porto Marinada Pokecenter."; | ||
} | ||
|
||
std::string AutoStory_Segment_17::end_text() const{ | ||
return "End: Defeated Cascarrafa Gym (Water). At Cascarrafa Gym."; | ||
} | ||
|
||
void AutoStory_Segment_17::run_segment(SingleSwitchProgramEnvironment& env, BotBaseContext& context, AutoStoryOptions options) const{ | ||
AutoStoryStats& stats = env.current_stats<AutoStoryStats>(); | ||
|
||
context.wait_for_all_requests(); | ||
env.console.overlay().add_log("Start Segment 13.2: Cascarrafa Gym (Water): Gym battle", COLOR_ORANGE); | ||
|
||
checkpoint_37(env, context, options.notif_status_update); | ||
checkpoint_38(env, context, options.notif_status_update); | ||
|
||
context.wait_for_all_requests(); | ||
env.console.log("End Segment 13.2: Cascarrafa Gym (Water): Gym battle", COLOR_GREEN); | ||
stats.m_segment++; | ||
env.update_stats(); | ||
|
||
} | ||
|
||
|
||
void checkpoint_37( | ||
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(); | ||
DirectionDetector direction; | ||
do_action_and_monitor_for_battles(env.program_info(), env.console, context, | ||
[&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ | ||
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 255, 50); | ||
|
||
// section 1 | ||
direction.change_direction(env.program_info(), env.console, context, 1.606); | ||
pbf_move_left_joystick(context, 128, 0, 200, 100); | ||
|
||
get_on_ride(env.program_info(), env.console, context); | ||
|
||
// section 2 | ||
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); | ||
}); | ||
|
||
overworld_navigation(env.program_info(), env.console, context, | ||
NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, | ||
128, 0, 30, 10, false); | ||
// section 3. set marker to shop/Kofu | ||
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 140, 27); | ||
walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 20); | ||
|
||
clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::BATTLE, CallbackEnum::PROMPT_DIALOG, CallbackEnum::DIALOG_ARROW}); | ||
run_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG, {CallbackEnum::GRADIENT_ARROW}); | ||
mash_button_till_overworld(env.console, context, BUTTON_A, 360); | ||
|
||
|
||
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_38( | ||
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(); | ||
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 255, 180, 170}); | ||
DirectionDetector direction; | ||
do_action_and_monitor_for_battles(env.program_info(), env.console, context, | ||
[&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ | ||
direction.change_direction(env.program_info(), env.console, context, 0.3491); | ||
pbf_move_left_joystick(context, 128, 0, 400, 100); | ||
direction.change_direction(env.program_info(), env.console, context, 5.075911); | ||
pbf_move_left_joystick(context, 128, 0, 525, 100); | ||
}); | ||
|
||
direction.change_direction(env.program_info(), env.console, context, 3.771252); | ||
get_on_ride(env.program_info(), env.console, context); | ||
// walk towards elevator | ||
pbf_move_left_joystick(context, 128, 0, 700, 100); | ||
// jump to ensure you get on elevator | ||
pbf_controller_state(context, BUTTON_B, DPAD_NONE, 128, 0, 128, 128, 200); | ||
pbf_wait(context, 3 * TICKS_PER_SECOND); | ||
// wait for overworld to reappear after stepping off elevator | ||
wait_for_overworld(env.program_info(), env.console, context, 30); | ||
|
||
pbf_move_left_joystick(context, 128, 0, 120, 100); | ||
|
||
direction.change_direction(env.program_info(), env.console, context, 5.11); | ||
pbf_move_left_joystick(context, 128, 0, 1600, 100); | ||
direction.change_direction(env.program_info(), env.console, context, 3.2245); | ||
|
||
|
||
handle_when_stationary_in_overworld(env.program_info(), env.console, context, | ||
[&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ | ||
walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 18); | ||
}, | ||
[&](const ProgramInfo& info, ConsoleHandle& console, BotBaseContext& context){ | ||
pbf_move_left_joystick(context, 255, 0, 100, 50); | ||
pbf_move_left_joystick(context, 0, 0, 100, 50); | ||
} | ||
); | ||
// talk to Nemona | ||
mash_button_till_overworld(env.console, context, BUTTON_A, 360); | ||
|
||
// talk to reception. Battle Kofu | ||
walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_SPAM_A, 10); | ||
clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::BATTLE, CallbackEnum::PROMPT_DIALOG, CallbackEnum::DIALOG_ARROW}); | ||
run_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG, {CallbackEnum::GRADIENT_ARROW}, true); | ||
mash_button_till_overworld(env.console, context, BUTTON_A, 360); | ||
|
||
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(); | ||
} | ||
} | ||
|
||
} | ||
|
||
|
||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.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,48 @@ | ||
/* Autostory | ||
* | ||
* From: https://github.com/PokemonAutomation/Arduino-Source | ||
* | ||
*/ | ||
|
||
#ifndef PokemonAutomation_PokemonSV_AutoStory_Segment_17_H | ||
#define PokemonAutomation_PokemonSV_AutoStory_Segment_17_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_17 : 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: At Porto Marinada Pokecenter. | ||
// end: Won auction at Porto Marinada, passed Gym challenge. | ||
void checkpoint_37(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update); | ||
|
||
// start: Won auction at Porto Marinada, passed Gym challenge. | ||
// end: Defeat Cascarrafa Gym | ||
void checkpoint_38(SingleSwitchProgramEnvironment& env, BotBaseContext& context, EventNotificationOption& notif_status_update); | ||
|
||
|
||
|
||
} | ||
} | ||
} | ||
#endif |
Oops, something went wrong.