Skip to content

Commit 731ac05

Browse files
committed
Added Sword of Justice & Gigas support
1 parent c3b82a5 commit 731ac05

File tree

3 files changed

+84
-4
lines changed

3 files changed

+84
-4
lines changed

SysBot.Pokemon/Actions/PokeRoutineExecutor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ public async Task StartGame(PokeTradeHubConfig config, CancellationToken token)
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))
322-
await Task.Delay(2_000, token).ConfigureAwait(false);
321+
while (!await IsOnOverworld(config, token).ConfigureAwait(false) && !await IsInBattle(token).ConfigureAwait(false))
322+
await Task.Delay(0_500, token).ConfigureAwait(false);
323323

324324
Log("Back in the overworld!");
325325
}

SysBot.Pokemon/BotEncounter/EncounterBot.cs

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ protected override async Task MainLoop(CancellationToken token)
4242
EncounterMode.VerticalLine => WalkInLine(token),
4343
EncounterMode.HorizontalLine => WalkInLine(token),
4444
EncounterMode.Eternatus => DoEternatusEncounter(token),
45+
EncounterMode.Regigigas => DoRegigigasEncounter(token),
4546
EncounterMode.Regis => DoRegiEncounter(token),
4647
EncounterMode.LegendaryDogs => DoDogEncounter(token),
48+
EncounterMode.SwordsJustice => DoJusticeEncounter(token),
4749
_ => WalkInLine(token),
4850
};
4951
await task.ConfigureAwait(false);
@@ -109,6 +111,33 @@ private async Task DoEternatusEncounter(CancellationToken token)
109111
}
110112
}
111113

114+
private async Task DoRegigigasEncounter(CancellationToken token)
115+
{
116+
Log("Reminder: LDN-MITM SYSMODULE IS REQUIRED IN ORDER FOR THIS BOT TO WORK!");
117+
while (!token.IsCancellationRequested)
118+
{
119+
Log("Looking for Gigas...");
120+
121+
//Click through all the menus until the encounter.
122+
while (!await IsInBattle(token).ConfigureAwait(false))
123+
await Click(A, 1_000, token).ConfigureAwait(false);
124+
125+
Log("An encounter has started!");
126+
127+
var pk = await ReadUntilPresent(RaidPokemonOffset, 2_000, 0_200, token).ConfigureAwait(false);
128+
if (pk != null)
129+
{
130+
if (await HandleEncounter(pk, true, token).ConfigureAwait(false))
131+
return;
132+
}
133+
134+
Connection.Log("Resetting Regigigas by restarting the game");
135+
136+
await CloseGame(Hub.Config, token).ConfigureAwait(false);
137+
await StartGame(Hub.Config, token).ConfigureAwait(false);
138+
}
139+
}
140+
112141
private async Task DoRegiEncounter(CancellationToken token)
113142
{
114143
Log("Reminder: LDN-MITM SYSMODULE IS REQUIRED IN ORDER FOR THIS BOT TO WORK!");
@@ -136,11 +165,12 @@ private async Task DoRegiEncounter(CancellationToken token)
136165
for (int i = 0; i < 3; i++)
137166
await ReadUntilChanged(BattleMenuOffset, BattleMenuReady, 5_000, 0_100, true, token).ConfigureAwait(false);
138167

139-
if (await HandleEncounter(pk, false, token).ConfigureAwait(false))
168+
if (await HandleEncounter(pk, true, token).ConfigureAwait(false))
140169
return;
141170

142171
Log("Restarting game...");
143172
await CloseGame(Hub.Config, token).ConfigureAwait(false);
173+
await StartGame(Hub.Config, token).ConfigureAwait(false);
144174
}
145175
}
146176

@@ -194,6 +224,46 @@ private async Task DoDogEncounter(CancellationToken token)
194224
}
195225
}
196226

227+
private async Task DoJusticeEncounter(CancellationToken token)
228+
{
229+
Log("Reminder: LDN-MITM SYSMODULE IS REQUIRED IN ORDER FOR THIS BOT TO WORK!");
230+
bool log;
231+
while (!token.IsCancellationRequested)
232+
{
233+
Log("Position saved. Rebooting game...");
234+
await CloseGame(Hub.Config, token).ConfigureAwait(false);
235+
await StartGame(Hub.Config, token).ConfigureAwait(false);
236+
237+
log = true;
238+
239+
while (!await IsInBattle(token).ConfigureAwait(false))
240+
{
241+
if (log) Log("Position could be wrong. Try to move a bit and save again.");
242+
log = false;
243+
}
244+
245+
Log("Encounter started! Checking details...");
246+
var pk = await ReadUntilPresent(WildPokemonOffset, 2_000, 0_200, token).ConfigureAwait(false);
247+
if (pk == null)
248+
{
249+
Log("Not right Offset. Restarting loop.");
250+
251+
// Flee and continue looping.
252+
while (await IsInBattle(token).ConfigureAwait(false))
253+
await FleeToOverworld(token).ConfigureAwait(false);
254+
continue;
255+
}
256+
257+
// Offsets are flickery so make sure we see it 3 times.
258+
for (int i = 0; i < 3; i++)
259+
await ReadUntilChanged(BattleMenuOffset, BattleMenuReady, 5_000, 0_100, true, token).ConfigureAwait(false);
260+
261+
if (await HandleEncounter(pk, true, token).ConfigureAwait(false))
262+
return;
263+
}
264+
}
265+
266+
197267
private async Task<int> StepUntilEncounter(CancellationToken token)
198268
{
199269
Log("Walking around until an encounter...");

SysBot.Pokemon/BotEncounter/EncounterModes.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,23 @@ public enum EncounterMode
1818
Eternatus,
1919

2020
/// <summary>
21-
/// Bot will soft reset for Regis. Do not use for Regigigas.
21+
/// Bot will soft reset Regigigas
22+
/// </summary>
23+
Regigigas,
24+
25+
/// <summary>
26+
/// Bot will soft reset for Regis
2227
/// </summary>
2328
Regis,
2429

2530
/// <summary>
2631
/// Bot will soft reset the Legendary Dogs
2732
/// </summary>
2833
LegendaryDogs,
34+
35+
/// <summary>
36+
/// Bot will soft reset the Swords of Justice Trio
37+
/// </summary>
38+
SwordsJustice,
2939
}
3040
}

0 commit comments

Comments
 (0)