1010#include " CommonFramework/Notifications/ProgramNotifications.h"
1111#include " CommonFramework/Tools/VideoResolutionCheck.h"
1212#include " CommonFramework/Tools/StatsTracking.h"
13+ #include " CommonFramework/VideoPipeline/VideoFeed.h"
1314#include " NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
1415#include " NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
1516#include " PokemonRSE/Inference/Dialogs/PokemonRSE_DialogDetector.h"
@@ -62,26 +63,14 @@ AudioStarterReset::AudioStarterReset()
6263 LockMode::LOCK_WHILE_RUNNING,
6364 Target::treecko
6465 )
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- )
7766 , NOTIFICATION_SHINY_POOCH(
7867 " Shiny Poochyena" ,
79- false , false ,
68+ false , false , ImageAttachmentMode::JPG,
8069 {" Notifs" }
8170 )
8271 , NOTIFICATION_SHINY_STARTER(
8372 " Shiny Starter" ,
84- true , false ,
73+ true , true , ImageAttachmentMode::JPG ,
8574 {" Notifs" , " Showcase" }
8675 )
8776 , NOTIFICATION_STATUS_UPDATE(" Status Update" , true , false , std::chrono::seconds(3600 ))
@@ -116,8 +105,9 @@ void AudioStarterReset::program(SingleSwitchProgramEnvironment& env, BotBaseCont
116105
117106 bool shiny_starter = false ;
118107 while (!shiny_starter) {
119-
108+ float shiny_coefficient = 1.0 ;
120109 ShinySoundDetector pooch_detector (env.console , [&](float error_coefficient) -> bool {
110+ shiny_coefficient = error_coefficient;
121111 return true ;
122112 });
123113
@@ -143,71 +133,84 @@ void AudioStarterReset::program(SingleSwitchProgramEnvironment& env, BotBaseCont
143133 }
144134 pbf_mash_button (context, BUTTON_A, 540 );
145135 context.wait_for_all_requests ();
146- env.log (" Starter selected. Checking for shiny Poochyena." );
147136
137+ env.log (" Starter selected. Checking for shiny Poochyena." );
148138 AdvanceDialogWatcher pooch_appeared (COLOR_YELLOW);
139+
149140 int res = run_until (
150141 env.console , context,
151142 [&](BotBaseContext& context) {
152143 int ret = wait_until (
153144 env.console , context,
154145 std::chrono::seconds (20 ),
155- {{pooch_detector }}
146+ {{pooch_appeared }}
156147 );
157- pooch_detector.throw_if_no_sound ();
158- if (ret == 0 ){
159- env.log (" Shiny Poochyena detected!" );
160- stats.poochyena ++;
161- send_program_status_notification (env, NOTIFICATION_SHINY_POOCH, " Shiny Poochyena found." );
162- }
163- else {
164- env.log (" Poochyena is not shiny." );
148+ if (ret == 0 ) {
149+ env.log (" Advance arrow detected." );
165150 }
151+ pbf_wait (context, 125 );
152+ context.wait_for_all_requests ();
166153 },
167- {{pooch_appeared }}
154+ {{pooch_detector }}
168155 );
169- if (res == 0 ) {
170- env.log (" Advance arrow detected. Pressing A." );
171- } // res != if pooch is shiny
156+ pooch_detector.throw_if_no_sound ();
157+ if (res == 0 ){
158+ env.log (" Shiny Poochyena detected!" );
159+ stats.poochyena ++;
160+ env.update_stats ();
161+ send_program_status_notification (env, NOTIFICATION_SHINY_POOCH, " Shiny Poochyena found." , env.console .video ().snapshot (), false );
162+ }
163+ else {
164+ env.log (" Poochyena is not shiny." );
165+ }
166+ context.wait_for_all_requests ();
172167
168+ float shiny_coefficient2 = 1.0 ;
173169 ShinySoundDetector starter_detector (env.console , [&](float error_coefficient) -> bool {
170+ shiny_coefficient2 = error_coefficient;
174171 return true ;
175172 });
176173
177- // Press A to send out your selected starter
178- env.log (" Sending out selected starter." );
179- pbf_press_button (context, BUTTON_A, 40 , 40 );
180-
181- int ret2 = run_until (
174+ BattleMenuWatcher battle_menu (COLOR_RED);
175+ int res2 = run_until (
182176 env.console , context,
183- [&](BotBaseContext& context){
184- env.log (" Wait for starter to come out." );
185- pbf_wait (context, STARTER_WAIT);
177+ [&](BotBaseContext& context) {
178+ env.log (" Sending out selected starter." );
179+ pbf_press_button (context, BUTTON_A, 40 , 40 );
180+
181+ int ret = wait_until (
182+ env.console , context,
183+ std::chrono::seconds (20 ),
184+ {{battle_menu}}
185+ );
186+ if (ret == 0 ) {
187+ env.log (" Battle menu detecteed!" );
188+ }
189+ pbf_wait (context, 125 );
186190 context.wait_for_all_requests ();
187191 },
188192 {{starter_detector}}
189193 );
190194 starter_detector.throw_if_no_sound ();
191- if (ret2 == 0 ){
195+ context.wait_for_all_requests ();
196+ if (res2 == 0 ){
192197 env.log (" Shiny starter detected!" );
193198 stats.shinystarter ++;
194-
195- send_program_status_notification (env, NOTIFICATION_SHINY_STARTER, " Shiny starter found!" );
196-
199+ env.update_stats ();
200+ send_program_status_notification (env, NOTIFICATION_SHINY_STARTER, " Shiny starter found!" , env.console .video ().snapshot (), true );
197201 shiny_starter = true ;
198- break ;
199202 }
200203 else {
201204 env.log (" Starter is not shiny." );
205+ env.log (" Soft resetting." );
206+ send_program_status_notification (
207+ env, NOTIFICATION_STATUS_UPDATE,
208+ " Soft resetting."
209+ );
210+ soft_reset (env.program_info (), env.console , context);
211+ stats.resets ++;
212+ env.update_stats ();
202213 }
203-
204- env.log (" Soft resetting." );
205- send_program_status_notification (
206- env, NOTIFICATION_STATUS_UPDATE,
207- " Soft resetting."
208- );
209- soft_reset (env.program_info (), env.console , context);
210- stats.resets ++;
211214 }
212215
213216 // if system set to nintendo switch, have go home when done option?
0 commit comments