private void buttonFind_ByIVRange_Click(object sender, EventArgs e) { uint year_ivrange = 0; uint month_ivrange = 1; uint date_ivrange = 1; uint hours_ivrange = 0; uint minutes_ivrange = 0; var nature = (Nature) comboBoxNature_IVRange.SelectedValue; if (maskedTextBoxYear_IVRange.Text != "") year_ivrange = uint.Parse(maskedTextBoxYear_IVRange.Text); if (maskedTextBoxMonth_IVRange.Text != "") month_ivrange = uint.Parse(maskedTextBoxMonth_IVRange.Text); if (maskedTextBoxDate_IVRange.Text != "") date_ivrange = uint.Parse(maskedTextBoxDate_IVRange.Text); if (maskedTextBoxHours_IVRange.Text != "") hours_ivrange = uint.Parse(maskedTextBoxHours_IVRange.Text); if (maskedTextBoxMinutes_IVRange.Text != "") minutes_ivrange = uint.Parse(maskedTextBoxMinutes_IVRange.Text); bool showMonster = checkBoxShowMonster.Checked; var Possibilities = new List<List<uint>> { new List<uint>(), new List<uint>(), new List<uint>(), new List<uint>(), new List<uint>(), new List<uint>() }; var minIvs = new uint[6]; uint.TryParse(maskedTextBoxMinHP.Text, out minIvs[0]); uint.TryParse(maskedTextBoxMinAtk.Text, out minIvs[1]); uint.TryParse(maskedTextBoxMinDef.Text, out minIvs[2]); uint.TryParse(maskedTextBoxMinSpAtk.Text, out minIvs[3]); uint.TryParse(maskedTextBoxMinSpDef.Text, out minIvs[4]); uint.TryParse(maskedTextBoxMinSpeed.Text, out minIvs[5]); var maxIvs = new uint[6]; uint.TryParse(maskedTextBoxMaxHP.Text, out maxIvs[0]); uint.TryParse(maskedTextBoxMaxAtk.Text, out maxIvs[1]); uint.TryParse(maskedTextBoxMaxDef.Text, out maxIvs[2]); uint.TryParse(maskedTextBoxMaxSpAtk.Text, out maxIvs[3]); uint.TryParse(maskedTextBoxMaxSpDef.Text, out maxIvs[4]); uint.TryParse(maskedTextBoxMaxSpeed.Text, out maxIvs[5]); uint minDefaultDelay; uint.TryParse(maskedTextBoxMinDelay_IVRange.Text, out minDefaultDelay); uint maxDefaultDelay; uint.TryParse(maskedTextBoxMaxDelay_IVRange.Text, out maxDefaultDelay); for (int statCnt = 0; statCnt <= 5; statCnt++) { for (uint charCnt = minIvs[statCnt]; charCnt <= maxIvs[statCnt]; charCnt++) { Possibilities[statCnt].Add(charCnt); } } int combinations = Possibilities[0].Count* Possibilities[1].Count* Possibilities[2].Count* Possibilities[3].Count* Possibilities[4].Count* Possibilities[5].Count; // If there are too many different combinations we need // to notify the user that they may not proceed. if (combinations > 100) { MessageBox.Show( "There were too many combinations of IV possibilities to accurately find your intitial seed (" + combinations + ") please try with a higher level Pokemon,", "Too many IV Combinations"); } else { var allSeeds = new List<Seed>(); // Iterate through all of the combinations of IVs and check // so something good, first using the IvToPID. foreach (uint combo_HP in Possibilities[0]) foreach (uint combo_Atk in Possibilities[1]) foreach (uint combo_Def in Possibilities[2]) foreach (uint combo_SpA in Possibilities[3]) foreach (uint combo_SpD in Possibilities[4]) foreach (uint combo_Spe in Possibilities[5]) { List<Seed> startingSeeds = IVtoSeed.GetSeeds( combo_HP, combo_Atk, combo_Def, combo_SpA, combo_SpD, combo_Spe, (uint) nature.Number, 0); allSeeds.AddRange(startingSeeds); } // We now have a complete list of starting seeds so we can run the // same logic that we normally run here, but we might want to tone // down how much we actually search. // Now that we have developed a list of possible seeds we need to // start working those backwards and then building a list of // initial seeds that may have been possible. var seeds = new List<SeedInitial>(); bool monsterFound = false; bool initialFound = false; foreach (Seed seed in allSeeds) { if (seed.FrameType == FrameType.Method1) { if (showMonster) { seeds.Add(new SeedInitial(seed.MonsterSeed, 0, "Monster", 0, 0)); } monsterFound = true; // start backing up, we are going to back up // a grand totol of 10,000 times max for the // time being, var rng = new PokeRngR(seed.MonsterSeed); // back to 500 for (uint backCount = 1; backCount < 500; backCount++) { uint testSeed = rng.Seed; rng.GetNext32BitNumber(); uint seedAB = testSeed >> 24; uint seedCD = (testSeed & 0x00FF0000) >> 16; uint seedEFGH = testSeed & 0x0000FFFF; if (seedEFGH > (minDefaultDelay + year_ivrange - 2000) && seedEFGH < (maxDefaultDelay + year_ivrange - 2000)) { // Disqualify on hours second as it is very likely // to be a poor choice for use to work with. //wfy back to exact hour if (seedCD == hours_ivrange) { for (uint secondsCount = 0; secondsCount < 60; secondsCount++) { if (((month_ivrange*date_ivrange + minutes_ivrange + secondsCount)%0x100) == seedAB) { var initialSeed = new SeedInitial( testSeed, backCount, "Initial", secondsCount, seedEFGH - (year_ivrange - 2000)); seeds.Add(initialSeed); initialFound = true; } } } } } } } dataGridViewSeeds_IVRange.DataSource = seeds; if (!monsterFound) { MessageBox.Show("No matches found for the IVs entered. Please check and try again.", "No Data Found", MessageBoxButtons.OK); } else if (!initialFound) { MessageBox.Show("No reasonable initial seed found. Please check your DATE and TIME.", "No Data Found", MessageBoxButtons.OK); } Settings.Default.YearIVR = year_ivrange.ToString(); Settings.Default.MonthIVR = month_ivrange.ToString(); Settings.Default.DateIVR = date_ivrange.ToString(); Settings.Default.MinutesIVR = minutes_ivrange.ToString(); Settings.Default.HoursIVR = hours_ivrange.ToString(); Settings.Default.DelayMinIVR = minDefaultDelay.ToString(); Settings.Default.DelayMaxIVR = maxDefaultDelay.ToString(); Settings.Default.Save(); } }
public List<Frame> Generate( FrameCompare frameCompare, uint hp, uint atk, uint def, uint spa, uint spd, uint spe, List<uint> natures, uint minEfgh, uint maxEfgh, uint id, uint sid) { frames = new List<Frame>(); var candidates = new List<Frame>(); var rng = new PokeRngR(0); uint x_test = spe | (spa << 5) | (spd << 10); uint y_test = hp | (atk << 5) | (def << 10); #region // Experimentally derived // Any possible test seed will have at most // a difference of 0x31 from the target seed. // If it's close enough, we can then modify it // to match. /* for (uint cnt = 0xFFFF; cnt > 0xF2CC; cnt--) { uint seed = (x_test << 16) | cnt; // Do a quick search for matching seeds // with a lower 16-bits between 0xFFFF and 0xF2CD. // We'll take the closest matches and subtract 0xD33 // until it produces the correct seed (or doesn't). // Best we can do until we find a way to // calculate them directly. rng.Seed = seed; ushort rng1 = rng.GetNext16BitNumber(); // We don't have to worry about unsigned overflow // because y_test is never more than 0x7FFF if (y_test < 0x31) { if (rng1 <= (y_test - 0x31)) { while ((seed & 0xFFFF) > 0xD32 && (rng1 & 0x7FFF) < y_test) { seed = seed - 0xD33; rng.Seed = seed; rng1 = rng.GetNext16BitNumber(); } } } else { if (rng1 >= (y_test - 0x31)) { while ((seed & 0xFFFF) > 0xD32 && (rng1 & 0x7FFF) < y_test) { seed = seed - 0xD33; rng.Seed = seed; rng1 = rng.GetNext16BitNumber(); } } } */ #endregion for (uint cnt = 0x0; cnt < 0xFFFF; cnt++) { uint seed = (x_test << 16) | cnt; rng.Seed = seed; ushort rng1 = rng.GetNext16BitNumber(); // Check to see if the next frame yields // the HP, Attack, and Defense IVs we're searching for // If not, skip 'em. if ((rng1 & 0x7FFF) != y_test) continue; // We have a max of 5 total RNG calls // to make a pokemon and we already have // one so lets go ahead and get 4 more. uint seedWondercard = rng.GetNext32BitNumber(); var rng2 = (ushort) (seedWondercard >> 16); ushort rng3 = rng.GetNext16BitNumber(); ushort rng4 = rng.GetNext16BitNumber(); uint method1Seed = rng.Seed; // Instead of re-searching the entire space for seeds that are // basically identical except for the upper bit, we'll // just flip the upper seed bits instead. for (int upperBit = 0; upperBit < 2; upperBit++) { rng2 = (ushort) (rng2 ^ 0x8000); rng3 = (ushort) (rng3 ^ 0x8000); rng4 = (ushort) (rng4 ^ 0x8000); method1Seed = method1Seed ^ 0x80000000; rng.Seed = rng.Seed ^ 0x80000000; if (frameType == FrameType.WondercardIVs) { seedWondercard = seedWondercard ^ 0x80000000; frame = Frame.GenerateFrame(seedWondercard, frameType, EncounterType, 0, seedWondercard, 0, 0, rng1, x_test, id, sid, 0, 0); candidates.Add(frame); } foreach (uint nature in natures) { if (frameType == FrameType.ChainedShiny) { var testRng = new PokeRngR(rng.Seed); var rngCalls = new uint[15]; rngCalls[0] = rng2; rngCalls[1] = rng3; rngCalls[2] = rng4; for (int calls = 3; calls < 15; calls++) { rngCalls[calls] = testRng.GetNext16BitNumber(); } testRng.GetNext32BitNumber(); testRng.GetNext32BitNumber(); uint chainedPIDLower = Functions.ChainedPIDLower( rngCalls[14], rngCalls[0], rngCalls[1], rngCalls[2], rngCalls[3], rngCalls[4], rngCalls[5], rngCalls[6], rngCalls[7], rngCalls[8], rngCalls[9], rngCalls[10], rngCalls[11], rngCalls[12]); uint chainedPIDUpper = Functions.ChainedPIDUpper(rngCalls[13], chainedPIDLower, id, sid); if (IVtoSeed.CheckPID(chainedPIDUpper, chainedPIDLower, nature)) { frame = Frame.GenerateFrame(testRng.Seed, frameType, EncounterType, 0, testRng.Seed, chainedPIDLower, chainedPIDUpper, rng1, x_test, id, sid, 0, 0); candidates.Add(frame); } } if (frameType == FrameType.Method1) { // Check Method 1 // [PID] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] if (IVtoSeed.CheckPID(rng2, rng3, nature)) { frame = Frame.GenerateFrame(method1Seed, frameType, EncounterType, 0, method1Seed, rng3, rng2, rng1, x_test, id, sid, 0, 0); candidates.Add(frame); } } if (frameType == FrameType.MethodJ) { // Check Method 1, then roll back to see if it is a hittable frame if (IVtoSeed.CheckPID(rng2, rng3, nature)) { var testRng = new PokeRngR(rng.Seed); uint testPid; uint nextRng = rng4; uint nextRng2 = testRng.GetNext32BitNumber(); uint slot = 0; // A spread is only made accessible if there are no other PIDs between // it and the calling frame that have the same nature as the spread. do { bool skipFrame = false; // Check to see if this is a valid non-Synch calling frame // If it is, we won't bother checking it with Synch because it works either way if (nextRng/0xA3E == nature) { uint testSeed = testRng.Seed; var encounterMod = EncounterMod.None; if (EncounterType != EncounterType.Stationary) { testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; slot = nextRng2; if (EncounterType == EncounterType.WildSurfing) { slot = testSeed; testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; } else if (EncounterType == EncounterType.WildOldRod) { slot = testSeed; testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; uint nibble = (testSeed >> 16)/656; if (nibble <= 48) { if (nibble > 24) { encounterMod = EncounterMod.SuctionCups; } testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; } else skipFrame = true; } else if (EncounterType == EncounterType.WildGoodRod) { slot = testSeed; testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; uint nibble = (testSeed >> 16)/656; if (nibble <= 98) { if (nibble > 49) { encounterMod = EncounterMod.SuctionCups; } testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; } else skipFrame = true; } else if (EncounterType == EncounterType.WildSuperRod) { slot = testSeed; testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; uint nibble = (testSeed >> 16)/656; if (nibble <= 99) { if (nibble > 74) { encounterMod = EncounterMod.SuctionCups; } testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; } else skipFrame = true; } } if (!skipFrame) { frame = Frame.GenerateFrame(testSeed, frameType, EncounterType, 0, testSeed, rng3, rng2, rng1, x_test, id, sid, 0, 0); frame.EncounterSlot = EncounterSlotCalc.encounterSlot(slot, frameType, EncounterType); frame.EncounterMod = encounterMod; candidates.Add(frame); } // Check if the frame appears as the result of a failed Synch if (nextRng2 >> 31 == 1) { if (EncounterType == EncounterType.WildOldRod) { uint nibble = (testSeed >> 16)/656; if (nibble > 24) { skipFrame = true; } } else if (EncounterType == EncounterType.WildGoodRod) { uint nibble = (testSeed >> 16)/656; if (nibble > 49) { skipFrame = true; } } else if (EncounterType == EncounterType.WildSuperRod) { uint nibble = (testSeed >> 16)/656; if (nibble > 74) { skipFrame = true; } } slot = slot*0xeeb9eb65 + 0xa3561a1; testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; if (!skipFrame) { frame = Frame.GenerateFrame(testSeed, frameType, EncounterType, 0, testSeed, rng3, rng2, rng1, x_test, id, sid, 0, 0); frame.EncounterSlot = EncounterSlotCalc.encounterSlot(slot, frameType, EncounterType); frame.EncounterMod = EncounterMod.Synchronize; candidates.Add(frame); } } } // Check to see if the spread is hittable with Synchronize else if (nextRng >> 15 == 0) { uint testSeed = testRng.Seed; if (EncounterType != EncounterType.Stationary) { testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; slot = nextRng2; if (EncounterType == EncounterType.WildSurfing) { slot = testSeed; testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; } else if (EncounterType == EncounterType.WildOldRod) { slot = testSeed; testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; uint nibble = (testSeed >> 16)/656; if (nibble > 24) { skipFrame = true; } else { testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; } } else if (EncounterType == EncounterType.WildGoodRod) { slot = testSeed; testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; uint nibble = (testSeed >> 16)/656; if (nibble > 49) { skipFrame = true; } else { testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; } } else if (EncounterType == EncounterType.WildSuperRod) { slot = testSeed; testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; uint nibble = (testSeed >> 16)/656; if (nibble > 74) { skipFrame = true; } else { testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; } } } if (!skipFrame) { frame = Frame.GenerateFrame(testSeed, frameType, EncounterType, 0, testSeed, rng3, rng2, rng1, x_test, id, sid, 0, 0); frame.Synchable = true; frame.EncounterMod = EncounterMod.Synchronize; frame.EncounterSlot = EncounterSlotCalc.encounterSlot(slot, frameType, EncounterType); candidates.Add(frame); } } testPid = (nextRng << 16) | nextRng2 >> 16; nextRng = testRng.GetNext16BitNumber(); nextRng2 = testRng.GetNext32BitNumber(); } while (testPid%25 != nature); } // Check DPPt Cute Charm (female) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] if (rng3/0x5556 != 0) { uint CCSeed; uint slot = 0; bool skipFrame = false; if (EncounterType == EncounterType.Stationary) CCSeed = method1Seed; else { CCSeed = method1Seed*0xeeb9eb65 + 0xa3561a1; slot = method1Seed; if (EncounterType == EncounterType.WildSurfing) { CCSeed = CCSeed*0xeeb9eb65 + 0xa3561a1; slot = slot*0xeeb9eb65 + 0xa3561a1; } else if (EncounterType == EncounterType.WildOldRod) { CCSeed = CCSeed*0xeeb9eb65 + 0xa3561a1; slot = slot*0xeeb9eb65 + 0xa3561a1; if ((CCSeed >> 16)/656 > 24) skipFrame = true; else CCSeed = CCSeed*0xeeb9eb65 + 0xa3561a1; } else if (EncounterType == EncounterType.WildGoodRod) { CCSeed = CCSeed*0xeeb9eb65 + 0xa3561a1; slot = slot*0xeeb9eb65 + 0xa3561a1; if ((CCSeed >> 16)/656 > 49) skipFrame = true; else CCSeed = CCSeed*0xeeb9eb65 + 0xa3561a1; } else if (EncounterType == EncounterType.WildSuperRod) { CCSeed = CCSeed*0xeeb9eb65 + 0xa3561a1; slot = slot*0xeeb9eb65 + 0xa3561a1; if ((CCSeed >> 16)/656 > 74) skipFrame = true; else CCSeed = CCSeed*0xeeb9eb65 + 0xa3561a1; } } // Each gender ratio has a different // unbiased (non-nature-affective) number that is // added to the PID var choppedPID = (ushort) (rng2/0xA3E); if (!skipFrame && IVtoSeed.CheckPID(0, choppedPID, nature)) { foreach (uint buffer in Functions.UnbiasedBuffer) { frame = Frame.GenerateFrame(CCSeed, frameType, EncounterType, 0, CCSeed, choppedPID + buffer, 0, rng1, x_test, id, sid, 0, 0); frame.EncounterSlot = EncounterSlotCalc.encounterSlot(slot, frameType, EncounterType); switch (buffer) { case 0x0: frame.EncounterMod = EncounterMod.CuteCharmFemale; break; case 0x96: frame.EncounterMod = EncounterMod.CuteCharm50M; break; case 0xC8: frame.EncounterMod = EncounterMod.CuteCharm25M; break; case 0x4B: frame.EncounterMod = EncounterMod.CuteCharm75M; break; case 0x32: frame.EncounterMod = EncounterMod.CuteCharm875M; break; default: frame.EncounterMod = EncounterMod.CuteCharm; break; } candidates.Add(frame); } } } } else if (frameType == FrameType.MethodK) { // Check Method 1, then roll back to see if it is a hittable frame if (IVtoSeed.CheckPID(rng2, rng3, nature)) { var testRng = new PokeRngR(rng.Seed); uint testPid; uint nextRng = rng4; uint nextRng2 = testRng.GetNext32BitNumber(); uint slot = 0; // A spread is only made accessible if there are no other PIDs between // it and the calling frame that have the same nature as the spread. do { bool skipFrame = false; // Check to see if this is a valid non-Synch calling frame // If it is, we won't bother checking it with Synch because it works either way if (nextRng%25 == nature) { uint testSeed = testRng.Seed; var encounterMod = EncounterMod.None; if (EncounterType != EncounterType.Stationary) { testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; slot = nextRng2; if (EncounterType == EncounterType.WildSurfing || EncounterType == EncounterType.BugCatchingContest || EncounterType == EncounterType.Headbutt) { slot = testSeed; testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; } else if (EncounterType == EncounterType.WildOldRod) { slot = testSeed; testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; uint nibble = (testSeed >> 16)%100; if (nibble <= 48) { if (nibble > 24) { encounterMod = EncounterMod.SuctionCups; } testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; } else skipFrame = true; } else if (EncounterType == EncounterType.WildGoodRod) { slot = testSeed; testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; uint nibble = (testSeed >> 16)%100; if (nibble <= 98) { if (nibble > 49) { encounterMod = EncounterMod.SuctionCups; } testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; } else skipFrame = true; } else if (EncounterType == EncounterType.WildSuperRod) { slot = testSeed; testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; uint nibble = (testSeed >> 16)%100; if (nibble <= 99) { if (nibble > 74) { encounterMod = EncounterMod.SuctionCups; } testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; } else skipFrame = true; } } if (!skipFrame) { frame = Frame.GenerateFrame(testSeed, frameType, EncounterType, 0, testSeed, rng3, rng2, rng1, x_test, id, sid, 0, 0); frame.EncounterSlot = EncounterSlotCalc.encounterSlot(slot, frameType, EncounterType); frame.EncounterMod = encounterMod; candidates.Add(frame); } // Check if the frame appears as the result of a failed Synch if (((nextRng2 >> 16) & 1) == 1) { if (EncounterType == EncounterType.WildOldRod) { uint nibble = (testSeed >> 16)%100; if (nibble > 24) { skipFrame = true; } } else if (EncounterType == EncounterType.WildGoodRod) { uint nibble = (testSeed >> 16)%100; if (nibble > 49) { skipFrame = true; } } else if (EncounterType == EncounterType.WildSuperRod) { uint nibble = (testSeed >> 16)%100; if (nibble > 74) { skipFrame = true; } } slot = slot*0xeeb9eb65 + 0xa3561a1; testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; if (!skipFrame) { frame = Frame.GenerateFrame(testSeed, frameType, EncounterType, 0, testSeed, rng3, rng2, rng1, x_test, id, sid, 0, 0); frame.EncounterSlot = EncounterSlotCalc.encounterSlot(slot, frameType, EncounterType); frame.EncounterMod = EncounterMod.Synchronize; candidates.Add(frame); } } } // Check to see if the spread is hittable with Synchronize else if ((nextRng & 1) == 0) { uint testSeed = testRng.Seed; if (EncounterType != EncounterType.Stationary) { testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; slot = nextRng2; if (EncounterType == EncounterType.WildSurfing || EncounterType == EncounterType.BugCatchingContest || EncounterType == EncounterType.Headbutt) { slot = testSeed; testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; } else if (EncounterType == EncounterType.WildOldRod) { slot = testSeed; testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; uint nibble = (testSeed >> 16)%100; if (nibble > 24) { skipFrame = true; } else { testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; } } else if (EncounterType == EncounterType.WildGoodRod) { slot = testSeed; testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; uint nibble = (testSeed >> 16)%100; if (nibble > 49) { skipFrame = true; } else { testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; } } else if (EncounterType == EncounterType.WildSuperRod) { slot = testSeed; testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; uint nibble = (testSeed >> 16)%100; if (nibble > 74) { skipFrame = true; } else { testSeed = testSeed*0xeeb9eb65 + 0xa3561a1; } } } if (!skipFrame) { frame = Frame.GenerateFrame(testSeed, frameType, EncounterType, 0, testSeed, rng3, rng2, rng1, x_test, id, sid, 0, 0); frame.Synchable = true; frame.EncounterMod = EncounterMod.Synchronize; frame.EncounterSlot = EncounterSlotCalc.encounterSlot(slot, frameType, EncounterType); candidates.Add(frame); } } testPid = (nextRng << 16) | nextRng2 >> 16; nextRng = testRng.GetNext16BitNumber(); nextRng2 = testRng.GetNext32BitNumber(); } while (testPid%25 != nature); } if (rng3%3 != 0) { uint CCSeed; uint slot = 0; bool skipFrame = false; if (EncounterType == EncounterType.Stationary) CCSeed = method1Seed; else { CCSeed = method1Seed*0xeeb9eb65 + 0xa3561a1; slot = method1Seed; if (EncounterType == EncounterType.WildSurfing || EncounterType == EncounterType.BugCatchingContest) { CCSeed = CCSeed*0xeeb9eb65 + 0xa3561a1; slot = slot*0xeeb9eb65 + 0xa3561a1; } else if (EncounterType == EncounterType.WildOldRod) { CCSeed = CCSeed*0xeeb9eb65 + 0xa3561a1; slot = slot*0xeeb9eb65 + 0xa3561a1; if ((CCSeed >> 16)%100 > 24) skipFrame = true; else CCSeed = CCSeed*0xeeb9eb65 + 0xa3561a1; } else if (EncounterType == EncounterType.WildGoodRod) { CCSeed = CCSeed*0xeeb9eb65 + 0xa3561a1; slot = slot*0xeeb9eb65 + 0xa3561a1; if ((CCSeed >> 16)%100 > 49) skipFrame = true; else CCSeed = CCSeed*0xeeb9eb65 + 0xa3561a1; } else if (EncounterType == EncounterType.WildSuperRod) { CCSeed = CCSeed*0xeeb9eb65 + 0xa3561a1; slot = slot*0xeeb9eb65 + 0xa3561a1; if ((CCSeed >> 16)%100 > 74) skipFrame = true; else CCSeed = CCSeed*0xeeb9eb65 + 0xa3561a1; } } // Check HGSS Cute Charm // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] // Each gender ratio has a different // unbiased (non-nature-affective) number that is // added to the PID var choppedPID = (ushort) (rng2%25); if (!skipFrame && IVtoSeed.CheckPID(0, choppedPID, nature)) { foreach (uint buffer in Functions.UnbiasedBuffer) { frame = Frame.GenerateFrame(CCSeed, frameType, EncounterType, 0, CCSeed, choppedPID + buffer, 0, rng1, x_test, id, sid, 0, 0); frame.EncounterSlot = EncounterSlotCalc.encounterSlot(slot, frameType, EncounterType); switch (buffer) { case 0x0: frame.EncounterMod = EncounterMod.CuteCharmFemale; break; case 0x96: frame.EncounterMod = EncounterMod.CuteCharm50M; break; case 0xC8: frame.EncounterMod = EncounterMod.CuteCharm25M; break; case 0x4B: frame.EncounterMod = EncounterMod.CuteCharm75M; break; case 0x32: frame.EncounterMod = EncounterMod.CuteCharm875M; break; default: frame.EncounterMod = EncounterMod.CuteCharm; break; } candidates.Add(frame); } } } } } } } // Now that we have some possibilities for frames, // We'll filter out ones that don't meet user criteria // Then roll back the RNG for each of them to make sure // each is within the user-specified maximum frames // from a DPPtHGSS-style seed. foreach (Frame candidate in candidates) { if (frameCompare.Compare(candidate)) { // start backing up frames until the user-specified max rng.Seed = candidate.Seed; const uint start = 1; for (uint backCount = start; backCount <= MaxResults; backCount++) { uint testSeed = rng.Seed; //uint seedAB = testSeed >> 24; uint seedCD = (testSeed & 0x00FF0000) >> 16; uint seedEFGH = testSeed & 0x0000FFFF; // Check to see if seed follows ABCDEFGH format // And matches-user specified delay if (seedEFGH > minEfgh && seedEFGH < maxEfgh) { // CD must be between 0-23 if (seedCD < 23) { if (backCount >= InitialFrame) { Frame frameCopy = Frame.Clone(candidate); frameCopy.Seed = testSeed; frameCopy.Number = backCount; frames.Add(frameCopy); } } } rng.GetNext32BitNumber(); } } } return frames; }
private void buttonFind_Stat_Click(object sender, EventArgs e) { uint year_stat = 0; uint month_stat = 1; uint date_stat = 1; uint hours_stat = 0; uint minutes_stat = 0; uint hp = 0; uint atk = 0; uint def = 0; uint spa = 0; uint spd = 0; uint spe = 0; uint level = 1; var pokemon = (Pokemon) comboBoxPokemon_Stat.SelectedValue; var nature = (Nature) comboBoxNature_Stat.SelectedValue; if (maskedTextBoxHP_Stat.Text != "") hp = uint.Parse(maskedTextBoxHP_Stat.Text); if (maskedTextBoxAtk_Stat.Text != "") atk = uint.Parse(maskedTextBoxAtk_Stat.Text); if (maskedTextBoxDef_Stat.Text != "") def = uint.Parse(maskedTextBoxDef_Stat.Text); if (maskedTextBoxSpA_Stat.Text != "") spa = uint.Parse(maskedTextBoxSpA_Stat.Text); if (maskedTextBoxSpD_Stat.Text != "") spd = uint.Parse(maskedTextBoxSpD_Stat.Text); if (maskedTextBoxSpe_Stat.Text != "") spe = uint.Parse(maskedTextBoxSpe_Stat.Text); if (maskedTextBoxLevel_Stat.Text != "") level = uint.Parse(maskedTextBoxLevel_Stat.Text); if (maskedTextBoxYear_Stat.Text != "") year_stat = uint.Parse(maskedTextBoxYear_Stat.Text); if (maskedTextBoxMonth_Stat.Text != "") month_stat = uint.Parse(maskedTextBoxMonth_Stat.Text); if (maskedTextBoxDate_Stat.Text != "") date_stat = uint.Parse(maskedTextBoxDate_Stat.Text); if (maskedTextBoxHours_Stat.Text != "") hours_stat = uint.Parse(maskedTextBoxHours_Stat.Text); if (maskedTextBoxMinutes_Stat.Text != "") minutes_stat = uint.Parse(maskedTextBoxMinutes_Stat.Text); bool showMonster = checkBoxShowMonster.Checked; var stats = new[] {hp, atk, def, spa, spd, spe}; Characteristic characteristic = null; if (comboBoxCharacteristic_Stat.SelectedItem.ToString() != "NONE") { characteristic = (Characteristic) comboBoxCharacteristic_Stat.SelectedItem; } // Run the IV checker with the stats and monster information // that were entered into the intial seed finder, var ivCheck = new IVCheck(pokemon, level, nature, characteristic, stats); // If there are any invalid IVs we need to notify the user // what we may not proceed. if (!ivCheck.IsValid) { MessageBox.Show( "There was a problem with the stats/nature/Pokemon you have entered. Please check them and try again. " + Environment.NewLine + Environment.NewLine + ivCheck, "Invalid Stats"); } else { uint minDefaultDelay = 550; if (radioButton_SS_HGSS.Checked) minDefaultDelay = 400; uint maxDefaultDelay = 1200; if (maskedTextBoxMinDelay_Stat.Text != "" && radioButton_SS_CUSTOM.Checked) minDefaultDelay = uint.Parse(maskedTextBoxMinDelay_Stat.Text); if (maskedTextBoxMaxDelay_Stat.Text != "" && radioButton_SS_CUSTOM.Checked) maxDefaultDelay = uint.Parse(maskedTextBoxMaxDelay_Stat.Text); int combinations = ivCheck.Possibilities[0].Count* ivCheck.Possibilities[1].Count* ivCheck.Possibilities[2].Count* ivCheck.Possibilities[3].Count* ivCheck.Possibilities[4].Count* ivCheck.Possibilities[5].Count; // If there are too many different combinations we need // to notify the user that they may not proceed. if (combinations > 100) { MessageBox.Show( "There were too many combinations of IV possibilities to accurately find your intitial seed (" + combinations + ") please try with a higher level Pokemon,", "To many IV Combinations"); } else { var allSeeds = new List<Seed>(); // Iterate through all of the combinations of IVs and check // so something good, first using the IvToPID. foreach (uint combo_HP in ivCheck.Possibilities[0]) foreach (uint combo_Atk in ivCheck.Possibilities[1]) foreach (uint combo_Def in ivCheck.Possibilities[2]) foreach (uint combo_SpA in ivCheck.Possibilities[3]) foreach (uint combo_SpD in ivCheck.Possibilities[4]) foreach (uint combo_Spe in ivCheck.Possibilities[5]) { List<Seed> startingSeeds = IVtoSeed.GetSeeds( combo_HP, combo_Atk, combo_Def, combo_SpA, combo_SpD, combo_Spe, (uint) nature.Number, 0); allSeeds.AddRange(startingSeeds); } // We now have a complete list of starting seeds so we can run the // same logic that we normally run here, but we might want to tone // down how much we actually search. // Now that we have developed a list of possible seeds we need to // start working those backwards and then building a list of // initial seeds that may have been possible. var seeds = new List<SeedInitial>(); bool monsterFound = false; bool initialFound = false; foreach (Seed seed in allSeeds) { if (seed.FrameType == FrameType.Method1) { if (showMonster) { seeds.Add(new SeedInitial(seed.MonsterSeed, 0, "Monster", 0, 0)); } monsterFound = true; // start backing up, we are going to back up // a grand totol of 10,000 times max for the // time being, var rng = new PokeRngR(seed.MonsterSeed); // back to 500 for (uint backCount = 1; backCount < 500; backCount++) { uint testSeed = rng.Seed; rng.GetNext32BitNumber(); uint seedAB = testSeed >> 24; uint seedCD = (testSeed & 0x00FF0000) >> 16; uint seedEFGH = testSeed & 0x0000FFFF; if (seedEFGH > (minDefaultDelay + year_stat - 2000) && seedEFGH < (maxDefaultDelay + year_stat - 2000)) { // Disqualify on hours second as it is very likely // to be a poor choice for use to work with. //wfy back to exact hour if (seedCD == hours_stat) { for (uint secondsCount = 0; secondsCount < 60; secondsCount++) { if (((month_stat*date_stat + minutes_stat + secondsCount)%0x100) == seedAB) { var initialSeed = new SeedInitial( testSeed, backCount, "Initial", secondsCount, seedEFGH - (year_stat - 2000)); seeds.Add(initialSeed); initialFound = true; } } } } } } } dataGridViewValues_Stat.DataSource = seeds; if (!monsterFound) { MessageBox.Show("No matches found for the IVs entered. Please check and try again.", "No Data Found", MessageBoxButtons.OK); } else if (!initialFound) { MessageBox.Show("No reasonable initial seed found. Please check your DATE and TIME.", "No Data Found", MessageBoxButtons.OK); } // Save our information for the next run Settings.Default.YearS = year_stat.ToString(); Settings.Default.MonthS = month_stat.ToString(); Settings.Default.DateS = date_stat.ToString(); Settings.Default.MinutesS = minutes_stat.ToString(); Settings.Default.HoursS = hours_stat.ToString(); if (maskedTextBoxMinDelay_Stat.Text != "" && radioButton_SIV_CUSTOM.Checked) { minDefaultDelay = uint.Parse(maskedTextBoxMinDelay_Stat.Text); Settings.Default.DelayMinS = minDefaultDelay.ToString(); } if (maskedTextBoxMaxDelay_Stat.Text != "" && radioButton_SIV_CUSTOM.Checked) { maxDefaultDelay = uint.Parse(maskedTextBoxMaxDelay_Stat.Text); Settings.Default.DelayMaxS = maxDefaultDelay.ToString(); } string SS_Mode = "DPP"; if (radioButton_SS_DPP.Checked) { SS_Mode = "DPP"; } else if (radioButton_SS_HGSS.Checked) { SS_Mode = "HGSS"; } else if (radioButton_SS_CUSTOM.Checked) { SS_Mode = "CUSTOM"; } Settings.Default.SSMode = SS_Mode; Settings.Default.Save(); } } }
private void buttonGenerate_Click(object sender, EventArgs e) { uint hp = 0; uint atk = 0; uint def = 0; uint spa = 0; uint spd = 0; uint spe = 0; if (maskedTextBoxHP_A.Text != "") hp = uint.Parse(maskedTextBoxHP_A.Text); if (maskedTextBoxAtk_A.Text != "") atk = uint.Parse(maskedTextBoxAtk_A.Text); if (maskedTextBoxDef_A.Text != "") def = uint.Parse(maskedTextBoxDef_A.Text); if (maskedTextBoxSpA_A.Text != "") spa = uint.Parse(maskedTextBoxSpA_A.Text); if (maskedTextBoxSpD_A.Text != "") spd = uint.Parse(maskedTextBoxSpD_A.Text); if (maskedTextBoxSpe_A.Text != "") spe = uint.Parse(maskedTextBoxSpe_A.Text); uint year_a = 0; uint month_a = 1; uint date_a = 1; uint hours_a = 0; uint minutes_a = 0; if (maskedTextBoxYear_A.Text != "") year_a = uint.Parse(maskedTextBoxYear_A.Text); if (maskedTextBoxMonth_A.Text != "") month_a = uint.Parse(maskedTextBoxMonth_A.Text); if (maskedTextBoxDate_A.Text != "") date_a = uint.Parse(maskedTextBoxDate_A.Text); if (maskedTextBoxHours_A.Text != "") hours_a = uint.Parse(maskedTextBoxHours_A.Text); if (maskedTextBoxMinutes_A.Text != "") minutes_a = uint.Parse(maskedTextBoxMinutes_A.Text); var nature = (Nature) comboBoxNature_A.SelectedValue; bool showMonster = checkBoxShowMonster.Checked; // Get a list of possible starting seeds that we are going to use // to work backwards and find probable initial seeds. List<Seed> startingSeeds = IVtoSeed.GetSeeds(hp, atk, def, spa, spd, spe, (uint) nature.Number); // Now that we have developed a list of possible seeds we need to // start working those backwards and then building a list of // initial seeds that may have been possible. var seeds = new List<SeedInitial>(); bool monsterFound = false; bool initialFound = false; uint minDefaultDelay = 550; if (radioButton_SIV_HGSS.Checked) minDefaultDelay = 400; uint maxDefaultDelay = 3600; if (maskedTextBoxMinDelay_A.Text != "" && radioButton_SIV_CUSTOM.Checked) minDefaultDelay = uint.Parse(maskedTextBoxMinDelay_A.Text); if (maskedTextBoxMaxDelay_A.Text != "" && radioButton_SIV_CUSTOM.Checked) maxDefaultDelay = uint.Parse(maskedTextBoxMaxDelay_A.Text); foreach (Seed seed in startingSeeds) { if (seed.FrameType == FrameType.Method1) { if (showMonster) { seeds.Add(new SeedInitial(seed.MonsterSeed, 0, "Monster", 0, 0)); } monsterFound = true; // start backing up, we are going to back up // a grand totol of 1000 times max for the // time being, var rng = new PokeRngR(seed.MonsterSeed); for (uint backCount = 1; backCount < 2000; backCount++) { uint testSeed = rng.Seed; rng.GetNext16BitNumber(); uint seedAB = testSeed >> 24; uint seedCD = (testSeed & 0x00FF0000) >> 16; uint seedEFGH = testSeed & 0x0000FFFF; if ((seedEFGH > (minDefaultDelay + year_a - 2000) && seedEFGH < (maxDefaultDelay + year_a - 2000)) || radioButton_SIV_OPEN.Checked) { // Disqualify on hours second as it is very likely // to be a poor choice for use to work with. if ((seedCD == hours_a) || radioButton_SIV_OPEN.Checked) { if (!radioButton_SIV_OPEN.Checked) { for (uint secondsCount = 0; secondsCount < 60; secondsCount++) { if (((month_a*date_a + minutes_a + secondsCount)%0x100) == seedAB) { var initialSeed = new SeedInitial( testSeed, backCount, "Initial", secondsCount, seedEFGH - (year_a - 2000)); seeds.Add(initialSeed); initialFound = true; } } } else // if (!checkBoxOpenSearch.Checked) { // Do the open search, which is completely open and does not // honor the min/max delay of the advanced search, so we should // likely make the selection of those mutially exclusive. if (seedCD < 24) { if ((checkBoxLowDelay.Checked && seedEFGH < 10000) || !checkBoxLowDelay.Checked) { var initialSeed = new SeedInitial( testSeed, backCount, "Initial", 0, seedEFGH - (year_a - 2000)); seeds.Add(initialSeed); initialFound = true; } } } } } } } } dataGridViewValues.DataSource = seeds; if (!monsterFound) { MessageBox.Show("No matches found for the IVs entered. Please check and try again.", "No Data Found", MessageBoxButtons.OK); } else if (!initialFound) { MessageBox.Show("No reasonable initial seed found. Please check your DATE and TIME.", "No Data Found", MessageBoxButtons.OK); } Settings.Default.YearA = year_a.ToString(); Settings.Default.MonthA = month_a.ToString(); Settings.Default.DateA = date_a.ToString(); Settings.Default.MinutesA = minutes_a.ToString(); Settings.Default.HoursA = hours_a.ToString(); if (maskedTextBoxMinDelay_A.Text != "" && radioButton_SIV_CUSTOM.Checked) { minDefaultDelay = uint.Parse(maskedTextBoxMinDelay_A.Text); Settings.Default.DelayMinA = minDefaultDelay.ToString(); } if (maskedTextBoxMaxDelay_A.Text != "" && radioButton_SIV_CUSTOM.Checked) { maxDefaultDelay = uint.Parse(maskedTextBoxMaxDelay_A.Text); Settings.Default.DelayMaxA = maxDefaultDelay.ToString(); } string SIV_Mode = "DPP"; if (radioButton_SIV_DPP.Checked) { SIV_Mode = "DPP"; } else if (radioButton_SIV_HGSS.Checked) { SIV_Mode = "HGSS"; } else if (radioButton_SIV_CUSTOM.Checked) { SIV_Mode = "CUSTOM"; } else if (radioButton_SIV_OPEN.Checked) { SIV_Mode = "OPEN"; } Settings.Default.SIVMode = SIV_Mode; Settings.Default.SIVLowDelay = checkBoxLowDelay.Checked; Settings.Default.Save(); }
public static List <Seed> GetSeeds( uint hp, uint atk, uint def, uint spa, uint spd, uint spe, uint nature, uint id) { var seeds = new List <Seed>(); uint ivs2 = spe | (spa << 5) | (spd << 10); uint ivs1 = hp | (atk << 5) | (def << 10); uint x_test = ivs2 << 16; uint x_testXD = ivs1 << 16; uint pid, pidXor, sid; bool pass = false; // Now we want to start with IV2 and call the RNG for // values between 0 and FFFF in the low order bits. for (uint cnt = 0; cnt <= 0xFFFF; cnt++) { //Check to see if the iv calls line up uint seedXD = x_testXD | cnt; var rngXD = new XdRng(seedXD); var rngXDR = new XdRngR(seedXD); uint rng1XD = rngXD.GetNext16BitNumber(); if ((rng1XD & 0x7FFF) == ivs2) { //Grab rest of RNG calls for XDColo uint rng2XD = rngXD.GetNext16BitNumber(); uint rng3XD = rngXD.GetNext16BitNumber(); uint rng4XD = rngXD.GetNext16BitNumber(); uint XDColoSeed = rngXDR.GetNext32BitNumber(); uint XDColoSeedXor = XDColoSeed ^ 0x80000000; sid = (rng4XD ^ rng3XD ^ id) & 0xFFF8; // Check Colosseum\XD // [IVs] [IVs] [xxx] [PID] [PID] // [START] [rng1] [rng3] pid = (rng3XD << 16) | rng4XD; if (pid % 25 == nature) { var newSeed = new Seed { Method = "Colosseum/XD", Pid = pid, MonsterSeed = XDColoSeed, Sid = sid }; seeds.Add(newSeed); } // Check Colosseum\XD XOR // [IVs] [IVs] [xxx] [PID] [PID] // [START] [rng1] [rng3] pidXor = pid ^ 0x80008000; if (pidXor % 25 == nature) { var newSeed = new Seed { Method = "Colosseum/XD", Pid = pidXor, MonsterSeed = XDColoSeedXor, Sid = sid }; seeds.Add(newSeed); } } // Now test rest of methods uint seed = x_test | cnt; var rng = new PokeRngR(seed); uint rng1 = rng.GetNext16BitNumber(); // We have a max of 5 total RNG calls // to make a pokemon and we already have // one so lets go ahead and get 4 more. uint rng2 = rng.GetNext16BitNumber(); uint rng3 = rng.GetNext16BitNumber(); uint rng4 = rng.GetNext16BitNumber(); uint method1Seed = rng.Seed; uint method1SeedXor = method1Seed ^ 0x80000000; sid = (rng2 ^ rng3 ^ id) & 0xFFF8; rng.GetNext16BitNumber(); uint method234Seed = rng.Seed; uint method234SeedXor = method234Seed ^ 0x80000000; //Checks that ivs line up if ((rng1 & 0x7FFF) == ivs1) { uint choppedPID; // Check Method 1 // [PID] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] pid = (rng2 << 16) + rng3; if (pid % 25 == nature) { // Build a seed to add to our collection var newSeed = new Seed { Method = "Method 1", Pid = pid, MonsterSeed = method1Seed, Sid = sid }; seeds.Add(newSeed); } // Check Method 1 XOR // [PID] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] pidXor = pid ^ 0x80008000; if (pidXor % 25 == nature) { // Build a seed to add to our collection var newSeed = new Seed { Method = "Method 1", Pid = pidXor, MonsterSeed = method1SeedXor, Sid = sid }; seeds.Add(newSeed); } // Check Reverse Method 1 // [PID] [PID] [IVs] [IVs] // [rng2] [rng3] [rng1] [START] pid = (rng3 << 16) + rng2; if (pid % 25 == nature) { // Build a seed to add to our collection var newSeed = new Seed { Method = "Reverse Method 1", Pid = pid, MonsterSeed = method1Seed, Sid = sid }; seeds.Add(newSeed); } // Check Reverse Method 1 XOR // [PID] [PID] [IVs] [IVs] // [rng2] [rng3] [rng1] [START] pid = pid ^ 0x80008000; if (pid % 25 == nature) { // Build a seed to add to our collection var newSeed = new Seed { Method = "Reverse Method 1", Pid = pid, MonsterSeed = method1SeedXor, Sid = sid }; seeds.Add(newSeed); } // Check Wishmkr // [PID] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] if (pid % 25 == nature) { if (method1Seed < 0x10000) { // Build a seed to add to our collection var newSeed = new Seed { Pid = pid, MonsterSeed = method1Seed, Sid = sid }; newSeed.Method = Functions.Shiny(newSeed.Pid, 20043, 0) ? "Wishmkr Shiny" : "Wishmkr"; seeds.Add(newSeed); } } // Check Wishmkr XOR // [PID] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] if (pidXor % 25 == nature) { if (method1SeedXor < 0x10000) { // Build a seed to add to our collection var newSeed = new Seed { Pid = pidXor, MonsterSeed = method1SeedXor, Sid = sid }; newSeed.Method = Functions.Shiny(newSeed.Pid, 20043, 0) ? "Wishmkr Shiny" : "Wishmkr"; seeds.Add(newSeed); } } // Check Method 2 // [PID] [PID] [xxxx] [IVs] [IVs] // [rng4] [rng3] [xxxx] [rng1] [START] pid = (rng3 << 16) + rng4; sid = (rng3 ^ rng4 ^ id) & 0xFFF8; if (pid % 25 == nature) { // Build a seed to add to our collection var newSeed = new Seed { Method = "Method 2", Pid = pid, MonsterSeed = method234Seed, Sid = sid }; seeds.Add(newSeed); } // Check Method 2 // [PID] [PID] [xxxx] [IVs] [IVs] // [rng4] [rng3] [xxxx] [rng1] [START] pidXor = pid ^ 0x80008000; if (pidXor % 25 == nature) { // Build a seed to add to our collection var newSeed = new Seed { Method = "Method 2", Pid = pidXor, MonsterSeed = method234SeedXor, Sid = sid }; seeds.Add(newSeed); } /* Removed because Method 3 doesn't exist in-game * // Check Method 3 * // [PID] [xxxx] [PID] [IVs] [IVs] * // [rng4] [xxxx] [rng2] [rng1] [START] * if (Check(rng1, rng2, rng4, hp, atk, def, nature)) * { * // Build a seed to add to our collection * Seed newSeed = new Seed(); * newSeed.Method = "Method 3"; * newSeed.Pid = (rng2 << 16) + rng4; * newSeed.MonsterSeed = method234Seed; * newSeed.Sid = (rng2 ^ rng4 ^ id) & 0xFFF8; * * seeds.Add(newSeed); * } */ // DPPt Cute Charm if (rng3 / 0x5556 != 0) { // Check DPPt Cute Charm // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = rng2 / 0xA3E; pass = choppedPID % 25 == nature; if (pass) { var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check DPPt Cute Charm (50% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] //choppedPID = rng2 / 0xA3E + 0x96; if (pass) { choppedPID += 0x96; var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check DPPt Cute Charm (25% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] //choppedPID = rng2 / 0xA3E + 0xC8; if (pass) { choppedPID += 0x32; var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check DPPt Cute Charm (75% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] //choppedPID = rng2 / 0xA3E + 0x4B; if (pass) { choppedPID -= 0x7D; var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check DPPt Cute Charm (87.5% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] //choppedPID = rng2 / 0xA3E + 0x32; if (pass) { choppedPID -= 0x19; var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } } // HGSS Cute Charm if (rng3 % 3 != 0) { // Check HGSS Cute Charm // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = rng2 % 25; pass = choppedPID == nature; if (pass) { var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check HGSS Cute Charm (50% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] //choppedPID = rng2 % 25 + 0x96; if (pass) { choppedPID += 0x96; var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check HGSS Cute Charm (25% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] //choppedPID = rng2 % 25 + 0xC8; if (pass) { choppedPID += 0x32; var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check HGSS Cute Charm (75% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] //choppedPID = rng2 % 25 + 0x4B; if (pass) { choppedPID -= 0x7D; var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check HGSS Cute Charm (87.5% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] //choppedPID = rng2 % 25 + 0x32; if (pass) { choppedPID -= 0x19; var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } } // DPPt Cute Charm XOR uint rng3Xor = rng3 ^ 0x8000; uint rng2Xor = rng2 ^ 0x8000; if (rng3Xor / 0x5556 != 0) { // Check DPPt Cute Charm // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = rng2Xor / 0xA3E; pass = choppedPID % 25 == nature; if (pass) { var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1SeedXor, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check DPPt Cute Charm (50% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] //choppedPID = rng2 / 0xA3E + 0x96; if (pass) { choppedPID += 0x96; var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1SeedXor, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check DPPt Cute Charm (25% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] //choppedPID = rng2 / 0xA3E + 0xC8; if (pass) { choppedPID += 0x32; var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1SeedXor, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check DPPt Cute Charm (75% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] //choppedPID = rng2 / 0xA3E + 0x4B; if (pass) { choppedPID -= 0x7D; var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1SeedXor, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check DPPt Cute Charm (87.5% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] //choppedPID = rng2 / 0xA3E + 0x32; if (pass) { choppedPID -= 0x19; var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1SeedXor, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } } // HGSS Cute Charm XOR if (rng3Xor % 3 != 0) { // Check HGSS Cute Charm // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = rng2Xor % 25; pass = choppedPID == nature; if (pass) { var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1SeedXor, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check HGSS Cute Charm (50% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] //choppedPID = rng2 % 25 + 0x96; if (pass) { choppedPID += 0x96; var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1SeedXor, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check HGSS Cute Charm (25% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] //choppedPID = rng2 % 25 + 0xC8; if (pass) { choppedPID += 0x32; var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1SeedXor, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check HGSS Cute Charm (75% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] //choppedPID = rng2 % 25 + 0x4B; if (pass) { choppedPID -= 0x7D; var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1SeedXor, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check HGSS Cute Charm (87.5% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] //choppedPID = rng2 % 25 + 0x32; if (pass) { choppedPID -= 0x19; var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1SeedXor, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } } } if ((rng2 & 0x7FFF) == ivs1) { // Check Method 4 // [PID] [PID] [IVs] [xxxx] [IVs] // [rng4] [rng3] [rng2] [xxxx] [START] pid = (rng3 << 16) + rng4; sid = (rng3 ^ rng4 ^ id) & 0xFFF8; if (pid % 25 == nature) { // Build a seed to add to our collection var newSeed = new Seed { Method = "Method 4", Pid = pid, MonsterSeed = method234Seed, Sid = sid }; seeds.Add(newSeed); } // Check Method 4 XOR // [PID] [PID] [IVs] [xxxx] [IVs] // [rng4] [rng3] [rng2] [xxxx] [START] pidXor = pid ^ 0x80008000; if (pidXor % 25 == nature) { // Build a seed to add to our collection var newSeed = new Seed { Method = "Method 4", Pid = pidXor, MonsterSeed = method234SeedXor, Sid = sid }; seeds.Add(newSeed); } } } return(seeds); }
// Overloaded method for SeedFinder's Open Search public static List <Seed> GetSeeds( uint hp, uint atk, uint def, uint spa, uint spd, uint spe, uint nature) { var seeds = new List <Seed>(); uint ivs2 = spe | (spa << 5) | (spd << 10); uint ivs1 = hp | (atk << 5) | (def << 10); uint x_test = ivs2 << 16; // Now we want to start with IV2 and call the RNG for // values between 0 and FFFF in the low order bits. for (uint cnt = 0; cnt <= 0xFFFF; cnt++) { // Set our test seed here so we can start // working backwards to see if the rest // of the information we were provided // is a match. uint seed = x_test | cnt; var rng = new PokeRngR(seed); // Right now, this simply assumes method // 1 and gets the value previous to check // for match. We need a clean way to do // this for all of our methods. uint rng1 = rng.GetNext16BitNumber(); //Check if ivs line up if ((rng1 & 0x7FFF) == ivs1) { // We have a max of 5 total RNG calls // to make a pokemon and we already have // one so lets go ahead and get 4 more. uint rng2 = rng.GetNext16BitNumber(); uint rng3 = rng.GetNext16BitNumber(); uint rng4 = rng.GetNext16BitNumber(); uint pid = (rng2 << 16) | rng3; uint method1Seed = rng.Seed; // Check Method 1 // [PID] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] if (pid % 25 == nature) { // Build a seed to add to our collection var newSeed = new Seed { Method = "Method 1", Pid = pid, MonsterSeed = method1Seed }; seeds.Add(newSeed); } // Check Method 1 XOR // [PID] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] pid ^= 0x80008000; if (pid % 25 == nature) { // Build a seed to add to our collection var newSeed = new Seed { Method = "Method 1", Pid = pid, MonsterSeed = method1Seed ^ 0x80000000 }; seeds.Add(newSeed); } } } return(seeds); }
// Overloaded method for SeedFinder's Open Search public static List<Seed> GetSeeds( uint hp, uint atk, uint def, uint spa, uint spd, uint spe, uint nature) { var seeds = new List<Seed>(); uint x4 = 0; uint x4_2 = 0; x4 = spe + (spa << 5) + (spd << 10); x4_2 = x4 ^ 0x8000; uint x8 = 0; uint x8_2 = 0; x8 = hp + (atk << 5) + (def << 10); x8_2 = x8 ^ 0x8000; // Now we want to start with IV2 and call the RNG for // values between 0 and FFFF in the low order bits. for (uint cnt = 0; cnt <= 0x1FFFE; cnt++) { uint x_test; uint x_testXD; // We want to test with the high bit // both set and not set, so we're going // to sneakily do them both. god help // me if i ever have to figure this out // in the future. x_test = (cnt & 1) == 0 ? x4 : x4_2; x_testXD = (cnt & 1) == 0 ? x8 : x8_2; // Set our test seed here so we can start // working backwards to see if the rest // of the information we were provided // is a match. uint seed = (x_test << 16) + (cnt%0xFFFF); uint seedXD = (x_testXD << 16) + (cnt%0xFFFF); var rng = new PokeRngR(seed); var rngXD = new XdRng(seedXD); var rngXDR = new XdRngR(seedXD); uint XDColoSeed = rngXDR.GetNext32BitNumber(); // Right now, this simply assumes method // 1 and gets the value previous to check // for match. We need a clean way to do // this for all of our methods. // We have a max of 5 total RNG calls // to make a pokemon and we already have // one so lets go ahead and get 4 more. ushort rng1 = rng.GetNext16BitNumber(); ushort rng2 = rng.GetNext16BitNumber(); ushort rng3 = rng.GetNext16BitNumber(); ushort rng4 = rng.GetNext16BitNumber(); ushort rng1XD = rngXD.GetNext16BitNumber(); ushort rng2XD = rngXD.GetNext16BitNumber(); ushort rng3XD = rngXD.GetNext16BitNumber(); ushort rng4XD = rngXD.GetNext16BitNumber(); uint method1Seed = rng.Seed; rng.GetNext16BitNumber(); uint method234Seed = rng.Seed; // Check Method 1 // [PID] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] if (Check(rng1, rng2, rng3, hp, atk, def, nature)) { // Build a seed to add to our collection var newSeed = new Seed { Method = "Method 1", Pid = ((uint) rng2 << 16) + rng3, MonsterSeed = method1Seed }; seeds.Add(newSeed); } } return seeds; }
public static List<Seed> GetSeeds( uint hp, uint atk, uint def, uint spa, uint spd, uint spe, uint nature, uint id) { var seeds = new List<Seed>(); uint x4 = 0; uint x4_2 = 0; x4 = spe + (spa << 5) + (spd << 10); x4_2 = x4 ^ 0x8000; uint x8 = 0; uint x8_2 = 0; x8 = hp + (atk << 5) + (def << 10); x8_2 = x8 ^ 0x8000; // Now we want to start with IV2 and call the RNG for // values between 0 and FFFF in the low order bits. for (uint cnt = 0; cnt <= 0x1FFFE; cnt++) { uint x_test; uint x_testXD; // We want to test with the high bit // both set and not set, so we're going // to sneakily do them both. god help // me if i ever have to figure this out // in the future. x_test = (cnt & 1) == 0 ? x4 : x4_2; x_testXD = (cnt & 1) == 0 ? x8 : x8_2; // Set our test seed here so we can start // working backwards to see if the rest // of the information we were provided // is a match. uint seed = (x_test << 16) + (cnt%0xFFFF); uint seedXD = (x_testXD << 16) + (cnt%0xFFFF); var rng = new PokeRngR(seed); var rngXD = new XdRng(seedXD); var rngXDR = new XdRngR(seedXD); uint XDColoSeed = rngXDR.GetNext32BitNumber(); // Right now, this simply assumes method // 1 and gets the value previous to check // for match. We need a clean way to do // this for all of our methods. // We have a max of 5 total RNG calls // to make a pokemon and we already have // one so lets go ahead and get 4 more. ushort rng1 = rng.GetNext16BitNumber(); ushort rng2 = rng.GetNext16BitNumber(); ushort rng3 = rng.GetNext16BitNumber(); ushort rng4 = rng.GetNext16BitNumber(); ushort rng1XD = rngXD.GetNext16BitNumber(); ushort rng2XD = rngXD.GetNext16BitNumber(); ushort rng3XD = rngXD.GetNext16BitNumber(); ushort rng4XD = rngXD.GetNext16BitNumber(); uint method1Seed = rng.Seed; rng.GetNext16BitNumber(); uint method234Seed = rng.Seed; ushort choppedPID; // Check Method 1 // [PID] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] if (Check(rng1, rng2, rng3, hp, atk, def, nature)) { // Build a seed to add to our collection var newSeed = new Seed(); newSeed.Method = "Method 1"; newSeed.Pid = ((uint) rng2 << 16) + rng3; newSeed.MonsterSeed = method1Seed; newSeed.Sid = (rng2 ^ (uint) rng3 ^ id) & 0xFFF8; seeds.Add(newSeed); } // Check Method 2 // [PID] [PID] [xxxx] [IVs] [IVs] // [rng4] [rng3] [xxxx] [rng1] [START] if (Check(rng1, rng3, rng4, hp, atk, def, nature)) { // Build a seed to add to our collection var newSeed = new Seed { Method = "Method 2", Pid = ((uint) rng3 << 16) + rng4, MonsterSeed = method234Seed, Sid = (rng3 ^ (uint) rng4 ^ id) & 0xFFF8 }; seeds.Add(newSeed); } /* * Removed because Method 3 doesn't exist in-game // Check Method 3 // [PID] [xxxx] [PID] [IVs] [IVs] // [rng4] [xxxx] [rng2] [rng1] [START] if (Check(rng1, rng2, rng4, hp, atk, def, nature)) { // Build a seed to add to our collection Seed newSeed = new Seed(); newSeed.Method = "Method 3"; newSeed.Pid = ((uint)rng2 << 16) + (uint)rng4; newSeed.MonsterSeed = method234Seed; newSeed.Sid = ((uint)rng2 ^ (uint)rng4 ^ id) & 0xFFF8; seeds.Add(newSeed); } */ // Check Method 4 // [PID] [PID] [IVs] [xxxx] [IVs] // [rng4] [rng3] [rng2] [xxxx] [START] if (Check(rng2, rng3, rng4, hp, atk, def, nature)) { // Build a seed to add to our collection var newSeed = new Seed { Method = "Method 4", Pid = ((uint) rng3 << 16) + rng4, MonsterSeed = method234Seed, Sid = (rng3 ^ (uint) rng4 ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check Colosseum\XD // [IVs] [IVs] [xxx] [PID] [PID] // [START] [rng1] [rng3] if (Check(rng1XD, rng3XD, rng4XD, spe, spa, spd, nature)) { var newSeed = new Seed { Method = "Colosseum/XD", Pid = ((uint) rng3XD << 16) + rng4XD, MonsterSeed = XDColoSeed, Sid = (rng4XD ^ (uint) rng3XD ^ id) & 0xFFF8 }; seeds.Add(newSeed); } if (rng3/0x5556 != 0) { // Check DPPt Cute Charm // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort) (rng2/0xA3E); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check DPPt Cute Charm (50% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort) (rng2/0xA3E + 0x96); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check DPPt Cute Charm (25% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort) (rng2/0xA3E + 0xC8); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check DPPt Cute Charm (75% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort) (rng2/0xA3E + 0x4B); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check DPPt Cute Charm (87.5% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort) (rng2/0xA3E + 0x32); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } } if (rng3%3 != 0) { // Check HGSS Cute Charm // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort) (rng2%25); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check HGSS Cute Charm (50% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort) (rng2%25 + 0x96); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check HGSS Cute Charm (25% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort) (rng2%25 + 0xC8); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check HGSS Cute Charm (75% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort) (rng2%25 + 0x4B); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check HGSS Cute Charm (87.5% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort) (rng2%25 + 0x32); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } } } return seeds; }
private void buttonGenerate_Click(object sender, EventArgs e) { // Initial seed that we are going to used for our frame generation ulong seed = 0; if (textBoxSeed.Text != "") { seed = ulong.Parse(textBoxSeed.Text, NumberStyles.HexNumber); } uint maxFrames = 1000; if (maskedTextBoxMaxFrames.Text != "") { maxFrames = uint.Parse(maskedTextBoxMaxFrames.Text); } // Generic RNG Interface IRNG rng = null; IRNG64 rng64 = null; // Instantiate based on the type that // the user has selected ------------ if (radioButtonCommon.Checked) { switch (comboBoxRNG.SelectedIndex) { case 0: rng = new PokeRng((uint) seed); break; case 1: rng = new PokeRngR((uint) seed); break; case 2: // if the given seed is 64 bit, remove the lower 32 bits. if (seed >= 0x100000000) seed >>= 32; rng = new MersenneTwister((uint) seed); break; case 3: rng64 = new BWRng(seed); break; case 4: rng64 = new BWRngR(seed); break; case 5: rng = new XdRng((uint) seed); break; case 6: rng = new XdRngR((uint) seed); break; case 7: rng = new ARng((uint) seed); break; case 8: rng = new ARngR((uint) seed); break; case 9: rng = new GRng((uint) seed); break; case 10: rng = new GRngR((uint) seed); break; case 11: rng = new EncounterRng((uint) seed); break; case 12: rng = new EncounterRngR((uint) seed); break; case 13: rng = new MersenneTwisterUntempered((int) seed); break; case 14: rng = new MersenneTwisterFast((uint) seed, (int) maxFrames); break; case 15: rng = new MersenneTwisterTable((uint) seed); break; } } if (radioButtonCustom.Checked) { // Check to see if we had valid values in the entry fields, and if so // covert them over to the adding and multiplier so we can instantiate // a generic LCRNG. ulong mult = 0; ulong add = 0; if (textBoxMult.Text != "") { mult = ulong.Parse(textBoxMult.Text, NumberStyles.HexNumber); } if (textBoxAdd.Text != "") { add = ulong.Parse(textBoxAdd.Text, NumberStyles.HexNumber); } if (checkBox64bit.Checked) { rng64 = new GenericRng64(seed, mult, add); } else { rng = new GenericRng((uint) seed, (uint) mult, (uint) add); } } // This is our collection of operators. At some point, if this gets // fancy, we may want to break it off and have it in it's own class var calculators = new Dictionary<string, Calculator>(); calculators["%"] = (x, y) => x%y; calculators["*"] = (x, y) => x*y; calculators["/"] = (x, y) => y == 0 ? 0 : x/y; calculators["&"] = (x, y) => x & y; calculators["^"] = (x, y) => x ^ y; calculators["|"] = (x, y) => x | y; calculators["+"] = (x, y) => x + y; calculators["-"] = (x, y) => x - y; calculators[">>"] = (x, y) => x >> (int) y; calculators["<<"] = (x, y) => x << (int) y; bool calcCustom1 = textBoxRValue1.Text != "" && (string) comboBoxOperator1.SelectedItem != null && (string) comboBoxLValue1.SelectedItem != null; bool calcCustom2 = (textBoxRValue2.Text != "" || comboBoxRValue2.SelectedIndex != 0) && (string) comboBoxOperator2.SelectedItem != null && (string) comboBoxLValue2.SelectedItem != null; bool calcCustom3 = (textBoxRValue3.Text != "" || comboBoxRValue3.SelectedIndex != 0) && (string) comboBoxOperator3.SelectedItem != null && (string) comboBoxLValue3.SelectedItem != null; bool calcCustom4 = (textBoxRValue4.Text != "" || comboBoxRValue4.SelectedIndex != 0) && (string) comboBoxOperator4.SelectedItem != null && (string) comboBoxLValue4.SelectedItem != null; bool calcCustom5 = (textBoxRValue5.Text != "" || comboBoxRValue5.SelectedIndex != 0) && (string) comboBoxOperator5.SelectedItem != null && (string) comboBoxLValue5.SelectedItem != null; bool calcCustom6 = (textBoxRValue6.Text != "" || comboBoxRValue6.SelectedIndex != 0) && (string) comboBoxOperator6.SelectedItem != null && (string) comboBoxLValue6.SelectedItem != null; bool calcCustom7 = (textBoxRValue7.Text != "" || comboBoxRValue7.SelectedIndex != 0) && (string) comboBoxOperator7.SelectedItem != null && (string) comboBoxLValue7.SelectedItem != null; // Build our custom item transform classes so that we can use them in // the future without having to do a parse of all of the items. ulong customRValue1; ulong customRValue2; ulong customRValue3; ulong customRValue4; ulong customRValue5; ulong customRValue6; ulong customRValue7; try { customRValue1 = (textBoxRValue1.Text == "" ? 0 : (checkBoxCustom1Hex.Checked ? ulong.Parse(textBoxRValue1.Text, NumberStyles.HexNumber) : ulong.Parse(textBoxRValue1.Text))); customRValue2 = (textBoxRValue2.Text == "" ? 0 : (checkBoxCustom2Hex.Checked ? ulong.Parse(textBoxRValue2.Text, NumberStyles.HexNumber) : ulong.Parse(textBoxRValue2.Text))); customRValue3 = (textBoxRValue3.Text == "" ? 0 : (checkBoxCustom3Hex.Checked ? ulong.Parse(textBoxRValue3.Text, NumberStyles.HexNumber) : ulong.Parse(textBoxRValue3.Text))); customRValue4 = (textBoxRValue4.Text == "" ? 0 : (checkBoxCustom4Hex.Checked ? ulong.Parse(textBoxRValue4.Text, NumberStyles.HexNumber) : ulong.Parse(textBoxRValue4.Text))); customRValue5 = (textBoxRValue5.Text == "" ? 0 : (checkBoxCustom5Hex.Checked ? ulong.Parse(textBoxRValue5.Text, NumberStyles.HexNumber) : ulong.Parse(textBoxRValue5.Text))); customRValue6 = (textBoxRValue6.Text == "" ? 0 : (checkBoxCustom6Hex.Checked ? ulong.Parse(textBoxRValue6.Text, NumberStyles.HexNumber) : ulong.Parse(textBoxRValue6.Text))); customRValue7 = (textBoxRValue7.Text == "" ? 0 : (checkBoxCustom7Hex.Checked ? ulong.Parse(textBoxRValue7.Text, NumberStyles.HexNumber) : ulong.Parse(textBoxRValue7.Text))); } catch (Exception ex) { MessageBox.Show("You must check off the Hex box in order to calculate using hex values.", ex.Message); return; } Calculator custom1Calc = ((string) comboBoxOperator1.SelectedItem == null ? null : calculators[(string) comboBoxOperator1.SelectedItem]); Calculator custom2Calc = ((string) comboBoxOperator2.SelectedItem == null ? null : calculators[(string) comboBoxOperator2.SelectedItem]); Calculator custom3Calc = ((string) comboBoxOperator3.SelectedItem == null ? null : calculators[(string) comboBoxOperator3.SelectedItem]); Calculator custom4Calc = ((string) comboBoxOperator4.SelectedItem == null ? null : calculators[(string) comboBoxOperator4.SelectedItem]); Calculator custom5Calc = ((string) comboBoxOperator5.SelectedItem == null ? null : calculators[(string) comboBoxOperator5.SelectedItem]); Calculator custom6Calc = ((string) comboBoxOperator6.SelectedItem == null ? null : calculators[(string) comboBoxOperator6.SelectedItem]); Calculator custom7Calc = ((string) comboBoxOperator7.SelectedItem == null ? null : calculators[(string) comboBoxOperator7.SelectedItem]); // Decide on whether we are going to display each of these items as // decimal or hex. Can be very useful either way, so it is an option. Custom1.DefaultCellStyle.Format = checkBoxCustom1Hex.Checked ? "X8" : ""; Custom2.DefaultCellStyle.Format = checkBoxCustom2Hex.Checked ? "X8" : ""; Custom3.DefaultCellStyle.Format = checkBoxCustom3Hex.Checked ? "X8" : ""; Custom4.DefaultCellStyle.Format = checkBoxCustom4Hex.Checked ? "X8" : ""; Custom5.DefaultCellStyle.Format = checkBoxCustom5Hex.Checked ? "X8" : ""; Custom6.DefaultCellStyle.Format = checkBoxCustom6Hex.Checked ? "X8" : ""; Custom7.DefaultCellStyle.Format = checkBoxCustom7Hex.Checked ? "X8" : ""; var frames = new List<FrameResearch>(); bool rngIs64Bit = (comboBoxRNG.SelectedIndex == 3 || comboBoxRNG.SelectedIndex == 4 || checkBox64bit.Checked && radioButtonCustom.Checked); // Loop through X times and create our research frames. for (uint cnt = 0; cnt < maxFrames; cnt++) { FrameResearch frame; if (!rngIs64Bit) { Column64Bit.Visible = false; Column32Bit.Visible = true; Column32BitHigh.Visible = false; Column32BitLow.Visible = false; uint rngResult = rng.Next(); // Start building the research frame that we are going to use frame = new FrameResearch {RNG64bit = rngIs64Bit, FrameNumber = cnt + 1, Full32 = rngResult}; } else { Column64Bit.Visible = true; Column32Bit.Visible = false; Column32BitHigh.Visible = true; Column32BitLow.Visible = true; ulong rngResult = rng64.Next(); // Start building the research frame that we are going to use frame = new FrameResearch {RNG64bit = rngIs64Bit, FrameNumber = cnt + 1, Full64 = rngResult}; } // Call Custom 1 //////////////////////////////////////////////////////////////// if (calcCustom1) { ulong customLValue1 = CustomCalcs(comboBoxLValue1, frame, frames); if (!rngIs64Bit) customLValue1 = (uint) customLValue1; frame.Custom1 = custom1Calc(customLValue1, customRValue1); } ////////////////////////////////////////////////////////////////////////////////// // Call Custom 2 //////////////////////////////////////////////////////////////// if (calcCustom2) { ulong customLValue2 = CustomCalcs(comboBoxLValue2, frame, frames); if ((string) comboBoxRValue2.SelectedItem != "None") customRValue2 = CustomCalcs(comboBoxRValue2, frame, frames); if (!rngIs64Bit) customLValue2 = (uint) customLValue2; frame.Custom2 = custom2Calc(customLValue2, customRValue2); } ////////////////////////////////////////////////////////////////////////////////// // Call Custom 3 //////////////////////////////////////////////////////////////// if (calcCustom3) { ulong customLValue3 = CustomCalcs(comboBoxLValue3, frame, frames); if ((string) comboBoxRValue3.SelectedItem != "None") customRValue3 = CustomCalcs(comboBoxRValue3, frame, frames); if (!rngIs64Bit) customLValue3 = (uint) customLValue3; frame.Custom3 = custom3Calc(customLValue3, customRValue3); } ////////////////////////////////////////////////////////////////////////////////// // Call Custom 4 //////////////////////////////////////////////////////////////// if (calcCustom4) { ulong customLValue4 = CustomCalcs(comboBoxLValue4, frame, frames); if ((string) comboBoxRValue4.SelectedItem != "None") customRValue4 = CustomCalcs(comboBoxRValue4, frame, frames); if (!rngIs64Bit) customLValue4 = (uint) customLValue4; frame.Custom4 = custom4Calc(customLValue4, customRValue4); } ////////////////////////////////////////////////////////////////////////////////// // Call Custom 5 //////////////////////////////////////////////////////////////// if (calcCustom5) { ulong customLValue5 = CustomCalcs(comboBoxLValue5, frame, frames); if ((string) comboBoxRValue5.SelectedItem != "None") customRValue5 = CustomCalcs(comboBoxRValue5, frame, frames); if (!rngIs64Bit) customLValue5 = (uint) customLValue5; frame.Custom5 = custom5Calc(customLValue5, customRValue5); } ////////////////////////////////////////////////////////////////////////////////// // Call Custom 6 //////////////////////////////////////////////////////////////// if (calcCustom6) { ulong customLValue6 = CustomCalcs(comboBoxLValue6, frame, frames); if ((string) comboBoxRValue6.SelectedItem != "None") customRValue6 = CustomCalcs(comboBoxRValue6, frame, frames); if (!rngIs64Bit) customLValue6 = (uint) customLValue6; frame.Custom6 = custom6Calc(customLValue6, customRValue6); } ////////////////////////////////////////////////////////////////////////////////// // Call Custom 7 //////////////////////////////////////////////////////////////// if (calcCustom7) { ulong customLValue7 = CustomCalcs(comboBoxLValue7, frame, frames); if ((string) comboBoxRValue7.SelectedItem != "None") customRValue7 = CustomCalcs(comboBoxRValue7, frame, frames); if (!rngIs64Bit) customLValue7 = (uint) customLValue7; frame.Custom7 = custom7Calc(customLValue7, customRValue7); } ////////////////////////////////////////////////////////////////////////////////// frames.Add(frame); } // Bind to the grid dataGridViewValues.DataSource = frames; dataGridViewValues.Focus(); }
// Add a list new Pokemon and do the breakdown public void Add( uint hp, uint atk, uint def, uint spa, uint spd, uint spe, Nature nature, string ability, GenderGenderRatio gender) { string ivs = hp + " / " + atk + " / " + def + " / " + spa + " / " + spd + " / " + spe; Pokemon.Add(new CalculateChainSidPokemon(ivs, nature.Name, ability, gender.ShortName)); // Build the block for the 2nd IV here. uint iv2 = spe + (spa << 5) + (spd << 10); uint iv2set = iv2 ^ 0x8000; uint iv1 = hp + (atk << 5) + (def << 10); uint iv1set = iv1 ^ 0x8000; var candidatePids = new List <CandidatePid>(); // Now we want to start with IV2 and call the RNG for // values between 0 and FFFF in the low order bits. for (uint cnt = 0; cnt <= 0x1FFFE; cnt++) { uint iv2_test; // We want to test with the high bit // both set and not set, so we're going // to sneakily do them both. god help // me if i ever have to figure this out // in the future. iv2_test = (cnt & 1) == 0 ? iv2 : iv2set; // Set our test seed here so we can start // working backwards to see if the rest // of the information we were provided // is a match. uint seed = (iv2_test << 16) + (cnt % 0xFFFF); var rng = new PokeRngR(seed); uint iv1_rng = rng.GetNext16BitNumber(); // Check for a canididate here if (iv1_rng == iv1 || iv1_rng == iv1set) { // Get the whole adjust number in a loop uint adjust = 0x0; for (int adjustCnt = 0; adjustCnt < 13; adjustCnt++) { uint adjustRng = rng.GetNext16BitNumber() & 1U; adjust |= (adjustRng << (15 - adjustCnt)); } // Get what we think was the initial PID uint pid2 = rng.GetNext16BitNumber(); // HIGHID uint pid1 = rng.GetNext16BitNumber(); // LOWID uint adjustedLow = adjust | (pid1 & 7); uint abilityNumber = adjustedLow & 1; uint genderNumber = adjustedLow & 0xFF; // lol make this not suck if ((ability == "Single Ability" || ( (abilityNumber == 0 && ability == "Ability 0") || (abilityNumber == 1 && ability == "Ability 1") )) && gender.Matches(genderNumber)) { var candidatePid = new CandidatePid { AdjustedLow = adjustedLow, NaturalHigh = pid2 }; candidatePids.Add(candidatePid); } } } var newSids = new List <uint>(); foreach (uint sid in CandidateSids) { // Check each candiate pid that we found for the // IV values and then see if the final PID with // a particular nature/gender is a match. If so // we can go ahead and add the sid to the new // list and exit early. foreach (CandidatePid candidatePid in candidatePids) { // Build our full adjusted PID uint adjustedHigh = candidatePid.AdjustedLow ^ Id ^ sid; adjustedHigh &= 0xFFF8; adjustedHigh += (candidatePid.NaturalHigh & 7); // for testing out the nature comparison uint pid = (adjustedHigh << 16) + candidatePid.AdjustedLow; // If any of them work, we will add this to // the new candidateSids list and break to // go to the next seed. Check the nature. uint pidNature = pid % 25; if (nature.Number == pidNature) { newSids.Add(sid); break; } } } CandidateSids = newSids; }
// Overloaded method for SeedFinder's Open Search public static List <Seed> GetSeeds( uint hp, uint atk, uint def, uint spa, uint spd, uint spe, uint nature) { var seeds = new List <Seed>(); uint x4 = spe + (spa << 5) + (spd << 10); uint x4_2 = x4 ^ 0x8000; uint x8 = hp + (atk << 5) + (def << 10); uint x8_2 = x8 ^ 0x8000; // Now we want to start with IV2 and call the RNG for // values between 0 and FFFF in the low order bits. for (uint cnt = 0; cnt <= 0xFFFE; cnt++) { uint x_test; uint x_testXD; // We want to test with the high bit // both set and not set, so we're going // to sneakily do them both. god help // me if i ever have to figure this out // in the future. x_test = (cnt & 1) == 0 ? x4 : x4_2; x_testXD = (cnt & 1) == 0 ? x8 : x8_2; // Set our test seed here so we can start // working backwards to see if the rest // of the information we were provided // is a match. uint seed = (x_test << 16) + (cnt & 0xFFFF); uint seedXD = (x_testXD << 16) + (cnt & 0xFFFF); var rng = new PokeRngR(seed); var rngXD = new XdRng(seedXD); var rngXDR = new XdRngR(seedXD); uint XDColoSeed = rngXDR.GetNext32BitNumber(); // Right now, this simply assumes method // 1 and gets the value previous to check // for match. We need a clean way to do // this for all of our methods. // We have a max of 5 total RNG calls // to make a pokemon and we already have // one so lets go ahead and get 4 more. ushort rng1 = rng.GetNext16BitNumber(); ushort rng2 = rng.GetNext16BitNumber(); ushort rng3 = rng.GetNext16BitNumber(); ushort rng4 = rng.GetNext16BitNumber(); ushort rng1XD = rngXD.GetNext16BitNumber(); ushort rng2XD = rngXD.GetNext16BitNumber(); ushort rng3XD = rngXD.GetNext16BitNumber(); ushort rng4XD = rngXD.GetNext16BitNumber(); uint method1Seed = rng.Seed; rng.GetNext16BitNumber(); uint method234Seed = rng.Seed; // Check Method 1 // [PID] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] if (Check(rng1, rng2, rng3, hp, atk, def, nature)) { // Build a seed to add to our collection var newSeed = new Seed { Method = "Method 1", Pid = ((uint)rng2 << 16) + rng3, MonsterSeed = method1Seed }; seeds.Add(newSeed); } } // Now we want to start with IV2 and call the RNG for // values between 0 and FFFF in the low order bits. for (uint cnt = 0xFFFF; cnt <= 0x1FFFE; cnt++) { uint x_test; uint x_testXD; // We want to test with the high bit // both set and not set, so we're going // to sneakily do them both. god help // me if i ever have to figure this out // in the future. x_test = (cnt & 1) == 0 ? x4 : x4_2; x_testXD = (cnt & 1) == 0 ? x8 : x8_2; // Set our test seed here so we can start // working backwards to see if the rest // of the information we were provided // is a match. uint seed = (x_test << 16) + ((cnt + 1) & 0xFFFF); uint seedXD = (x_testXD << 16) + ((cnt + 1) & 0xFFFF); var rng = new PokeRngR(seed); var rngXD = new XdRng(seedXD); var rngXDR = new XdRngR(seedXD); uint XDColoSeed = rngXDR.GetNext32BitNumber(); // Right now, this simply assumes method // 1 and gets the value previous to check // for match. We need a clean way to do // this for all of our methods. // We have a max of 5 total RNG calls // to make a pokemon and we already have // one so lets go ahead and get 4 more. ushort rng1 = rng.GetNext16BitNumber(); ushort rng2 = rng.GetNext16BitNumber(); ushort rng3 = rng.GetNext16BitNumber(); ushort rng4 = rng.GetNext16BitNumber(); ushort rng1XD = rngXD.GetNext16BitNumber(); ushort rng2XD = rngXD.GetNext16BitNumber(); ushort rng3XD = rngXD.GetNext16BitNumber(); ushort rng4XD = rngXD.GetNext16BitNumber(); uint method1Seed = rng.Seed; rng.GetNext16BitNumber(); uint method234Seed = rng.Seed; // Check Method 1 // [PID] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] if (Check(rng1, rng2, rng3, hp, atk, def, nature)) { // Build a seed to add to our collection var newSeed = new Seed { Method = "Method 1", Pid = ((uint)rng2 << 16) + rng3, MonsterSeed = method1Seed }; seeds.Add(newSeed); } } return(seeds); }
public static List <Seed> GetSeeds( uint hp, uint atk, uint def, uint spa, uint spd, uint spe, uint nature, uint id) { var seeds = new List <Seed>(); uint x4 = spe + (spa << 5) + (spd << 10); uint x4_2 = x4 ^ 0x8000; uint x8 = hp + (atk << 5) + (def << 10); uint x8_2 = x8 ^ 0x8000; // Now we want to start with IV2 and call the RNG for // values between 0 and FFFF in the low order bits. for (uint cnt = 0; cnt <= 0xFFFE; cnt++) { uint x_test; uint x_testXD; // We want to test with the high bit // both set and not set, so we're going // to sneakily do them both. god help // me if i ever have to figure this out // in the future. x_test = (cnt & 1) == 0 ? x4 : x4_2; x_testXD = (cnt & 1) == 0 ? x8 : x8_2; // Set our test seed here so we can start // working backwards to see if the rest // of the information we were provided // is a match. uint seed = (x_test << 16) + cnt; uint seedXD = (x_testXD << 16) + cnt; var rng = new PokeRngR(seed); var rngXD = new XdRng(seedXD); var rngXDR = new XdRngR(seedXD); uint XDColoSeed = rngXDR.GetNext32BitNumber(); // Right now, this simply assumes method // 1 and gets the value previous to check // for match. We need a clean way to do // this for all of our methods. // We have a max of 5 total RNG calls // to make a pokemon and we already have // one so lets go ahead and get 4 more. ushort rng1 = rng.GetNext16BitNumber(); ushort rng2 = rng.GetNext16BitNumber(); ushort rng3 = rng.GetNext16BitNumber(); ushort rng4 = rng.GetNext16BitNumber(); ushort rng1XD = rngXD.GetNext16BitNumber(); ushort rng2XD = rngXD.GetNext16BitNumber(); ushort rng3XD = rngXD.GetNext16BitNumber(); ushort rng4XD = rngXD.GetNext16BitNumber(); uint method1Seed = rng.Seed; rng.GetNext16BitNumber(); uint method234Seed = rng.Seed; ushort choppedPID; // Check Method 1 // [PID] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] if (Check(rng1, rng2, rng3, hp, atk, def, nature)) { // Build a seed to add to our collection var newSeed = new Seed(); newSeed.Method = "Method 1"; newSeed.Pid = ((uint)rng2 << 16) + rng3; newSeed.MonsterSeed = method1Seed; newSeed.Sid = (rng2 ^ (uint)rng3 ^ id) & 0xFFF8; seeds.Add(newSeed); } // Check Wishmkr // [PID] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] if (Check(rng1, rng3, rng2, hp, atk, def, nature)) { if (method1Seed < 0x10000) { // Build a seed to add to our collection var newSeed = new Seed(); newSeed.Pid = ((uint)rng3 << 16) + rng2; newSeed.MonsterSeed = method1Seed; newSeed.Sid = (rng2 ^ (uint)rng3 ^ id) & 0xFFF8; if (Functions.Shiny(newSeed.Pid, 20043, 0)) { newSeed.Method = "Wishmkr Shiny"; } else { newSeed.Method = "Wishmkr"; } seeds.Add(newSeed); } } // Check Method 2 // [PID] [PID] [xxxx] [IVs] [IVs] // [rng4] [rng3] [xxxx] [rng1] [START] if (Check(rng1, rng3, rng4, hp, atk, def, nature)) { // Build a seed to add to our collection var newSeed = new Seed { Method = "Method 2", Pid = ((uint)rng3 << 16) + rng4, MonsterSeed = method234Seed, Sid = (rng3 ^ (uint)rng4 ^ id) & 0xFFF8 }; seeds.Add(newSeed); } /* * Removed because Method 3 doesn't exist in-game * // Check Method 3 * // [PID] [xxxx] [PID] [IVs] [IVs] * // [rng4] [xxxx] [rng2] [rng1] [START] * if (Check(rng1, rng2, rng4, hp, atk, def, nature)) * { * // Build a seed to add to our collection * Seed newSeed = new Seed(); * newSeed.Method = "Method 3"; * newSeed.Pid = ((uint)rng2 << 16) + (uint)rng4; * newSeed.MonsterSeed = method234Seed; * newSeed.Sid = ((uint)rng2 ^ (uint)rng4 ^ id) & 0xFFF8; * * seeds.Add(newSeed); * } */ // Check Method 4 // [PID] [PID] [IVs] [xxxx] [IVs] // [rng4] [rng3] [rng2] [xxxx] [START] if (Check(rng2, rng3, rng4, hp, atk, def, nature)) { // Build a seed to add to our collection var newSeed = new Seed { Method = "Method 4", Pid = ((uint)rng3 << 16) + rng4, MonsterSeed = method234Seed, Sid = (rng3 ^ (uint)rng4 ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check Colosseum\XD // [IVs] [IVs] [xxx] [PID] [PID] // [START] [rng1] [rng3] if (Check(rng1XD, rng3XD, rng4XD, spe, spa, spd, nature)) { var newSeed = new Seed { Method = "Colosseum/XD", Pid = ((uint)rng3XD << 16) + rng4XD, MonsterSeed = XDColoSeed, Sid = (rng4XD ^ (uint)rng3XD ^ id) & 0xFFF8 }; seeds.Add(newSeed); } if (rng3 / 0x5556 != 0) { // Check DPPt Cute Charm // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort)(rng2 / 0xA3E); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check DPPt Cute Charm (50% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort)(rng2 / 0xA3E + 0x96); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check DPPt Cute Charm (25% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort)(rng2 / 0xA3E + 0xC8); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check DPPt Cute Charm (75% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort)(rng2 / 0xA3E + 0x4B); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check DPPt Cute Charm (87.5% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort)(rng2 / 0xA3E + 0x32); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } } if (rng3 % 3 != 0) { // Check HGSS Cute Charm // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort)(rng2 % 25); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check HGSS Cute Charm (50% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort)(rng2 % 25 + 0x96); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check HGSS Cute Charm (25% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort)(rng2 % 25 + 0xC8); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check HGSS Cute Charm (75% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort)(rng2 % 25 + 0x4B); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check HGSS Cute Charm (87.5% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort)(rng2 % 25 + 0x32); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } } } // Now we want to start with IV2 and call the RNG for // values between 0 and FFFF in the low order bits. for (uint cnt = 0xFFFF; cnt <= 0x1FFFE; cnt++) { uint x_test; uint x_testXD; // We want to test with the high bit // both set and not set, so we're going // to sneakily do them both. god help // me if i ever have to figure this out // in the future. x_test = (cnt & 1) == 0 ? x4 : x4_2; x_testXD = (cnt & 1) == 0 ? x8 : x8_2; // Set our test seed here so we can start // working backwards to see if the rest // of the information we were provided // is a match. uint seed = (x_test << 16) + ((cnt + 1) & 0xFFFF); uint seedXD = (x_testXD << 16) + ((cnt + 1) & 0xFFFF); var rng = new PokeRngR(seed); var rngXD = new XdRng(seedXD); var rngXDR = new XdRngR(seedXD); uint XDColoSeed = rngXDR.GetNext32BitNumber(); // Right now, this simply assumes method // 1 and gets the value previous to check // for match. We need a clean way to do // this for all of our methods. // We have a max of 5 total RNG calls // to make a pokemon and we already have // one so lets go ahead and get 4 more. ushort rng1 = rng.GetNext16BitNumber(); ushort rng2 = rng.GetNext16BitNumber(); ushort rng3 = rng.GetNext16BitNumber(); ushort rng4 = rng.GetNext16BitNumber(); ushort rng1XD = rngXD.GetNext16BitNumber(); ushort rng2XD = rngXD.GetNext16BitNumber(); ushort rng3XD = rngXD.GetNext16BitNumber(); ushort rng4XD = rngXD.GetNext16BitNumber(); uint method1Seed = rng.Seed; rng.GetNext16BitNumber(); uint method234Seed = rng.Seed; ushort choppedPID; // Check Method 1 // [PID] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] if (Check(rng1, rng2, rng3, hp, atk, def, nature)) { // Build a seed to add to our collection var newSeed = new Seed(); newSeed.Method = "Method 1"; newSeed.Pid = ((uint)rng2 << 16) + rng3; newSeed.MonsterSeed = method1Seed; newSeed.Sid = (rng2 ^ (uint)rng3 ^ id) & 0xFFF8; seeds.Add(newSeed); } // Check Wishmkr // [PID] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] if (Check(rng1, rng3, rng2, hp, atk, def, nature)) { if (method1Seed < 0x10000) { // Build a seed to add to our collection var newSeed = new Seed(); newSeed.Pid = ((uint)rng3 << 16) + rng2; newSeed.MonsterSeed = method1Seed; newSeed.Sid = (rng2 ^ (uint)rng3 ^ id) & 0xFFF8; if (Functions.Shiny(newSeed.Pid, 20043, 0)) { newSeed.Method = "Wishmkr Shiny"; } else { newSeed.Method = "Wishmkr"; } seeds.Add(newSeed); } } // Check Method 2 // [PID] [PID] [xxxx] [IVs] [IVs] // [rng4] [rng3] [xxxx] [rng1] [START] if (Check(rng1, rng3, rng4, hp, atk, def, nature)) { // Build a seed to add to our collection var newSeed = new Seed { Method = "Method 2", Pid = ((uint)rng3 << 16) + rng4, MonsterSeed = method234Seed, Sid = (rng3 ^ (uint)rng4 ^ id) & 0xFFF8 }; seeds.Add(newSeed); } /* * Removed because Method 3 doesn't exist in-game * // Check Method 3 * // [PID] [xxxx] [PID] [IVs] [IVs] * // [rng4] [xxxx] [rng2] [rng1] [START] * if (Check(rng1, rng2, rng4, hp, atk, def, nature)) * { * // Build a seed to add to our collection * Seed newSeed = new Seed(); * newSeed.Method = "Method 3"; * newSeed.Pid = ((uint)rng2 << 16) + (uint)rng4; * newSeed.MonsterSeed = method234Seed; * newSeed.Sid = ((uint)rng2 ^ (uint)rng4 ^ id) & 0xFFF8; * * seeds.Add(newSeed); * } */ // Check Method 4 // [PID] [PID] [IVs] [xxxx] [IVs] // [rng4] [rng3] [rng2] [xxxx] [START] if (Check(rng2, rng3, rng4, hp, atk, def, nature)) { // Build a seed to add to our collection var newSeed = new Seed { Method = "Method 4", Pid = ((uint)rng3 << 16) + rng4, MonsterSeed = method234Seed, Sid = (rng3 ^ (uint)rng4 ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check Colosseum\XD // [IVs] [IVs] [xxx] [PID] [PID] // [START] [rng1] [rng3] if (Check(rng1XD, rng3XD, rng4XD, spe, spa, spd, nature)) { var newSeed = new Seed { Method = "Colosseum/XD", Pid = ((uint)rng3XD << 16) + rng4XD, MonsterSeed = XDColoSeed, Sid = (rng4XD ^ (uint)rng3XD ^ id) & 0xFFF8 }; seeds.Add(newSeed); } if (rng3 / 0x5556 != 0) { // Check DPPt Cute Charm // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort)(rng2 / 0xA3E); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check DPPt Cute Charm (50% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort)(rng2 / 0xA3E + 0x96); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check DPPt Cute Charm (25% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort)(rng2 / 0xA3E + 0xC8); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check DPPt Cute Charm (75% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort)(rng2 / 0xA3E + 0x4B); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check DPPt Cute Charm (87.5% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort)(rng2 / 0xA3E + 0x32); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (DPPt)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } } if (rng3 % 3 != 0) { // Check HGSS Cute Charm // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort)(rng2 % 25); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check HGSS Cute Charm (50% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort)(rng2 % 25 + 0x96); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check HGSS Cute Charm (25% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort)(rng2 % 25 + 0xC8); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check HGSS Cute Charm (75% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort)(rng2 % 25 + 0x4B); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } // Check HGSS Cute Charm (87.5% male) // [CC Check] [PID] [IVs] [IVs] // [rng3] [rng2] [rng1] [START] choppedPID = (ushort)(rng2 % 25 + 0x32); if (Check(rng1, 0, choppedPID, hp, atk, def, nature)) { var newSeed = new Seed { Method = "Cute Charm (HGSS)", Pid = choppedPID, MonsterSeed = method1Seed, Sid = (choppedPID ^ id) & 0xFFF8 }; seeds.Add(newSeed); } } } return(seeds); }
// Add a list new Pokemon and do the breakdown public void Add( uint hp, uint atk, uint def, uint spa, uint spd, uint spe, Nature nature, string ability, GenderGenderRatio gender) { string ivs = hp + " / " + atk + " / " + def + " / " + spa + " / " + spd + " / " + spe; Pokemon.Add(new CalculateChainSidPokemon(ivs, nature.Name, ability, gender.ShortName)); // Build the block for the 2nd IV here. uint iv2 = spe + (spa << 5) + (spd << 10); uint iv2set = iv2 ^ 0x8000; uint iv1 = hp + (atk << 5) + (def << 10); uint iv1set = iv1 ^ 0x8000; var candidatePids = new List<CandidatePid>(); // Now we want to start with IV2 and call the RNG for // values between 0 and FFFF in the low order bits. for (uint cnt = 0; cnt <= 0x1FFFE; cnt++) { uint iv2_test; // We want to test with the high bit // both set and not set, so we're going // to sneakily do them both. god help // me if i ever have to figure this out // in the future. iv2_test = (cnt & 1) == 0 ? iv2 : iv2set; // Set our test seed here so we can start // working backwards to see if the rest // of the information we were provided // is a match. uint seed = (iv2_test << 16) + (cnt%0xFFFF); var rng = new PokeRngR(seed); uint iv1_rng = rng.GetNext16BitNumber(); // Check for a canididate here if (iv1_rng == iv1 || iv1_rng == iv1set) { // Get the whole adjust number in a loop uint adjust = 0x0; for (int adjustCnt = 0; adjustCnt < 13; adjustCnt++) { uint adjustRng = rng.GetNext16BitNumber()%2U; adjust |= (adjustRng << (15 - adjustCnt)); } // Get what we think was the initial PID uint pid2 = rng.GetNext16BitNumber(); // HIGHID uint pid1 = rng.GetNext16BitNumber(); // LOWID uint adjustedLow = adjust | (pid1 & 7); uint abilityNumber = adjustedLow%0x2; uint genderNumber = adjustedLow & 0xFF; // lol make this not suck if ((ability == "Single Ability" || ( (abilityNumber == 0 && ability == "Ability 0") || (abilityNumber == 1 && ability == "Ability 1") )) && gender.Matches(genderNumber)) { var candidatePid = new CandidatePid {AdjustedLow = adjustedLow, NaturalHigh = pid2}; candidatePids.Add(candidatePid); } } } var newSids = new List<uint>(); foreach (uint sid in CandidateSids) { // Check each candiate pid that we found for the // IV values and then see if the final PID with // a particular nature/gender is a match. If so // we can go ahead and add the sid to the new // list and exit early. foreach (CandidatePid candidatePid in candidatePids) { // Build our full adjusted PID uint adjustedHigh = candidatePid.AdjustedLow ^ Id ^ sid; adjustedHigh &= 0xFFF8; adjustedHigh += (candidatePid.NaturalHigh & 7); // for testing out the nature comparison uint pid = (adjustedHigh << 16) + candidatePid.AdjustedLow; // If any of them work, we will add this to // the new candidateSids list and break to // go to the next seed. Check the nature. uint pidNature = pid%25; if (nature.Number == pidNature) { newSids.Add(sid); break; } } } CandidateSids = newSids; }