Skip to content

Commit 63231cd

Browse files
committed
fix dateskip, improve dailyfarmer, alolantrade favs
1 parent 7813008 commit 63231cd

File tree

4 files changed

+105
-63
lines changed

4 files changed

+105
-63
lines changed

SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_Navigation.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void home_to_date_time(ProControllerContext& context, bool to_date_change, bool
167167

168168
void home_to_date_time(JoyconContext& context, bool to_date_change){
169169
Milliseconds tv = context->timing_variation();
170-
Milliseconds unit = 32ms + tv;
170+
Milliseconds unit = 50ms + tv;
171171

172172
//From ControllerPerformanceClass::SerialPABotBase_Wireless_ESP32
173173
//as Joycon will only have that controller type
@@ -206,7 +206,6 @@ void home_to_date_time(JoyconContext& context, bool to_date_change){
206206
pbf_move_joystick(context, 128, 255, 4*unit, unit);
207207
pbf_move_joystick(context, 128, 255, 360ms, 304ms);
208208
pbf_move_joystick(context, 128, 255, 2*unit, unit);
209-
//pbf_move_joystick(context, 128, 255, 2*unit, unit);
210209

211210
if (!to_date_change){
212211
ssf_press_button(context, BUTTON_A, 360ms, 2*unit, unit);

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

Lines changed: 80 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,69 @@ DailyItemFarmer::DailyItemFarmer()
9393
PA_ADD_OPTION(NOTIFICATIONS);
9494
}
9595

96+
void DailyItemFarmer::start_local_trade(SingleSwitchProgramEnvironment& env, JoyconContext& context){
97+
env.log("Starting local trade.");
98+
//Open Menu -> Communication -> Nearby player -> Local Trade
99+
pbf_press_button(context, BUTTON_X, 200ms, 500ms);
100+
pbf_move_joystick(context, 255, 128, 100ms, 100ms);
101+
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
102+
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
103+
pbf_wait(context, 1000ms); //Black screen
104+
context.wait_for_all_requests();
105+
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
106+
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
107+
108+
//Enter link code
109+
switch(LINK_CODE) {
110+
case LinkCode::Pikachu:
111+
break;
112+
case LinkCode::Eevee:
113+
pbf_move_joystick(context, 255, 128, 100ms, 100ms);
114+
break;
115+
case LinkCode::Bulbasaur:
116+
pbf_move_joystick(context, 255, 128, 100ms, 100ms);
117+
pbf_move_joystick(context, 255, 128, 100ms, 100ms);
118+
break;
119+
case LinkCode::Charmander:
120+
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
121+
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
122+
break;
123+
case LinkCode::Squirtle:
124+
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
125+
break;
126+
case LinkCode::Pidgey:
127+
pbf_move_joystick(context, 128, 255, 100ms, 100ms);
128+
break;
129+
case LinkCode::Caterpie:
130+
pbf_move_joystick(context, 128, 255, 100ms, 100ms);
131+
pbf_move_joystick(context, 255, 128, 100ms, 100ms);
132+
break;
133+
case LinkCode::Rattata:
134+
pbf_move_joystick(context, 128, 255, 100ms, 100ms);
135+
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
136+
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
137+
break;
138+
case LinkCode::Jigglypuff:
139+
pbf_move_joystick(context, 128, 255, 100ms, 100ms);
140+
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
141+
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
142+
break;
143+
case LinkCode::Diglett:
144+
pbf_move_joystick(context, 128, 255, 100ms, 100ms);
145+
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
146+
break;
147+
default:
148+
env.log("Invalid link code selection. Defaulting to Pikachu.");
149+
break;
150+
}
151+
//Select symbol three times, then enter link search
152+
pbf_press_button(context, BUTTON_A, 200ms, 100ms);
153+
pbf_press_button(context, BUTTON_A, 200ms, 100ms);
154+
pbf_press_button(context, BUTTON_A, 200ms, 100ms);
155+
pbf_wait(context, 1000ms); //let search start
156+
context.wait_for_all_requests();
157+
}
158+
96159
void DailyItemFarmer::program(SingleSwitchProgramEnvironment& env, CancellableScope& scope){
97160
JoyconContext context(scope, env.console.controller<JoyconController>());
98161
assert_16_9_720p_min(env.logger(), env.console);
@@ -108,78 +171,35 @@ void DailyItemFarmer::program(SingleSwitchProgramEnvironment& env, CancellableSc
108171

109172
uint8_t year = MAX_YEAR;
110173

174+
//Roll the date back before doing anything else.
175+
start_local_trade(env, context);
176+
pbf_press_button(context, BUTTON_HOME, 160ms, 1000ms);
177+
home_to_date_time(context, true);
178+
env.log("Rolling date back.");
179+
roll_date_backward_N(context, MAX_YEAR);
180+
year = 0;
181+
pbf_press_button(context, BUTTON_HOME, 160ms, ConsoleSettings::instance().SETTINGS_TO_HOME_DELAY0);
182+
pbf_press_button(context, BUTTON_HOME, 160ms, ConsoleSettings::instance().SETTINGS_TO_HOME_DELAY0);
183+
pbf_mash_button(context, BUTTON_B, 5000ms);
184+
context.wait_for_all_requests();
185+
186+
env.log("Starting pickup loop.");
111187
for (uint32_t count = 0; count < ATTEMPTS; count++) {
112-
//Pick up item
188+
env.log("Pick up item.");
113189
pbf_mash_button(context, BUTTON_A, 4000ms);
114190
context.wait_for_all_requests();
115191

116-
//Open Menu -> Communication -> Nearby player -> Local Trade
117-
pbf_press_button(context, BUTTON_X, 200ms, 500ms);
118-
pbf_move_joystick(context, 255, 128, 100ms, 100ms);
119-
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
120-
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
121-
pbf_wait(context, 1000ms); //Black screen
122-
context.wait_for_all_requests();
123-
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
124-
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
125-
126-
//Enter link code
127-
switch(LINK_CODE) {
128-
case LinkCode::Pikachu:
129-
break;
130-
case LinkCode::Eevee:
131-
pbf_move_joystick(context, 255, 128, 100ms, 100ms);
132-
break;
133-
case LinkCode::Bulbasaur:
134-
pbf_move_joystick(context, 255, 128, 100ms, 100ms);
135-
pbf_move_joystick(context, 255, 128, 100ms, 100ms);
136-
break;
137-
case LinkCode::Charmander:
138-
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
139-
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
140-
break;
141-
case LinkCode::Squirtle:
142-
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
143-
break;
144-
case LinkCode::Pidgey:
145-
pbf_move_joystick(context, 128, 255, 100ms, 100ms);
146-
break;
147-
case LinkCode::Caterpie:
148-
pbf_move_joystick(context, 128, 255, 100ms, 100ms);
149-
pbf_move_joystick(context, 255, 128, 100ms, 100ms);
150-
break;
151-
case LinkCode::Rattata:
152-
pbf_move_joystick(context, 128, 255, 100ms, 100ms);
153-
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
154-
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
155-
break;
156-
case LinkCode::Jigglypuff:
157-
pbf_move_joystick(context, 128, 255, 100ms, 100ms);
158-
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
159-
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
160-
break;
161-
case LinkCode::Diglett:
162-
pbf_move_joystick(context, 128, 255, 100ms, 100ms);
163-
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
164-
break;
165-
default:
166-
env.log("Invalid link code selection. Defaulting to Pikachu.");
167-
break;
168-
}
169-
//Select symbol three times, then enter link search
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();
192+
start_local_trade(env, context);
175193

176194
//Dateskip
177195
pbf_press_button(context, BUTTON_HOME, 160ms, 1000ms);
178196
home_to_date_time(context, true);
179197
if (year >= MAX_YEAR){
198+
env.log("Rolling date back.");
180199
roll_date_backward_N(context, MAX_YEAR);
181200
year = 0;
182201
}else{
202+
env.log("Rolling date forward.");
183203
roll_date_forward_1(context);
184204
year++;
185205
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class DailyItemFarmer : public SingleSwitchProgramInstance{
3030
virtual void program(SingleSwitchProgramEnvironment& env, CancellableScope& scope) override;
3131

3232
private:
33+
void start_local_trade(SingleSwitchProgramEnvironment& env, JoyconContext& context);
34+
3335
SimpleIntegerOption<uint32_t> ATTEMPTS;
3436

3537
enum class LinkCode{

SerialPrograms/Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_AlolanTrade.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ void AlolanTrade::program(SingleSwitchProgramEnvironment& env, CancellableScope&
218218
context.wait_for_all_requests();
219219

220220
//Now check for shinies. Check everything that was traded.
221+
env.log("Checking received Pokemon.");
221222
for (uint16_t i = 0; i < NUM_TRADES; i++) {
222223
VideoSnapshot screen = env.console.video().snapshot();
223224
ShinySymbolDetector shiny_checker(COLOR_YELLOW);
@@ -229,7 +230,27 @@ void AlolanTrade::program(SingleSwitchProgramEnvironment& env, CancellableScope&
229230
env.update_stats();
230231
send_program_notification(env, NOTIFICATION_SHINY, COLOR_YELLOW, "Shiny found!", {}, "", screen, true);
231232
shiny_found = true;
232-
//TODO: Favorite the shiny.
233+
234+
//Back out to menu and favorite the shiny.
235+
env.log("Favoriting shiny.");
236+
pbf_press_button(context, BUTTON_B, 200ms, 5000ms);
237+
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
238+
pbf_move_joystick(context, 128, 0, 100ms, 100ms);
239+
pbf_move_joystick(context, 128, 0, 100ms, 100ms);
240+
pbf_move_joystick(context, 128, 0, 100ms, 200ms);
241+
pbf_press_button(context, BUTTON_A, 200ms, 800ms);
242+
pbf_press_button(context, BUTTON_A, 200ms, 800ms);
243+
pbf_press_button(context, BUTTON_B, 200ms, 800ms);
244+
245+
//Go into summary again
246+
env.log("Navigating back into summary.");
247+
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
248+
pbf_move_joystick(context, 128, 255, 100ms, 100ms);
249+
pbf_move_joystick(context, 128, 255, 100ms, 100ms);
250+
pbf_press_button(context, BUTTON_A, 200ms, 100ms);
251+
context.wait_for_all_requests();
252+
pbf_wait(context, 5000ms);
253+
context.wait_for_all_requests();
233254
}
234255
else {
235256
env.log("Not shiny.");

0 commit comments

Comments
 (0)