Skip to content

Commit 7a4ca3e

Browse files
committed
working farmer
1 parent 42ec6a8 commit 7a4ca3e

File tree

2 files changed

+33
-18
lines changed

2 files changed

+33
-18
lines changed

SerialPrograms/Source/PokemonLGPE/Programs/Farming/PokemonLGPE_DailyItemRespawnFarmer.cpp

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,10 @@ DailyItemRespawnFarmer_Descriptor::DailyItemRespawnFarmer_Descriptor()
4343
struct DailyItemRespawnFarmer_Descriptor::Stats : public StatsTracker{
4444
Stats()
4545
: skips(m_stats["Skips"])
46-
, resets(m_stats["Resets"])
4746
{
4847
m_display_order.emplace_back("Skips");
49-
m_display_order.emplace_back("Resets");
5048
}
5149
std::atomic<uint64_t>& skips;
52-
std::atomic<uint64_t>& resets;
5350
};
5451
std::unique_ptr<StatsTracker> DailyItemRespawnFarmer_Descriptor::make_stats() const{
5552
return std::unique_ptr<StatsTracker>(new Stats());
@@ -62,7 +59,7 @@ DailyItemRespawnFarmer::DailyItemRespawnFarmer()
6259
30, 1
6360
)
6461
, LINK_CODE(
65-
"<b>Link Code:</b><br>Only needed when running multiple LGPE date-skip programs at the same time. The link code used when matching for a trade/battle.",
62+
"<b>Link Code:</b><br>The link code used when matching for a trade/battle. This only needs to be changed when running multiple LGPE date-skip programs at the same time.",
6663
{ //Combinations of 3 different symbols is possible but 10 choices seems like enough.
6764
{LinkCode::Pikachu, "pikachu", "Pikachu"},
6865
{LinkCode::Eevee, "eevee", "Eevee"},
@@ -78,11 +75,11 @@ DailyItemRespawnFarmer::DailyItemRespawnFarmer()
7875
LockMode::LOCK_WHILE_RUNNING,
7976
LinkCode::Pikachu
8077
)
81-
, GO_HOME_WHEN_DONE(false)
8278
, FIX_TIME_WHEN_DONE(
8379
"<b>Fix Time when Done:</b><br>Fix the time after the program finishes.",
8480
LockMode::UNLOCK_WHILE_RUNNING, false
8581
)
82+
, GO_HOME_WHEN_DONE(false)
8683
, NOTIFICATION_STATUS_UPDATE("Status Update", true, false, std::chrono::seconds(3600))
8784
, NOTIFICATIONS({
8885
&NOTIFICATION_STATUS_UPDATE,
@@ -91,8 +88,8 @@ DailyItemRespawnFarmer::DailyItemRespawnFarmer()
9188
{
9289
PA_ADD_OPTION(ATTEMPTS);
9390
PA_ADD_OPTION(LINK_CODE);
94-
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
9591
PA_ADD_OPTION(FIX_TIME_WHEN_DONE);
92+
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
9693
PA_ADD_OPTION(NOTIFICATIONS);
9794
}
9895

@@ -109,15 +106,20 @@ void DailyItemRespawnFarmer::program(SingleSwitchProgramEnvironment& env, Cancel
109106
* Should work for other hidden daily items, game corner, mt moon moonstones, etc.
110107
*/
111108

109+
uint8_t year = MAX_YEAR;
110+
112111
for (uint32_t count = 0; count < ATTEMPTS; count++) {
113112
//Pick up item
114-
pbf_mash_button(context, BUTTON_A, 3000ms);
113+
pbf_mash_button(context, BUTTON_A, 4000ms);
114+
context.wait_for_all_requests();
115115

116116
//Open Menu -> Communication -> Nearby player -> Local Trade
117117
pbf_press_button(context, BUTTON_X, 200ms, 500ms);
118118
pbf_move_joystick(context, 255, 128, 100ms, 100ms);
119119
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
120120
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
121+
pbf_wait(context, 1000ms); //Black screen
122+
context.wait_for_all_requests();
121123
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
122124
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
123125

@@ -165,17 +167,28 @@ void DailyItemRespawnFarmer::program(SingleSwitchProgramEnvironment& env, Cancel
165167
break;
166168
}
167169
//Select symbol three times, then enter link search
168-
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
169-
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
170-
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
170+
pbf_press_button(context, BUTTON_A, 200ms, 100ms);
171+
pbf_press_button(context, BUTTON_A, 200ms, 100ms);
172+
pbf_press_button(context, BUTTON_A, 200ms, 100ms);
173+
pbf_wait(context, 1000ms); //let search start
174+
context.wait_for_all_requests();
171175

172176
//Dateskip
177+
pbf_press_button(context, BUTTON_HOME, 160ms, 1000ms);
178+
home_to_date_time(context, true);
179+
if (year >= MAX_YEAR){
180+
roll_date_backward_N(context, MAX_YEAR);
181+
year = 0;
182+
}else{
183+
roll_date_forward_1(context);
184+
year++;
185+
}
186+
pbf_press_button(context, BUTTON_HOME, 160ms, ConsoleSettings::instance().SETTINGS_TO_HOME_DELAY0);
173187

174-
//Re-enter game
175-
176-
//Close out link menu
177-
178-
//stats.
188+
//Re-enter game and close out link menu
189+
pbf_press_button(context, BUTTON_HOME, 160ms, ConsoleSettings::instance().SETTINGS_TO_HOME_DELAY0);
190+
pbf_mash_button(context, BUTTON_B, 5000ms);
191+
context.wait_for_all_requests();
179192

180193
stats.skips++;
181194
env.update_stats();
@@ -184,8 +197,10 @@ void DailyItemRespawnFarmer::program(SingleSwitchProgramEnvironment& env, Cancel
184197
if (FIX_TIME_WHEN_DONE){
185198
pbf_press_button(context, BUTTON_HOME, 80ms, 1000ms);
186199
home_to_date_time(context, false);
187-
pbf_press_button(context, BUTTON_A, 20ms, 10ms);
188-
pbf_press_button(context, BUTTON_A, 20ms, 10ms);
200+
pbf_press_button(context, BUTTON_A, 30ms, 50ms);
201+
context.wait_for_all_requests();
202+
pbf_press_button(context, BUTTON_A, 30ms, 50ms);
203+
context.wait_for_all_requests();
189204
pbf_press_button(context, BUTTON_HOME, 160ms, ConsoleSettings::instance().SETTINGS_TO_HOME_DELAY0);
190205
resume_game_from_home(env.console, context);
191206
}

SerialPrograms/Source/PokemonLGPE/Programs/Farming/PokemonLGPE_DailyItemRespawnFarmer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class DailyItemRespawnFarmer : public SingleSwitchProgramInstance{
4646
};
4747
EnumDropdownOption<LinkCode> LINK_CODE;
4848

49-
GoHomeWhenDoneOption GO_HOME_WHEN_DONE;
5049
BooleanCheckBoxOption FIX_TIME_WHEN_DONE;
50+
GoHomeWhenDoneOption GO_HOME_WHEN_DONE;
5151

5252
EventNotificationOption NOTIFICATION_STATUS_UPDATE;
5353
EventNotificationsOption NOTIFICATIONS;

0 commit comments

Comments
 (0)