Skip to content

Commit 482661d

Browse files
committed
Migrate RSE and Zelda programs to TimeDurationOption.
1 parent fa97389 commit 482661d

15 files changed

+65
-83
lines changed

SerialPrograms/Source/PokemonRSE/PokemonRSE_Navigation.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "CommonTools/Async/InferenceRoutines.h"
1111
#include "CommonTools/VisualDetectors/BlackScreenDetector.h"
1212
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
13-
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
1413
#include "PokemonRSE/Inference/Dialogs/PokemonRSE_DialogDetector.h"
1514
#include "PokemonRSE/Inference/Sounds/PokemonRSE_ShinySoundDetector.h"
1615
#include "PokemonRSE/PokemonRSE_Settings.h"
@@ -25,7 +24,7 @@ void soft_reset(const ProgramInfo& info, VideoStream& stream, SwitchControllerCo
2524
// A + B + Select + Start
2625
pbf_press_button(context, BUTTON_B | BUTTON_Y | BUTTON_MINUS | BUTTON_PLUS, 10, 180);
2726

28-
pbf_mash_button(context, BUTTON_PLUS, GameSettings::instance().START_BUTTON_MASH);
27+
pbf_mash_button(context, BUTTON_PLUS, GameSettings::instance().START_BUTTON_MASH0);
2928
context.wait_for_all_requests();
3029

3130
pbf_press_button(context, BUTTON_A, 20, 40);
@@ -34,8 +33,8 @@ void soft_reset(const ProgramInfo& info, VideoStream& stream, SwitchControllerCo
3433
BlackScreenOverWatcher detector(COLOR_RED, {0.282, 0.064, 0.448, 0.871});
3534
int ret = wait_until(
3635
stream, context,
37-
std::chrono::milliseconds(GameSettings::instance().ENTER_GAME_WAIT * (1000 / TICKS_PER_SECOND)),
38-
{{detector}}
36+
GameSettings::instance().ENTER_GAME_WAIT0,
37+
{detector}
3938
);
4039
if (ret == 0){
4140
stream.log("Entered game!");

SerialPrograms/Source/PokemonRSE/PokemonRSE_Settings.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,15 @@ GameSettings& GameSettings::instance(){
2424
GameSettings::GameSettings()
2525
: BatchOption(LockMode::LOCK_WHILE_RUNNING)
2626
, m_soft_reset_timings("<font size=4><b>Soft Reset Timings:</b></font>")
27-
, START_BUTTON_MASH(
27+
, START_BUTTON_MASH0(
2828
"<b>Start Button Mash:</b><br>Mash Start for this long after a soft reset to get to the main menu.",
2929
LockMode::LOCK_WHILE_RUNNING,
30-
TICKS_PER_SECOND,
31-
"5 * TICKS_PER_SECOND"
30+
"5000ms"
3231
)
33-
, ENTER_GAME_WAIT(
32+
, ENTER_GAME_WAIT0(
3433
"<b>Enter Game Wait:</b><br>Wait this long for the game to load.",
3534
LockMode::LOCK_WHILE_RUNNING,
36-
TICKS_PER_SECOND,
37-
"3 * TICKS_PER_SECOND"
35+
"3000ms"
3836
)
3937
, m_shiny_audio_settings("<font size=4><b>Shiny Audio Settings:</b></font>")
4038
, SHINY_SOUND_THRESHOLD(
@@ -49,8 +47,8 @@ GameSettings::GameSettings()
4947
)
5048
{
5149
PA_ADD_STATIC(m_soft_reset_timings);
52-
PA_ADD_OPTION(START_BUTTON_MASH);
53-
PA_ADD_OPTION(ENTER_GAME_WAIT);
50+
PA_ADD_OPTION(START_BUTTON_MASH0);
51+
PA_ADD_OPTION(ENTER_GAME_WAIT0);
5452
PA_ADD_STATIC(m_shiny_audio_settings);
5553
PA_ADD_OPTION(SHINY_SOUND_THRESHOLD);
5654
PA_ADD_OPTION(SHINY_SOUND_LOW_FREQUENCY);

SerialPrograms/Source/PokemonRSE/PokemonRSE_Settings.h

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

1010
#include "Common/Cpp/Options/StaticTextOption.h"
11-
#include "Common/Cpp/Options/BooleanCheckBoxOption.h"
1211
#include "Common/Cpp/Options/FloatingPointOption.h"
13-
#include "Common/Cpp/Options/TimeExpressionOption.h"
12+
#include "Common/Cpp/Options/TimeDurationOption.h"
1413
#include "CommonFramework/Panels/SettingsPanel.h"
1514

1615
namespace PokemonAutomation{
@@ -24,8 +23,8 @@ class GameSettings : public BatchOption{
2423
static GameSettings& instance();
2524

2625
SectionDividerOption m_soft_reset_timings;
27-
TimeExpressionOption<uint16_t> START_BUTTON_MASH;
28-
TimeExpressionOption<uint16_t> ENTER_GAME_WAIT;
26+
MillisecondsOption START_BUTTON_MASH0;
27+
MillisecondsOption ENTER_GAME_WAIT0;
2928

3029
SectionDividerOption m_shiny_audio_settings;
3130
FloatingPointOption SHINY_SOUND_THRESHOLD;

SerialPrograms/Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_AudioStarterReset.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#ifndef PokemonAutomation_PokemonRSE_AudioStarterReset_H
88
#define PokemonAutomation_PokemonRSE_AudioStarterReset_H
99

10-
#include "Common/Cpp/Options/SimpleIntegerOption.h"
11-
#include "Common/Cpp/Options/TimeExpressionOption.h"
1210
#include "CommonFramework/Notifications/EventNotificationsTable.h"
1311
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
1412

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,10 @@ std::unique_ptr<StatsTracker> ShinyHuntDeoxys_Descriptor::make_stats() const{
5050
}
5151

5252
ShinyHuntDeoxys::ShinyHuntDeoxys()
53-
: WALK_UP_DOWN_TIME(
53+
: WALK_UP_DOWN_TIME0(
5454
"<b>Walk up/down time</b><br>Spend this long to run up to the triangle rock.",
5555
LockMode::LOCK_WHILE_RUNNING,
56-
TICKS_PER_SECOND,
57-
"440"
56+
"3520ms"
5857
)
5958
, NOTIFICATION_SHINY(
6059
"Shiny Found",
@@ -68,7 +67,7 @@ ShinyHuntDeoxys::ShinyHuntDeoxys()
6867
&NOTIFICATION_PROGRAM_FINISH,
6968
})
7069
{
71-
PA_ADD_OPTION(WALK_UP_DOWN_TIME);
70+
PA_ADD_OPTION(WALK_UP_DOWN_TIME0);
7271
PA_ADD_OPTION(NOTIFICATIONS);
7372
}
7473

@@ -199,8 +198,8 @@ void ShinyHuntDeoxys::program(SingleSwitchProgramEnvironment& env, SwitchControl
199198
while (true) {
200199
env.log("Walking up to Deoxys.");
201200
//Walk up to the triangle rock from the ship. No bike allowed.
202-
ssf_press_button(context, BUTTON_B, 0, WALK_UP_DOWN_TIME);
203-
pbf_press_dpad(context, DPAD_UP, WALK_UP_DOWN_TIME, 20);
201+
ssf_press_button(context, BUTTON_B, 0ms, WALK_UP_DOWN_TIME0);
202+
pbf_press_dpad(context, DPAD_UP, WALK_UP_DOWN_TIME0, 160ms);
204203
context.wait_for_all_requests();
205204

206205
solve_puzzle(env, context);
@@ -223,8 +222,8 @@ void ShinyHuntDeoxys::program(SingleSwitchProgramEnvironment& env, SwitchControl
223222
context.wait_for_all_requests();
224223

225224
//Walk down from the triangle rock to the ship.
226-
ssf_press_button(context, BUTTON_B, 0, WALK_UP_DOWN_TIME);
227-
pbf_press_dpad(context, DPAD_DOWN, WALK_UP_DOWN_TIME, 20);
225+
ssf_press_button(context, BUTTON_B, 0ms, WALK_UP_DOWN_TIME0);
226+
pbf_press_dpad(context, DPAD_DOWN, WALK_UP_DOWN_TIME0, 160ms);
228227
context.wait_for_all_requests();
229228

230229
stats.resets++;

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

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

10-
#include "Common/Cpp/Options/SimpleIntegerOption.h"
11-
#include "Common/Cpp/Options/TimeExpressionOption.h"
10+
#include "Common/Cpp/Options/TimeDurationOption.h"
1211
#include "CommonFramework/Notifications/EventNotificationsTable.h"
1312
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
1413

@@ -29,7 +28,7 @@ class ShinyHuntDeoxys : public SingleSwitchProgramInstance{
2928
virtual void program(SingleSwitchProgramEnvironment& env, SwitchControllerContext& context) override;
3029

3130
private:
32-
TimeExpressionOption<uint16_t> WALK_UP_DOWN_TIME;
31+
MillisecondsOption WALK_UP_DOWN_TIME0;
3332

3433
EventNotificationOption NOTIFICATION_SHINY;
3534
EventNotificationOption NOTIFICATION_STATUS_UPDATE;

SerialPrograms/Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_StarterReset.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,11 @@ StarterReset::StarterReset()
6060
LockMode::LOCK_WHILE_RUNNING,
6161
Target::treecko
6262
)
63-
, STARTER_WAIT(
64-
"<b>Send out starter wait:</b><br>After pressing A to send out your selected starter, wait this long for the animation. Make sure to add extra time in case it is shiny.",
65-
LockMode::LOCK_WHILE_RUNNING,
66-
TICKS_PER_SECOND,
67-
"6 * TICKS_PER_SECOND"
68-
)
63+
// , STARTER_WAIT0(
64+
// "<b>Send out starter wait:</b><br>After pressing A to send out your selected starter, wait this long for the animation. Make sure to add extra time in case it is shiny.",
65+
// LockMode::LOCK_WHILE_RUNNING,
66+
// "6000ms"
67+
// )
6968
, NOTIFICATION_SHINY_STARTER(
7069
"Shiny Starter",
7170
true, true, ImageAttachmentMode::JPG,
@@ -76,7 +75,7 @@ StarterReset::StarterReset()
7675
&NOTIFICATION_SHINY_STARTER,
7776
&NOTIFICATION_STATUS_UPDATE,
7877
&NOTIFICATION_PROGRAM_FINISH,
79-
})
78+
})
8079
{
8180
PA_ADD_OPTION(TARGET);
8281
PA_ADD_OPTION(NOTIFICATIONS);

SerialPrograms/Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_StarterReset.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
#ifndef PokemonAutomation_PokemonRSE_StarterReset_H
88
#define PokemonAutomation_PokemonRSE_StarterReset_H
99

10-
#include "Common/Cpp/Options/SimpleIntegerOption.h"
11-
#include "Common/Cpp/Options/TimeExpressionOption.h"
10+
#include "Common/Cpp/Options/TimeDurationOption.h"
1211
#include "CommonFramework/Notifications/EventNotificationsTable.h"
1312
#include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h"
1413

@@ -36,7 +35,7 @@ class StarterReset : public SingleSwitchProgramInstance{
3635
};
3736
EnumDropdownOption<Target> TARGET;
3837

39-
TimeExpressionOption<uint16_t> STARTER_WAIT;
38+
// MillisecondsOption STARTER_WAIT0;
4039

4140
EventNotificationOption NOTIFICATION_SHINY_STARTER;
4241
EventNotificationOption NOTIFICATION_STATUS_UPDATE;

SerialPrograms/Source/ZeldaTotK/Programs/ZeldaTotK_BowItemDuper.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,24 @@ BowItemDuper::BowItemDuper()
4646
LockMode::UNLOCK_WHILE_RUNNING,
4747
100
4848
)
49-
, TICK_DELAY(
49+
, TICK_DELAY0(
5050
"<b>Menu Delay:</b><br>Adjustable delay for exiting and reentering the menu. "
5151
"This should not typically be lower than 5 nor exceed 25 for successful results. "
5252
"Too low and the game will eat inputs and put the program in an irrecoverable state."
5353
"Too high and the dupes will not be successful.",
5454
LockMode::UNLOCK_WHILE_RUNNING,
55-
TICKS_PER_SECOND,
56-
"15"
55+
"120ms"
5756
)
5857
, GO_HOME_WHEN_DONE(false)
5958
, NOTIFICATION_STATUS_UPDATE("Status Update", true, false, std::chrono::seconds(3600))
6059
, NOTIFICATIONS({
6160
&NOTIFICATION_STATUS_UPDATE,
6261
&NOTIFICATION_PROGRAM_FINISH,
6362
// &NOTIFICATION_ERROR_FATAL,
64-
})
63+
})
6564
{
6665
PA_ADD_OPTION(ATTEMPTS);
67-
PA_ADD_OPTION(TICK_DELAY);
66+
PA_ADD_OPTION(TICK_DELAY0);
6867
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
6968
PA_ADD_OPTION(NOTIFICATIONS);
7069
}
@@ -101,7 +100,7 @@ void BowItemDuper::program(SingleSwitchProgramEnvironment& env, SwitchController
101100
pbf_press_button(context, BUTTON_A, 10, 15);
102101

103102
// NOW WE HAVE TO PRESS PLUS AS FAST AS POSSIBLE
104-
pbf_press_button(context, BUTTON_PLUS, 3, TICK_DELAY);
103+
pbf_press_button(context, BUTTON_PLUS, 24ms, TICK_DELAY0);
105104
pbf_press_button(context, BUTTON_PLUS, 3, 3);
106105

107106
// navigate back to the "current" bow, then drop it

SerialPrograms/Source/ZeldaTotK/Programs/ZeldaTotK_BowItemDuper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define PokemonAutomation_ZeldaTotK_BowItemDuper_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
#include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h"
@@ -31,7 +31,7 @@ class BowItemDuper : public SingleSwitchProgramInstance{
3131

3232
private:
3333
SimpleIntegerOption<uint32_t> ATTEMPTS;
34-
TimeExpressionOption<uint16_t> TICK_DELAY;
34+
MillisecondsOption TICK_DELAY0;
3535
GoHomeWhenDoneOption GO_HOME_WHEN_DONE;
3636
EventNotificationOption NOTIFICATION_STATUS_UPDATE;
3737
EventNotificationsOption NOTIFICATIONS;

0 commit comments

Comments
 (0)