Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
#include "CommonFramework/Notifications/ProgramNotifications.h"
#include "CommonFramework/VideoPipeline/VideoOverlay.h"
#include "CommonTools/Async/InferenceRoutines.h"
#include "CommonTools/VisualDetectors/BlackScreenDetector.h"
#include "CommonTools/StartupChecks/VideoResolutionCheck.h"
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
#include "Pokemon/Pokemon_Strings.h"
#include "PokemonLA/Inference/Sounds/PokemonLA_ShinySoundDetector.h"
#include "PokemonLZA/Programs/PokemonLZA_BasicNavigation.h"
Expand Down Expand Up @@ -58,6 +60,17 @@ std::unique_ptr<StatsTracker> ShinyHunt_FlySpotReset_Descriptor::make_stats() co

ShinyHunt_FlySpotReset::ShinyHunt_FlySpotReset()
: SHINY_DETECTED("Shiny Detected", "", "2000 ms", ShinySoundDetectedAction::NOTIFY_ON_FIRST_ONLY)
, ROUTE("<b>Hunt Route:</b>",
{
{Route::NO_MOVEMENT, "no_movement", "No Movement"},
{Route::WILD_ZONE_19, "wild_zone_19", "Wild Zone 19"},
{Route::ALPHA_PIDGEY, "alpha_pidgey", "Alpha Pidgey (Wild Zone 1)"},
// {Route::ALPHA_PIKACHU, "alpha_pikachu", "Alpha Pikachu (Wild Zone 6)"},
// {Route::CUSTOMISED_MACRO, "customised_macro", "Customised Macro"},
},
LockMode::LOCK_WHILE_RUNNING,
Route::NO_MOVEMENT
)
, NOTIFICATION_STATUS("Status Update", true, false, std::chrono::seconds(3600))
, NOTIFICATIONS({
&NOTIFICATION_STATUS,
Expand All @@ -68,10 +81,103 @@ ShinyHunt_FlySpotReset::ShinyHunt_FlySpotReset()
})
{
PA_ADD_STATIC(SHINY_REQUIRES_AUDIO);
PA_ADD_OPTION(ROUTE);
PA_ADD_OPTION(SHINY_DETECTED);
PA_ADD_OPTION(NOTIFICATIONS);
}

namespace {

typedef std::function<void(SingleSwitchProgramEnvironment&, ProControllerContext&, ShinyHunt_FlySpotReset_Descriptor::Stats&, bool)> route_func;

void route_default(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
ShinyHunt_FlySpotReset_Descriptor::Stats& stats,
bool to_zoom_to_max){
// Open map
bool can_fast_travel = open_map(env.console, context, to_zoom_to_max);
if (!can_fast_travel){
stats.errors++;
env.update_stats();
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"FlySpotReset: Cannot open map for fast travel.",
env.console
);
}

// Move map cursor upwards a little bit
pbf_move_left_joystick(context, 128, 64, 100ms, 200ms);

// Fly from map to reset spawns
FastTravelState travel_status = fly_from_map(env.console, context);
if (travel_status != FastTravelState::SUCCESS){
stats.errors++;
env.update_stats();
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"FlySpotReset: Cannot fast travel after moving map cursor.",
env.console
);
}
}

void route_wild_zone_19(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
ShinyHunt_FlySpotReset_Descriptor::Stats& stats,
bool to_zoom_to_max){
if (run_a_straight_path_in_overworld(env.console, context, 0, 80, 6500ms) == 0) {
open_map(env.console, context, to_zoom_to_max);
pbf_move_left_joystick(context, 0, 64, 100ms, 100ms);
if (fly_from_map(env.console, context) == FastTravelState::NOT_AT_FLY_SPOT) {
pbf_move_left_joystick(context, 128, 192, 100ms, 100ms);
fly_from_map(env.console, context);
}
} else {
open_map(env.console, context, to_zoom_to_max);
pbf_move_left_joystick(context, 0, 64, 100ms, 100ms);
fly_from_map(env.console, context);
}
wait_until_overworld(env.console, context, 50s);
}

void route_alpha_pidgey(
SingleSwitchProgramEnvironment& env,
ProControllerContext& context,
ShinyHunt_FlySpotReset_Descriptor::Stats& stats,
bool to_zoom_to_max){
int ret = -1;
{
BlackScreenOverWatcher black_screen(COLOR_BLUE);
ret = run_until<ProControllerContext>(
env.console, context,
[&](ProControllerContext& context){
ssf_press_button(context, BUTTON_B, 0ms, 500ms, 0ms);
pbf_move_left_joystick(context, 255, 128, 4000ms, 0ms);
pbf_move_left_joystick(context, 128, 255, 7400ms, 0ms);
pbf_move_left_joystick(context, 0, 128, 3000ms, 0ms);
pbf_press_button(context, BUTTON_A, 500ms, 2500ms); // elevator up
pbf_move_left_joystick(context, 255, 128, 100ms, 0ms);
pbf_press_button(context, BUTTON_L, 100ms, 1000ms);
},
{black_screen}
);
}
if (ret == 0){
wait_until_overworld(env.console, context, 50s);
}
open_map(env.console, context, to_zoom_to_max);
pbf_move_left_joystick(context, 128, 255, 200ms, 100ms);
if (fly_from_map(env.console, context) == FastTravelState::NOT_AT_FLY_SPOT) {
pbf_move_left_joystick(context, 255, 128, 100ms, 100ms);
fly_from_map(env.console, context);
}
wait_until_overworld(env.console, context);
}

} // namespace

void ShinyHunt_FlySpotReset::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
assert_16_9_720p_min(env.logger(), env.console);
Expand All @@ -96,42 +202,34 @@ void ShinyHunt_FlySpotReset::program(SingleSwitchProgramEnvironment& env, ProCon
);
});

route_func route;
switch (ROUTE) {
case Route::NO_MOVEMENT:
route = route_default;
break;
case Route::WILD_ZONE_19:
route = route_wild_zone_19;
break;
case Route::ALPHA_PIDGEY:
route = route_alpha_pidgey;
break;
default:
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"route not implemented",
env.console
);
}

bool to_zoom_to_max = true;
run_until<ProControllerContext>(
env.console, context,
[&](ProControllerContext& context){
while (true){
context.wait_for_all_requests();
shiny_sound_handler.process_pending(context);

// Open map
bool can_fast_travel = open_map(env.console, context, to_zoom_to_max);
route(env, context, stats, to_zoom_to_max);
to_zoom_to_max = false;
if (!can_fast_travel){
stats.errors++;
env.update_stats();
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"FlySpotReset: Cannot open map for fast travel.",
env.console
);
}

// Move map cursor upwards a little bit
pbf_move_left_joystick(context, 128, 64, 100ms, 200ms);

// Fly from map to reset spawns
FastTravelState travel_status = fly_from_map(env.console, context);
if (travel_status != FastTravelState::SUCCESS){
stats.errors++;
env.update_stats();
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"FlySpotReset: Cannot fast travel after moving map cursor.",
env.console
);
}

stats.resets++;
env.update_stats();
if (stats.resets.load(std::memory_order_relaxed) % 10 == 0){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,18 @@ class ShinyHunt_FlySpotReset : public SingleSwitchProgramInstance{

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

private:
enum class Route{
NO_MOVEMENT,
WILD_ZONE_19,
ALPHA_PIDGEY,
ALPHA_PIKACHU,
CUSTOMISED_MACRO = 255,
};

private:
PokemonLA::ShinyRequiresAudioText SHINY_REQUIRES_AUDIO;
ShinySoundDetectedActionOption SHINY_DETECTED;
EnumDropdownOption<Route> ROUTE;

EventNotificationOption NOTIFICATION_STATUS;
EventNotificationsOption NOTIFICATIONS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#include "Common/Cpp/PrettyPrint.h"
#include "CommonFramework/VideoPipeline/VideoOverlay.h"
#include "CommonTools/Async/InferenceRoutines.h"
#include "CommonTools/VisualDetectors/BlackScreenDetector.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 "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
#include "Pokemon/Pokemon_Strings.h"
#include "PokemonLA/Inference/Sounds/PokemonLA_ShinySoundDetector.h"
#include "PokemonLZA/Programs/PokemonLZA_BasicNavigation.h"
Expand Down Expand Up @@ -61,12 +61,11 @@ ShinyHunt_ShuttleRun::ShinyHunt_ShuttleRun()
: DURATION("<b>Duration:</b><br>Run the program this long.", LockMode::UNLOCK_WHILE_RUNNING, "5 h")
, ROUTE("<b>Hunt Route:</b>",
{
// {Route::SCRAGGY, "scraggy", "Sewers: Scraggy"},
{Route::WILD_ZONE_19, "wild_zone_19", "Wild Zone 19"},
{Route::WILD_ZONE_3_TOWER, "wild_zone_3_tower", "Wild Zone 3 Tower"},
{Route::ALPHA_PIDGEOT, "alpha_pidgeot", "Alpha Pidgeot (Jaune Sector 4)"},
},
LockMode::LOCK_WHILE_RUNNING,
Route::WILD_ZONE_19
Route::WILD_ZONE_3_TOWER
)
, SHINY_DETECTED("Shiny Detected", "", "1000 ms", ShinySoundDetectedAction::NOTIFY_ON_FIRST_ONLY)
, NOTIFICATION_STATUS("Status Update", true, false, std::chrono::seconds(3600))
Expand All @@ -87,26 +86,10 @@ ShinyHunt_ShuttleRun::ShinyHunt_ShuttleRun()
namespace {


void route_scraggy(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
void route_alpha_pidgeot(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
//TODO
}

void route_wild_zone_19(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
if (run_a_straight_path_in_overworld(env.console, context, 0, 80, 6500ms) == 0) {
open_map(env.console, context, false);
pbf_move_left_joystick(context, 0, 128, 100ms, 100ms);
if (fly_from_map(env.console, context) == FastTravelState::NOT_AT_FLY_SPOT) {
pbf_move_left_joystick(context, 128, 255, 100ms, 100ms);
fly_from_map(env.console, context);
}
} else {
open_map(env.console, context, false);
pbf_move_left_joystick(context, 0, 128, 100ms, 100ms);
fly_from_map(env.console, context);
}
wait_until_overworld(env.console, context, 50s);
}

void route_wild_zone_3_tower(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
for(int i = 0; i < 6; i++){
// if there is no day/night change and no button drop, this loop should only have three iterations
Expand Down Expand Up @@ -155,11 +138,8 @@ void ShinyHunt_ShuttleRun::program(SingleSwitchProgramEnvironment& env, ProContr
});
std::function<void(SingleSwitchProgramEnvironment&, ProControllerContext&)> route;
switch (ROUTE) {
case Route::SCRAGGY:
route = route_scraggy;
break;
case Route::WILD_ZONE_19:
route = route_wild_zone_19;
case Route::ALPHA_PIDGEOT:
route = route_alpha_pidgeot;
break;
case Route:: WILD_ZONE_3_TOWER:
route = route_wild_zone_3_tower;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ class ShinyHunt_ShuttleRun : public SingleSwitchProgramInstance {
virtual void program(SingleSwitchProgramEnvironment& env, ProControllerContext& context) override;

enum class Route{
SCRAGGY,
WILD_ZONE_19,
FIRE_STARTERS,
DRATINI,
WILD_ZONE_3_TOWER,
ALPHA_PIDGEOT,
CUSTOMISED_MACRO = 255,
};

Expand Down