Skip to content

Commit 2f67e6d

Browse files
committed
move wild zone 19 route to FlySpotReset
1 parent 3d3cd66 commit 2f67e6d

File tree

4 files changed

+105
-60
lines changed

4 files changed

+105
-60
lines changed

SerialPrograms/Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_ShinyHunt_FlySpotReset.cpp

Lines changed: 87 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ std::unique_ptr<StatsTracker> ShinyHunt_FlySpotReset_Descriptor::make_stats() co
5858

5959
ShinyHunt_FlySpotReset::ShinyHunt_FlySpotReset()
6060
: SHINY_DETECTED("Shiny Detected", "", "2000 ms", ShinySoundDetectedAction::NOTIFY_ON_FIRST_ONLY)
61+
, ROUTE("<b>Hunt Route:</b>",
62+
{
63+
{Route::NO_MOVEMENT, "no_movement", "No Movement"},
64+
{Route::WILD_ZONE_19, "wild_zone_19", "Wild Zone 19"},
65+
// {Route::ALPHA_PIDGEY, "alpha_pidgey", "Alpha Pidgey (Wild Zone 1)"},
66+
// {Route::ALPHA_PIKACHU, "alpha_pikachu", "Alpha Pikachu (Wild Zone 6)"},
67+
// {Route::CUSTOMISED_MACRO, "customised_macro", "Customised Macro"},
68+
},
69+
LockMode::LOCK_WHILE_RUNNING,
70+
Route::NO_MOVEMENT
71+
)
6172
, NOTIFICATION_STATUS("Status Update", true, false, std::chrono::seconds(3600))
6273
, NOTIFICATIONS({
6374
&NOTIFICATION_STATUS,
@@ -68,10 +79,69 @@ ShinyHunt_FlySpotReset::ShinyHunt_FlySpotReset()
6879
})
6980
{
7081
PA_ADD_STATIC(SHINY_REQUIRES_AUDIO);
82+
PA_ADD_OPTION(ROUTE);
7183
PA_ADD_OPTION(SHINY_DETECTED);
7284
PA_ADD_OPTION(NOTIFICATIONS);
7385
}
7486

87+
namespace {
88+
89+
typedef std::function<void(SingleSwitchProgramEnvironment&, ProControllerContext&, ShinyHunt_FlySpotReset_Descriptor::Stats&, bool)> route_func;
90+
91+
void route_default(
92+
SingleSwitchProgramEnvironment& env,
93+
ProControllerContext& context,
94+
ShinyHunt_FlySpotReset_Descriptor::Stats& stats,
95+
bool to_zoom_to_max){
96+
// Open map
97+
bool can_fast_travel = open_map(env.console, context, to_zoom_to_max);
98+
if (!can_fast_travel){
99+
stats.errors++;
100+
env.update_stats();
101+
OperationFailedException::fire(
102+
ErrorReport::SEND_ERROR_REPORT,
103+
"FlySpotReset: Cannot open map for fast travel.",
104+
env.console
105+
);
106+
}
107+
108+
// Move map cursor upwards a little bit
109+
pbf_move_left_joystick(context, 128, 64, 100ms, 200ms);
110+
111+
// Fly from map to reset spawns
112+
FastTravelState travel_status = fly_from_map(env.console, context);
113+
if (travel_status != FastTravelState::SUCCESS){
114+
stats.errors++;
115+
env.update_stats();
116+
OperationFailedException::fire(
117+
ErrorReport::SEND_ERROR_REPORT,
118+
"FlySpotReset: Cannot fast travel after moving map cursor.",
119+
env.console
120+
);
121+
}
122+
}
123+
124+
void route_wild_zone_19(
125+
SingleSwitchProgramEnvironment& env,
126+
ProControllerContext& context,
127+
ShinyHunt_FlySpotReset_Descriptor::Stats& stats,
128+
bool to_zoom_to_max){
129+
if (run_a_straight_path_in_overworld(env.console, context, 0, 80, 6500ms) == 0) {
130+
open_map(env.console, context, to_zoom_to_max);
131+
pbf_move_left_joystick(context, 0, 64, 100ms, 100ms);
132+
if (fly_from_map(env.console, context) == FastTravelState::NOT_AT_FLY_SPOT) {
133+
pbf_move_left_joystick(context, 128, 192, 100ms, 100ms);
134+
fly_from_map(env.console, context);
135+
}
136+
} else {
137+
open_map(env.console, context, to_zoom_to_max);
138+
pbf_move_left_joystick(context, 0, 64, 100ms, 100ms);
139+
fly_from_map(env.console, context);
140+
}
141+
wait_until_overworld(env.console, context, 50s);
142+
}
143+
144+
} // namespace
75145

76146
void ShinyHunt_FlySpotReset::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
77147
assert_16_9_720p_min(env.logger(), env.console);
@@ -96,42 +166,31 @@ void ShinyHunt_FlySpotReset::program(SingleSwitchProgramEnvironment& env, ProCon
96166
);
97167
});
98168

169+
route_func route;
170+
switch (ROUTE) {
171+
case Route::NO_MOVEMENT:
172+
route = route_default;
173+
break;
174+
case Route::WILD_ZONE_19:
175+
route = route_wild_zone_19;
176+
break;
177+
default:
178+
OperationFailedException::fire(
179+
ErrorReport::SEND_ERROR_REPORT,
180+
"route not implemented",
181+
env.console
182+
);
183+
}
184+
99185
bool to_zoom_to_max = true;
100186
run_until<ProControllerContext>(
101187
env.console, context,
102188
[&](ProControllerContext& context){
103189
while (true){
104190
context.wait_for_all_requests();
105191
shiny_sound_handler.process_pending(context);
106-
107-
// Open map
108-
bool can_fast_travel = open_map(env.console, context, to_zoom_to_max);
192+
route(env, context, stats, to_zoom_to_max);
109193
to_zoom_to_max = false;
110-
if (!can_fast_travel){
111-
stats.errors++;
112-
env.update_stats();
113-
OperationFailedException::fire(
114-
ErrorReport::SEND_ERROR_REPORT,
115-
"FlySpotReset: Cannot open map for fast travel.",
116-
env.console
117-
);
118-
}
119-
120-
// Move map cursor upwards a little bit
121-
pbf_move_left_joystick(context, 128, 64, 100ms, 200ms);
122-
123-
// Fly from map to reset spawns
124-
FastTravelState travel_status = fly_from_map(env.console, context);
125-
if (travel_status != FastTravelState::SUCCESS){
126-
stats.errors++;
127-
env.update_stats();
128-
OperationFailedException::fire(
129-
ErrorReport::SEND_ERROR_REPORT,
130-
"FlySpotReset: Cannot fast travel after moving map cursor.",
131-
env.console
132-
);
133-
}
134-
135194
stats.resets++;
136195
env.update_stats();
137196
if (stats.resets.load(std::memory_order_relaxed) % 10 == 0){

SerialPrograms/Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_ShinyHunt_FlySpotReset.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,18 @@ class ShinyHunt_FlySpotReset : public SingleSwitchProgramInstance{
3434

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

37-
private:
37+
enum class Route{
38+
NO_MOVEMENT,
39+
WILD_ZONE_19,
40+
ALPHA_PIDGEY,
41+
ALPHA_PIKACHU,
42+
CUSTOMISED_MACRO = 255,
43+
};
44+
45+
private:
3846
PokemonLA::ShinyRequiresAudioText SHINY_REQUIRES_AUDIO;
3947
ShinySoundDetectedActionOption SHINY_DETECTED;
48+
EnumDropdownOption<Route> ROUTE;
4049

4150
EventNotificationOption NOTIFICATION_STATUS;
4251
EventNotificationsOption NOTIFICATIONS;

SerialPrograms/Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_ShuttleRun.cpp

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
#include "CommonFramework/Notifications/ProgramNotifications.h"
1010
#include "CommonFramework/VideoPipeline/VideoOverlay.h"
1111
#include "CommonTools/Async/InferenceRoutines.h"
12-
#include "CommonTools/VisualDetectors/BlackScreenDetector.h"
12+
// #include "CommonTools/VisualDetectors/BlackScreenDetector.h"
1313
#include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h"
1414
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
15-
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
15+
// #include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
1616
#include "Pokemon/Pokemon_Strings.h"
1717
#include "PokemonLA/Inference/Sounds/PokemonLA_ShinySoundDetector.h"
1818
#include "PokemonLZA/Programs/PokemonLZA_BasicNavigation.h"
@@ -60,11 +60,10 @@ ShinyHunt_ShuttleRun::ShinyHunt_ShuttleRun()
6060
: DURATION("<b>Duration:</b><br>Run the program this long.", LockMode::UNLOCK_WHILE_RUNNING, "5 h")
6161
, ROUTE("<b>Hunt Route:</b>",
6262
{
63-
// {Route::SCRAGGY, "scraggy", "Sewers: Scraggy"},
64-
{Route::WILD_ZONE_19, "wild_zone_19", "Wild Zone 19"},
63+
{Route::ALPHA_PIDGEOT, "alpha_pidgeot", "Alpha Pidgeot (Jaune Sector 4)"},
6564
},
6665
LockMode::LOCK_WHILE_RUNNING,
67-
Route::WILD_ZONE_19
66+
Route::ALPHA_PIDGEOT
6867
)
6968
, SHINY_DETECTED("Shiny Detected", "", "1000 ms", ShinySoundDetectedAction::NOTIFY_ON_FIRST_ONLY)
7069
, NOTIFICATION_STATUS("Status Update", true, false, std::chrono::seconds(3600))
@@ -85,26 +84,10 @@ ShinyHunt_ShuttleRun::ShinyHunt_ShuttleRun()
8584
namespace {
8685

8786

88-
void route_scraggy(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
87+
void route_alpha_pidgeot(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
8988
//TODO
9089
}
9190

92-
void route_wild_zone_19(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
93-
if (run_a_straight_path_in_overworld(env.console, context, 0, 80, 6500ms) == 0) {
94-
open_map(env.console, context, false);
95-
pbf_move_left_joystick(context, 0, 128, 100ms, 100ms);
96-
if (fly_from_map(env.console, context) == FastTravelState::NOT_AT_FLY_SPOT) {
97-
pbf_move_left_joystick(context, 128, 255, 100ms, 100ms);
98-
fly_from_map(env.console, context);
99-
}
100-
} else {
101-
open_map(env.console, context, false);
102-
pbf_move_left_joystick(context, 0, 128, 100ms, 100ms);
103-
fly_from_map(env.console, context);
104-
}
105-
wait_until_overworld(env.console, context, 50s);
106-
}
107-
10891
} // namespace
10992

11093
void ShinyHunt_ShuttleRun::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
@@ -124,11 +107,8 @@ void ShinyHunt_ShuttleRun::program(SingleSwitchProgramEnvironment& env, ProContr
124107
});
125108
std::function<void(SingleSwitchProgramEnvironment&, ProControllerContext&)> route;
126109
switch (ROUTE) {
127-
case Route::SCRAGGY:
128-
route = route_scraggy;
129-
break;
130-
case Route::WILD_ZONE_19:
131-
route = route_wild_zone_19;
110+
case Route::ALPHA_PIDGEOT:
111+
route = route_alpha_pidgeot;
132112
break;
133113
default:
134114
OperationFailedException::fire(

SerialPrograms/Source/PokemonLZA/Programs/ShinyHunting/PokemonLZA_ShuttleRun.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ class ShinyHunt_ShuttleRun : public SingleSwitchProgramInstance {
3535
virtual void program(SingleSwitchProgramEnvironment& env, ProControllerContext& context) override;
3636

3737
enum class Route{
38-
SCRAGGY,
39-
WILD_ZONE_19,
40-
FIRE_STARTERS,
41-
DRATINI,
38+
ALPHA_PIDGEOT,
4239
CUSTOMISED_MACRO = 255,
4340
};
4441

0 commit comments

Comments
 (0)