private async Task ReviveFossil(FossilCount count, CancellationToken token) { await Click(A, 1100, token).ConfigureAwait(false); await Click(A, 1300, token).ConfigureAwait(false); if (count.UseSecondOption1(FossilSpecies)) { await Click(DDOWN, 300, token).ConfigureAwait(false); } await Click(A, 1300, token).ConfigureAwait(false); if (count.UseSecondOption2(FossilSpecies)) { await Click(DDOWN, 300, token).ConfigureAwait(false); } await Click(A, 1200, token).ConfigureAwait(false); await Click(A, 1200, token).ConfigureAwait(false); await Click(A, 4000, token).ConfigureAwait(false); await Click(A, 1200, token).ConfigureAwait(false); await Click(A, 1200, token).ConfigureAwait(false); if (GameLang == LanguageID.French) { await Click(A, 800, token).ConfigureAwait(false); } await Click(A, 1200, token).ConfigureAwait(false); await Click(A, 4500, token).ConfigureAwait(false); Log("Getting fossil! Clearing destination slot."); await SetBoxPokemon(Blank, InjectBox, InjectSlot, token).ConfigureAwait(false); await Click(A, 2400, token).ConfigureAwait(false); await Click(A, 1800, token).ConfigureAwait(false); }
private static FossilCount ReadCounts(InventoryPouch pouch) { var counts = new FossilCount(); foreach (var item in pouch.Items) { counts.SetCount(item.Index, item.Count); } return(counts); }
private async Task ReviveFossil(FossilCount count, CancellationToken token) { Log("Starting fossil revival routine..."); if (GameLang == LanguageID.Spanish) { await Click(A, 0_900, token).ConfigureAwait(false); } await Click(A, 1_100, token).ConfigureAwait(false); // French is slightly slower. if (GameLang == LanguageID.French) { await Task.Delay(0_200, token).ConfigureAwait(false); } await Click(A, 1_300, token).ConfigureAwait(false); // Selecting first fossil. if (count.UseSecondOption1(Hub.Config.SWSH_Fossil.Species)) { await Click(DDOWN, 0_300, token).ConfigureAwait(false); } await Click(A, 1_300, token).ConfigureAwait(false); // Selecting second fossil. if (count.UseSecondOption2(Hub.Config.SWSH_Fossil.Species)) { await Click(DDOWN, 300, token).ConfigureAwait(false); } // A spam through accepting the fossil and agreeing to revive. for (int i = 0; i < 8; i++) { await Click(A, 0_400, token).ConfigureAwait(false); } // Safe to mash B from here until we get out of all menus. while (!await SWSHIsGiftFound(token).ConfigureAwait(false)) { await Click(B, 0_400, token).ConfigureAwait(false); } }
private async Task ReviveFossil(FossilCount count, CancellationToken token) { Log("Starting fossil revival routine..."); if (GameLang == LanguageID.Spanish) { await Click(A, 0_900, token).ConfigureAwait(false); } await Click(A, 1_100, token).ConfigureAwait(false); // French is slightly slower. if (GameLang == LanguageID.French) { await Task.Delay(0_200, token).ConfigureAwait(false); } await Click(A, 1_300, token).ConfigureAwait(false); // Selecting first fossil. if (count.UseSecondOption1(Hub.Config.Fossil.Species)) { await Click(DDOWN, 0_300, token).ConfigureAwait(false); } await Click(A, 1_300, token).ConfigureAwait(false); // Selecting second fossil. if (count.UseSecondOption2(Hub.Config.Fossil.Species)) { await Click(DDOWN, 300, token).ConfigureAwait(false); } // A spam through accepting the fossil and agreeing to revive. while (await ReadUntilPresent(await ParsePointer(giftpoke, token), 2_000, 0_200, token).ConfigureAwait(false) == null) { await Click(A, 0_400, token).ConfigureAwait(false); await Task.Delay(1_000, token).ConfigureAwait(false); } }
protected override async Task MainLoop(CancellationToken token) { Log("Identifying trainer data of the host console."); await IdentifyTrainer(token).ConfigureAwait(false); var originalTextSpeed = await EnsureTextSpeedFast(token).ConfigureAwait(false); Log("Checking destination slot for revived fossil Pokémon to see if anything is in the slot..."); var existing = await GetBoxSlotQuality(InjectBox, InjectSlot, token).ConfigureAwait(false); if (existing.Quality != SlotQuality.Overwritable) { PrintBadSlotMessage(existing); return; } Log("Checking item counts..."); var pouchData = await Connection.ReadBytesAsync(PokeDataOffsets.ItemTreasureAddress, 80, token).ConfigureAwait(false); var counts = FossilCount.GetFossilCounts(pouchData); int reviveCount = counts.PossibleRevives(FossilSpecies); if (reviveCount == 0) { Log("Insufficient fossil pieces to start. Please obtain at least one of each required fossil piece before starting."); return; } Log("Starting main FossilBot loop."); Config.IterateNextRoutine(); while (!token.IsCancellationRequested && Config.NextRoutineType == PokeRoutineType.FossilBot) { await ReviveFossil(counts, token).ConfigureAwait(false); Log("Fossil revived. Checking details."); var pk = await ReadBoxPokemon(InjectBox, InjectSlot, token).ConfigureAwait(false); if (pk.Species == 0 || !pk.ChecksumValid) { Log("Invalid data detected in destination slot. Restarting loop."); continue; } encounterCount++; Log($"Encounter: {encounterCount}:{Environment.NewLine}{ShowdownSet.GetShowdownText(pk)}{Environment.NewLine}{Environment.NewLine}"); if (DumpSetting.Dump) { DumpPokemon(DumpSetting.DumpFolder, "fossil", pk); } Counts.AddCompletedFossils(); if (StopCondition(pk)) { if (Settings.ContinueAfterMatch) { Log("Result found! Continuing to collect more fossils."); continue; } Log("Result found! Stopping routine execution; re-start the bot(s) to search again."); return; } if (encounterCount % reviveCount != 0) { continue; } Log($"Ran out of fossils to revive {FossilSpecies}."); if (Settings.InjectWhenEmpty) { Log("Restoring original pouch data."); await Connection.WriteBytesAsync(pouchData, PokeDataOffsets.ItemTreasureAddress, token).ConfigureAwait(false); await Task.Delay(200, token).ConfigureAwait(false); } else { Log("Re-start the game then re-start the bot(s), or set \"Inject Fossils\" to True in the config."); return; } } await SetTextSpeed(originalTextSpeed, token).ConfigureAwait(false); }
public override async Task MainLoop(CancellationToken token) { Log("Identifying trainer data of the host console."); await IdentifyTrainer(token).ConfigureAwait(false); Log("Checking item counts..."); var pouchData = await Connection.ReadBytesAsync(ItemTreasureAddress, 80, token).ConfigureAwait(false); var counts = FossilCount.GetFossilCounts(pouchData); int reviveCount = counts.PossibleRevives(Hub.Config.SWSH_Fossil.Species); if (reviveCount == 0) { Log("Insufficient fossil pieces. Please obtain at least one of each required fossil piece first."); return; } Log("Starting main FossilBot loop."); Config.IterateNextRoutine(); while (!token.IsCancellationRequested && Config.NextRoutineType == PokeRoutineType.SWSH_FossilBot) { if (encounterCount != 0 && encounterCount % reviveCount == 0) { Log($"Ran out of fossils to revive {Hub.Config.SWSH_Fossil.Species}."); Log("Restarting the game to restore the puch data."); await CloseGame(Hub.Config, token).ConfigureAwait(false); await StartGame(Hub.Config, token).ConfigureAwait(false); } await ReviveFossil(counts, token).ConfigureAwait(false); Log("Fossil revived. Checking details..."); var pk = await ReadUntilPresent(await ParsePointer(PokeGift, token), 2_000, 0_200, token).ConfigureAwait(false); if (pk == null) { Log("RAM may be shifted, please restart the game and the bot."); } else { encounterCount++; Log($"Encounter: {encounterCount}:{Environment.NewLine}{ShowdownParsing.GetShowdownText(pk)}{Environment.NewLine}"); if (DumpSetting.Dump) { DumpPokemon(DumpSetting.DumpFolder, "fossil", pk); } Counts.AddCompletedFossils(); if (StopConditionSettings.EncounterFound(pk, DesiredMinIVs, DesiredMaxIVs, Hub.Config.StopConditions)) { if (Hub.Config.StopConditions.CaptureVideoClip) { await Task.Delay(Hub.Config.StopConditions.ExtraTimeWaitCaptureVideo, token).ConfigureAwait(false); await PressAndHold(CAPTURE, 2_000, 1_000, token).ConfigureAwait(false); } Log("Result found! Stopping routine execution; restart the bot(s) to search again."); await DetachController(token).ConfigureAwait(false); return; } while (!await IsOnOverworld(Hub.Config, token).ConfigureAwait(false)) { await Click(B, 0_200, token).ConfigureAwait(false); } } } }
protected override async Task MainLoop(CancellationToken token) { Log("Identifying trainer data of the host console."); await IdentifyTrainer(token).ConfigureAwait(false); await SetCurrentBox(0, token).ConfigureAwait(false); var existing = await ReadBoxPokemon(InjectBox, InjectSlot, token).ConfigureAwait(false); if (existing.Species != 0 && existing.ChecksumValid) { Log("Destination slot is occupied! Dumping the Pokémon found there..."); DumpPokemon(DumpSetting.DumpFolder, "saved", existing); } Log("Clearing destination slot to start the bot."); await SetBoxPokemon(Blank, InjectBox, InjectSlot, token).ConfigureAwait(false); Log("Checking item counts..."); var pouchData = await Connection.ReadBytesAsync(ItemTreasureAddress, 80, Config.ConnectionType, token).ConfigureAwait(false); var counts = FossilCount.GetFossilCounts(pouchData); int reviveCount = counts.PossibleRevives(Hub.Config.Fossil.Species); if (reviveCount == 0) { Log("Insufficient fossil pieces. Please obtain at least one of each required fossil piece first."); return; } Log("Starting main FossilBot loop."); Config.IterateNextRoutine(); while (!token.IsCancellationRequested && Config.NextRoutineType == PokeRoutineType.FossilBot) { if (encounterCount != 0 && encounterCount % reviveCount == 0) { Log($"Ran out of fossils to revive {Hub.Config.Fossil.Species}."); if (Hub.Config.Fossil.InjectWhenEmpty) { Log("Restoring original pouch data."); await Connection.WriteBytesAsync(pouchData, ItemTreasureAddress, Config.ConnectionType, token).ConfigureAwait(false); await Task.Delay(500, token).ConfigureAwait(false); } else { Log("Restart the game and the bot(s) or set \"Inject Fossils\" to True in the config."); return; } } await ReviveFossil(counts, token).ConfigureAwait(false); Log("Fossil revived. Checking details..."); var pk = await ReadBoxPokemon(InjectBox, InjectSlot, token).ConfigureAwait(false); if (pk.Species == 0 || !pk.ChecksumValid) { Log("Invalid data detected in destination slot. Restarting loop."); continue; } encounterCount++; Log($"Encounter: {encounterCount}:{Environment.NewLine}{ShowdownSet.GetShowdownText(pk)}{Environment.NewLine}{Environment.NewLine}"); if (DumpSetting.Dump) { DumpPokemon(DumpSetting.DumpFolder, "fossil", pk); } Counts.AddCompletedFossils(); Counts.AddEncounteredSpecies(pk); if (StopConditionSettings.EncounterFound(pk, DesiredIVs, Hub.Config.StopConditions)) { if (Hub.Config.StopConditions.CaptureVideoClip) { await Task.Delay(Hub.Config.StopConditions.ExtraTimeWaitCaptureVideo).ConfigureAwait(false); await PressAndHold(CAPTURE, 2_000, 1_000, token).ConfigureAwait(false); } if (Hub.Config.Fossil.ContinueAfterMatch) { Log($"{Ping}Result found! Continuing to collect more fossils."); } else { Log($"{Ping}Result found! Stopping routine execution; restart the bot(s) to search again."); await DetachController(token).ConfigureAwait(false); return; } } Log("Clearing destination slot."); await SetBoxPokemon(Blank, InjectBox, InjectSlot, token).ConfigureAwait(false); } }
public override async Task MainLoop(CancellationToken token) { Log("Identifying trainer data of the host console."); await IdentifyTrainer(token).ConfigureAwait(false); Log("Checking item counts..."); var pouchData = await Connection.ReadBytesAsync(ItemTreasureAddress, 80, token).ConfigureAwait(false); var counts = FossilCount.GetFossilCounts(pouchData); int reviveCount = counts.PossibleRevives(Hub.Config.Fossil.Species); if (reviveCount == 0) { Log("Insufficient fossil pieces. Please obtain at least one of each required fossil piece first."); return; } Config.IterateNextRoutine(); while (!token.IsCancellationRequested && Config.NextRoutineType == PokeRoutineType.FossilBot) { await ReviveFossil(counts, token).ConfigureAwait(false); Log("Fossil revived. Checking details..."); var pk = await ReadUntilPresent(await ParsePointer(giftpoke, token), 2_000, 0_200, token).ConfigureAwait(false); if (pk == null) { Log("RAM probably shifted."); continue; } encounterCount++; string showdowntext = ShowdownParsing.GetShowdownText(pk); if (pk.IsShiny && pk.ShinyXor == 0) { showdowntext = showdowntext.Replace("Shiny: Yes", "Shiny: Square"); } else if (pk.IsShiny) { showdowntext = showdowntext.Replace("Shiny: Yes", "Shiny: Star"); } Log($"Encounter: {encounterCount}:{Environment.NewLine}{Environment.NewLine}{showdowntext}{Environment.NewLine}{Environment.NewLine}"); if (DumpSetting.Dump) { DumpPokemon(DumpSetting.DumpFolder, "fossil", pk); } Counts.AddCompletedFossils(); if (StopConditionSettings.EncounterFound(pk, DesiredIVs, Hub.Config.StopConditions)) { if (Hub.Config.StopConditions.CaptureVideoClip) { await Task.Delay(Hub.Config.StopConditions.ExtraTimeWaitCaptureVideo, token).ConfigureAwait(false); await PressAndHold(CAPTURE, 2_000, 1_000, token).ConfigureAwait(false); } if (!String.IsNullOrEmpty(Hub.Config.Discord.UserTag)) { Log($"<@{Hub.Config.Discord.UserTag}> Result found! Stopping routine execution; restart the bot(s) to search again."); } else { Log("Result found! Stopping routine execution; restart the bot(s) to search again."); } await DetachController(token).ConfigureAwait(false); return; } else { await CloseGame(Hub.Config, token).ConfigureAwait(false); await StartGame(Hub.Config, token).ConfigureAwait(false); } } }