Skip to content

Commit 7566c46

Browse files
committed
remove unneccessary options and small cleanup
1 parent 360b67c commit 7566c46

File tree

2 files changed

+14
-27
lines changed

2 files changed

+14
-27
lines changed

SerialPrograms/Source/PokemonSwSh/Programs/RNG/PokemonSwSh_DailyHighlightRNG.cpp

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
*
77
*/
88

9-
#include <algorithm>
10-
#include <set>
119
#include "Common/Cpp/PrettyPrint.h"
1210
#include "CommonFramework/Exceptions/ProgramFinishedException.h"
1311
#include "CommonFramework/Exceptions/OperationFailedException.h"
@@ -23,7 +21,6 @@
2321
#include "Pokemon/Pokemon_Strings.h"
2422
#include "PokemonSwSh/PokemonSwSh_Settings.h"
2523
#include "PokemonSwSh/Commands/PokemonSwSh_Commands_DateSpam.h"
26-
#include "PokemonSwSh/Inference/PokemonSwSh_DialogBoxDetector.h"
2724
#include "PokemonSwSh/Inference/PokemonSwSh_SelectionArrowFinder.h"
2825
#include "PokemonSwSh/Inference/PokemonSwSh_YCommDetector.h"
2926
#include "PokemonSwSh/Programs/PokemonSwSh_MenuNavigation.h"
@@ -84,9 +81,6 @@ DailyHighlightRNG::DailyHighlightRNG()
8481
: NUM_HIGHLIGHTS(
8582
"<b>Number of highlights:</b><br>How many daily highlights should be bought. <br>A value of 0 will run until you stop the program.",
8683
LockMode::UNLOCK_WHILE_RUNNING, 0)
87-
, CONTINUE(
88-
"<b>Continue from last time:</b><br>If the initial two daily highlights are already manipulated and should be bought.",
89-
LockMode::UNLOCK_WHILE_RUNNING, false)
9084
, FIX_TIME_WHEN_DONE(
9185
"<b>Fix Time when Done:</b><br>Fix the time after the program finishes.<br>Doesn't do anything if Number of highlights is 0.",
9286
LockMode::UNLOCK_WHILE_RUNNING, false)
@@ -146,7 +140,6 @@ DailyHighlightRNG::DailyHighlightRNG()
146140
PA_ADD_OPTION(START_LOCATION);
147141

148142
PA_ADD_OPTION(NUM_HIGHLIGHTS);
149-
PA_ADD_OPTION(CONTINUE);
150143
PA_ADD_OPTION(FIX_TIME_WHEN_DONE);
151144
PA_ADD_OPTION(GO_HOME_WHEN_DONE);
152145
PA_ADD_OPTION(SAVE_ITERATIONS);
@@ -155,12 +148,6 @@ DailyHighlightRNG::DailyHighlightRNG()
155148
PA_ADD_OPTION(NOTIFICATIONS);
156149

157150
PA_ADD_STATIC(m_advanced_options);
158-
PA_ADD_OPTION(MOVE_TIME);
159-
PA_ADD_OPTION(MOVE_TIME2);
160-
PA_ADD_OPTION(LEFT_X);
161-
PA_ADD_OPTION(LEFT_Y);
162-
PA_ADD_OPTION(RIGHT_X);
163-
PA_ADD_OPTION(RIGHT_Y);
164151
PA_ADD_OPTION(MAX_UNKNOWN_ADVANCES);
165152
PA_ADD_OPTION(ADVANCE_PRESS_DURATION);
166153
PA_ADD_OPTION(ADVANCE_RELEASE_DURATION);
@@ -177,14 +164,16 @@ void DailyHighlightRNG::interact_with_trader(SingleSwitchProgramEnvironment& env
177164
pbf_press_button(context, BUTTON_A, 160ms, 600ms);
178165
pbf_press_button(context, BUTTON_A, 160ms, 160ms);
179166

180-
//Check if talking to the NPC was successfull
167+
// Check if talking to the NPC was successfull
181168
VideoOverlaySet boxes(env.console);
182169
SelectionArrowFinder arrow_detector(env.console, ImageFloatBox(0.5, 0.58, 0.2, 0.08));
183170
arrow_detector.make_overlays(boxes);
184171

185172
context.wait_for_all_requests();
186173
int ret = wait_until(env.console, context, 3000ms, { arrow_detector });
187174
if (ret < 0) {
175+
DailyHighlightRNG_Descriptor::Stats& stats = env.current_stats<DailyHighlightRNG_Descriptor::Stats>();
176+
stats.errors++;
188177
OperationFailedException::fire(
189178
ErrorReport::SEND_ERROR_REPORT,
190179
"Failed to talk to the trader.",
@@ -194,6 +183,7 @@ void DailyHighlightRNG::interact_with_trader(SingleSwitchProgramEnvironment& env
194183
}
195184

196185
void DailyHighlightRNG::buy_highlight(SingleSwitchProgramEnvironment& env, ProControllerContext& context) {
186+
// The player is expected to be in main dialog of the trader
197187
env.log("Buying Highlight.");
198188
env.console.overlay().add_log("Buying Highlight!", COLOR_WHITE);
199189
pbf_press_dpad(context, DPAD_DOWN, 80ms, 80ms);
@@ -215,6 +205,7 @@ void DailyHighlightRNG::buy_highlight(SingleSwitchProgramEnvironment& env, ProCo
215205
);
216206

217207
if (ret < 0) {
208+
env.
218209
OperationFailedException::fire(
219210
ErrorReport::SEND_ERROR_REPORT,
220211
"Could not detect dialog.",
@@ -248,13 +239,14 @@ uint8_t DailyHighlightRNG::calibrate_num_npc_from_party(SingleSwitchProgramEnvir
248239
env.log("Calibrating NPC amount.");
249240
env.console.overlay().add_log("Calibrating NPC amount.", COLOR_WHITE);
250241

251-
env.current_stats<DailyHighlightRNG_Descriptor::Stats>().reads++;
242+
DailyHighlightRNG_Descriptor::Stats& stats = env.current_stats<DailyHighlightRNG_Descriptor::Stats>();
243+
stats.reads++;
252244
std::pair<Xoroshiro128PlusState, uint64_t> result = refind_rng_state_and_animations(env.console, context, rng.get_state(), 0, 100, SAVE_SCREENSHOTS, LOG_VALUES);
253245
Xoroshiro128PlusState new_state = result.first;
254246
uint64_t additional_advances = result.second;
255247

256248
// Calculate state for possible NPC amounts
257-
const uint8_t MAX_NPCS = 4; // Usually either 1 or 2, maybe(?) 3 or 4 -> high numbers suggest bad npc state
249+
const uint8_t MAX_NPCS = 6; // Usually either 1 or 2, sometimes 3 or 4, maybe 5 or 6 -> high numbers suggest bad npc state
258250
std::vector<Xoroshiro128PlusState> rng_states;
259251

260252
for (size_t i = 0; i <= MAX_NPCS; i++) {
@@ -340,9 +332,6 @@ size_t DailyHighlightRNG::calculate_target(SingleSwitchProgramEnvironment& env,
340332
void DailyHighlightRNG::prepare_game_state(SingleSwitchProgramEnvironment& env, ProControllerContext& context) {
341333
env.log("Prepare player position.");
342334
env.console.overlay().add_log("Reset Player Position.", COLOR_WHITE);
343-
344-
// Return to overworld
345-
return_to_overworld(env, context);
346335

347336
// Open map
348337
pbf_press_button(context, BUTTON_X, 160ms, GameSettings::instance().OVERWORLD_TO_MENU_DELAY0);
@@ -366,6 +355,8 @@ void DailyHighlightRNG::return_to_overworld(SingleSwitchProgramEnvironment& env,
366355
{ {y_comm_icon_detector} }
367356
);
368357
if (ret != 0) {
358+
DailyHighlightRNG_Descriptor::Stats& stats = env.current_stats<DailyHighlightRNG_Descriptor::Stats>();
359+
stats.errors++;
369360
OperationFailedException::fire(
370361
ErrorReport::SEND_ERROR_REPORT,
371362
"Cannot detect the Y-Comm icon.",
@@ -420,6 +411,7 @@ void DailyHighlightRNG::program(SingleSwitchProgramEnvironment& env, ProControll
420411
pbf_press_button(context, BUTTON_B, 40ms, 40ms);
421412
}
422413

414+
423415
Xoroshiro128Plus rng(0, 0);
424416
bool is_state_valid = false;
425417
size_t iteration = 0;
@@ -446,10 +438,13 @@ void DailyHighlightRNG::program(SingleSwitchProgramEnvironment& env, ProControll
446438
if (!is_state_valid) {
447439
successfull_iterations = 0;
448440
prepare_game_state(env, context);
441+
442+
// open and close the menu and immediately walk to the trader
449443
pbf_press_button(context, BUTTON_X, 160ms, GameSettings::instance().OVERWORLD_TO_MENU_DELAY0);
450444
return_to_overworld(env, context);
451445
move_to_trader(env, context);
452446
interact_with_trader(env, context);
447+
453448
return_to_overworld(env, context);
454449
navigate_to_party(env, context);
455450
context.wait_for_all_requests();

SerialPrograms/Source/PokemonSwSh/Programs/RNG/PokemonSwSh_DailyHighlightRNG.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ class DailyHighlightRNG : public SingleSwitchProgramInstance{
4545
private:
4646
StartInGripOrGameOption START_LOCATION;
4747
SimpleIntegerOption<uint16_t> NUM_HIGHLIGHTS;
48-
BooleanCheckBoxOption CONTINUE;
4948
BooleanCheckBoxOption FIX_TIME_WHEN_DONE;
5049
GoHomeWhenDoneOption GO_HOME_WHEN_DONE;
5150
SimpleIntegerOption<uint16_t> SAVE_ITERATIONS;
@@ -55,13 +54,6 @@ class DailyHighlightRNG : public SingleSwitchProgramInstance{
5554
EventNotificationsOption NOTIFICATIONS;
5655

5756
SectionDividerOption m_advanced_options;
58-
MillisecondsOption MOVE_TIME;
59-
MillisecondsOption MOVE_TIME2;
60-
SimpleIntegerOption<uint8_t> LEFT_X;
61-
SimpleIntegerOption<uint8_t> LEFT_Y;
62-
SimpleIntegerOption<uint8_t> RIGHT_X;
63-
SimpleIntegerOption<uint8_t> RIGHT_Y;
64-
6557
SimpleIntegerOption<uint32_t> MAX_UNKNOWN_ADVANCES;
6658
MillisecondsOption ADVANCE_PRESS_DURATION;
6759
MillisecondsOption ADVANCE_RELEASE_DURATION;

0 commit comments

Comments
 (0)