protected override async Task EncounterLoop(SAV8SWSH sav, CancellationToken token) { var monoffset = GetResetOffset(Hub.Config.Encounter.EncounteringType); var pkoriginal = monoffset is BoxStartOffset ? await ReadBoxPokemon(0, 0, token).ConfigureAwait(false) : new PK8(); while (!token.IsCancellationRequested) { PK8?pknew; Log("Looking for a Pokémon..."); do { await DoExtraCommands(token, Hub.Config.Encounter.EncounteringType).ConfigureAwait(false); pknew = await ReadUntilPresent(monoffset, 0_050, 0_050, BoxFormatSlotSize, token).ConfigureAwait(false); } while (pknew is null || SearchUtil.HashByDetails(pkoriginal) == SearchUtil.HashByDetails(pknew)); TradeExtensions <PK8> .EncounterLogs(pknew, "EncounterLogPretty_Reset.txt"); if (await HandleEncounter(pknew, token).ConfigureAwait(false)) { return; } Log("No match, resetting the game..."); await CloseGame(Hub.Config, token).ConfigureAwait(false); await StartGame(Hub.Config, token).ConfigureAwait(false); } }
protected override async Task EncounterLoop(SAV8SWSH sav, CancellationToken token) { bool campEntered = false; while (!token.IsCancellationRequested) { await Click(X, 2_000, token).ConfigureAwait(false); if (!campEntered) { await Click(DDOWN, 0_600, token).ConfigureAwait(false); await Click(DRIGHT, 0_600, token).ConfigureAwait(false); campEntered = true; } Log("Entering camp..."); await Click(A, 12_000, token).ConfigureAwait(false); await Click(B, 2_000, token).ConfigureAwait(false); await Click(A, 0_500, token).ConfigureAwait(false); while (!await IsInBattle(token).ConfigureAwait(false)) { await Task.Delay(2_000).ConfigureAwait(false); } var pk = await ReadUntilPresent(WildPokemonOffset, 2_000, 0_200, BoxFormatSlotSize, token).ConfigureAwait(false); if (pk == null) { Log("Invalid data detected. Restarting loop."); continue; } else { TradeExtensions <PK8> .EncounterLogs(pk, "EncounterLogPretty_SoJ.txt"); if (await HandleEncounter(pk, token).ConfigureAwait(false)) { return; } } Log("Fleeing from battle..."); while (await IsInBattle(token).ConfigureAwait(false)) { await FleeToOverworld(token).ConfigureAwait(false); } while (!await IsOnOverworld(Hub.Config, token).ConfigureAwait(false)) { await Task.Delay(2_000).ConfigureAwait(false); } } }
protected override async Task EncounterLoop(SAV8SWSH sav, CancellationToken token) { while (!token.IsCancellationRequested) { Log("Looking for a new dog..."); // At the start of each loop, an A press is needed to exit out of a prompt. await Click(A, 0_100, token).ConfigureAwait(false); await SetStick(LEFT, 0, 30000, 1_000, token).ConfigureAwait(false); // Encounters Zacian/Zamazenta and clicks through all the menus. while (!await IsInBattle(token).ConfigureAwait(false)) { await Click(A, 0_300, token).ConfigureAwait(false); } Log("Encounter started! Checking details..."); var pk = await ReadUntilPresent(LegendaryPokemonOffset, 2_000, 0_200, BoxFormatSlotSize, token).ConfigureAwait(false); if (pk == null) { Log("Invalid data detected. Restarting loop."); continue; } // Get rid of any stick stuff left over so we can flee properly. await ResetStick(token).ConfigureAwait(false); // Wait for the entire cutscene. await Task.Delay(15_000, token).ConfigureAwait(false); // Offsets are flickery so make sure we see it 3 times. for (int i = 0; i < 3; i++) { await ReadUntilChanged(BattleMenuOffset, BattleMenuReady, 5_000, 0_100, true, token).ConfigureAwait(false); } TradeExtensions <PK8> .EncounterLogs(pk, "EncounterLogPretty_EncounterDog.txt"); if (await HandleEncounter(pk, token).ConfigureAwait(false)) { return; } Log("Running away..."); await FleeToOverworld(token).ConfigureAwait(false); // Extra delay to be sure we're fully out of the battle. await Task.Delay(0_250, token).ConfigureAwait(false); } }
protected override async Task EncounterLoop(SAV8SWSH sav, CancellationToken token) { while (!token.IsCancellationRequested) { var attempts = await StepUntilEncounter(token).ConfigureAwait(false); if (attempts < 0) // aborted { continue; } Log($"Encounter found after {attempts} attempts! Checking details..."); // Reset stick while we wait for the encounter to load. await ResetStick(token).ConfigureAwait(false); var pk = await ReadUntilPresent(WildPokemonOffset, 2_000, 0_200, BoxFormatSlotSize, token).ConfigureAwait(false); if (pk == null) { Log("Invalid data detected. Restarting loop."); // Flee and continue looping. await FleeToOverworld(token).ConfigureAwait(false); continue; } // Offsets are flickery so make sure we see it 3 times. for (int i = 0; i < 3; i++) { await ReadUntilChanged(BattleMenuOffset, BattleMenuReady, 5_000, 0_100, true, token).ConfigureAwait(false); } TradeExtensions <PK8> .EncounterLogs(pk, "EncounterLogPretty_EncounterLine.txt"); if (await HandleEncounter(pk, token).ConfigureAwait(false)) { return; } Log("Running away..."); await FleeToOverworld(token).ConfigureAwait(false); } }
private async Task <bool> HandleEncounter(PK8 pk, bool legends, CancellationToken token) { encounterCount++; Log($"Encounter: {encounterCount}{Environment.NewLine}{ShowdownParsing.GetShowdownText(pk)}{Environment.NewLine}{(StopConditionSettings.HasMark(pk, out RibbonIndex mark) ? $"Mark: {mark.ToString().Replace("Mark", "")}{Environment.NewLine}" : "")}"); TradeExtensions.EncounterLogs(pk); if (legends) { Counts.AddCompletedLegends(); } else { Counts.AddCompletedEncounters(); } if (DumpSetting.Dump && !string.IsNullOrEmpty(DumpSetting.DumpFolder)) { DumpPokemon(DumpSetting.DumpFolder, legends ? "legends" : "encounters", pk); } if (StopConditionSettings.EncounterFound(pk, DesiredIVs, Hub.Config.StopConditions)) { Log(Hub.Config.StopConditions.CatchEncounter && (Hub.Config.Encounter.EncounteringType == EncounterMode.VerticalLine || Hub.Config.Encounter.EncounteringType == EncounterMode.HorizontalLine) ? "Result found! Attempting to catch..." : $"{(!Hub.Config.StopConditions.PingOnMatch.Equals(string.Empty) ? $"<@{Hub.Config.StopConditions.PingOnMatch}>\n" : "")}Result found! Stopping routine execution; restart the bot(s) to search again."); 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 (Hub.Config.StopConditions.CatchEncounter && (Hub.Config.Encounter.EncounteringType == EncounterMode.VerticalLine || Hub.Config.Encounter.EncounteringType == EncounterMode.HorizontalLine)) { await CatchWildPokemon(pk, token).ConfigureAwait(false); } return(true); } return(false); }
private async Task DoCurryMonEncounter(int ingrIndex, int berryIndex, int berryCount, int ingredientCount, CancellationToken token) { bool firstRun = true; PK8? comparison = null; while (!token.IsCancellationRequested && Config.NextRoutineType == PokeRoutineType.CurryBot) { if (await IsOnOverworld(Hub.Config, token).ConfigureAwait(false)) { Log("Entering camp..."); await Click(X, 2_000, token).ConfigureAwait(false); await Click(A, Settings.EnterCamp, token).ConfigureAwait(false); } if (!await LairStatusCheck(0xFF000000, 0x6B311300, token).ConfigureAwait(false)) // Check if camp screen. { await Click(B, 2_000, token).ConfigureAwait(false); } await CookingCurry(ingrIndex, berryIndex, berryCount, firstRun, token).ConfigureAwait(false); ingredientCount--; berryCount -= berryCount >= 10 ? 10 : 1; firstRun = false; Log("Checking for a camper..."); PK8?camperMon = await GetCampPokemon(token).ConfigureAwait(false); if (camperMon != null && string.IsNullOrEmpty(camperMon.OT_Name) && camperMon != comparison) { comparison = camperMon; await SetStick(RIGHT, 0, 30_000, 1_000, token).ConfigureAwait(false); await SetStick(RIGHT, 0, 0, 0_100, token).ConfigureAwait(false); Log($"New camper found on curry #{curryCount}."); TradeExtensions <PK8> .EncounterLogs(camperMon, "EncounterLogPretty_Curry.txt"); if (await HandleEncounter(camperMon, token).ConfigureAwait(false)) { return; } } else { Log($"No new campers on curry #{curryCount}..."); } if (!Settings.RestorePouches && (ingredientCount <= 0 || berryCount <= 0)) { Log("Ran out of ingredients to make curry. Stopping..."); return; } else if (Settings.RestorePouches && (ingredientCount <= 1 || berryCount <= 10)) { Log("Restoring ingredient and berry pouches..."); await Connection.WriteBytesAsync(BerryPouch, BerryPouchOffset, token).ConfigureAwait(false); berryCount = BerryCount; await Connection.WriteBytesAsync(IngredientPouch, IngredientPouchOffset, token).ConfigureAwait(false); ingredientCount = IngredientCount; } } }