Skip to content

Commit 38964ff

Browse files
committed
fixes for nav and deoxys
1 parent 5733e72 commit 38964ff

File tree

4 files changed

+26
-27
lines changed

4 files changed

+26
-27
lines changed

SerialPrograms/Source/PokemonRSE/PokemonRSE_Navigation.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ namespace NintendoSwitch{
2121
namespace PokemonRSE{
2222

2323

24-
void soft_reset(const ProgramInfo& info, VideoStream& stream, SwitchControllerContext& context){
24+
void soft_reset(const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
2525
// A + B + Select + Start
2626
pbf_press_button(context, BUTTON_B | BUTTON_Y | BUTTON_MINUS | BUTTON_PLUS, 10, 180);
2727

28-
pbf_mash_button(context, BUTTON_PLUS, GameSettings::instance().START_BUTTON_MASH);
28+
pbf_mash_button(context, BUTTON_PLUS, GameSettings::instance().START_BUTTON_MASH0);
2929
context.wait_for_all_requests();
3030

3131
pbf_press_button(context, BUTTON_A, 20, 40);
@@ -34,7 +34,7 @@ void soft_reset(const ProgramInfo& info, VideoStream& stream, SwitchControllerCo
3434
BlackScreenOverWatcher detector(COLOR_RED, {0.282, 0.064, 0.448, 0.871});
3535
int ret = wait_until(
3636
stream, context,
37-
std::chrono::milliseconds(GameSettings::instance().ENTER_GAME_WAIT * (1000 / TICKS_PER_SECOND)),
37+
GameSettings::instance().ENTER_GAME_WAIT0,
3838
{{detector}}
3939
);
4040
if (ret == 0){
@@ -50,7 +50,7 @@ void soft_reset(const ProgramInfo& info, VideoStream& stream, SwitchControllerCo
5050
context.wait_for_all_requests();
5151
}
5252

53-
void flee_battle(VideoStream& stream, SwitchControllerContext& context) {
53+
void flee_battle(VideoStream& stream, ProControllerContext& context) {
5454
stream.log("Navigate to Run.");
5555
pbf_press_dpad(context, DPAD_RIGHT, 20, 20);
5656
pbf_press_dpad(context, DPAD_DOWN, 20, 20);
@@ -90,7 +90,7 @@ void flee_battle(VideoStream& stream, SwitchControllerContext& context) {
9090
}
9191
}
9292

93-
bool handle_encounter(VideoStream& stream, SwitchControllerContext& context, bool send_out_lead) {
93+
bool handle_encounter(VideoStream& stream, ProControllerContext& context, bool send_out_lead) {
9494
float shiny_coefficient = 1.0;
9595
ShinySoundDetector shiny_detector(stream.logger(), [&](float error_coefficient) -> bool{
9696
shiny_coefficient = error_coefficient;
@@ -102,9 +102,9 @@ bool handle_encounter(VideoStream& stream, SwitchControllerContext& context, boo
102102
pbf_mash_button(context, BUTTON_A, 540);
103103
context.wait_for_all_requests();
104104

105-
int res = run_until<SwitchControllerContext>(
105+
int res = run_until<ProControllerContext>(
106106
stream, context,
107-
[&](SwitchControllerContext& context) {
107+
[&](ProControllerContext& context) {
108108
int ret = wait_until(
109109
stream, context,
110110
std::chrono::seconds(30),

SerialPrograms/Source/PokemonRSE/PokemonRSE_Navigation.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include "CommonFramework/Tools/VideoStream.h"
1313
#include "Common/NintendoSwitch/NintendoSwitch_ControllerDefs.h"
14-
#include "NintendoSwitch/Controllers/NintendoSwitch_Controller.h"
14+
#include "NintendoSwitch/Controllers/NintendoSwitch_ProController.h"
1515

1616
namespace PokemonAutomation{
1717
struct ProgramInfo;
@@ -20,15 +20,15 @@ namespace PokemonRSE{
2020

2121
// Press A+B+Select+Start at the same time to soft reset, then re-enters the game.
2222
// For now this assumes no dry battery.
23-
void soft_reset(const ProgramInfo& info, VideoStream& stream, SwitchControllerContext &context);
23+
void soft_reset(const ProgramInfo& info, VideoStream& stream, ProControllerContext &context);
2424

2525
// Run from battle. Cursor must start on the FIGHT button. Assumes fleeing will always work. (Smoke Ball)
26-
void flee_battle(VideoStream& stream, SwitchControllerContext& context);
26+
void flee_battle(VideoStream& stream, ProControllerContext& context);
2727

2828
// After press A/walking up to enter a battle, run this handle the battle start and to check if opponent is shiny.
2929
// Set send_out_lead to true and then use flee_battle() after if game is Emerald.
3030
// For R/S, send_out_lead as false and then soft_reset() to save time.
31-
bool handle_encounter(VideoStream& stream, SwitchControllerContext& context, bool send_out_lead);
31+
bool handle_encounter(VideoStream& stream, ProControllerContext& context, bool send_out_lead);
3232

3333

3434
}

SerialPrograms/Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_ShinyHunt-Deoxys.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@ ShinyHuntDeoxys::ShinyHuntDeoxys()
6060
LockMode::LOCK_WHILE_RUNNING,
6161
StartPos::rock_unsolved
6262
)
63-
, WALK_UP_DOWN_TIME(
63+
, WALK_UP_DOWN_TIME0(
6464
"<b>Walk up/down time</b><br>Spend this long to run up to the triangle rock.",
6565
LockMode::LOCK_WHILE_RUNNING,
66-
TICKS_PER_SECOND,
67-
"440"
66+
"3520 ms"
6867
)
6968
, NOTIFICATION_SHINY(
7069
"Shiny Found",
@@ -79,11 +78,11 @@ ShinyHuntDeoxys::ShinyHuntDeoxys()
7978
})
8079
{
8180
PA_ADD_OPTION(STARTPOS);
82-
PA_ADD_OPTION(WALK_UP_DOWN_TIME);
81+
PA_ADD_OPTION(WALK_UP_DOWN_TIME0);
8382
PA_ADD_OPTION(NOTIFICATIONS);
8483
}
8584

86-
void ShinyHuntDeoxys::solve_puzzle(SingleSwitchProgramEnvironment& env, SwitchControllerContext& context) {
85+
void ShinyHuntDeoxys::solve_puzzle(SingleSwitchProgramEnvironment& env, ProControllerContext& context) {
8786
env.log("Step 1: Press A from below.");
8887
pbf_press_button(context, BUTTON_A, 20, 40);
8988

@@ -187,7 +186,7 @@ void ShinyHuntDeoxys::solve_puzzle(SingleSwitchProgramEnvironment& env, SwitchCo
187186
context.wait_for_all_requests();
188187
}
189188

190-
void ShinyHuntDeoxys::program(SingleSwitchProgramEnvironment& env, SwitchControllerContext& context){
189+
void ShinyHuntDeoxys::program(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
191190
ShinyHuntDeoxys_Descriptor::Stats& stats = env.current_stats<ShinyHuntDeoxys_Descriptor::Stats>();
192191

193192
/*
@@ -218,8 +217,8 @@ void ShinyHuntDeoxys::program(SingleSwitchProgramEnvironment& env, SwitchControl
218217
case StartPos::boat:
219218
env.log("StartPos: Walking up to Deoxys.");
220219
//Walk up to the triangle rock from the ship. No bike allowed.
221-
ssf_press_button(context, BUTTON_B, 0, WALK_UP_DOWN_TIME);
222-
pbf_press_dpad(context, DPAD_UP, WALK_UP_DOWN_TIME, 20);
220+
ssf_press_button(context, BUTTON_B, 0ms, WALK_UP_DOWN_TIME0);
221+
pbf_press_dpad(context, DPAD_UP, WALK_UP_DOWN_TIME0, 160ms);
223222
context.wait_for_all_requests();
224223
case StartPos::rock_unsolved:
225224
env.log("StartPos: Solving puzzle.");
@@ -253,14 +252,14 @@ void ShinyHuntDeoxys::program(SingleSwitchProgramEnvironment& env, SwitchControl
253252

254253
//Walk down from the triangle rock to the ship.
255254
env.log("Walking down to ship.");
256-
ssf_press_button(context, BUTTON_B, 0, WALK_UP_DOWN_TIME);
257-
pbf_press_dpad(context, DPAD_DOWN, WALK_UP_DOWN_TIME, 20);
255+
ssf_press_button(context, BUTTON_B, 0ms, WALK_UP_DOWN_TIME0);
256+
pbf_press_dpad(context, DPAD_DOWN, WALK_UP_DOWN_TIME0, 160ms);
258257
context.wait_for_all_requests();
259258

260259
env.log("Walking up to Deoxys rock.");
261260
//Walk up to the triangle rock from the ship. Bike is not allowed on Birth Island.
262-
ssf_press_button(context, BUTTON_B, 0, WALK_UP_DOWN_TIME);
263-
pbf_press_dpad(context, DPAD_UP, WALK_UP_DOWN_TIME, 20);
261+
ssf_press_button(context, BUTTON_B, 0ms, WALK_UP_DOWN_TIME0);
262+
pbf_press_dpad(context, DPAD_UP, WALK_UP_DOWN_TIME0, 160ms);
264263
context.wait_for_all_requests();
265264

266265
env.log("Solving puzzle.");

SerialPrograms/Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_ShinyHunt-Deoxys.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define PokemonAutomation_PokemonRSE_ShinyHuntDeoxys_H
99

1010
#include "Common/Cpp/Options/SimpleIntegerOption.h"
11-
#include "Common/Cpp/Options/TimeExpressionOption.h"
11+
#include "Common/Cpp/Options/TimeDurationOption.h"
1212
#include "CommonFramework/Notifications/EventNotificationsTable.h"
1313
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
1414

@@ -26,7 +26,7 @@ class ShinyHuntDeoxys_Descriptor : public SingleSwitchProgramDescriptor{
2626
class ShinyHuntDeoxys : public SingleSwitchProgramInstance{
2727
public:
2828
ShinyHuntDeoxys();
29-
virtual void program(SingleSwitchProgramEnvironment& env, SwitchControllerContext& context) override;
29+
virtual void program(SingleSwitchProgramEnvironment& env, ProControllerContext& context) override;
3030

3131
private:
3232
enum class StartPos{
@@ -36,13 +36,13 @@ class ShinyHuntDeoxys : public SingleSwitchProgramInstance{
3636
};
3737
EnumDropdownOption<StartPos> STARTPOS;
3838

39-
TimeExpressionOption<uint16_t> WALK_UP_DOWN_TIME;
39+
MillisecondsOption WALK_UP_DOWN_TIME0;
4040

4141
EventNotificationOption NOTIFICATION_SHINY;
4242
EventNotificationOption NOTIFICATION_STATUS_UPDATE;
4343
EventNotificationsOption NOTIFICATIONS;
4444

45-
void solve_puzzle(SingleSwitchProgramEnvironment& env, SwitchControllerContext& context);
45+
void solve_puzzle(SingleSwitchProgramEnvironment& env, ProControllerContext& context);
4646
};
4747

4848
}

0 commit comments

Comments
 (0)