Skip to content

Commit 961caaa

Browse files
committed
lgpe fossil farmer initial files and basic options
1 parent c3b0383 commit 961caaa

File tree

5 files changed

+253
-1
lines changed

5 files changed

+253
-1
lines changed

SerialPrograms/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,8 @@ file(GLOB MAIN_SOURCES
13741374
Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.h
13751375
Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.cpp
13761376
Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.h
1377+
Source/PokemonLGPE/Programs/Farming/PokemonLGPE_DailyItemRespawnFarmer.cpp
1378+
Source/PokemonLGPE/Programs/Farming/PokemonLGPE_DailyItemRespawnFarmer.h
13771379
Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_AlolanTrade.cpp
13781380
Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_AlolanTrade.h
13791381
Source/PokemonLGPE/Programs/PokemonLGPE_GameEntry.cpp

SerialPrograms/SerialPrograms.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ SOURCES += \
674674
Source/PokemonLA/Resources/PokemonLA_PokemonSprites.cpp \
675675
Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.cpp \
676676
Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.cpp \
677+
Source/PokemonLGPE/Programs/Farming/PokemonLGPE_DailyItemRespawnFarmer.cpp \
677678
Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_AlolanTrade.cpp \
678679
Source/PokemonLGPE/Programs/PokemonLGPE_GameEntry.cpp \
679680
Source/PokemonLGPE/PokemonLGPE_Panels.cpp \
@@ -1864,6 +1865,7 @@ HEADERS += \
18641865
Source/PokemonLA/Resources/PokemonLA_PokemonSprites.h \
18651866
Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.h \
18661867
Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.h \
1868+
Source/PokemonLGPE/Programs/Farming/PokemonLGPE_DailyItemRespawnFarmer.h \
18671869
Source/PokemonLGPE/Programs/ShinyHunting/PokemonLGPE_AlolanTrade.h \
18681870
Source/PokemonLGPE/Programs/PokemonLGPE_GameEntry.h \
18691871
Source/PokemonLGPE/PokemonLGPE_Panels.h \

SerialPrograms/Source/PokemonLGPE/PokemonLGPE_Panels.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "PokemonLGPE_Panels.h"
1010
#include "PokemonLGPE_Settings.h"
1111

12+
#include "Programs/Farming/PokemonLGPE_DailyItemRespawnFarmer.h"
1213
#include "Programs/ShinyHunting/PokemonLGPE_AlolanTrade.h"
1314

1415
namespace PokemonAutomation{
@@ -25,7 +26,8 @@ std::vector<PanelEntry> PanelListFactory::make_panels() const{
2526
ret.emplace_back("---- Settings ----");
2627
ret.emplace_back(make_settings<GameSettings_Descriptor, GameSettingsPanel>());
2728

28-
//ret.emplace_back("---- General ----");
29+
ret.emplace_back("---- General ----");
30+
ret.emplace_back(make_single_switch_program<DailyItemRespawnFarmer_Descriptor, DailyItemRespawnFarmer>());
2931

3032
ret.emplace_back("---- Shiny Hunting ----");
3133
ret.emplace_back(make_single_switch_program<AlolanTrade_Descriptor, AlolanTrade>());
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
/* LGPE Daily Item Respawn Farmer
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#include "CommonFramework/Exceptions/OperationFailedException.h"
8+
#include "CommonFramework/Notifications/ProgramNotifications.h"
9+
#include "CommonFramework/ProgramStats/StatsTracking.h"
10+
#include "CommonFramework/VideoPipeline/VideoFeed.h"
11+
#include "CommonTools/Async/InferenceRoutines.h"
12+
#include "CommonTools/StartupChecks/VideoResolutionCheck.h"
13+
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
14+
#include "NintendoSwitch/Controllers/NintendoSwitch_Joycon.h"
15+
#include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h"
16+
#include "Pokemon/Pokemon_Strings.h"
17+
#include "CommonTools/VisualDetectors/BlackScreenDetector.h"
18+
#include "PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.h"
19+
#include "PokemonLGPE/Programs/PokemonLGPE_GameEntry.h"
20+
#include "PokemonLGPE_DailyItemRespawnFarmer.h"
21+
22+
namespace PokemonAutomation{
23+
namespace NintendoSwitch{
24+
namespace PokemonLGPE{
25+
26+
DailyItemRespawnFarmer_Descriptor::DailyItemRespawnFarmer_Descriptor()
27+
: SingleSwitchProgramDescriptor(
28+
"PokemonLGPE:DailyItemRespawnFarmer",
29+
Pokemon::STRING_POKEMON + " LGPE", "Daily Item Respawn Farmer",
30+
"",
31+
"Farm daily item respawns, such as fossils, by date-skipping.",
32+
FeedbackType::NONE,
33+
AllowCommandsWhenRunning::DISABLE_COMMANDS,
34+
{ControllerFeature::NintendoSwitch_RightJoycon},
35+
FasterIfTickPrecise::NOT_FASTER
36+
)
37+
{}
38+
39+
struct DailyItemRespawnFarmer_Descriptor::Stats : public StatsTracker{
40+
Stats()
41+
: trades(m_stats["Trades"])
42+
, resets(m_stats["Resets"])
43+
{
44+
m_display_order.emplace_back("Trades");
45+
m_display_order.emplace_back("Resets");
46+
}
47+
std::atomic<uint64_t>& trades;
48+
std::atomic<uint64_t>& resets;
49+
};
50+
std::unique_ptr<StatsTracker> DailyItemRespawnFarmer_Descriptor::make_stats() const{
51+
return std::unique_ptr<StatsTracker>(new Stats());
52+
}
53+
54+
DailyItemRespawnFarmer::DailyItemRespawnFarmer()
55+
: ATTEMPTS(
56+
"<b>Number of attempts:</b>",
57+
LockMode::LOCK_WHILE_RUNNING,
58+
30, 1
59+
)
60+
, LINK_CODE(
61+
"<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+
{ //Combinations of 3 different symbols is possible but 10 choices seems like enough.
63+
{LinkCode::Pikachu, "pikachu", "Pikachu"},
64+
{LinkCode::Eevee, "eevee", "Eevee"},
65+
{LinkCode::Bulbasaur, "bulbasaur", "Bulbasaur"},
66+
{LinkCode::Charmander, "charmander", "Charmander"},
67+
{LinkCode::Squirtle, "squirtle", "Squirtle"},
68+
{LinkCode::Pidgey, "pidgey", "Pidgey"},
69+
{LinkCode::Caterpie, "caterpie", "Caterpie"},
70+
{LinkCode::Rattata, "rattata", "Rattata"},
71+
{LinkCode::Jigglypuff, "jigglypuff", "Jigglypuff"},
72+
{LinkCode::Diglett, "diglett", "Diglett"},
73+
},
74+
LockMode::LOCK_WHILE_RUNNING,
75+
LinkCode::Pikachu
76+
)
77+
, GO_HOME_WHEN_DONE(false)
78+
, NOTIFICATION_STATUS_UPDATE("Status Update", true, false, std::chrono::seconds(3600))
79+
, NOTIFICATIONS({
80+
&NOTIFICATION_STATUS_UPDATE,
81+
&NOTIFICATION_PROGRAM_FINISH,
82+
})
83+
{
84+
PA_ADD_OPTION(ATTEMPTS);
85+
PA_ADD_OPTION(LINK_CODE);
86+
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
87+
PA_ADD_OPTION(NOTIFICATIONS);
88+
}
89+
90+
void DailyItemRespawnFarmer::program(SingleSwitchProgramEnvironment& env, CancellableScope& scope){
91+
JoyconContext context(scope, env.console.controller<JoyconController>());
92+
assert_16_9_720p_min(env.logger(), env.console);
93+
//DailyItemRespawnFarmer_Descriptor::Stats& stats = env.current_stats<DailyItemRespawnFarmer_Descriptor::Stats>();
94+
95+
/* Stand in front of the fossil spawn near Mewtwo.
96+
* Use a repel to keep wild encounters away.
97+
* Start program in-game.
98+
* 100% daily spawn. Only works near Mewtwo.
99+
* Other cave item spawns are tied to steps taken.
100+
* Should work for other hidden daily items, game corner, mt moon moonstones, etc.
101+
*/
102+
103+
for (uint32_t count = 0; count < ATTEMPTS; count++) {
104+
//Pick up item
105+
pbf_mash_button(context, BUTTON_A, 3000ms);
106+
107+
//Open Menu -> Communication -> Nearby player -> Local Trade
108+
pbf_press_button(context, BUTTON_X, 200ms, 500ms);
109+
pbf_move_joystick(context, 255, 128, 100ms, 100ms);
110+
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
111+
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
112+
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
113+
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
114+
115+
//Enter link code
116+
switch(LINK_CODE) {
117+
case LinkCode::Pikachu:
118+
break;
119+
case LinkCode::Eevee:
120+
pbf_move_joystick(context, 255, 128, 100ms, 100ms);
121+
break;
122+
case LinkCode::Bulbasaur:
123+
pbf_move_joystick(context, 255, 128, 100ms, 100ms);
124+
pbf_move_joystick(context, 255, 128, 100ms, 100ms);
125+
break;
126+
case LinkCode::Charmander:
127+
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
128+
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
129+
break;
130+
case LinkCode::Squirtle:
131+
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
132+
break;
133+
case LinkCode::Pidgey:
134+
pbf_move_joystick(context, 128, 255, 100ms, 100ms);
135+
break;
136+
case LinkCode::Caterpie:
137+
pbf_move_joystick(context, 128, 255, 100ms, 100ms);
138+
pbf_move_joystick(context, 255, 128, 100ms, 100ms);
139+
break;
140+
case LinkCode::Rattata:
141+
pbf_move_joystick(context, 128, 255, 100ms, 100ms);
142+
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
143+
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
144+
break;
145+
case LinkCode::Jigglypuff:
146+
pbf_move_joystick(context, 128, 255, 100ms, 100ms);
147+
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
148+
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
149+
break;
150+
case LinkCode::Diglett:
151+
pbf_move_joystick(context, 128, 255, 100ms, 100ms);
152+
pbf_move_joystick(context, 0, 128, 100ms, 100ms);
153+
154+
break;
155+
default:
156+
break;
157+
}
158+
//Select symbol three times, then enter link search
159+
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
160+
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
161+
pbf_press_button(context, BUTTON_A, 200ms, 1000ms);
162+
163+
//Dateskip
164+
165+
//Re-enter game
166+
167+
//Close out link menu
168+
169+
//stats.
170+
}
171+
172+
173+
if (GO_HOME_WHEN_DONE) {
174+
pbf_press_button(context, BUTTON_HOME, 200ms, 1000ms);
175+
}
176+
send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH);
177+
}
178+
179+
180+
}
181+
}
182+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/* LGPE Daily Item Respawn Farmer
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_PokemonLGPE_DailyItemRespawnFarmer_H
8+
#define PokemonAutomation_PokemonLGPE_DailyItemRespawnFarmer_H
9+
10+
#include "NintendoSwitch/Controllers/NintendoSwitch_Joycon.h"
11+
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
12+
#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h"
13+
#include "CommonFramework/Notifications/EventNotificationsTable.h"
14+
#include "Common/Cpp/Options/SimpleIntegerOption.h"
15+
16+
namespace PokemonAutomation{
17+
namespace NintendoSwitch{
18+
namespace PokemonLGPE{
19+
20+
class DailyItemRespawnFarmer_Descriptor : public SingleSwitchProgramDescriptor{
21+
public:
22+
DailyItemRespawnFarmer_Descriptor();
23+
struct Stats;
24+
virtual std::unique_ptr<StatsTracker> make_stats() const override;
25+
};
26+
27+
class DailyItemRespawnFarmer : public SingleSwitchProgramInstance{
28+
public:
29+
DailyItemRespawnFarmer();
30+
virtual void program(SingleSwitchProgramEnvironment& env, CancellableScope& scope) override;
31+
32+
private:
33+
SimpleIntegerOption<uint32_t> ATTEMPTS;
34+
35+
enum class LinkCode{
36+
Pikachu,
37+
Eevee,
38+
Bulbasaur,
39+
Charmander,
40+
Squirtle,
41+
Pidgey,
42+
Caterpie,
43+
Rattata,
44+
Jigglypuff,
45+
Diglett,
46+
};
47+
EnumDropdownOption<LinkCode> LINK_CODE;
48+
49+
GoHomeWhenDoneOption GO_HOME_WHEN_DONE;
50+
51+
EventNotificationOption NOTIFICATION_STATUS_UPDATE;
52+
EventNotificationsOption NOTIFICATIONS;
53+
};
54+
55+
56+
57+
58+
}
59+
}
60+
}
61+
#endif
62+
63+
64+

0 commit comments

Comments
 (0)