|
5 | 5 | */ |
6 | 6 |
|
7 | 7 | #include <algorithm> |
| 8 | +#include "Common/Cpp/PrettyPrint.h" |
8 | 9 | #include "CommonFramework/Logging/Logger.h" |
9 | 10 | #include "CommonFramework/Exceptions/ProgramFinishedException.h" |
10 | | -#include "CommonFramework/Exceptions/OperationFailedException.h" |
11 | | -#include "CommonFramework/Exceptions/FatalProgramException.h" |
| 11 | +//#include "CommonFramework/Exceptions/OperationFailedException.h" |
| 12 | +//#include "CommonFramework/Exceptions/FatalProgramException.h" |
12 | 13 | #include "CommonFramework/Tools/ProgramEnvironment.h" |
13 | 14 | #include "CommonTools/Async/InferenceRoutines.h" |
14 | 15 | #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" |
15 | | -#include "Pokemon/Pokemon_Notification.h" |
16 | | -#include "PokemonSV/Options/PokemonSV_EncounterBotCommon.h" |
| 16 | +//#include "Pokemon/Pokemon_Notification.h" |
| 17 | +//#include "PokemonSV/Options/PokemonSV_EncounterBotCommon.h" |
17 | 18 | #include "PokemonSV/Inference/PokemonSV_SweatBubbleDetector.h" |
18 | 19 | #include "PokemonSV/Programs/Battles/PokemonSV_Battles.h" |
19 | | -#include "PokemonSV/Programs/Battles/PokemonSV_BasicCatcher.h" |
| 20 | +//#include "PokemonSV/Programs/Battles/PokemonSV_BasicCatcher.h" |
20 | 21 | #include "PokemonSV_LetsGoTools.h" |
21 | 22 |
|
22 | 23 | //#include <iostream> |
@@ -195,34 +196,49 @@ bool use_lets_go_to_clear_in_front( |
195 | 196 | if (ret == 0){ |
196 | 197 | if (throw_ball_if_bubble){ |
197 | 198 | stream.log("Detected sweat bubble. Throwing ball..."); |
198 | | - pbf_mash_button(context, BUTTON_ZR, 5 * TICKS_PER_SECOND); |
| 199 | + pbf_mash_button(context, BUTTON_ZR, 5000ms); |
199 | 200 | }else{ |
200 | 201 | stream.log("Detected sweat bubble. Will not throw ball."); |
201 | 202 | } |
202 | 203 | }else{ |
203 | 204 | stream.log("Did not detect sweat bubble."); |
204 | 205 | } |
205 | 206 |
|
206 | | - WallClock last_kill = tracker.last_kill(); |
207 | 207 | context.wait_for_all_requests(); |
208 | 208 | std::chrono::seconds timeout(6); |
209 | 209 | while (true){ |
| 210 | +// cout << "last kill: " << last_kill << endl; |
210 | 211 | if (command){ |
211 | 212 | // cout << "running command..." << endl; |
212 | 213 | command(context); |
213 | 214 | context.wait_for_all_requests(); |
214 | 215 | command = nullptr; |
215 | 216 | }else{ |
216 | 217 | // cout << "Waiting out... " << timeout.count() << " seconds" << endl; |
217 | | - context.wait_until(last_kill + timeout); |
| 218 | + context.wait_until(tracker.last_kill() + timeout); |
218 | 219 | } |
219 | 220 | // timeout = std::chrono::seconds(3); |
220 | | - if (last_kill == tracker.last_kill()){ |
| 221 | + |
| 222 | + WallClock now = current_time(); |
| 223 | + WallClock last_kill_time = tracker.last_kill(); |
| 224 | + WallDuration last_kill; |
| 225 | + if (last_kill_time == WallClock::min()){ |
| 226 | + stream.log("Last Kill: Never"); |
| 227 | + last_kill = WallDuration::max(); |
| 228 | + }else{ |
| 229 | + last_kill = now - last_kill_time; |
| 230 | + stream.log( |
| 231 | + "Last Kill: " + |
| 232 | + tostr_fixed(std::chrono::duration_cast<Milliseconds>(last_kill).count() / 1000., 3) + |
| 233 | + " seconds ago" |
| 234 | + ); |
| 235 | + } |
| 236 | + |
| 237 | + if (last_kill > timeout){ |
221 | 238 | // cout << "no kill" << endl; |
222 | 239 | break; |
223 | 240 | } |
224 | 241 | // cout << "found kill" << endl; |
225 | | - last_kill = tracker.last_kill(); |
226 | 242 | } |
227 | 243 | stream.log("Nothing left to clear..."); |
228 | 244 | tracker.throw_if_no_sound(); |
|
0 commit comments