Skip to content

Commit 650c623

Browse files
author
Gin
committed
Add option to reset game and skip cur outbreak
1 parent a4392ed commit 650c623

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

SerialPrograms/Source/PokemonLA/PokemonLA_TravelLocations.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ TravelLocations::TravelLocations()
165165
"Alabaster Icelands - Icepeak Arena",
166166
MapRegion::ICELANDS, 0, 2, nullptr, true
167167
)
168+
, Retreat(
169+
"retreat",
170+
"Ancient Retreat",
171+
MapRegion::RETREAT, 0, 0, nullptr, false
172+
)
168173
{
169174
add_location(Fieldlands_Fieldlands);
170175
add_location(Fieldlands_Heights);
@@ -190,6 +195,7 @@ TravelLocations::TravelLocations()
190195
add_location(Icelands_PearlSettlement);
191196
add_location(Icelands_PearlSettlement_SW);
192197
add_location(Icelands_Arena);
198+
add_location(Retreat);
193199
}
194200

195201

SerialPrograms/Source/PokemonLA/PokemonLA_TravelLocations.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ class TravelLocations{
7979
const TravelLocation Icelands_PearlSettlement_SW;
8080
const TravelLocation Icelands_Arena;
8181

82+
const TravelLocation Retreat;
83+
8284

8385
private:
8486
TravelLocations();

SerialPrograms/Source/PokemonLA/Programs/General/PokemonLA_OutbreakFinder.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ std::unique_ptr<StatsTracker> OutbreakFinder_Descriptor::make_stats() const{
182182

183183
OutbreakFinder::OutbreakFinder()
184184
: GO_HOME_WHEN_DONE(false)
185+
, RESET_GAME_AND_CONTINUE_SEARCHING(
186+
"<b>Reset game and continue searching at start</b><br>If the last outbreak found by the program does not yield what you want, check "
187+
"this option to let the program reset the game and skip the ongoing outbreaks at start, before continuing the search.<br>"
188+
"Note: you must have saved at Jubilife Village front gate beforehand.",
189+
LockMode::LOCK_WHILE_RUNNING,
190+
false
191+
)
185192
, LANGUAGE(
186193
"<b>Game Language:</b>",
187194
Pokemon::PokemonNameReader::instance().languages(),
@@ -218,6 +225,7 @@ OutbreakFinder::OutbreakFinder()
218225
&NOTIFICATION_ERROR_FATAL,
219226
})
220227
{
228+
PA_ADD_OPTION(RESET_GAME_AND_CONTINUE_SEARCHING);
221229
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
222230
PA_ADD_OPTION(LANGUAGE);
223231
PA_ADD_OPTION(DESIRED_MO_SLUGS);
@@ -336,6 +344,8 @@ std::set<std::string> OutbreakFinder::read_travel_map_outbreaks(
336344
void OutbreakFinder::goto_region_and_return(SingleSwitchProgramEnvironment& env, ProControllerContext& context,
337345
bool inside_travel_map
338346
){
347+
env.log("Go to a random region and back to refresh outbreaks...");
348+
env.console.overlay().add_log("Refresh outbreaks");
339349
OutbreakFinder_Descriptor::Stats& stats = env.current_stats<OutbreakFinder_Descriptor::Stats>();
340350

341351
if (inside_travel_map == false){
@@ -730,12 +740,14 @@ bool OutbreakFinder::run_iteration(
730740
os << "Found desired MMO pokemon (including desired MMO pokemon with star symbols): ";
731741
for (const auto& pokemon : found_pokemon){
732742
os << pokemon << ", ";
743+
env.console.overlay().add_log("Found " + pokemon);
733744
}
734745
env.log(os.str());
735746
return true;
736747
}
737748

738749
env.log("No target MMO sprite found. Reset game...");
750+
env.console.overlay().add_log("No target MMO");
739751
pbf_press_button(context, BUTTON_HOME, 160ms, GameSettings::instance().GAME_TO_HOME_DELAY0);
740752
reset_game_from_home(env, env.console, context, ConsoleSettings::instance().TOLERATE_SYSTEM_UPDATE_MENU_FAST);
741753
}
@@ -745,7 +757,6 @@ bool OutbreakFinder::run_iteration(
745757
send_program_status_notification(env, NOTIFICATION_STATUS);
746758

747759
// Go to region and return.
748-
env.log("Go to a random region and back to refresh outbreaks...");
749760
goto_region_and_return(env, context, inside_travel_map);
750761

751762
return false;
@@ -761,10 +772,20 @@ std::set<std::string> OutbreakFinder::to_set(const StringSelectTableOption& opti
761772
}
762773

763774
void OutbreakFinder::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
764-
// OutbreakFinder_Descriptor::Stats& stats = env.current_stats<OutbreakFinder_Descriptor::Stats>();
765775

766-
// goto_Mai_from_camp(env.logger(), context, Camp::HIGHLANDS_HIGHLANDS);
767-
// return;
776+
if (RESET_GAME_AND_CONTINUE_SEARCHING){
777+
// press a random button to let Switch register the wired controller
778+
pbf_press_button(context, BUTTON_ZL, 10ms, 30ms);
779+
// the outbreak found by the last program run did not yield what the user wants.
780+
// so we reset the game now and skip the ongoing outbreaks
781+
env.log("Reset game and skip ongoing outbreaks");
782+
pbf_press_button(context, BUTTON_HOME, 160ms, GameSettings::instance().GAME_TO_HOME_DELAY0);
783+
reset_game_from_home(env, env.console, context, ConsoleSettings::instance().TOLERATE_SYSTEM_UPDATE_MENU_FAST);
784+
785+
// Go to region and return.
786+
bool inside_travel_map = false;
787+
goto_region_and_return(env, context, inside_travel_map);
788+
}
768789

769790
std::set<std::string> desired_outbreaks = to_set(DESIRED_MO_SLUGS);
770791
std::set<std::string> desired_MMO_pokemon = to_set(DESIRED_MMO_SLUGS);

SerialPrograms/Source/PokemonLA/Programs/General/PokemonLA_OutbreakFinder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class OutbreakFinder : public SingleSwitchProgramInstance{
8282

8383
private:
8484
GoHomeWhenDoneOption GO_HOME_WHEN_DONE;
85+
BooleanCheckBoxOption RESET_GAME_AND_CONTINUE_SEARCHING;
8586

8687
OCR::LanguageOCROption LANGUAGE;
8788

SerialPrograms/Source/PokemonLA/Programs/PokemonLA_RegionNavigation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ void goto_camp_from_jubilife(
247247
ProgramEnvironment& env, VideoStream& stream, ProControllerContext& context,
248248
const TravelLocation& location
249249
){
250+
stream.overlay().add_log("Travel to " + std::string(MAP_REGION_NAMES[int(location.region)]));
250251
// Move backwards and talk to guard to open the map.
251252
context.wait_for_all_requests();
252253
open_travel_map_from_jubilife(env, stream, context);

0 commit comments

Comments
 (0)