/// <summary> /// Analyzes a <see cref="PKM"/> to find a matching PIDIV method. /// </summary> /// <param name="pk">Input <see cref="PKM"/>.</param> /// <returns><see cref="PIDIV"/> object containing seed and method info.</returns> public static PIDIV Analyze(PKM pk) { if (pk.Format < 3) { return(AnalyzeGB(pk)); } var pid = pk.EncryptionConstant; var top = pid >> 16; var bot = pid & 0xFFFF; var IVs = new uint[6]; for (int i = 0; i < 6; i++) { IVs[i] = (uint)pk.GetIV(i); } if (GetLCRNGMatch(top, bot, IVs, out PIDIV pidiv)) { return(pidiv); } if (pk.Species == (int)Species.Unown && GetLCRNGUnownMatch(top, bot, IVs, out pidiv)) // frlg only { return(pidiv); } if (GetColoStarterMatch(pk, top, bot, IVs, out pidiv)) { return(pidiv); } if (GetXDRNGMatch(pk, top, bot, IVs, out pidiv)) { return(pidiv); } // Special cases if (GetLCRNGRoamerMatch(top, bot, IVs, out pidiv)) { return(pidiv); } if (GetChannelMatch(top, bot, IVs, out pidiv, pk)) { return(pidiv); } if (GetMG4Match(pid, IVs, out pidiv)) { return(pidiv); } if (GetBACDMatch(pk, pid, IVs, out pidiv)) { return(pidiv); } if (GetModifiedPIDMatch(pk, pid, IVs, out pidiv)) { return(pidiv); } return(PIDIV.None); // no match }
/// <summary> /// Sets the values based on the current <see cref="PKM.IVs"/>. /// </summary> /// <param name="a">Accessor for setting the values</param> /// <param name="pk">Retriever for IVs</param> public static void SetSuggestedAwakenedValues(this IAwakened a, PKM pk) { for (int i = 0; i < 6; i++) { if (pk.GetIV(i) > 2) { a.SetAV(i, 200); } } }
public static bool GetIsFixedIVSequenceValidNoRand(IReadOnlyList <int> IVs, PKM pkm) { for (int i = 0; i < 6; i++) { if (IVs[i] != pkm.GetIV(i)) { return(false); } } return(true); }
public static IEnumerable <uint> GetCuteCharmSeeds(PKM pk) { Span <uint> IVs = stackalloc uint[6]; for (int i = 0; i < 6; i++) { IVs[i] = (uint)pk.GetIV(i); } var bot = GetIVChunk(IVs, 0); var top = GetIVChunk(IVs, 3); return(GetSeedsFromIVs(RNG.LCRNG, top, bot)); }
public static bool GetIsFixedIVSequenceValid(IReadOnlyList <int> IVs, PKM pkm, int max = 31) { for (int i = 0; i < 6; i++) { if ((uint)IVs[i] > max) // random { continue; } if (IVs[i] != pkm.GetIV(i)) { return(false); } } return(true); }
private static bool IsGoIVSetValid(PKM pkm) { // Stamina*2 | 1 -> HP // ATK * 2 | 1 -> ATK&SPA // DEF * 2 | 1 -> DEF&SPD // Speed is random. // All IVs must be odd (except speed) and equal to their counterpart. if ((pkm.GetIV(1) & 1) != 1 || pkm.GetIV(1) != pkm.GetIV(4)) // ATK=SPA { return(false); } if ((pkm.GetIV(2) & 1) != 1 || pkm.GetIV(2) != pkm.GetIV(5)) // DEF=SPD { return(false); } return((pkm.GetIV(0) & 1) == 1); // HP }