@@ -25,7 +25,7 @@ StarterReset_Descriptor::StarterReset_Descriptor()
2525 " PokemonRSE:StarterReset" ,
2626 " Pokemon RSE" , " Starter Reset" ,
2727 " ComputerControl/blob/master/Wiki/Programs/PokemonRSE/StarterReset.md" ,
28- " Soft reset for a shiny starter." ,
28+ " (Audio only) Soft reset for a shiny starter. WIP, audio recognition does not work well ." ,
2929 // FeedbackType::VIDEO_AUDIO,
3030 FeedbackType::NONE,
3131 AllowCommandsWhenRunning::DISABLE_COMMANDS,
@@ -62,11 +62,34 @@ StarterReset::StarterReset()
6262 LockMode::LOCK_WHILE_RUNNING,
6363 Target::treecko
6464 )
65+ , POOCH_WAIT(
66+ " <b>Battle start wait:</b><br>Time for battle to start and for Poochyena to appear. Make sure to add extra time in case the Poochyena is shiny." ,
67+ LockMode::LOCK_WHILE_RUNNING,
68+ TICKS_PER_SECOND,
69+ " 6 * TICKS_PER_SECOND"
70+ )
71+ , STARTER_WAIT(
72+ " <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." ,
73+ LockMode::LOCK_WHILE_RUNNING,
74+ TICKS_PER_SECOND,
75+ " 6 * TICKS_PER_SECOND"
76+ )
77+ , NOTIFICATION_SHINY_POOCH(
78+ " Shiny Poochyena" ,
79+ false , false ,
80+ {" Notifs" }
81+ )
82+ , NOTIFICATION_SHINY_STARTER(
83+ " Shiny Starter" ,
84+ true , false ,
85+ {" Notifs" , " Showcase" }
86+ )
6587 , NOTIFICATION_STATUS_UPDATE(" Status Update" , true , false , std::chrono::seconds(3600 ))
6688 , NOTIFICATIONS({
89+ &NOTIFICATION_SHINY_POOCH,
90+ &NOTIFICATION_SHINY_STARTER,
6791 &NOTIFICATION_STATUS_UPDATE,
6892 &NOTIFICATION_PROGRAM_FINISH,
69- // &NOTIFICATION_ERROR_FATAL,
7093 })
7194{
7295 PA_ADD_OPTION (TARGET);
@@ -78,74 +101,51 @@ void StarterReset::program(SingleSwitchProgramEnvironment& env, BotBaseContext&
78101 StarterReset_Descriptor::Stats& stats = env.current_stats <StarterReset_Descriptor::Stats>();
79102
80103 /*
81- * Stand in front of birch's bag.
82- *
83- * text speed fast
104+ * Settings: Text Speed fast.
105+ * Setup: Stand in front of the Professor's bag and save the game.
84106 *
85- * have to do the SR method instead of run away
107+ * Required to fight, so have to do the SR method instead of run away
108+ * Soft reset programs are only for Ruby/Sapphire, as Emerald has the 0 seed issue.
86109 *
87- * ONLY FOR RS, emerald has rng anyway
88- *
89- * This assumes no dry battery. If you have a dry battery, just do RNG.
90- */
91-
92- /*
93- start at birch bag
94-
95- starter selection
96-
97- wild pooch appears, shiny check (audio?)
98-
99- go starter
100-
101- now shiny check
102-
103- track starter shiny, zig shiny, number of attempts, errors
104-
105- if not shiny, soft reset
106-
107- soft reset checks for dry battery and returns true or false!
108-
110+ * This also assumes no dry battery.
109111 */
110112
111113 bool shiny_starter = false ;
112114 while (!shiny_starter) {
113115
114- float shiny_coefficient = 1.0 ;
115116 ShinySoundDetector pooch_detector (env.console , [&](float error_coefficient) -> bool {
116- // Warning: This callback will be run from a different thread than this function.
117- shiny_coefficient = error_coefficient;
118117 return true ;
119118 });
120119
120+ env.log (" Opening bag and selecting starter." );
121+ pbf_press_button (context, BUTTON_A, 40 , 180 );
122+
123+ switch (TARGET) {
124+ case Target::treecko:
125+ pbf_press_dpad (context, DPAD_LEFT, 40 , 100 );
126+ break ;
127+ case Target::torchic:
128+ // Default cursor position, do nothing.
129+ break ;
130+ case Target::mudkip:
131+ pbf_press_dpad (context, DPAD_RIGHT, 40 , 100 );
132+ break ;
133+ default :
134+ OperationFailedException::fire (
135+ env.console , ErrorReport::SEND_ERROR_REPORT,
136+ " StarterReset: Invalid target."
137+ );
138+ break ;
139+ }
140+ pbf_mash_button (context, BUTTON_A, 540 );
141+ env.log (" Starter selected. Checking for shiny Poochyena." );
142+
143+
121144 int ret = run_until (
122145 env.console , context,
123146 [&](BotBaseContext& context){
124- env.log (" Opening bag and selecting starter." );
125- pbf_press_button (context, BUTTON_A, 40 , 180 );
126-
127- switch (TARGET) {
128- case Target::treecko:
129- pbf_press_dpad (context, DPAD_LEFT, 40 , 100 );
130- break ;
131- case Target::torchic:
132- // Default cursor position, do nothing.
133- break ;
134- case Target::mudkip:
135- pbf_press_dpad (context, DPAD_RIGHT, 40 , 100 );
136- break ;
137- default :
138- OperationFailedException::fire (
139- env.console , ErrorReport::SEND_ERROR_REPORT,
140- " StarterReset: Invalid target."
141- );
142- break ;
143- }
144- pbf_mash_button (context, BUTTON_A, 540 );
145- env.log (" Starter selected. Checking for shiny Poochyena." );
146-
147147 // Wait for battle to start and for Pooch battle cry
148- pbf_wait (context, 400 );
148+ pbf_wait (context, POOCH_WAIT );
149149
150150 context.wait_for_all_requests ();
151151
@@ -156,33 +156,48 @@ void StarterReset::program(SingleSwitchProgramEnvironment& env, BotBaseContext&
156156 if (ret == 0 ){
157157 env.log (" Shiny Poochyena detected!" );
158158 stats.poochyena ++;
159+ send_program_status_notification (env, NOTIFICATION_SHINY_POOCH, " Shiny Poochyena found." );
160+ }
161+ else {
162+ env.log (" Poochyena is not shiny." );
159163 }
160164
161165 ShinySoundDetector starter_detector (env.console , [&](float error_coefficient) -> bool {
162- // Warning: This callback will be run from a different thread than this function.
163- shiny_coefficient = error_coefficient;
164166 return true ;
165167 });
166168
169+ // Press A to send out your selected starter
170+ env.log (" Sending out selected starter." );
171+ pbf_press_button (context, BUTTON_A, 40 , 40 );
172+
167173 int ret2 = run_until (
168174 env.console , context,
169175 [&](BotBaseContext& context){
170- env.log (" Sending out selected starter." );
171- // Press A to send out your selected starter
172- pbf_press_button ( context, BUTTON_A, 40 , 400 );
176+ env.log (" Wait for starter to come out ." );
177+ pbf_wait (context, STARTER_WAIT);
178+ context. wait_for_all_requests ( );
173179 },
174180 {{starter_detector}}
175181 );
176182 starter_detector.throw_if_no_sound ();
177183 if (ret2 == 0 ){
178184 env.log (" Shiny starter detected!" );
179185 stats.shinystarter ++;
186+
187+ send_program_status_notification (env, NOTIFICATION_SHINY_STARTER, " Shiny starter found!" );
188+
180189 shiny_starter = true ;
181190 break ;
182-
191+ }
192+ else {
193+ env.log (" Starter is not shiny." );
183194 }
184195
185196 env.log (" Soft resetting." );
197+ send_program_status_notification (
198+ env, NOTIFICATION_STATUS_UPDATE,
199+ " Soft resetting."
200+ );
186201 soft_reset (env.program_info (), env.console , context);
187202 stats.resets ++;
188203 }
0 commit comments