Skip to content

Commit 65b5e93

Browse files
author
Gin
committed
Add hyperspace wildzone reset route to fly spot reset
1 parent 14995c8 commit 65b5e93

File tree

8 files changed

+94
-6
lines changed

8 files changed

+94
-6
lines changed

SerialPrograms/Scripts/check_detector_regions.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,17 @@
3232

3333
raw_image = image.copy()
3434

35+
# ==================================================================
36+
# LZA Map detector
37+
add_infer_box_to_image(raw_image, 0.760730, 0.937023, 0.241416, 0.064885, image)
38+
add_infer_box_to_image(raw_image, 0.005000, 0.150000, 0.025000, 0.110000, image)
39+
add_infer_box_to_image(raw_image, 0.005000, 0.210000, 0.025000, 0.110000, image)
3540

3641

3742
# ==================================================================
3843
# LZA alert eye detector
39-
add_infer_box_to_image(raw_image, 0.485, 0.088, 0.029, 0.034, image)
40-
add_infer_box_to_image(raw_image, 0.464, 0.142, 0.071, 0.074, image)
44+
# add_infer_box_to_image(raw_image, 0.485, 0.088, 0.029, 0.034, image)
45+
# add_infer_box_to_image(raw_image, 0.464, 0.142, 0.071, 0.074, image)
4146

4247

4348
# ==================================================================

SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_BasicNavigation.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,46 @@ bool open_map(ConsoleHandle& console, ProControllerContext& context, bool zoom_t
165165
);
166166
}
167167

168+
void open_hyperspace_map(ConsoleHandle& console, ProControllerContext& context){
169+
pbf_press_button(context, BUTTON_PLUS, 240ms, 40ms);
170+
context.wait_for_all_requests();
171+
console.log("Opening Hyperspace Map...");
172+
console.overlay().add_log("Open Hyperspace Map");
173+
174+
WallClock deadline = current_time() + 30s;
175+
176+
MapWatcher map_detector(COLOR_RED, &console.overlay());
177+
178+
do{
179+
map_detector.reset_state();
180+
181+
int ret = wait_until(
182+
console, context,
183+
5000ms,
184+
{map_detector}
185+
);
186+
switch (ret){
187+
case 0:
188+
console.log("Detected map!", COLOR_BLUE);
189+
console.overlay().add_log("Map Detected");
190+
return;
191+
default:
192+
console.log("Map not found. Press + again", COLOR_ORANGE);
193+
pbf_press_button(context, BUTTON_PLUS, 240ms, 80ms);
194+
console.overlay().add_log("Map not Found. Press + Again");
195+
context.wait_for_all_requests();
196+
}
197+
198+
}while (current_time() < deadline);
199+
200+
console.overlay().add_log("Failed to Open Hyperspace Map After 30 sec", COLOR_RED);
201+
OperationFailedException::fire(
202+
ErrorReport::SEND_ERROR_REPORT,
203+
"open_map(): Unable to find map after 30 seconds.",
204+
console
205+
);
206+
}
207+
168208

169209
FastTravelState fly_from_map(ConsoleHandle& console, ProControllerContext& context){
170210
console.log("Flying from map...");

SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_BasicNavigation.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ enum class FastTravelState{
4040
// that state if we need
4141
};
4242

43-
// Press button + to open the map.
43+
// Press button + to open the normal Lumiose map.
4444
// Will repeatedly pressing button + to ensure the map is opened.
4545
// Robust against day/night changes: if there is a day/night chane before opening the map,
4646
// it will keep trying to open the map until day/night change finishes.
@@ -49,6 +49,12 @@ enum class FastTravelState{
4949
// Note the function uses flyable fast travel icons on map to detect if you are being chased. This
5050
// means for most reliable detection, set zoom_to_max to True.
5151
bool open_map(ConsoleHandle& console, ProControllerContext& context, bool zoom_to_max = false);
52+
53+
// Press button + to open Hyperspace Lumiose map.
54+
// Will repeatedly pressing button + to ensure the map is opened.
55+
// It does not detect whether the player can fast travel or not.
56+
void open_hyperspace_map(ConsoleHandle& console, ProControllerContext& context);
57+
5258
// Starting at map view, press A to fast travel to the current selected fast travel location
5359
// Return FastTravelState:
5460
// - SUCCESS: fast travel successful. After the function returns, the player character is on the overworld

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

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ ShinyHunt_FlySpotReset::ShinyHunt_FlySpotReset()
6262
: SHINY_DETECTED("Shiny Detected", "", "2000 ms", ShinySoundDetectedAction::NOTIFY_ON_FIRST_ONLY)
6363
, ROUTE("<b>Hunt Route:</b>",
6464
{
65-
{Route::NO_MOVEMENT, "no_movement", "No Movement"},
65+
{Route::NO_MOVEMENT, "no_movement", "No Movement in Lumiose"},
66+
{Route::HYPERSPACE_WILD_ZONE, "hyperspace_wild_zone", "Hyperspace Wild Zone"},
6667
{Route::WILD_ZONE_19, "wild_zone_19", "Wild Zone 19"},
6768
{Route::ALPHA_PIDGEY, "alpha_pidgey", "Alpha Pidgey (Wild Zone 1)"},
6869
// {Route::ALPHA_PIKACHU, "alpha_pikachu", "Alpha Pikachu (Wild Zone 6)"},
@@ -102,7 +103,7 @@ void route_default(
102103
env.update_stats();
103104
OperationFailedException::fire(
104105
ErrorReport::SEND_ERROR_REPORT,
105-
"FlySpotReset: Cannot open map for fast travel.",
106+
"route_default(): Cannot open map for fast travel.",
106107
env.console
107108
);
108109
}
@@ -117,7 +118,27 @@ void route_default(
117118
env.update_stats();
118119
OperationFailedException::fire(
119120
ErrorReport::SEND_ERROR_REPORT,
120-
"FlySpotReset: Cannot fast travel after moving map cursor.",
121+
"route_default(): Cannot fast travel after moving map cursor.",
122+
env.console
123+
);
124+
}
125+
}
126+
127+
void route_hyperspace_wild_zone(
128+
SingleSwitchProgramEnvironment& env,
129+
ProControllerContext& context,
130+
ShinyHunt_FlySpotReset_Descriptor::Stats& stats,
131+
bool to_zoom_to_max){
132+
open_hyperspace_map(env.console, context);
133+
134+
// Fly from map to reset spawns
135+
FastTravelState travel_status = fly_from_map(env.console, context);
136+
if (travel_status != FastTravelState::SUCCESS){
137+
stats.errors++;
138+
env.update_stats();
139+
OperationFailedException::fire(
140+
ErrorReport::SEND_ERROR_REPORT,
141+
"route_hyperspace_wild_zone(): Cannot fast travel after moving map cursor.",
121142
env.console
122143
);
123144
}
@@ -207,6 +228,9 @@ void ShinyHunt_FlySpotReset::program(SingleSwitchProgramEnvironment& env, ProCon
207228
case Route::NO_MOVEMENT:
208229
route = route_default;
209230
break;
231+
case Route::HYPERSPACE_WILD_ZONE:
232+
route = route_hyperspace_wild_zone;
233+
break;
210234
case Route::WILD_ZONE_19:
211235
route = route_wild_zone_19;
212236
break;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class ShinyHunt_FlySpotReset : public SingleSwitchProgramInstance{
3636

3737
enum class Route{
3838
NO_MOVEMENT,
39+
HYPERSPACE_WILD_ZONE,
3940
WILD_ZONE_19,
4041
ALPHA_PIDGEY,
4142
ALPHA_PIKACHU,

SerialPrograms/Source/Tests/PokemonLZA_Tests.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "PokemonLZA/Inference/Boxes/PokemonLZA_BoxDetection.h"
1616
#include "PokemonLZA/Inference/Boxes/PokemonLZA_BoxInfoDetector.h"
1717
#include "PokemonLZA/Inference/Map/PokemonLZA_MapIconDetector.h"
18+
#include "PokemonLZA/Inference/Map/PokemonLZA_MapDetector.h"
1819
#include "PokemonLZA/Inference/Map/PokemonLZA_DirectionArrowDetector.h"
1920
#include "PokemonLZA/Inference/PokemonLZA_OverworldPartySelectionDetector.h"
2021
#include "CommonFramework/ImageTools/ImageBoxes.h"
@@ -518,5 +519,13 @@ int test_pokemonLZA_DirectionArrowDetector(const ImageViewRGB32& image, int targ
518519
return 0;
519520
}
520521

522+
int test_pokemonLZA_MapDetector(const ImageViewRGB32& image, bool target){
523+
auto overlay = DummyVideoOverlay();
524+
MapDetector detector(COLOR_RED, &overlay);
525+
bool result = detector.detect(image);
526+
TEST_RESULT_EQUAL(result, target);
527+
return 0;
528+
}
529+
521530

522531
}

SerialPrograms/Source/Tests/PokemonLZA_Tests.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343

4444
int test_pokemonLZA_DirectionArrowDetector(const ImageViewRGB32& image, int target_angle);
4545

46+
int test_pokemonLZA_MapDetector(const ImageViewRGB32& image, bool target);
47+
4648
}
4749

4850
#endif

SerialPrograms/Source/Tests/TestMap.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ const std::map<std::string, TestFunction> TEST_MAP = {
300300
{"PokemonLZA_MapIconDetector", test_pokemonLZA_MapIconDetector},
301301
{"PokemonLZA_OverworldPartySelectionDetector", std::bind(image_words_detector_helper, test_pokemonLZA_OverworldPartySelectionDetector, _1)},
302302
{"PokemonLZA_DirectionArrowDetector", std::bind(image_int_detector_helper, test_pokemonLZA_DirectionArrowDetector, _1)},
303+
{"PokemonLZA_MapDetector", std::bind(image_bool_detector_helper, test_pokemonLZA_MapDetector, _1)},
303304
};
304305

305306
TestFunction find_test_function(const std::string& test_space, const std::string& test_name){

0 commit comments

Comments
 (0)