Skip to content

Commit 4e5422b

Browse files
committed
QOL Improvements
1 parent 9bfdccc commit 4e5422b

File tree

3 files changed

+77
-13
lines changed

3 files changed

+77
-13
lines changed

SysBot.Pokemon/Actions/PokeRoutineExecutor.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,16 @@ public async Task StartGame(PokeTradeHubConfig config, CancellationToken token)
313313
Log("Restarting the game!");
314314

315315
// Switch Logo lag, skip cutscene, game load screen
316-
await Task.Delay(11_000 + config.Timings.ExtraTimeLoadGame, token).ConfigureAwait(false);
316+
await Task.Delay(13_000 + config.Timings.ExtraTimeLoadGame, token).ConfigureAwait(false);
317317

318318
for (int i = 0; i < 5; i++)
319319
await Click(A, 1_000, token).ConfigureAwait(false);
320320

321-
while (!await IsOnOverworld(config, token).ConfigureAwait(false))
321+
while (!await IsOnOverworld(config, token).ConfigureAwait(false) && !await IsInBattle(token))
322+
{
322323
await Task.Delay(2_000, token).ConfigureAwait(false);
324+
await Click(A, 1_000, token).ConfigureAwait(false);
325+
}
323326

324327
Log("Back in the overworld!");
325328
}
@@ -453,11 +456,10 @@ public async Task PokeCamp(CancellationToken token)
453456
{
454457
// Open Poke Camp and return to the overworld
455458
Log("Opening Camp...");
456-
await Click(X, 1_000, token).ConfigureAwait(false);
457-
await Click(A, 0_600, token).ConfigureAwait(false);
458-
await Click(B, 6_600, token).ConfigureAwait(false);
459-
await Click(B, 1_000, token).ConfigureAwait(false);
460-
await Click(A, 1_600, token).ConfigureAwait(false);
459+
await Click(X, 1_500, token).ConfigureAwait(false);
460+
await Click(A, 8_000, token).ConfigureAwait(false);
461+
await Click(B, 2_000, token).ConfigureAwait(false);
462+
await Click(A, 1_000, token).ConfigureAwait(false);
461463
}
462464
}
463465
}

SysBot.Pokemon/BotEncounter/EncounterBot.cs

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ protected override async Task MainLoop(CancellationToken token)
4646
EncounterMode.Regis => DoRegiEncounter(token),
4747
EncounterMode.LegendaryDogs => DoDogEncounter(token),
4848
EncounterMode.SwordsJustice => DoJusticeEncounter(token),
49+
EncounterMode.GalarianArticuno => DoGArticunoEncounter(token),
4950
//EncounterMode.LGPE => DoLGPEEncounter(token),
5051
_ => WalkInLine(token),
5152
};
@@ -227,21 +228,34 @@ private async Task DoDogEncounter(CancellationToken token)
227228

228229
private async Task DoJusticeEncounter(CancellationToken token)
229230
{
231+
Log("For a better experience, ldn-mitm sysmodule is suggested to be installed.");
232+
bool reset = false;
230233
while (!token.IsCancellationRequested)
231234
{
232235
// Waiting to be in the overworld
233236
while (!await IsOnOverworld(Hub.Config, token).ConfigureAwait(false))
234-
await Task.Delay(2_000, token).ConfigureAwait(false);
237+
await Task.Delay(0_500, token).ConfigureAwait(false);
235238

236239
// Enter and exit Pokecamp in order to respawn the Pokemon
237240
await PokeCamp(token);
238241

239242
//Check position
240243
int i = 0;
241-
while (!await IsInBattle(token).ConfigureAwait(false))
244+
while (!await IsInBattle(token).ConfigureAwait(false) && !reset)
242245
{
243-
await Task.Delay(1_000, token).ConfigureAwait(false);
244-
if (i==5) Log("Position could be wrong or Pokécamp option is not the first available in the menu.\n");
246+
await Task.Delay(0_500, token).ConfigureAwait(false);
247+
if (i == 15)
248+
{
249+
Log("Position could be wrong or Pokécamp option is not the first available in the menu.\nTrying to reset the game.");
250+
reset = true;
251+
}
252+
if (reset == true)
253+
{
254+
reset = false;
255+
i = 0;
256+
await CloseGame(Hub.Config, token).ConfigureAwait(false);
257+
await StartGame(Hub.Config, token).ConfigureAwait(false);
258+
}
245259
i++;
246260
}
247261

@@ -260,14 +274,56 @@ private async Task DoJusticeEncounter(CancellationToken token)
260274

261275
// Offsets are flickery so make sure we see it 3 times.
262276
for (i = 0; i < 3; i++)
263-
await ReadUntilChanged(BattleMenuOffset, BattleMenuReady, 5_000, 0_100, true, token).ConfigureAwait(false);
277+
await ReadUntilChanged(BattleMenuOffset, BattleMenuReady, 5_000, 0_100, true, token).ConfigureAwait(false);
264278

265279
if (await HandleEncounter(pk, true, token).ConfigureAwait(false))
266280
return;
267281

268-
// Run awai if not the wanted encounter
282+
// Run away if not the wanted encounter
269283
while (await IsInBattle(token).ConfigureAwait(false))
284+
{
285+
await Task.Delay(1_000, token).ConfigureAwait(false);
270286
await FleeToOverworld(token).ConfigureAwait(false);
287+
}
288+
}
289+
}
290+
291+
private async Task DoGArticunoEncounter(CancellationToken token)
292+
{
293+
Log("PLEASE NOTE THAT THIS BOT IS NOT FULLY FUNCTIONAL. ONLY AVAILABLE FOR TESTING PURPOSES.");
294+
while (!token.IsCancellationRequested)
295+
{
296+
//Waiting for Articuno Battle
297+
int i = 0;
298+
while (await ReadUntilPresent(WildPokemonOffset, 2_000, 0_200, token).ConfigureAwait(false) == null)
299+
{
300+
await Task.Delay(0_500, token).ConfigureAwait(false);
301+
if (i == 5) Log("The Pokémon is flew away. Sorry.");
302+
i++;
303+
}
304+
305+
//Read Pokémon Information
306+
Log("Encounter Articuno started! Checking details...");
307+
var pk = await ReadUntilPresent(WildPokemonOffset, 2_000, 0_200, token).ConfigureAwait(false);
308+
if (pk == null)
309+
Log("Not right Offset.");
310+
311+
// Offsets are flickery so make sure we see it 3 times.
312+
for (i = 0; i < 3; i++)
313+
await ReadUntilChanged(BattleMenuOffset, BattleMenuReady, 5_000, 0_100, true, token).ConfigureAwait(false);
314+
315+
if (await HandleEncounter(pk, true, token).ConfigureAwait(false))
316+
return;
317+
318+
// Run awai if not the wanted encounter
319+
await FleeToOverworld(token).ConfigureAwait(false);
320+
321+
// Waiting to be in the overworld
322+
while (!await IsOnOverworld(Hub.Config, token).ConfigureAwait(false))
323+
await Click(A, 1_000, token).ConfigureAwait(false);
324+
325+
// Enter and exit Pokecamp in order to respawn the Pokemon
326+
await PokeCamp(token);
271327
}
272328
}
273329

@@ -362,6 +418,7 @@ private async Task ResetStick(CancellationToken token)
362418
private async Task FleeToOverworld(CancellationToken token)
363419
{
364420
// This routine will always escape a battle.
421+
await Task.Delay(1_000, token).ConfigureAwait(false);
365422
await Click(DUP, 0_400, token).ConfigureAwait(false);
366423
await Click(A, 0_400, token).ConfigureAwait(false);
367424
await Click(B, 0_400, token).ConfigureAwait(false);

SysBot.Pokemon/BotEncounter/EncounterModes.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public enum EncounterMode
3737
/// </summary>
3838
SwordsJustice,
3939

40+
/// <summary>
41+
/// Bot will soft reset the Swords of Justice Trio
42+
/// </summary>
43+
GalarianArticuno,
44+
4045
//LGPE,
4146
}
4247
}

0 commit comments

Comments
 (0)