@@ -77,65 +77,69 @@ LegendaryHuntEmerald::LegendaryHuntEmerald()
7777 PA_ADD_OPTION (NOTIFICATIONS);
7878}
7979
80- void LegendaryHuntEmerald::reset_room (SingleSwitchProgramEnvironment& env, SwitchControllerContext& context) {
81- switch (TARGET) {
82- case Target::regis:
83- // turn around, walk down 4
84-
85- // black screen over
86-
87- // turn around, up one
88-
89- // black screen over
90-
91- // reverse the above
92-
93- break ;
94- case Target::hooh:
95- // Turn around
96-
97- // 10 steps down
98-
99- // Turn right
100-
101- // Take one step
102-
103- // Wait for black screen over
104-
105- // Turn left and take a step
106-
107- // now turn right and take a step
108-
109- // wait for black screen over
110-
111- // now reverse the above, but only take 9 steps up
112- break ;
113- case Target::lugia:
114- // Turn around
115-
116- // 5 steps down
117-
118- // Turn right
119-
120- // 3 steps right
121-
122-
123- // Wait for black screen over
124-
125- // turn up, take one step
80+ void LegendaryHuntEmerald::reset_lugia (SingleSwitchProgramEnvironment& env, SwitchControllerContext& context) {
81+ BlackScreenOverWatcher exit_area (COLOR_RED, {0.282 , 0.064 , 0.448 , 0.871 });
82+ // Turn around, 5 steps down
83+ ssf_press_button (context, BUTTON_B, 0 , 90 );
84+ pbf_press_dpad (context, DPAD_DOWN, 90 , 20 );
85+
86+ // Turn right, 3 steps right. Wait for black screen over.
87+ int ret = run_until<SwitchControllerContext>(
88+ env.console , context,
89+ [](SwitchControllerContext& context){
90+ ssf_press_button (context, BUTTON_B, 0 , 90 );
91+ pbf_press_dpad (context, DPAD_RIGHT, 90 , 20 );
92+ pbf_wait (context, 300 );
93+ },
94+ {exit_area}
95+ );
96+ context.wait_for_all_requests ();
97+ if (ret != 0 ){
98+ env.log (" Failed to exit area." , COLOR_RED);
99+ OperationFailedException::fire (
100+ ErrorReport::SEND_ERROR_REPORT,
101+ " Failed to exit area." ,
102+ env.console
103+ );
104+ }
105+ else {
106+ env.log (" Left area." );
107+ }
126108
127- // now turn back down and take a step
109+ BlackScreenOverWatcher enter_area (COLOR_RED, {0.282 , 0.064 , 0.448 , 0.871 });
110+ // turn up, take one step. then turn back down and take a step. wait for black screen over.
111+ int ret2 = run_until<SwitchControllerContext>(
112+ env.console , context,
113+ [](SwitchControllerContext& context){
114+ ssf_press_button (context, BUTTON_B, 0 , 40 );
115+ pbf_press_dpad (context, DPAD_UP, 40 , 20 );
116+
117+ ssf_press_button (context, BUTTON_B, 0 , 40 );
118+ pbf_press_dpad (context, DPAD_DOWN, 40 , 20 );
119+ pbf_wait (context, 300 );
120+ },
121+ {enter_area}
122+ );
123+ context.wait_for_all_requests ();
124+ if (ret2 != 0 ){
125+ env.log (" Failed to enter area." , COLOR_RED);
126+ OperationFailedException::fire (
127+ ErrorReport::SEND_ERROR_REPORT,
128+ " Failed to enter area." ,
129+ env.console
130+ );
131+ }
132+ else {
133+ env.log (" Entered area." );
134+ }
128135
129- // wait for black screen over
136+ // reverse above steps
137+ ssf_press_button (context, BUTTON_B, 0 , 70 );
138+ pbf_press_dpad (context, DPAD_LEFT, 70 , 20 );
130139
131- // reverse above steps
132- break ;
133- case Target::latis:
140+ ssf_press_button (context, BUTTON_B, 0 , 90 );
141+ pbf_press_dpad (context, DPAD_UP, 90 , 20 );
134142
135- break ;
136- default :
137- break ;
138- }
139143 context.wait_for_all_requests ();
140144}
141145
@@ -176,8 +180,53 @@ void LegendaryHuntEmerald::program(SingleSwitchProgramEnvironment& env, SwitchCo
176180 pbf_mash_button (context, BUTTON_B, 250 );
177181 context.wait_for_all_requests ();
178182
179- // Exit and reenter
180- reset_room (env, context);
183+ // Exit and re-enter the room
184+ switch (TARGET) {
185+ case Target::regis:
186+ // turn around, walk down 4
187+
188+ // black screen over
189+
190+ // turn around, up one
191+
192+ // black screen over
193+
194+ // reverse the above
195+
196+ break ;
197+ case Target::hooh:
198+ // Turn around
199+
200+ // 10 steps down
201+
202+ // Turn right
203+
204+ // Take one step
205+
206+ // Wait for black screen over
207+
208+ // Turn left and take a step
209+
210+ // now turn right and take a step
211+
212+ // wait for black screen over
213+
214+ // now reverse the above, but only take 9 steps up
215+ break ;
216+ case Target::lugia:
217+ reset_lugia (env, context);
218+ break ;
219+ case Target::latis:
220+ // TODO
221+ break ;
222+ default :
223+ OperationFailedException::fire (
224+ ErrorReport::SEND_ERROR_REPORT,
225+ " Invalid target!" ,
226+ env.console
227+ );
228+ break ;
229+ }
181230
182231 stats.resets ++;
183232 env.update_stats ();
0 commit comments