Skip to content

Commit 91d838d

Browse files
committed
pokemon emerald game dropdown/panels
1 parent c061551 commit 91d838d

File tree

7 files changed

+394
-0
lines changed

7 files changed

+394
-0
lines changed

SerialPrograms/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,12 @@ file(GLOB MAIN_SOURCES
10971097
Source/PokemonBDSP/Programs/Trading/PokemonBDSP_TradeRoutines.h
10981098
Source/PokemonBDSP/Resources/PokemonBDSP_NameDatabase.cpp
10991099
Source/PokemonBDSP/Resources/PokemonBDSP_NameDatabase.h
1100+
Source/PokemonEmerald/Programs/ShinyHunting/PokemonEmerald_StarterReset.cpp
1101+
Source/PokemonEmerald/Programs/ShinyHunting/PokemonEmerald_StarterReset.h
1102+
Source/PokemonEmerald/PokemonEmerald_Panels.cpp
1103+
Source/PokemonEmerald/PokemonEmerald_Panels.h
1104+
Source/PokemonEmerald/PokemonEmerald_Settings.cpp
1105+
Source/PokemonEmerald/PokemonEmerald_Settings.h
11001106
Source/PokemonHome/Inference/PokemonHome_BallReader.cpp
11011107
Source/PokemonHome/Inference/PokemonHome_BallReader.h
11021108
Source/PokemonHome/Inference/PokemonHome_BoxGenderDetector.cpp
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* Pokemon Emerald Panels
2+
*
3+
* From: https://github.com/PokemonAutomation/Arduino-Source
4+
*
5+
*/
6+
7+
#include "Pokemon/Pokemon_Strings.h"
8+
#include "PokemonEmerald_Panels.h"
9+
10+
//#include "PokemonSV_Settings.h"
11+
12+
#include "Programs/ShinyHunting/PokemonEmerald_StarterReset.h"
13+
14+
namespace PokemonAutomation{
15+
namespace NintendoSwitch{
16+
namespace PokemonEmerald{
17+
18+
19+
20+
PanelListFactory::PanelListFactory()
21+
: PanelListDescriptor("Pokemon Emerald")
22+
{}
23+
24+
std::vector<PanelEntry> PanelListFactory::make_panels() const{
25+
std::vector<PanelEntry> ret;
26+
27+
// ret.emplace_back("---- Settings ----"); TODO: Add device selection?
28+
// ret.emplace_back(make_settings<GameSettings_Descriptor, GameSettingsPanel>());
29+
30+
//ret.emplace_back("---- General ----");
31+
32+
ret.emplace_back("---- Shiny Hunting ----");
33+
ret.emplace_back(make_single_switch_program<StarterReset_Descriptor, StarterReset>());
34+
35+
return ret;
36+
}
37+
38+
39+
40+
41+
}
42+
}
43+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* Pokemon Emerald Panels
2+
*
3+
* From: https://github.com/PokemonAutomation/Arduino-Source
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_PokemonEmerald_Panels_H
8+
#define PokemonAutomation_PokemonEmerald_Panels_H
9+
10+
#include "CommonFramework/Panels/PanelList.h"
11+
12+
namespace PokemonAutomation{
13+
namespace NintendoSwitch{
14+
namespace PokemonEmerald{
15+
16+
17+
18+
class PanelListFactory : public PanelListDescriptor{
19+
public:
20+
PanelListFactory();
21+
virtual std::vector<PanelEntry> make_panels() const;
22+
};
23+
24+
25+
26+
}
27+
}
28+
}
29+
#endif
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/* Pokemon Emerald Settings
2+
*
3+
* From: https://github.com/PokemonAutomation/Arduino-Source
4+
*
5+
*/
6+
7+
#include "Common/NintendoSwitch/NintendoSwitch_ControllerDefs.h"
8+
#include "CommonFramework/Globals.h"
9+
10+
#include "PokemonEmerald_Settings.h"
11+
12+
namespace PokemonAutomation{
13+
namespace NintendoSwitch{
14+
namespace PokemonEmerald{
15+
16+
17+
18+
GameSettings& GameSettings::instance(){
19+
static GameSettings settings;
20+
return settings;
21+
}
22+
GameSettings::GameSettings()
23+
: BatchOption(LockMode::LOCK_WHILE_RUNNING)
24+
, m_menu_navigation("<font size=4><b>Menu Navigation Timings:</b></font>")
25+
, GAME_TO_HOME_DELAY(
26+
"<b>Game to Home Delay:</b><br>Delay from pressing home to entering the the Switch home menu.",
27+
LockMode::LOCK_WHILE_RUNNING,
28+
TICKS_PER_SECOND,
29+
"125"
30+
)
31+
, m_start_game_timings("<font size=4><b>Start Game Timings:</b></font>")
32+
, START_GAME_MASH(
33+
"<b>1. Start Game Mash:</b><br>Mash A for this long to start the game.",
34+
LockMode::LOCK_WHILE_RUNNING,
35+
TICKS_PER_SECOND,
36+
"2 * TICKS_PER_SECOND"
37+
)
38+
, START_GAME_WAIT(
39+
"<b>2. Start Game Wait:</b><br>Wait this long for the game to load.",
40+
LockMode::LOCK_WHILE_RUNNING,
41+
TICKS_PER_SECOND,
42+
"60 * TICKS_PER_SECOND"
43+
)
44+
, ENTER_GAME_MASH(
45+
"<b>3. Enter Game Mash:</b><br>Mash A for this long to enter the game.",
46+
LockMode::LOCK_WHILE_RUNNING,
47+
TICKS_PER_SECOND,
48+
"5 * TICKS_PER_SECOND"
49+
)
50+
, ENTER_GAME_WAIT(
51+
"<b>4. Enter Game Wait:</b><br>Wait this long for the game to enter the overworld.",
52+
LockMode::LOCK_WHILE_RUNNING,
53+
TICKS_PER_SECOND,
54+
"60 * TICKS_PER_SECOND"
55+
)
56+
{
57+
PA_ADD_STATIC(m_start_game_timings);
58+
PA_ADD_OPTION(START_GAME_MASH);
59+
PA_ADD_OPTION(START_GAME_WAIT);
60+
PA_ADD_OPTION(ENTER_GAME_MASH);
61+
PA_ADD_OPTION(ENTER_GAME_WAIT);
62+
}
63+
64+
65+
66+
67+
68+
GameSettings_Descriptor::GameSettings_Descriptor()
69+
: PanelDescriptor(
70+
Color(),
71+
"PokemonEmerald:GlobalSettings",
72+
"Pokemon Emerald", "Pokemon Emerald Settings",
73+
"ComputerControl/blob/master/Wiki/Programs/PokemonEmerald/EmeraldSettings.md",
74+
"Global Pokemon Emerald Settings"
75+
)
76+
{}
77+
78+
79+
80+
GameSettingsPanel::GameSettingsPanel(const GameSettings_Descriptor& descriptor)
81+
: SettingsPanelInstance(descriptor)
82+
, settings(GameSettings::instance())
83+
{
84+
PA_ADD_OPTION(settings);
85+
}
86+
87+
88+
89+
90+
91+
}
92+
}
93+
}
94+
95+
96+
97+
98+
99+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/* Pokemon Emerald Settings
2+
*
3+
* From: https://github.com/PokemonAutomation/Arduino-Source
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_PokemonEmerald_Settings_H
8+
#define PokemonAutomation_PokemonEmerald_Settings_H
9+
10+
#include "Common/Cpp/Options/StaticTextOption.h"
11+
#include "Common/Cpp/Options/BooleanCheckBoxOption.h"
12+
#include "Common/Cpp/Options/FloatingPointOption.h"
13+
#include "Common/Cpp/Options/TimeExpressionOption.h"
14+
#include "CommonFramework/Panels/SettingsPanel.h"
15+
16+
namespace PokemonAutomation{
17+
namespace NintendoSwitch{
18+
namespace PokemonEmerald{
19+
20+
21+
class GameSettings : public BatchOption{
22+
GameSettings();
23+
public:
24+
static GameSettings& instance();
25+
26+
SectionDividerOption m_menu_navigation;
27+
TimeExpressionOption<uint16_t> GAME_TO_HOME_DELAY;
28+
29+
SectionDividerOption m_start_game_timings;
30+
TimeExpressionOption<uint16_t> START_GAME_MASH;
31+
TimeExpressionOption<uint16_t> START_GAME_WAIT;
32+
TimeExpressionOption<uint16_t> ENTER_GAME_MASH;
33+
TimeExpressionOption<uint16_t> ENTER_GAME_WAIT;
34+
35+
};
36+
37+
38+
39+
40+
class GameSettings_Descriptor : public PanelDescriptor{
41+
public:
42+
GameSettings_Descriptor();
43+
};
44+
45+
46+
class GameSettingsPanel : public SettingsPanelInstance{
47+
public:
48+
GameSettingsPanel(const GameSettings_Descriptor& descriptor);
49+
private:
50+
GameSettings& settings;
51+
};
52+
53+
54+
}
55+
}
56+
}
57+
#endif
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/* Emerald Starter Reset
2+
*
3+
* From: https://github.com/PokemonAutomation/Arduino-Source
4+
*
5+
*/
6+
7+
#include "Common/Cpp/PrettyPrint.h"
8+
#include "CommonFramework/Notifications/ProgramNotifications.h"
9+
#include "CommonFramework/Tools/StatsTracking.h"
10+
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
11+
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
12+
#include "PokemonEmerald_StarterReset.h"
13+
14+
namespace PokemonAutomation{
15+
namespace NintendoSwitch{
16+
namespace PokemonEmerald{
17+
18+
StarterReset_Descriptor::StarterReset_Descriptor()
19+
: SingleSwitchProgramDescriptor(
20+
"PokemonEmerald:StarterReset",
21+
"Pokemon Emerald", "Starter Reset",
22+
"ComputerControl/blob/master/Wiki/Programs/PokemonEmerald/StarterReset.md",
23+
"Soft reset for a shiny starter. Battery cannot be dry.",
24+
FeedbackType::VIDEO_AUDIO,
25+
AllowCommandsWhenRunning::DISABLE_COMMANDS,
26+
PABotBaseLevel::PABOTBASE_12KB
27+
)
28+
{}
29+
30+
struct StarterReset_Descriptor::Stats : public StatsTracker{
31+
Stats()
32+
: dupe_attempts(m_stats["Dupe Attempts"])
33+
{
34+
m_display_order.emplace_back("Dupe Attempts");
35+
}
36+
std::atomic<uint64_t>& dupe_attempts;
37+
};
38+
std::unique_ptr<StatsTracker> StarterReset_Descriptor::make_stats() const{
39+
return std::unique_ptr<StatsTracker>(new Stats());
40+
}
41+
42+
StarterReset::StarterReset()
43+
: ATTEMPTS(
44+
"<b>Duplication Attempts:</b><br>The number of times you wish to run this routine.",
45+
LockMode::UNLOCK_WHILE_RUNNING,
46+
100
47+
)
48+
, GO_HOME_WHEN_DONE(false)
49+
, NOTIFICATION_STATUS_UPDATE("Status Update", true, false, std::chrono::seconds(3600))
50+
, NOTIFICATIONS({
51+
&NOTIFICATION_STATUS_UPDATE,
52+
&NOTIFICATION_PROGRAM_FINISH,
53+
// &NOTIFICATION_ERROR_FATAL,
54+
})
55+
{
56+
PA_ADD_OPTION(ATTEMPTS);
57+
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
58+
PA_ADD_OPTION(NOTIFICATIONS);
59+
}
60+
61+
void StarterReset::program(SingleSwitchProgramEnvironment& env, BotBaseContext& context){
62+
StarterReset_Descriptor::Stats& stats = env.current_stats<StarterReset_Descriptor::Stats>();
63+
64+
/*
65+
* Stand in front of birch's bag.
66+
*
67+
* text speed fast
68+
*
69+
* have to do the SR method instead of run away
70+
*
71+
* cannot have dry battery
72+
*/
73+
74+
uint32_t c = 0;
75+
76+
77+
/*
78+
start at birch bag
79+
80+
starter selection
81+
82+
wild zig appears, shiny check (audio?)
83+
84+
go starter
85+
86+
now shiny check
87+
88+
track starter shiny, zig shiny, number of attempts, errors
89+
90+
if not shiny, soft reset
91+
92+
soft reset checks for dry battery and returns true or false!
93+
94+
*/
95+
96+
97+
98+
while (c < ATTEMPTS){
99+
env.log("Current Attempts: " + tostr_u_commas(c));
100+
101+
// increment counter, increment stats
102+
c++;
103+
stats.dupe_attempts++;
104+
env.update_stats();
105+
send_program_status_notification(env, NOTIFICATION_STATUS_UPDATE);
106+
107+
}
108+
109+
GO_HOME_WHEN_DONE.run_end_of_program(context);
110+
send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH);
111+
}
112+
113+
}
114+
}
115+
}
116+

0 commit comments

Comments
 (0)