Skip to content
Closed
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
3 changes: 3 additions & 0 deletions SerialPrograms/Source/PokemonLZA/PokemonLZA_Panels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "Programs/ShinyHunting/PokemonLZA_BeldumHunter.h"
#include "Programs/ShinyHunting/PokemonLZA_AutoFossil.h"
#include "Programs/ShinyHunting/PokemonLZA_WildZoneEntrance.h"
#include "Programs/ShinyHunting/PokemonLZA_SewerWhirlipedeRunner.h"

// Developer
#include "Programs/TestPrograms/PokemonLZA_OverworldWatcher.h"
Expand Down Expand Up @@ -68,8 +69,10 @@ std::vector<PanelEntry> PanelListFactory::make_panels() const{
ret.emplace_back(make_single_switch_program<ShinyHunt_BenchSit_Descriptor, ShinyHunt_BenchSit>());
ret.emplace_back(make_single_switch_program<ShinyHunt_OverworldReset_Descriptor, ShinyHunt_OverworldReset>());
ret.emplace_back(make_single_switch_program<ShinyHunt_WildZoneEntrance_Descriptor, ShinyHunt_WildZoneEntrance>());

if (IS_BETA_VERSION){
ret.emplace_back(make_single_switch_program<AutoFossil_Descriptor, AutoFossil>());
ret.emplace_back(make_single_switch_program<ShinyHunt_SewerWhirlipedeRunner_Descriptor, ShinyHunt_SewerWhirlipedeRunner>());
}

if (PreloadSettings::instance().DEVELOPER_MODE){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/* Shiny Hunt - Sewer Whirlipede Runner
*
* From: https://github.com/PokemonAutomation/
*
*/

#include "CommonFramework/Exceptions/OperationFailedException.h"
#include "CommonFramework/ProgramStats/StatsTracking.h"
#include "CommonFramework/Notifications/ProgramNotifications.h"
#include "CommonTools/Async/InferenceRoutines.h"
#include "CommonTools/VisualDetectors/BlackScreenDetector.h"
#include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h"
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
#include "Pokemon/Pokemon_Strings.h"
#include "PokemonLZA/Inference/PokemonLZA_ButtonDetector.h"
#include "PokemonLZA/Programs/PokemonLZA_BasicNavigation.h"
#include "PokemonLZA_SewerWhirlipedeRunner.h"

namespace PokemonAutomation {
namespace NintendoSwitch {
namespace PokemonLZA {

using namespace Pokemon;


ShinyHunt_SewerWhirlipedeRunner_Descriptor::ShinyHunt_SewerWhirlipedeRunner_Descriptor()
: SingleSwitchProgramDescriptor(
"PokemonLZA:ShinyHunt-SewerWhirlipedeRunner", STRING_POKEMON + " LZA",
"Shiny Hunt - Sewer Whirlipede Runner",
"Programs/PokemonLZA/ShinyHunt-SewerWhirlipedeRunner.html",
"Shiny hunt by repeatedly respawning static alpha Whirlipede, running just outside of the Lumiose Sewers.",
ProgramControllerClass::StandardController_NoRestrictions, FeedbackType::REQUIRED,
AllowCommandsWhenRunning::DISABLE_COMMANDS, {}
)
{}
class ShinyHunt_SewerWhirlipedeRunner_Descriptor::Stats : public StatsTracker{
public:
Stats()
: resets(m_stats["Whirlipede Respawning"])
, day_changes(m_stats["Day/Night Changes"])
, errors(m_stats["Errors"])
{
m_display_order.emplace_back("Whirlipede Respawning");
m_display_order.emplace_back("Day/Night Changes");
m_display_order.emplace_back("Errors", HIDDEN_IF_ZERO);
}

std::atomic<uint64_t>& resets;
std::atomic<uint64_t>& day_changes;
std::atomic<uint64_t>& errors;
};
std::unique_ptr<StatsTracker> ShinyHunt_SewerWhirlipedeRunner_Descriptor::make_stats() const{
return std::unique_ptr<StatsTracker>(new Stats());
}


ShinyHunt_SewerWhirlipedeRunner::ShinyHunt_SewerWhirlipedeRunner()
: DURATION("<b>duration:</b><br>Run the program this long.", LockMode::UNLOCK_WHILE_RUNNING, "1 h")
, NOTIFICATION_STATUS("Status Update", true, false, std::chrono::seconds(3600))
, NOTIFICATIONS({
&NOTIFICATION_STATUS,
&NOTIFICATION_PROGRAM_FINISH,
&NOTIFICATION_ERROR_RECOVERABLE,
&NOTIFICATION_ERROR_FATAL,
})
{
PA_ADD_OPTION(DURATION);
PA_ADD_OPTION(NOTIFICATIONS);
}


void run_one_way(ConsoleHandle& console, ProControllerContext& context){
ButtonWatcher buttonA(COLOR_RED, ButtonType::ButtonA, {0.3, 0.2, 0.4, 0.7}, &console.overlay());
run_until<ProControllerContext>(
console, context,
[](ProControllerContext& context){
pbf_move_left_joystick(context, 128, 255, 100ms, 100ms);
pbf_press_button(context, BUTTON_L, 100ms, 100ms);
ssf_press_button(context, BUTTON_B, 0ms, 500ms, 0ms);
pbf_move_left_joystick(context, 165, 0, 3000ms, 0ms);
},
{{buttonA}}
);
}

void fly_to_lumiose_sewers(ConsoleHandle& console, ProControllerContext& context){
context.wait_for_all_requests();
pbf_move_left_joystick(context, 192, 192, 50ms, 200ms); // TODO: inference
fly_from_map(console, context);
context.wait_for(std::chrono::milliseconds(1000));
}

void run_at_lumiose_sewers_entrance(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context
){
ShinyHunt_SewerWhirlipedeRunner_Descriptor::Stats& stats = env.current_stats<ShinyHunt_SewerWhirlipedeRunner_Descriptor::Stats>();
context.wait_for_all_requests();

BlackScreenOverWatcher black_screen(COLOR_BLUE);
int ret = run_until<ProControllerContext>(
env.console, context,
[&](ProControllerContext& context){
run_one_way(env.console, context);
},
{{black_screen}}
);
if (ret == 0){
env.console.log("[SewerWhirlipedeRunner] Detected day/night change");
stats.day_changes++;
context.wait_for(std::chrono::milliseconds(2000));
}
open_map(env.console, context);
fly_to_lumiose_sewers(env.console, context);
}

void ShinyHunt_SewerWhirlipedeRunner::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
ShinyHunt_SewerWhirlipedeRunner_Descriptor::Stats& stats =
env.current_stats<ShinyHunt_SewerWhirlipedeRunner_Descriptor::Stats>();
WallClock deadline = current_time() + DURATION.get();
do{
send_program_status_notification(env, NOTIFICATION_STATUS);
stats.resets++;
run_at_lumiose_sewers_entrance(env, context);
env.update_stats();
}while (current_time() < deadline);

go_home(env.console, context);
send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH);
}


} // namespace PokemonLZA
} // namespace NintendoSwitch
} // namespace PokemonAutomation
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* Shiny Hunt - Sewer Whirlipede Runner
*
* From: https://github.com/PokemonAutomation/
*
*/

#ifndef PokemonAutomation_PokemonLZA_Sewer_Whirlipede_Runner_H
#define PokemonAutomation_PokemonLZA_Sewer_Whirlipede_Runner_H

#include "Common/Cpp/Options/TimeDurationOption.h"
#include "CommonFramework/Notifications/EventNotificationsTable.h"
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"

namespace PokemonAutomation {
namespace NintendoSwitch {
namespace PokemonLZA {


class ShinyHunt_SewerWhirlipedeRunner_Descriptor : public SingleSwitchProgramDescriptor {
public:
ShinyHunt_SewerWhirlipedeRunner_Descriptor();

class Stats;
virtual std::unique_ptr<StatsTracker> make_stats() const override;
};


class ShinyHunt_SewerWhirlipedeRunner : public SingleSwitchProgramInstance {
public:
ShinyHunt_SewerWhirlipedeRunner();

virtual void program(SingleSwitchProgramEnvironment& env, ProControllerContext& context) override;

private:
MillisecondsOption DURATION;
EventNotificationOption NOTIFICATION_STATUS;
EventNotificationsOption NOTIFICATIONS;
};


} // namespace PokemonLZA
} // namespace NintendoSwitch
} // namespace PokemonAutomation
#endif
2 changes: 2 additions & 0 deletions SerialPrograms/SourceFiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,8 @@ file(GLOB LIBRARY_SOURCES
Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_ShinyHunt_OverworldReset.h
Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_WildZoneEntrance.cpp
Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_WildZoneEntrance.h
Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_SewerWhirlipedeRunner.cpp
Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_SewerWhirlipedeRunner.h
Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_MoveBoxArrow.cpp
Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_MoveBoxArrow.h
Source/PokemonLZA/Programs/TestPrograms/PokemonLZA_OverworldWatcher.cpp
Expand Down