Skip to content

Commit fa8845a

Browse files
naussikaGin890
authored andcommitted
move wild zone 19 route to FlySpotReset
1 parent cc5e0bc commit fa8845a

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
@@ -10,10 +10,10 @@
1010
#include "Common/Cpp/PrettyPrint.h"
1111
#include "CommonFramework/VideoPipeline/VideoOverlay.h"
1212
#include "CommonTools/Async/InferenceRoutines.h"
13-
#include "CommonTools/VisualDetectors/BlackScreenDetector.h"
13+
// #include "CommonTools/VisualDetectors/BlackScreenDetector.h"
1414
#include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h"
1515
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
16-
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
16+
// #include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
1717
#include "Pokemon/Pokemon_Strings.h"
1818
#include "PokemonLA/Inference/Sounds/PokemonLA_ShinySoundDetector.h"
1919
#include "PokemonLZA/Programs/PokemonLZA_BasicNavigation.h"
@@ -61,12 +61,11 @@ ShinyHunt_ShuttleRun::ShinyHunt_ShuttleRun()
6161
: DURATION("<b>Duration:</b><br>Run the program this long.", LockMode::UNLOCK_WHILE_RUNNING, "5 h")
6262
, ROUTE("<b>Hunt Route:</b>",
6363
{
64-
// {Route::SCRAGGY, "scraggy", "Sewers: Scraggy"},
65-
{Route::WILD_ZONE_19, "wild_zone_19", "Wild Zone 19"},
6664
{Route::WILD_ZONE_3_TOWER, "wild_zone_3_tower", "Wild Zone 3 Tower"},
65+
{Route::ALPHA_PIDGEOT, "alpha_pidgeot", "Alpha Pidgeot (Jaune Sector 4)"},
6766
},
6867
LockMode::LOCK_WHILE_RUNNING,
69-
Route::WILD_ZONE_19
68+
Route::WILD_ZONE_3_TOWER
7069
)
7170
, SHINY_DETECTED("Shiny Detected", "", "1000 ms", ShinySoundDetectedAction::NOTIFY_ON_FIRST_ONLY)
7271
, NOTIFICATION_STATUS("Status Update", true, false, std::chrono::seconds(3600))
@@ -87,26 +86,10 @@ ShinyHunt_ShuttleRun::ShinyHunt_ShuttleRun()
8786
namespace {
8887

8988

90-
void route_scraggy(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
89+
void route_alpha_pidgeot(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
9190
//TODO
9291
}
9392

94-
void route_wild_zone_19(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
95-
if (run_a_straight_path_in_overworld(env.console, context, 0, 80, 6500ms) == 0) {
96-
open_map(env.console, context, false);
97-
pbf_move_left_joystick(context, 0, 128, 100ms, 100ms);
98-
if (fly_from_map(env.console, context) == FastTravelState::NOT_AT_FLY_SPOT) {
99-
pbf_move_left_joystick(context, 128, 255, 100ms, 100ms);
100-
fly_from_map(env.console, context);
101-
}
102-
} else {
103-
open_map(env.console, context, false);
104-
pbf_move_left_joystick(context, 0, 128, 100ms, 100ms);
105-
fly_from_map(env.console, context);
106-
}
107-
wait_until_overworld(env.console, context, 50s);
108-
}
109-
11093
void route_wild_zone_3_tower(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
11194
for(int i = 0; i < 6; i++){
11295
// if there is no day/night change and no button drop, this loop should only have three iterations
@@ -155,11 +138,8 @@ void ShinyHunt_ShuttleRun::program(SingleSwitchProgramEnvironment& env, ProContr
155138
});
156139
std::function<void(SingleSwitchProgramEnvironment&, ProControllerContext&)> route;
157140
switch (ROUTE) {
158-
case Route::SCRAGGY:
159-
route = route_scraggy;
160-
break;
161-
case Route::WILD_ZONE_19:
162-
route = route_wild_zone_19;
141+
case Route::ALPHA_PIDGEOT:
142+
route = route_alpha_pidgeot;
163143
break;
164144
case Route:: WILD_ZONE_3_TOWER:
165145
route = route_wild_zone_3_tower;

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,8 @@ 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,
4238
WILD_ZONE_3_TOWER,
39+
ALPHA_PIDGEOT,
4340
CUSTOMISED_MACRO = 255,
4441
};
4542

0 commit comments

Comments
 (0)