Beispiel #1
0
 public NatureLock(int lockNum)
 {
     lockInfo = natureLockListGales(lockNum);
     rand     = new List <uint>();
     if (lockInfo != null)
     {
         backCount   = lockInfo.Length;
         frontCount  = backCount == 1 ? 0 : backCount - 2;
         shadowCount = backCount - 1;
         x           = 0;
         if (backCount == 1)
         {
             getCurrLock();
         }
     }
     reverse = new XdRngR(0);
     forward = new XdRng(0);
 }
Beispiel #2
0
        private void searchPokeSpot(uint seed, uint frame)
        {
            var rng = new XdRng(seed);

            rngList[0] = seed;

            for (int x = 1; x < 6; x++)
            {
                rngList[x] = rng.GetNext32BitNumber();
            }

            j = 5;

            for (uint x = 1; x <= frame; x++, rngList[j] = rng.GetNext32BitNumber())
            {
                j = ++j % 6;
                filterPokeSpot(x);
            }
        }
        public List<Frame> Generate(
            FrameCompare frameCompare,
            uint id,
            uint sid)
        {
            frames = new List<Frame>();

            //  The first thing we need to do is check for
            //  whether we are using the LCRNG or MTRNG
            if (frameType == FrameType.Gen4Normal ||
                frameType == FrameType.Gen4International)
            {
                mt.Reseed((uint) InitialSeed);
                frame = null;

                for (uint cnt = 1; cnt < InitialFrame + maxResults; cnt++)
                {
                    if (cnt < InitialFrame)
                    {
                        mt.Nextuint();
                        continue;
                    }

                    switch (frameType)
                    {
                        case FrameType.Gen4Normal:
                            uint mtResult = mt.Nextuint();

                            frame =
                                Frame.GenerateFrame(
                                    FrameType.Gen4Normal,
                                    cnt,
                                    mtResult,
                                    mtResult,
                                    id, sid);

                            break;

                        case FrameType.Gen4International:

                            //  We want to get our random number
                            //  first and then go through and check
                            //  to see if it is shiny.
                            uint pid = mt.Nextuint();

                            for (int n = 0; n <= 3; n++)
                            {
                                uint tid = (id & 0xffff) | ((sid & 0xffff) << 16);

                                uint a = pid ^ tid;
                                uint b = a & 0xffff;
                                uint c = (a >> 16) & 0xffff;
                                uint d = b ^ c;

                                if (d < 8)
                                {
                                    break;
                                }

                                // ARNG
                                pid = pid*0x6c078965 + 1;
                            }

                            frame =
                                Frame.GenerateFrame(
                                    FrameType.Gen4International,
                                    cnt,
                                    pid,
                                    pid,
                                    id, sid);

                            break;
                    }

                    if (frameCompare.Compare(frame))
                    {
                        frames.Add(frame);
                    }
                }
            }
            else if (frameType == FrameType.Method5Standard)
            {
                mt.Reseed((uint) InitialSeed);

                for (uint cnt = 1; cnt < InitialFrame; cnt++)
                {
                    mt.Nextuint();
                }

                for (int i = 0; i < (maxResults + 6); i++)
                {
                    rngArray[i] = mt.Nextuint() >> 27;
                }

                for (uint cnt = 0; cnt < maxResults; cnt++)
                {
                    if (EncounterType == EncounterType.Roamer)
                    {
                        if (!frameCompare.CompareIV(0, rngArray[cnt + 1]))
                            continue;
                        if (!frameCompare.CompareIV(1, rngArray[cnt + 2]))
                            continue;
                        if (!frameCompare.CompareIV(2, rngArray[cnt + 3]))
                            continue;
                        if (!frameCompare.CompareIV(3, rngArray[cnt + 6]))
                            continue;
                        if (!frameCompare.CompareIV(4, rngArray[cnt + 4]))
                            continue;
                        if (!frameCompare.CompareIV(5, rngArray[cnt + 5]))
                            continue;

                        frame =
                            Frame.GenerateFrame(
                                FrameType.Method5Standard,
                                cnt + InitialFrame,
                                (uint) InitialSeed,
                                rngArray[cnt + 1],
                                rngArray[cnt + 2],
                                rngArray[cnt + 3],
                                rngArray[cnt + 6],
                                rngArray[cnt + 4],
                                rngArray[cnt + 5]);
                    }
                    else
                    {
                        if (!frameCompare.CompareIV(0, rngArray[cnt]))
                            continue;
                        if (!frameCompare.CompareIV(1, rngArray[cnt + 1]))
                            continue;
                        if (!frameCompare.CompareIV(2, rngArray[cnt + 2]))
                            continue;
                        if (!frameCompare.CompareIV(3, rngArray[cnt + 3]))
                            continue;
                        if (!frameCompare.CompareIV(4, rngArray[cnt + 4]))
                            continue;
                        if (!frameCompare.CompareIV(5, rngArray[cnt + 5]))
                            continue;

                        frame =
                            Frame.GenerateFrame(
                                FrameType.Method5Standard,
                                cnt + InitialFrame,
                                (uint) InitialSeed,
                                rngArray[cnt],
                                rngArray[cnt + 1],
                                rngArray[cnt + 2],
                                rngArray[cnt + 3],
                                rngArray[cnt + 4],
                                rngArray[cnt + 5]);
                    }

                    frames.Add(frame);
                }
            }
            else if (frameType == FrameType.Method5CGear)
            {
                mt.Reseed((uint) InitialSeed);

                // first two frames are skipped
                mt.Nextuint();
                mt.Nextuint();

                for (uint cnt = 1; cnt < InitialFrame; cnt++)
                {
                    mt.Nextuint();
                }

                for (int i = 0; i < (maxResults + 8); i++)
                {
                    rngArray[i] = mt.Nextuint() >> 27;
                }

                for (uint cnt = 0; cnt < maxResults; cnt++)
                {
                    frame = null;

                    if (EncounterType == EncounterType.Roamer)
                    {
                        if (!frameCompare.CompareIV(0, rngArray[cnt + 1]))
                            continue;
                        if (!frameCompare.CompareIV(1, rngArray[cnt + 2]))
                            continue;
                        if (!frameCompare.CompareIV(2, rngArray[cnt + 3]))
                            continue;
                        if (!frameCompare.CompareIV(3, rngArray[cnt + 6]))
                            continue;
                        if (!frameCompare.CompareIV(4, rngArray[cnt + 4]))
                            continue;
                        if (!frameCompare.CompareIV(5, rngArray[cnt + 5]))
                            continue;

                        frame =
                            Frame.GenerateFrame(
                                FrameType.Method5CGear,
                                cnt + InitialFrame,
                                (uint) InitialSeed,
                                rngArray[cnt + 1],
                                rngArray[cnt + 2],
                                rngArray[cnt + 3],
                                rngArray[cnt + 6],
                                rngArray[cnt + 4],
                                rngArray[cnt + 5]);
                    }
                    else
                    {
                        if (!frameCompare.CompareIV(0, rngArray[cnt]))
                            continue;
                        if (!frameCompare.CompareIV(1, rngArray[cnt + 1]))
                            continue;
                        if (!frameCompare.CompareIV(2, rngArray[cnt + 2]))
                            continue;
                        if (!frameCompare.CompareIV(3, rngArray[cnt + 3]))
                            continue;
                        if (!frameCompare.CompareIV(4, rngArray[cnt + 4]))
                            continue;
                        if (!frameCompare.CompareIV(5, rngArray[cnt + 5]))
                            continue;

                        frame =
                            Frame.GenerateFrame(
                                FrameType.Method5CGear,
                                cnt + InitialFrame,
                                (uint) InitialSeed,
                                rngArray[cnt],
                                rngArray[cnt + 1],
                                rngArray[cnt + 2],
                                rngArray[cnt + 3],
                                rngArray[cnt + 4],
                                rngArray[cnt + 5]);
                    }

                    frames.Add(frame);
                }
            }
            else if (frameType == FrameType.Method5Natures)
            {
                rng64.Seed = InitialSeed;
                int encounterSlot = 0;
                const uint item = 0;
                var mod = EncounterMod.None;

                uint idLower = (id & 1) ^ (sid & 1);

                for (uint cnt = 1; cnt < InitialFrame; cnt++)
                {
                    rng64.GetNext64BitNumber();
                }

                for (int cnt = 0; cnt < maxResults + 7; cnt++)
                {
                    rngArray[cnt] = rng64.GetNext32BitNumber();
                }

                var entreeTimer = new CGearTimer();
                for (uint cnt = 0; cnt < maxResults; cnt++)
                {
                    uint nature;
                    uint pid;
                    bool synchable;
                    if (EncounterType == EncounterType.Gift || EncounterType == EncounterType.Roamer)
                    {
                        nature = (uint) (((ulong) rngArray[1 + cnt]*25) >> 32);
                        synchable = false;

                        pid = rngArray[0 + cnt];
                        if (EncounterType != EncounterType.Roamer)
                            pid = pid ^ 0x10000;
                    }
                    else
                    {
                        uint idTest;
                        if (EncounterType == EncounterType.Wild || EncounterType == EncounterType.WildSurfing ||
                            EncounterType == EncounterType.WildWaterSpot)
                        {
                            encounterSlot = EncounterSlotCalc.encounterSlot(rngArray[1 + cnt], frameType, EncounterType,
                                                                            isBW2);

                            if (EncounterMod == EncounterMod.Synchronize)
                            {
                                synchable = (rngArray[0 + cnt] >> 31) == 1;
                                if (synchable)
                                    nature = (uint) SynchNature;
                                else
                                    nature = (uint) (((ulong) rngArray[4 + cnt]*25) >> 32);

                                pid = rngArray[3 + cnt];
                                pid = pid ^ 0x10000;
                            }
                            else if (EncounterMod == EncounterMod.CuteCharm)
                            {
                                pid = rngArray[3 + cnt];
                                pid = pid ^ 0x10000;

                                // not a synch, but the CC check -- need to relabel (unfinished)
                                synchable = ((((ulong) rngArray[0 + cnt]*0xFFFF) >> 32)/656) < 67;

                                // failed CC check
                                if (!synchable)
                                {
                                    // leave it as-is
                                    nature = (uint) (((ulong) rngArray[4 + cnt]*25) >> 32);
                                }
                                else
                                {
                                    pid = Functions.GenderModPID(pid, rngArray[4 + cnt], SynchNature);
                                    nature = (uint) (((ulong) rngArray[5 + cnt]*25) >> 32);
                                }

                                synchable = false;
                            }
                            else if (EncounterMod == EncounterMod.Compoundeyes ||
                                     EncounterMod == EncounterMod.SuctionCups)
                            {
                                synchable = false;
                                encounterSlot = EncounterSlotCalc.encounterSlot(rngArray[0 + cnt], frameType,
                                                                                EncounterType);
                                nature = (uint) (((ulong) rngArray[3 + cnt]*25) >> 32);

                                pid = rngArray[2 + cnt];
                                pid = pid ^ 0x10000;
                            }
                            else if (EncounterMod == EncounterMod.Search)
                            {
                                pid = rngArray[3 + cnt];
                                pid = pid ^ 0x10000;

                                // not a synch, but the CC check -- need to relabel (unfinished)
                                synchable = ((((ulong) rngArray[0 + cnt]*0xFFFF) >> 32)/656) < 67;

                                // passed CC check
                                if (synchable)
                                {
                                    // Add all the Cute Charm possibilities
                                    nature = (uint) (((ulong) rngArray[5 + cnt]*25) >> 32);

                                    for (int i = -4; i < 5; i++)
                                    {
                                        if (i == 0)
                                            continue;

                                        uint tempPid = Functions.GenderModPID(pid, rngArray[4 + cnt], i);

                                        idTest = (idLower ^ (tempPid & 1) ^ (tempPid >> 31));
                                        if (idTest == 1)
                                            tempPid = (tempPid ^ 0x80000000);

                                        frame = Frame.GenerateFrame(
                                            FrameType.Method5Natures,
                                            EncounterType,
                                            cnt + InitialFrame,
                                            rngArray[0 + cnt],
                                            tempPid,
                                            id,
                                            sid,
                                            nature,
                                            false,
                                            encounterSlot,
                                            item);

                                        switch (i)
                                        {
                                            case 1:
                                                frame.EncounterMod = EncounterMod.CuteCharm50M;
                                                break;
                                            case 2:
                                                frame.EncounterMod = EncounterMod.CuteCharm75M;
                                                break;
                                            case 3:
                                                frame.EncounterMod = EncounterMod.CuteCharm25M;
                                                break;
                                            case 4:
                                                frame.EncounterMod = EncounterMod.CuteCharm875M;
                                                break;
                                            case -1:
                                                frame.EncounterMod = EncounterMod.CuteCharm50F;
                                                break;
                                            case -2:
                                                frame.EncounterMod = EncounterMod.CuteCharm75F;
                                                break;
                                            case -3:
                                                frame.EncounterMod = EncounterMod.CuteCharm25F;
                                                break;
                                            case -4:
                                                frame.EncounterMod = EncounterMod.CuteCharm125F;
                                                break;
                                        }

                                        if (frameCompare.Compare(frame))
                                        {
                                            frames.Add(frame);
                                        }
                                    }
                                }

                                synchable = (rngArray[0 + cnt] >> 31) == 1;
                                nature = (uint) (((ulong) rngArray[4 + cnt]*25) >> 32);

                                if (synchable && !frameCompare.CompareNature(nature))
                                    mod = EncounterMod.Synchronize;
                                else
                                    mod = EncounterMod.None;
                            }
                            else
                            {
                                pid = rngArray[3 + cnt];
                                pid = pid ^ 0x10000;

                                synchable = (rngArray[0 + cnt] >> 31) == 1;
                                nature = (uint) (((ulong) rngArray[4 + cnt]*25) >> 32);
                            }

                            idTest = (idLower ^ (pid & 1) ^ (pid >> 31));
                            if (idTest == 1)
                                pid = (pid ^ 0x80000000);
                        }
                        else if (EncounterType == EncounterType.WildCaveSpot)
                        {
                            if (((ulong) rngArray[0 + cnt]*1000 >> 32) < 400)
                            {
                                encounterSlot = EncounterSlotCalc.encounterSlot(rngArray[2 + cnt], frameType,
                                                                                EncounterType);
                            }
                            else
                            {
                                uint calc = ((ulong) rngArray[1 + cnt]*1000 >> 32) < 100 ? 1000u : 1700u;

                                uint result = (uint) ((ulong) rngArray[2 + cnt]*calc >> 32)/100;

                                if (calc == 1000)
                                    encounterSlot = (int) result + 13;
                                else
                                    encounterSlot = (int) result + 23;
                            }

                            if (EncounterMod == EncounterMod.Synchronize)
                            {
                                synchable = (rngArray[1 + cnt] >> 31) == 1;
                                if (synchable)
                                    nature = (uint) SynchNature;
                                else
                                    nature = (uint) (((ulong) rngArray[5 + cnt]*25) >> 32);

                                pid = rngArray[4 + cnt];
                                pid = pid ^ 0x10000;
                            }
                            else if (EncounterMod == EncounterMod.CuteCharm)
                            {
                                pid = rngArray[4 + cnt];
                                pid = pid ^ 0x10000;

                                // not a synch, but the CC check -- need to relabel (unfinished)
                                synchable = ((((ulong) rngArray[1 + cnt]*0xFFFF) >> 32)/656) < 67;

                                // failed CC check
                                if (!synchable)
                                {
                                    // leave it as-is
                                    nature = (uint) (((ulong) rngArray[5 + cnt]*25) >> 32);
                                }
                                else
                                {
                                    pid = Functions.GenderModPID(pid, rngArray[5 + cnt], SynchNature);
                                    nature = (uint) (((ulong) rngArray[6 + cnt]*25) >> 32);
                                }

                                synchable = false;
                            }
                            else if (EncounterMod == EncounterMod.Compoundeyes ||
                                     EncounterMod == EncounterMod.SuctionCups)
                            {
                                synchable = false;
                                encounterSlot = EncounterSlotCalc.encounterSlot(rngArray[1 + cnt], frameType,
                                                                                EncounterType);
                                nature = (uint) (((ulong) rngArray[4 + cnt]*25) >> 32);

                                pid = rngArray[3 + cnt];
                                pid = pid ^ 0x10000;
                            }
                            else if (EncounterMod == EncounterMod.Search)
                            {
                                // Check for item or battle
                                if (((ulong) rngArray[0 + cnt]*1000 >> 32) < 400)
                                {
                                    encounterSlot = EncounterSlotCalc.encounterSlot(rngArray[1 + cnt], frameType,
                                                                                    EncounterType);
                                }
                                else
                                    continue;

                                // Let's do Suction Cups since it affects the hittable frames

                                pid = rngArray[3 + cnt];
                                pid = pid ^ 0x10000;

                                nature = (uint) (((ulong) rngArray[4 + cnt]*25) >> 32);

                                frame = Frame.GenerateFrame(
                                    FrameType.Method5Natures,
                                    EncounterType,
                                    cnt + InitialFrame,
                                    rngArray[0 + cnt],
                                    pid,
                                    id,
                                    sid,
                                    nature,
                                    false,
                                    encounterSlot,
                                    item);

                                if (frameCompare.Compare(frame))
                                {
                                    frame.EncounterMod = EncounterMod.SuctionCups;
                                    frames.Add(frame);
                                }

                                // Now for regular\Synchronize\Cute Charm encounters

                                pid = rngArray[4 + cnt];
                                pid = pid ^ 0x10000;

                                // not a synch, but the CC check -- need to relabel (unfinished)
                                synchable = ((((ulong) rngArray[1 + cnt]*0xFFFF) >> 32)/656) < 67;

                                // passed CC check
                                if (synchable)
                                {
                                    // Add all the Cute Charm possibilities
                                    nature = (uint) (((ulong) rngArray[6 + cnt]*25) >> 32);

                                    for (int i = -4; i < 5; i++)
                                    {
                                        if (i == 0)
                                            continue;

                                        uint tempPid = Functions.GenderModPID(pid, rngArray[5 + cnt], i);

                                        idTest = (idLower ^ (tempPid & 1) ^ (tempPid >> 31));
                                        if (idTest == 1)
                                            tempPid = (tempPid ^ 0x80000000);

                                        frame = Frame.GenerateFrame(
                                            FrameType.Method5Natures,
                                            EncounterType,
                                            cnt + InitialFrame,
                                            rngArray[0 + cnt],
                                            tempPid,
                                            id,
                                            sid,
                                            nature,
                                            false,
                                            encounterSlot,
                                            item);

                                        switch (i)
                                        {
                                            case 1:
                                                frame.EncounterMod = EncounterMod.CuteCharm50M;
                                                break;
                                            case 2:
                                                frame.EncounterMod = EncounterMod.CuteCharm75M;
                                                break;
                                            case 3:
                                                frame.EncounterMod = EncounterMod.CuteCharm25M;
                                                break;
                                            case 4:
                                                frame.EncounterMod = EncounterMod.CuteCharm875M;
                                                break;
                                            case -1:
                                                frame.EncounterMod = EncounterMod.CuteCharm50F;
                                                break;
                                            case -2:
                                                frame.EncounterMod = EncounterMod.CuteCharm75F;
                                                break;
                                            case -3:
                                                frame.EncounterMod = EncounterMod.CuteCharm25F;
                                                break;
                                            case -4:
                                                frame.EncounterMod = EncounterMod.CuteCharm125F;
                                                break;
                                        }

                                        if (frameCompare.Compare(frame))
                                        {
                                            frames.Add(frame);
                                        }
                                    }
                                }

                                idTest = (idLower ^ (pid & 1) ^ (pid >> 31));
                                if (idTest == 1)
                                    pid = (pid ^ 0x80000000);

                                synchable = (rngArray[1 + cnt] >> 31) == 1;
                                nature = (uint) (((ulong) rngArray[5 + cnt]*25) >> 32);

                                if (synchable && !frameCompare.CompareNature(nature))
                                    mod = EncounterMod.Synchronize;
                                else
                                    mod = EncounterMod.None;
                            }
                            else
                            {
                                pid = rngArray[4 + cnt];
                                pid = pid ^ 0x10000;

                                synchable = (rngArray[1 + cnt] >> 31) == 1;
                                nature = (uint) (((ulong) rngArray[5 + cnt]*25) >> 32);
                            }

                            idTest = (idLower ^ (pid & 1) ^ (pid >> 31));
                            if (idTest == 1)
                                pid = (pid ^ 0x80000000);
                        }
                        else if (EncounterType == EncounterType.WildSwarm)
                        {
                            bool swarm = (((ulong) rngArray[1 + cnt]*0xFFFF/0x290) >> 32) < 40;
                            if (swarm)
                                // we'll use non-existent slot 12 to denote a swarm
                                encounterSlot = 12;
                            else
                                encounterSlot = EncounterSlotCalc.encounterSlot(rngArray[2 + cnt], frameType,
                                                                                EncounterType);

                            if (EncounterMod == EncounterMod.Synchronize)
                            {
                                synchable = (rngArray[0 + cnt] >> 31) == 1;
                                if (synchable)
                                    nature = (uint) SynchNature;
                                else
                                    nature = (uint) (((ulong) rngArray[5 + cnt]*25) >> 32);

                                pid = rngArray[4 + cnt];
                                pid = pid ^ 0x10000;
                            }
                            else if (EncounterMod == EncounterMod.CuteCharm)
                            {
                                // not a synch, but the CC check -- need to relabel (unfinished)
                                synchable = ((((ulong) rngArray[0 + cnt]*0xFFFF) >> 32)/656) < 67;

                                pid = rngArray[4 + cnt];
                                pid = pid ^ 0x10000;

                                // failed CC check
                                if (!synchable)
                                {
                                    // leave it as-is
                                    nature = (uint) (((ulong) rngArray[5 + cnt]*25) >> 32);
                                }
                                else
                                {
                                    pid = Functions.GenderModPID(pid, rngArray[5 + cnt], SynchNature);
                                    nature = (uint) (((ulong) rngArray[6 + cnt]*25) >> 32);
                                }

                                synchable = false;
                            }
                            else if (EncounterMod == EncounterMod.Compoundeyes)
                            {
                                swarm = (((ulong) rngArray[0 + cnt]*0xFFFF/0x290) >> 32) < 40;
                                if (swarm)
                                    // we'll use non-existent slot 12 to denote a swarm
                                    encounterSlot = 12;
                                else
                                    encounterSlot = EncounterSlotCalc.encounterSlot(rngArray[1 + cnt], frameType,
                                                                                    EncounterType);

                                synchable = false;
                                nature = (uint) (((ulong) rngArray[4 + cnt]*25) >> 32);

                                pid = rngArray[3 + cnt];
                                pid = pid ^ 0x10000;
                            }
                            else if (EncounterMod == EncounterMod.Search)
                            {
                                pid = rngArray[4 + cnt];
                                pid = pid ^ 0x10000;

                                // not a synch, but the CC check -- need to relabel (unfinished)
                                // also never used
                                synchable = ((((ulong) rngArray[0 + cnt]*0xFFFF) >> 32)/656) < 67;

                                // Add all the Cute Charm possibilities
                                nature = (uint) (((ulong) rngArray[6 + cnt]*25) >> 32);

                                for (int i = -4; i < 5; i++)
                                {
                                    if (i == 0)
                                        continue;

                                    uint tempPid = Functions.GenderModPID(pid, rngArray[5 + cnt], i);

                                    idTest = (idLower ^ (tempPid & 1) ^ (tempPid >> 31));
                                    if (idTest == 1)
                                        tempPid = (tempPid ^ 0x80000000);

                                    frame = Frame.GenerateFrame(
                                        FrameType.Method5Natures,
                                        EncounterType,
                                        cnt + InitialFrame,
                                        rngArray[0 + cnt],
                                        tempPid,
                                        id,
                                        sid,
                                        nature,
                                        false,
                                        encounterSlot,
                                        item);

                                    switch (i)
                                    {
                                        case 1:
                                            frame.EncounterMod = EncounterMod.CuteCharm50M;
                                            break;
                                        case 2:
                                            frame.EncounterMod = EncounterMod.CuteCharm75M;
                                            break;
                                        case 3:
                                            frame.EncounterMod = EncounterMod.CuteCharm25M;
                                            break;
                                        case 4:
                                            frame.EncounterMod = EncounterMod.CuteCharm875M;
                                            break;
                                        case -1:
                                            frame.EncounterMod = EncounterMod.CuteCharm50F;
                                            break;
                                        case -2:
                                            frame.EncounterMod = EncounterMod.CuteCharm75F;
                                            break;
                                        case -3:
                                            frame.EncounterMod = EncounterMod.CuteCharm25F;
                                            break;
                                        case -4:
                                            frame.EncounterMod = EncounterMod.CuteCharm125F;
                                            break;
                                    }

                                    if (frameCompare.Compare(frame))
                                    {
                                        frames.Add(frame);
                                    }
                                }

                                idTest = (idLower ^ (pid & 1) ^ (pid >> 31));
                                if (idTest == 1)
                                    pid = (pid ^ 0x80000000);

                                synchable = (rngArray[0 + cnt] >> 31) == 1;
                                nature = (uint) (((ulong) rngArray[5 + cnt]*25) >> 32);

                                if (synchable && !frameCompare.CompareNature(nature))
                                    mod = EncounterMod.Synchronize;
                                else
                                    mod = EncounterMod.None;
                            }
                            else
                            {
                                synchable = (rngArray[0 + cnt] >> 31) == 1;
                                nature = (uint) (((ulong) rngArray[5 + cnt]*25) >> 32);

                                pid = rngArray[4 + cnt];
                                pid = pid ^ 0x10000;
                            }

                            idTest = (idLower ^ (pid & 1) ^ (pid >> 31));
                            if (idTest == 1)
                                pid = (pid ^ 0x80000000);
                        }
                        else if (EncounterType == EncounterType.Stationary)
                        {
                            if (EncounterMod == EncounterMod.Synchronize)
                            {
                                synchable = (rngArray[0 + cnt] >> 31) == 1;
                                if (synchable)
                                    nature = (uint) SynchNature;
                                else
                                    nature = (uint) (((ulong) rngArray[2 + cnt]*25) >> 32);

                                pid = rngArray[1 + cnt];
                                pid = pid ^ 0x10000;
                            }
                            else if (EncounterMod == EncounterMod.CuteCharm)
                            {
                                // not a synch, but the CC check -- need to relabel (unfinished)
                                synchable = ((((ulong) rngArray[0 + cnt]*0xFFFF) >> 32)/656) < 67;

                                pid = rngArray[1 + cnt];
                                pid = pid ^ 0x10000;

                                // failed CC check
                                if (!synchable)
                                {
                                    // leave it as-is
                                    nature = (uint) (((ulong) rngArray[2 + cnt]*25) >> 32);
                                }
                                else
                                {
                                    pid = Functions.GenderModPID(pid, rngArray[2 + cnt], SynchNature);
                                    nature = (uint) (((ulong) rngArray[3 + cnt]*25) >> 32);
                                }

                                synchable = false;
                            }
                            else if (EncounterMod == EncounterMod.Compoundeyes)
                            {
                                synchable = false;
                                nature = (uint) (((ulong) rngArray[1 + cnt]*25) >> 32);

                                pid = rngArray[0 + cnt];
                                pid = pid ^ 0x10000;
                            }
                            else if (EncounterMod == EncounterMod.Search)
                            {
                                pid = rngArray[1 + cnt];
                                pid = pid ^ 0x10000;

                                // not a synch, but the CC check -- need to relabel (unfinished)
                                synchable = ((((ulong) rngArray[0 + cnt]*0xFFFF) >> 32)/656) < 67;

                                // CC check
                                if (synchable)
                                {
                                    // Add only 50% Cute Charm possibilities because the only applicable
                                    // stationaries have a 50\50 male-female ratio.
                                    nature = (uint) (((ulong) rngArray[3 + cnt]*25) >> 32);

                                    for (int i = -1; i < 2; i++)
                                    {
                                        if (i == 0)
                                            continue;

                                        uint tempPid = Functions.GenderModPID(pid, rngArray[2 + cnt], i);

                                        idTest = (idLower ^ (tempPid & 1) ^ (tempPid >> 31));
                                        if (idTest == 1)
                                            tempPid = (tempPid ^ 0x80000000);

                                        frame = Frame.GenerateFrame(
                                            FrameType.Method5Natures,
                                            EncounterType,
                                            cnt + InitialFrame,
                                            rngArray[0 + cnt],
                                            tempPid,
                                            id,
                                            sid,
                                            nature,
                                            false,
                                            encounterSlot,
                                            item);

                                        switch (i)
                                        {
                                            case 1:
                                                frame.EncounterMod = EncounterMod.CuteCharm50M;
                                                break;
                                            case -1:
                                                frame.EncounterMod = EncounterMod.CuteCharm50F;
                                                break;
                                        }

                                        if (frameCompare.Compare(frame))
                                        {
                                            frames.Add(frame);
                                        }
                                    }
                                }

                                synchable = (rngArray[0 + cnt] >> 31) == 1;
                                nature = (uint) (((ulong) rngArray[2 + cnt]*25) >> 32);

                                if (synchable && !frameCompare.CompareNature(nature))
                                    mod = EncounterMod.Synchronize;
                                else
                                    mod = EncounterMod.None;
                            }
                            else
                            {
                                synchable = (rngArray[0 + cnt] >> 31) == 1;
                                nature = (uint) (((ulong) rngArray[2 + cnt]*25) >> 32);

                                pid = rngArray[1 + cnt];
                                pid = pid ^ 0x10000;
                            }

                            idTest = (idLower ^ (pid & 1) ^ (pid >> 31));
                            if (idTest == 1)
                                pid = (pid ^ 0x80000000);
                        }
                        else if (EncounterType == EncounterType.AllEncounterShiny)
                        {
                            // used for Time Finder searches only

                            pid = rngArray[3 + cnt];
                            pid = pid ^ 0x10000;

                            nature = (uint) (((ulong) rngArray[4 + cnt]*25) >> 32);

                            synchable = ((rngArray[0 + cnt] >> 31) == 1) && ((rngArray[2 + cnt] >> 31) == 1);

                            idTest = (idLower ^ (pid & 1) ^ (pid >> 31));
                            if (idTest == 1)
                            {
                                // not the actual PID, but guaranteed to be non-shiny so it won't show up in search results
                                pid = id << 16 | sid ^ 0x100;
                            }
                        }
                        else if (EncounterType == EncounterType.LarvestaEgg)
                        {
                            pid = rngArray[0 + cnt];
                            nature = (uint) (((ulong) rngArray[2 + cnt]*25) >> 32);
                            synchable = false;
                        }
                        else if (EncounterType == EncounterType.Entralink)
                        {
                            pid = rngArray[0 + cnt];

                            synchable = false;

                            // genderless
                            if (frameCompare.GenderFilter.GenderValue == 0xFF)
                            {
                                // leave it as-is
                                nature = (uint) (((ulong) rngArray[4 + cnt]*25) >> 32);
                            }
                                // always female
                            else if (frameCompare.GenderFilter.GenderValue == 0xFE)
                            {
                                var genderAdjustment = (uint) ((0x8*(ulong) rngArray[1 + cnt]) >> 32);
                                pid = (pid & 0xFFFFFF00) | (genderAdjustment + 1);
                                nature = (uint) (((ulong) rngArray[5 + cnt]*25) >> 32);
                            }
                                // always male
                            else if (frameCompare.GenderFilter.GenderValue == 0x0)
                            {
                                var genderAdjustment = (uint) ((0xF6*(ulong) rngArray[1 + cnt]) >> 32);
                                pid = (pid & 0xFFFFFF00) | (genderAdjustment + 8);
                                nature = (uint) (((ulong) rngArray[5 + cnt]*25) >> 32);
                            }
                            else
                            {
                                if (frameCompare.GenderFilter.GenderCriteria == GenderCriteria.Male)
                                {
                                    var genderAdjustment =
                                        (uint)
                                        (((0xFE - frameCompare.GenderFilter.GenderValue)*(ulong) rngArray[1 + cnt]) >>
                                         32);
                                    pid = (pid & 0xFFFFFF00) |
                                          (genderAdjustment + frameCompare.GenderFilter.GenderValue);
                                }
                                else if (frameCompare.GenderFilter.GenderCriteria == GenderCriteria.Female)
                                {
                                    var genderAdjustment =
                                        (uint)
                                        (((frameCompare.GenderFilter.GenderValue - 1)*(ulong) rngArray[1 + cnt]) >> 32);
                                    pid = (pid & 0xFFFFFF00) | (genderAdjustment + 1);
                                }
                                nature = (uint) (((ulong) rngArray[5 + cnt]*25) >> 32);
                            }
                            if ((pid & 0x10000) == 0x10000)
                                pid = pid ^ 0x10000;

                            //note: might be wrong
                            pid ^= 0x10000000;
                        }
                        else if (EncounterType == EncounterType.HiddenGrotto)
                        {
                            // unknown call at 0
                            synchable = (rngArray[1 + cnt] >> 31) == 1;
                            pid = rngArray[2 + cnt];

                            // genderless
                            if (frameCompare.GenderFilter.GenderValue == 0xFF)
                            {
                                // leave it as-is
                                nature = (uint) (((ulong) rngArray[3 + cnt]*25) >> 32);
                            }
                                // always female
                            else if (frameCompare.GenderFilter.GenderValue == 0xFE)
                            {
                                var genderAdjustment = (uint) ((0x8*(ulong) rngArray[3 + cnt]) >> 32);
                                pid = (pid & 0xFFFFFF00) | (genderAdjustment + 1);
                                nature = (uint) (((ulong) rngArray[4 + cnt]*25) >> 32);
                            }
                                // always male
                            else if (frameCompare.GenderFilter.GenderValue == 0x0)
                            {
                                var genderAdjustment = (uint) ((0xF6*(ulong) rngArray[3 + cnt]) >> 32);
                                pid = (pid & 0xFFFFFF00) | (genderAdjustment + 8);
                                nature = (uint) (((ulong) rngArray[4 + cnt]*25) >> 32);
                            }
                            else
                            {
                                if (frameCompare.GenderFilter.GenderCriteria == GenderCriteria.Male)
                                {
                                    var genderAdjustment =
                                        (uint)
                                        (((0xFE - frameCompare.GenderFilter.GenderValue)*(ulong) rngArray[3 + cnt]) >>
                                         32);
                                    pid = (pid & 0xFFFFFF00) |
                                          (genderAdjustment + frameCompare.GenderFilter.GenderValue);
                                }
                                else if (frameCompare.GenderFilter.GenderCriteria == GenderCriteria.Female)
                                {
                                    var genderAdjustment =
                                        (uint)
                                        (((frameCompare.GenderFilter.GenderValue - 1)*(ulong) rngArray[3 + cnt]) >> 32);
                                    pid = (pid & 0xFFFFFF00) | (genderAdjustment + 1);
                                }
                                nature = (uint) (((ulong) rngArray[4 + cnt]*25) >> 32);
                            }
                            if (synchable && EncounterMod == EncounterMod.Synchronize)
                                nature = (uint) SynchNature;
                            pid = pid ^ 0x10000;
                        }
                        else
                        {
                            // Fishing, Shaking Grass Spots

                            // check for Fishing nibble
                            if (EncounterMod == EncounterMod.SuctionCups && EncounterType == EncounterType.WildSuperRod)
                            {
                                encounterSlot = EncounterSlotCalc.encounterSlot(rngArray[1 + cnt], frameType,
                                                                                EncounterType);

                                synchable = false;
                                nature = (uint) (((ulong) rngArray[4 + cnt]*25) >> 32);

                                pid = rngArray[3 + cnt];
                                pid = pid ^ 0x10000;
                            }
                            else
                            {
                                if (EncounterType == EncounterType.WildSuperRod && (rngArray[1 + cnt] >> 16)/656 >= 50)
                                    continue;

                                encounterSlot = EncounterSlotCalc.encounterSlot(rngArray[2 + cnt], frameType,
                                                                                EncounterType);

                                if (EncounterMod == EncounterMod.Synchronize)
                                {
                                    synchable = (rngArray[0 + cnt] >> 31) == 1;
                                    if (synchable)
                                        nature = (uint) SynchNature;
                                    else
                                        nature = (uint) (((ulong) rngArray[5 + cnt]*25) >> 32);

                                    pid = rngArray[4 + cnt];
                                    pid = pid ^ 0x10000;
                                }
                                else if (EncounterMod == EncounterMod.CuteCharm)
                                {
                                    // not a synch, but the CC check -- need to relabel (unfinished)
                                    synchable = ((((ulong) rngArray[0 + cnt]*0xFFFF) >> 32)/656) < 67;

                                    pid = rngArray[4 + cnt];
                                    pid = pid ^ 0x10000;

                                    // failed CC check
                                    if (!synchable)
                                    {
                                        // leave it as-is
                                        nature = (uint) (((ulong) rngArray[5 + cnt]*25) >> 32);
                                    }
                                    else
                                    {
                                        pid = Functions.GenderModPID(pid, rngArray[5 + cnt], SynchNature);
                                        nature = (uint) (((ulong) rngArray[6 + cnt]*25) >> 32);
                                    }

                                    synchable = false;
                                }
                                else if (EncounterMod == EncounterMod.Compoundeyes)
                                {
                                    if (EncounterType == EncounterType.WildSuperRod &&
                                        (rngArray[0 + cnt] >> 16)/656 >= 50)
                                        continue;

                                    synchable = false;
                                    encounterSlot = EncounterSlotCalc.encounterSlot(rngArray[1 + cnt], frameType,
                                                                                    EncounterType);
                                    nature = (uint) (((ulong) rngArray[4 + cnt]*25) >> 32);

                                    pid = rngArray[3 + cnt];
                                    pid = pid ^ 0x10000;
                                }
                                else if (EncounterMod == EncounterMod.SuctionCups)
                                {
                                    synchable = false;
                                    encounterSlot = EncounterSlotCalc.encounterSlot(rngArray[1 + cnt], frameType,
                                                                                    EncounterType);
                                    nature = (uint) (((ulong) rngArray[4 + cnt]*25) >> 32);

                                    pid = rngArray[3 + cnt];
                                    pid = pid ^ 0x10000;
                                }
                                else if (EncounterMod == EncounterMod.Search)
                                {
                                    if (EncounterType == EncounterType.WildSuperRod)
                                    {
                                        // Do the Suction Cups check for fishing frames
                                        encounterSlot = EncounterSlotCalc.encounterSlot(rngArray[1 + cnt], frameType,
                                                                                        EncounterType);
                                        nature = (uint) (((ulong) rngArray[4 + cnt]*25) >> 32);

                                        pid = rngArray[3 + cnt];
                                        pid = pid ^ 0x10000;

                                        idTest = (idLower ^ (pid & 1) ^ (pid >> 31));
                                        if (idTest == 1)
                                            pid = (pid ^ 0x80000000);

                                        frame = Frame.GenerateFrame(
                                            FrameType.Method5Natures,
                                            EncounterType,
                                            cnt + InitialFrame,
                                            rngArray[0 + cnt],
                                            pid,
                                            id,
                                            sid,
                                            nature,
                                            false,
                                            encounterSlot,
                                            item);

                                        if (frameCompare.Compare(frame))
                                        {
                                            frame.EncounterMod = EncounterMod.SuctionCups;
                                            frames.Add(frame);
                                        }
                                    }

                                    pid = rngArray[4 + cnt];
                                    pid = pid ^ 0x10000;

                                    // not a synch, but the CC check -- need to relabel (unfinished)
                                    synchable = ((((ulong) rngArray[0 + cnt]*0xFFFF) >> 32)/656) < 67;

                                    // passed CC check
                                    if (synchable)
                                    {
                                        // Add all the Cute Charm possibilities
                                        nature = (uint) (((ulong) rngArray[6 + cnt]*25) >> 32);

                                        for (int i = -4; i < 5; i++)
                                        {
                                            if (i == 0)
                                                continue;

                                            uint tempPid = Functions.GenderModPID(pid, rngArray[5 + cnt], i);

                                            idTest = (idLower ^ (tempPid & 1) ^ (tempPid >> 31));
                                            if (idTest == 1)
                                                tempPid = (tempPid ^ 0x80000000);

                                            frame = Frame.GenerateFrame(
                                                FrameType.Method5Natures,
                                                EncounterType,
                                                cnt + InitialFrame,
                                                rngArray[0 + cnt],
                                                tempPid,
                                                id,
                                                sid,
                                                nature,
                                                false,
                                                encounterSlot,
                                                item);

                                            switch (i)
                                            {
                                                case 1:
                                                    frame.EncounterMod = EncounterMod.CuteCharm50M;
                                                    break;
                                                case 2:
                                                    frame.EncounterMod = EncounterMod.CuteCharm75M;
                                                    break;
                                                case 3:
                                                    frame.EncounterMod = EncounterMod.CuteCharm25M;
                                                    break;
                                                case 4:
                                                    frame.EncounterMod = EncounterMod.CuteCharm875M;
                                                    break;
                                                case -1:
                                                    frame.EncounterMod = EncounterMod.CuteCharm50F;
                                                    break;
                                                case -2:
                                                    frame.EncounterMod = EncounterMod.CuteCharm75F;
                                                    break;
                                                case -3:
                                                    frame.EncounterMod = EncounterMod.CuteCharm25F;
                                                    break;
                                                case -4:
                                                    frame.EncounterMod = EncounterMod.CuteCharm125F;
                                                    break;
                                            }

                                            if (frameCompare.Compare(frame))
                                            {
                                                frames.Add(frame);
                                            }
                                        }
                                    }

                                    pid = rngArray[4 + cnt];
                                    pid = pid ^ 0x10000;

                                    synchable = (rngArray[0 + cnt] >> 31) == 1;
                                    nature = (uint) (((ulong) rngArray[5 + cnt]*25) >> 32);

                                    if (synchable && !frameCompare.CompareNature(nature))
                                        mod = EncounterMod.Synchronize;
                                    else
                                        mod = EncounterMod.None;
                                }
                                else
                                {
                                    synchable = (rngArray[0 + cnt] >> 31) == 1;
                                    nature = (uint) (((ulong) rngArray[5 + cnt]*25) >> 32);

                                    pid = rngArray[4 + cnt];
                                    pid = pid ^ 0x10000;
                                }
                            }

                            idTest = idLower ^ (pid & 1) ^ (pid >> 31);
                            if (idTest == 1)
                            {
                                pid = (pid ^ 0x80000000);
                            }
                        }
                    }

                    // worthless calculation
                    int ability = (int) (pid >> 16) & 1;

                    if (RNGIVs != null)
                    {
                        frame =
                            Frame.GenerateFrame(
                                FrameType.Method5Natures,
                                EncounterType,
                                cnt + InitialFrame,
                                rngArray[0 + cnt],
                                pid,
                                id,
                                sid,
                                nature,
                                synchable,
                                encounterSlot,
                                item,
                                RNGIVs);
                    }
                    else
                    {
                        frame =
                            Frame.GenerateFrame(
                                FrameType.Method5Natures,
                                EncounterType,
                                cnt + InitialFrame,
                                rngArray[0 + cnt],
                                pid,
                                id,
                                sid,
                                nature,
                                synchable,
                                encounterSlot,
                                item);
                    }

                    frame.EncounterMod = mod;
                    frame.CGearTime = entreeTimer.GetTime(rngArray[0 + cnt]);

                    if (frameCompare.Compare(frame))
                    {
                        frames.Add(frame);
                    }
                }
            }
            else if (frameType == FrameType.BWBred)
            {
                rng64.Seed = InitialSeed;
                var rngQueue = new Queue<uint>();

                uint rngResult;

                for (uint cnt = 0; cnt < InitialFrame - 1; cnt++)
                {
                    rng64.GetNext64BitNumber();
                }

                for (uint cnt = 0; cnt < maxResults + 50; cnt++)
                {
                    rngResult = rng64.GetNext32BitNumber();
                    rngQueue.Enqueue(rngResult);
                }

                rngArray = rngQueue.ToArray();

                for (uint cnt = 0; cnt < maxResults; cnt++)
                {
                    frame = null;
                    // there's two extra rng calls before the eggs are generated
                    int index = 2;

                    uint nature;
                    bool dream;
                    bool everstone = false;

                    // for Nidoran\Volbeat\Illumise determination
                    // if 0, get Nidoran-F\Volbeat
                    // if 1, get Nidoran-M\Illumise
                    var speciesSpecial = (int) (rngArray[index + cnt] >> 31);
                    // Everstone activation calc
                    //int off = MaleOnlySpecies ? 1 : 0;
                    if (MaleOnlySpecies) index++;
                    //index = 1
                    nature = (uint) ((ulong) (rngArray[index++ + cnt])*25 >> 32);
                    if (SynchNature > -1)
                    {
                        if ((rngArray[index++ + cnt] >> 31) == 1)
                        {
                            nature = (uint) SynchNature;
                            everstone = true;
                        }
                    }
                    // it appears to only actually use this for dream world otherwise it's ignored
                    /*uint test = Functions.RNGRange(rngArray[index++ + cnt], 0x64);
                    switch (MotherAbility)
                    {
                        case 0:
                            ability = test > 0x50 ? 1u : 0;
                            break;
                        case 1:
                            ability = test > 0x14 ? 1u : 0;
                            break;
                        case 2:
                            if (test < 0x14) ability = 0;
                            else ability = test >= 0x28 ? 2u : 1;
                            break;
                        default:
                            ability = test > 0x50 ? 1u : 0;
                            break;
                    }
                    // again a worthless calculation
                    if (DittoUsed) ability = Functions.RNGRange(rngArray[index++ + cnt], 2);*/
                    dream = Functions.RNGRange(rngArray[index++ + cnt], 0x64) >= 0x28 && !DittoUsed;
                    if (DittoUsed) ++index;

                    // IV Inheritance calc
                    // Uses every two RNG calls, first to determine IV, second to determine which parent
                    // If an IV is repeated it skips two RNG calls and checks the next
                    uint inh = Functions.RNGRange(rngArray[index + cnt], 6);
                    uint inh1 = inh;
                    uint par1 = rngArray[index + 1 + cnt] >> 31;

                    uint maxSkips = 0;

                    index = index + 2;
                    inh = Functions.RNGRange(rngArray[index + cnt], 6);
                    while (inh == inh1)
                    {
                        maxSkips += 2;
                        index = index + 2;
                        inh = Functions.RNGRange(rngArray[index + cnt], 6);

                        if (index + cnt >= rngArray.Length - 3)
                        {
                            for (int refill = 0; refill < 50; refill++)
                            {
                                rngResult = rng64.GetNext32BitNumber();
                                rngQueue.Enqueue(rngResult);
                            }

                            rngArray = rngQueue.ToArray();
                        }
                    }
                    uint inh2 = inh;
                    uint par2 = rngArray[index + 1 + cnt] >> 31;

                    index = index + 2;
                    inh = Functions.RNGRange(rngArray[index + cnt], 6);
                    while (inh == inh1 || inh == inh2)
                    {
                        maxSkips += 2;
                        index = index + 2;
                        inh = Functions.RNGRange(rngArray[index + cnt], 6);

                        if (index + cnt >= rngArray.Length - 3)
                        {
                            for (int refill = 0; refill < 50; refill++)
                            {
                                rngResult = rng64.GetNext32BitNumber();
                                rngQueue.Enqueue(rngResult);
                            }

                            rngArray = rngQueue.ToArray();
                        }
                    }
                    uint inh3 = inh;
                    uint par3 = rngArray[index + 1 + cnt] >> 31;

                    uint pid = Functions.RNGRange(rngArray[index + 2 + cnt], 0xFFFFFFFF);

                    if (ParentA != null & ParentB != null && RNGIVs != null)
                    {
                        frame =
                            Frame.GenerateFrame(
                                FrameType.BWBred,
                                cnt + InitialFrame,
                                rngArray[cnt],
                                speciesSpecial,
                                inh1,
                                inh2,
                                inh3,
                                par1,
                                par2,
                                par3,
                                ParentA,
                                ParentB,
                                RNGIVs,
                                pid,
                                id,
                                sid,
                                dream,
                                everstone,
                                nature,
                                maxSkips);
                    }
                    else
                    {
                        frame =
                            Frame.GenerateFrame(
                                FrameType.BWBred,
                                cnt + InitialFrame,
                                rngArray[cnt],
                                speciesSpecial,
                                inh1,
                                inh2,
                                inh3,
                                par1,
                                par2,
                                par3,
                                pid,
                                id,
                                sid,
                                dream,
                                everstone,
                                nature,
                                maxSkips);
                    }

                    if (frameCompare.Compare(frame))
                    {
                        frames.Add(frame);
                    }
                }
            }

            else if (frameType == FrameType.BWBredInternational)
            {
                rng64.Seed = InitialSeed;
                var rngQueue = new Queue<uint>();

                uint rngResult;

                for (uint cnt = 0; cnt < InitialFrame - 1; cnt++)
                {
                    rng64.GetNext64BitNumber();
                }

                for (uint cnt = 0; cnt < InitialFrame + maxResults + 50; cnt++)
                {
                    rngResult = rng64.GetNext32BitNumber();
                    rngQueue.Enqueue(rngResult);
                }

                rngArray = rngQueue.ToArray();

                for (uint cnt = 0; cnt < maxResults; cnt++)
                {
                    frame = null;
                    int index = 1;

                    uint nature;
                    bool dream;
                    bool everstone = false;

                    // for Nidoran\Volbeat\Illumise determination
                    // if 0, get Nidoran-F\Volbeat
                    // if 1, get Nidoran-M\Illumise
                    var speciesSpecial = (int) (rngArray[index + cnt] >> 31);
                    // Everstone activation calc
                    //int off = MaleOnlySpecies ? 1 : 0;
                    if (MaleOnlySpecies) index++;
                    //index = 1
                    if (SynchNature > -1)
                    {
                        nature = (uint) ((ulong) (rngArray[index++ + cnt])*25 >> 32);
                        if ((rngArray[index++ + cnt] >> 31) == 1)
                        {
                            nature = (uint) SynchNature;
                            everstone = true;
                        }
                        // Dream World ability calc
                        dream = !DittoUsed && (uint) ((ulong) (rngArray[index++ + cnt])*5 >> 32) > 1;
                    }
                    else
                    {
                        nature = (uint) ((ulong) (rngArray[index++ + cnt])*25 >> 32);
                        // Dream World ability calc
                        dream = !DittoUsed && (uint) ((ulong) (rngArray[index++ + cnt])*5 >> 32) > 1;
                    }
                    if (DittoUsed) index = index + 2;

                    // IV Inheritance calc
                    // Uses every two RNG calls, first to determine IV, second to determine which parent
                    // If an IV is repeated it skips two RNG calls and checks the next
                    uint inh = Functions.RNGRange(rngArray[index + cnt], 6);
                    uint inh1 = inh;
                    uint par1 = rngArray[index + 1 + cnt] >> 31;

                    uint maxSkips = 0;

                    index = index + 2;
                    inh = Functions.RNGRange(rngArray[index + cnt], 6);
                    while (inh == inh1)
                    {
                        maxSkips += 2;
                        index = index + 2;
                        inh = Functions.RNGRange(rngArray[index + cnt], 6);

                        if (index + cnt >= rngArray.Length - 3)
                        {
                            for (int refill = 0; refill < 50; refill++)
                            {
                                rngResult = rng64.GetNext32BitNumber();
                                rngQueue.Enqueue(rngResult);
                            }

                            rngArray = rngQueue.ToArray();
                        }
                    }
                    uint inh2 = inh;
                    uint par2 = rngArray[index + 1 + cnt] >> 31;

                    index = index + 2;
                    inh = Functions.RNGRange(rngArray[index + cnt], 6);
                    while (inh == inh1 || inh == inh2)
                    {
                        maxSkips += 2;
                        index = index + 2;
                        inh = Functions.RNGRange(rngArray[index + cnt], 6);

                        if (index + cnt >= rngArray.Length - 3)
                        {
                            for (int refill = 0; refill < 50; refill++)
                            {
                                rngResult = rng64.GetNext32BitNumber();
                                rngQueue.Enqueue(rngResult);
                            }

                            rngArray = rngQueue.ToArray();
                        }
                    }
                    uint inh3 = inh;
                    uint par3 = rngArray[index + 1 + cnt] >> 31;

                    uint pid = rngArray[index + 2 + cnt] - 1;
                    const int masuda = 6;
                    for (int n = 0; n < masuda; n++)
                    {
                        pid = rngArray[index + n + 2 + cnt] - 1;
                        uint tid = (id & 0xffff) | ((sid & 0xffff) << 16);

                        uint a = pid ^ tid;
                        uint b = a & 0xffff;
                        uint c = (a >> 16) & 0xffff;
                        uint d = b ^ c;

                        if (d < 8)
                        {
                            break;
                        }
                    }

                    if (ParentA != null & ParentB != null && RNGIVs != null)
                    {
                        frame =
                            Frame.GenerateFrame(
                                FrameType.BWBred,
                                cnt + InitialFrame,
                                rngArray[0 + cnt],
                                speciesSpecial,
                                inh1,
                                inh2,
                                inh3,
                                par1,
                                par2,
                                par3,
                                ParentA,
                                ParentB,
                                RNGIVs,
                                pid,
                                id,
                                sid,
                                dream,
                                everstone,
                                nature,
                                maxSkips);
                    }
                    else
                    {
                        frame =
                            Frame.GenerateFrame(
                                FrameType.BWBred,
                                cnt + InitialFrame,
                                rngArray[0 + cnt],
                                speciesSpecial,
                                inh1,
                                inh2,
                                inh3,
                                par1,
                                par2,
                                par3,
                                pid,
                                id,
                                sid,
                                dream,
                                everstone,
                                nature,
                                maxSkips);
                    }

                    if (frameCompare.Compare(frame))
                    {
                        frames.Add(frame);
                    }
                }
            }
            else if (frameType == FrameType.BW2BredInternational)
            {
                rng64.Seed = InitialSeed;
                var rngQueue = new Queue<uint>();
                var inhQueue = new Queue<uint>();

                uint rngResult;

                int callCount = 13;
                if (SynchNature > -1)
                {
                    callCount++; // Everstone consumes extra RNG call
                }

                if (DittoUsed)
                {
                    callCount++; // Ditto consumes extra RNG call
                }

                for (uint cnt = 0; cnt < InitialFrame - 1; cnt++)
                {
                    rng64.GetNext64BitNumber();
                }

                for (uint cnt = 0; cnt < InitialFrame + maxResults + 50; cnt++)
                {
                    rngResult = rng64.GetNext32BitNumber();
                    rngQueue.Enqueue(rngResult);
                    inhQueue.Enqueue((uint) ((ulong) (rngResult)*6 >> 32));
                }

                rngArray = rngQueue.ToArray();
                uint[] inhArray = inhQueue.ToArray();

                for (uint cnt = 0; cnt < maxResults; cnt++)
                {
                    frame = null;
                    int index = 1;

                    uint nature;
                    bool dream;
                    bool everstone = false;

                    // for Nidoran\Volbeat\Illumise determination
                    // if 0, get Nidoran-F\Volbeat
                    // if 1, get Nidoran-M\Illumise
                    var speciesSpecial = (int) (rngArray[index + cnt] >> 31);
                    // Everstone activation calc
                    //int off = MaleOnlySpecies ? 1 : 0;
                    if (MaleOnlySpecies) index++;
                    //index = 1
                    if (SynchNature > -1)
                    {
                        nature = (uint) ((ulong) (rngArray[index++ + cnt])*25 >> 32);
                        if ((rngArray[index++ + cnt] >> 31) == 1)
                        {
                            nature = (uint) SynchNature;
                            everstone = true;
                        }
                        // Dream World ability calc
                        dream = !DittoUsed && (uint) ((ulong) (rngArray[index++ + cnt])*5 >> 32) > 1;
                    }
                    else
                    {
                        nature = (uint) ((ulong) (rngArray[index++ + cnt])*25 >> 32);
                        // Dream World ability calc
                        dream = !DittoUsed && (uint) ((ulong) (rngArray[index++ + cnt])*5 >> 32) > 1;
                    }

                    // IV Inheritance calc
                    // Uses every two RNG calls, first to determine IV, second to determine which parent
                    // If an IV is repeated it skips two RNG calls and checks the next
                    uint inh = inhArray[index + cnt];
                    uint inh1 = inh;
                    uint par1 = rngArray[index + 1 + cnt] >> 31;

                    uint maxSkips = 0;

                    index = index + 2;
                    inh = inhArray[index + cnt];
                    while (inh == inh1)
                    {
                        maxSkips += 2;
                        index = index + 2;
                        inh = inhArray[index + cnt];

                        if (index + cnt >= rngArray.Length - 3)
                        {
                            for (int refill = 0; refill < 50; refill++)
                            {
                                rngResult = rng64.GetNext32BitNumber();
                                rngQueue.Enqueue(rngResult);
                                inhQueue.Enqueue((uint) ((ulong) (rngResult)*6 >> 32));
                            }

                            rngArray = rngQueue.ToArray();
                            inhArray = inhQueue.ToArray();
                        }
                    }
                    uint inh2 = inh;
                    uint par2 = rngArray[index + 1 + cnt] >> 31;

                    index = index + 2;
                    inh = inhArray[index + cnt];
                    while (inh == inh1 || inh == inh2)
                    {
                        maxSkips += 2;
                        index = index + 2;
                        inh = inhArray[index + cnt];

                        if (index + cnt >= rngArray.Length - 3)
                        {
                            for (int refill = 0; refill < 50; refill++)
                            {
                                rngResult = rng64.GetNext32BitNumber();
                                rngQueue.Enqueue(rngResult);
                                inhQueue.Enqueue((uint) ((ulong) (rngResult)*6 >> 32));
                            }

                            rngArray = rngQueue.ToArray();
                            inhArray = inhQueue.ToArray();
                        }
                    }
                    uint inh3 = inh;
                    uint par3 = rngArray[index + 1 + cnt] >> 31;

                    uint pid = rngArray[index + 2 + cnt] - 1;
                    int masuda = ShinyCharm ? 8 : 6;
                    for (int n = 0; n < masuda; n++)
                    {
                        pid = rngArray[index + n + 2 + cnt] - 1;
                        uint tid = (id & 0xffff) | ((sid & 0xffff) << 16);

                        uint a = pid ^ tid;
                        uint b = a & 0xffff;
                        uint c = (a >> 16) & 0xffff;
                        uint d = b ^ c;

                        if (d < 8)
                        {
                            break;
                        }
                    }

                    if (ParentA != null & ParentB != null && RNGIVs != null)
                    {
                        frame =
                            Frame.GenerateFrame(
                                FrameType.BWBred,
                                cnt + InitialFrame,
                                rngArray[0 + cnt],
                                speciesSpecial,
                                inh1,
                                inh2,
                                inh3,
                                par1,
                                par2,
                                par3,
                                ParentA,
                                ParentB,
                                RNGIVs,
                                pid,
                                id,
                                sid,
                                dream,
                                everstone,
                                nature,
                                maxSkips);
                    }
                    else
                    {
                        frame =
                            Frame.GenerateFrame(
                                FrameType.BWBred,
                                cnt + InitialFrame,
                                rngArray[0 + cnt],
                                speciesSpecial,
                                inh1,
                                inh2,
                                inh3,
                                par1,
                                par2,
                                par3,
                                pid,
                                id,
                                sid,
                                dream,
                                everstone,
                                nature,
                                maxSkips);
                    }

                    if (frameCompare.Compare(frame))
                    {
                        frames.Add(frame);
                    }
                }
            }
            else if (frameType == FrameType.Wondercard5thGen)
            {
                rng64.Seed = InitialSeed;

                if (maxResults < 1000)
                {
                    rngArray = new uint[maxResults + 33];

                    for (uint cnt = 0; cnt < InitialFrame - 1; cnt++)
                    {
                        rng64.GetNext64BitNumber();
                    }

                    for (int cnt = 0; cnt < maxResults + 33; cnt++)
                    {
                        rngArray[cnt] = rng64.GetNext32BitNumber();
                    }

                    for (uint cnt = 0; cnt < maxResults; cnt++)
                    {
                        Frame frame = Frame.GenerateFrame(
                            FrameType.Wondercard5thGen,
                            id, sid,
                            cnt + InitialFrame,
                            rngArray[0 + cnt],
                            rngArray[22 + cnt] >> 27,
                            rngArray[23 + cnt] >> 27,
                            rngArray[24 + cnt] >> 27,
                            rngArray[25 + cnt] >> 27,
                            rngArray[26 + cnt] >> 27,
                            rngArray[27 + cnt] >> 27,
                            rngArray[32 + cnt],
                            rngArray[30 + cnt]);

                        if (frameCompare.Compare(frame))
                        {
                            frames.Add(frame);
                        }
                    }
                }
                else
                {
                    rngQueue = new Queue<uint>();

                    for (uint cnt = 0; cnt < InitialFrame - 1; cnt++)
                    {
                        rng64.GetNext64BitNumber();
                    }

                    for (int cnt = 0; cnt < 33; cnt++)
                    {
                        rngQueue.Enqueue(rng64.GetNext32BitNumber());
                    }

                    for (uint cnt = InitialFrame; cnt < InitialFrame + maxResults; cnt++)
                    {
                        rngArray = rngQueue.ToArray();

                        Frame frame = Frame.GenerateFrame(
                            FrameType.Wondercard5thGen,
                            id, sid,
                            cnt,
                            rngArray[0],
                            rngArray[22] >> 27,
                            rngArray[23] >> 27,
                            rngArray[24] >> 27,
                            rngArray[25] >> 27,
                            rngArray[26] >> 27,
                            rngArray[27] >> 27,
                            rngArray[32],
                            rngArray[30]);

                        if (frameCompare.Compare(frame))
                        {
                            frames.Add(frame);
                        }

                        rngQueue.Dequeue();
                        rngQueue.Enqueue(rng64.GetNext32BitNumber());
                    }
                }
            }
            else if (frameType == FrameType.Wondercard5thGenFixed)
            {
                rng64.Seed = InitialSeed;

                if (maxResults < 1000)
                {
                    rngArray = new uint[maxResults + 36];

                    for (uint cnt = 0; cnt < InitialFrame - 1; cnt++)
                    {
                        rng64.GetNext64BitNumber();
                    }

                    for (int cnt = 0; cnt < maxResults + 36; cnt++)
                    {
                        rngArray[cnt] = rng64.GetNext32BitNumber();
                    }

                    for (uint cnt = 0; cnt < maxResults; cnt++)
                    {
                        //note: pid field is unused look into later
                        uint pid = Functions.GenderModPID(rngArray[30 + cnt], rngArray[31 + cnt], 0);
                        Frame frame =
                            Frame.GenerateFrame(
                                FrameType.Wondercard5thGenFixed,
                                id, sid,
                                cnt + InitialFrame,
                                rngArray[0 + cnt],
                                rngArray[24 + cnt] >> 27,
                                rngArray[25 + cnt] >> 27,
                                rngArray[26 + cnt] >> 27,
                                rngArray[27 + cnt] >> 27,
                                rngArray[28 + cnt] >> 27,
                                rngArray[29 + cnt] >> 27,
                                rngArray[35 + cnt],
                                rngArray[30 + cnt]);

                        if (frameCompare.Compare(frame))
                        {
                            frames.Add(frame);
                        }
                    }
                }
                else
                {
                    rngQueue = new Queue<uint>();
                    for (int i = 0; i < InitialFrame - 1; ++i)
                    {
                        rng64.GetNext64BitNumber();
                    }

                    for (int cnt = 0; cnt < 36; cnt++)
                    {
                        rngQueue.Enqueue(rng64.GetNext32BitNumber());
                    }

                    for (uint cnt = InitialFrame; cnt < InitialFrame + maxResults; cnt++)
                    {
                        rngArray = rngQueue.ToArray();

                        Frame frame =
                            Frame.GenerateFrame(
                                FrameType.Wondercard5thGenFixed,
                                id, sid,
                                cnt,
                                rngArray[0],
                                rngArray[24] >> 27,
                                rngArray[25] >> 27,
                                rngArray[26] >> 27,
                                rngArray[27] >> 27,
                                rngArray[28] >> 27,
                                rngArray[29] >> 27,
                                rngArray[35],
                                rngArray[30]);
                        if (frameCompare.Compare(frame))
                        {
                            frames.Add(frame);
                        }
                        rngQueue.Dequeue();
                        rngQueue.Enqueue(rng64.GetNext32BitNumber());
                    }
                }
            }
            else if (frameType == FrameType.MethodH1 || frameType == FrameType.MethodH2 ||
                     frameType == FrameType.MethodH4)
            {
                //  Instantiate our hunt RNG and fail RNG
                var huntRng = new PokeRng(0);

                //  Instantiate our regular RNG
                var rng1 = new PokeRng((uint) InitialSeed);
                var rng2 = new PokeRng(0);

                for (uint cnt = 1; cnt < InitialFrame; cnt++)
                {
                    rng1.Next();
                }

                for (ulong cnt = InitialFrame; cnt < maxResults + InitialFrame; cnt++)
                {
                    //  Get our first RNG call.  If we are using a
                    //  syncher this will determine whether we are
                    //  going to honor it.
                    uint seed = rng1.Seed;
                    // skip the level and battle calcs
                    rng1.GetNext16BitNumber();

                    //  Basically save our RNG state here
                    //  so that we only advance rng1 once
                    //  per monster.
                    rng2.Seed = rng1.Seed;

                    // if it's safari zone it's one before
                    // note: this should all be done inside the encounter slot calc
                    uint encounterCall = EncounterType == EncounterType.SafariZone ? seed : rng2.Seed;
                    int encounterSlot = EncounterSlotCalc.encounterSlot(encounterCall, frameType, EncounterType);

                    rng2.GetNext16BitNumber();
                    uint firstRng = rng2.GetNext16BitNumber();

                    uint nature = 0;
                    ulong offset = cnt + 3;

                    Compare CuteCheck = x => true;
                    if (EncounterMod != EncounterMod.Synchronize && EncounterMod != EncounterMod.CuteCharm)
                    {
                        //  Dont want to synch at all, just use the
                        //  RNG call to get our hunt nature,
                        nature = firstRng%25;
                    }
                    else if (EncounterMod == EncounterMod.Synchronize)
                    {
                        //  Check for even/odd on the high order bit.
                        if ((firstRng & 1) == 0)
                        {
                            //  Set the hunt to the nature of our syncher
                            nature = (uint) SynchNature;
                        }
                        else
                        {
                            //  Ok, we wanted to synch, but missed it so lets
                            //  get the next RNG call and then go ahead and
                            //  use that for the nature.
                            nature = (uint) rng2.GetNext16BitNumber()%25;
                            offset++;
                        }
                    }
                    else if (EncounterMod == EncounterMod.CuteCharm)
                    {
                        //  Check for even/odd on the high order bit.
                        if ((firstRng%3) > 0)
                        {
                            switch (SynchNature)
                            {
                                case -1:
                                    CuteCheck = x => (x & 0xFF) < 127;
                                    break;
                                case 1:
                                    CuteCheck = x => (x & 0xFF) >= 127;
                                    break;
                                case -2:
                                    CuteCheck = x => (x & 0xFF) < 191;
                                    break;
                                case 2:
                                    CuteCheck = x => (x & 0xFF) >= 63;
                                    break;
                                case -3:
                                    CuteCheck = x => (x & 0xFF) < 63;
                                    break;
                                case 3:
                                    CuteCheck = x => (x & 0xFF) >= 191;
                                    break;
                                case -4:
                                    CuteCheck = x => (x & 0xFF) < 31;
                                    break;
                                case 4:
                                    CuteCheck = x => (x & 0xFF) >= 31;
                                    break;
                                default:
                                    CuteCheck = x => true;
                                    break;
                            }
                        }
                        // either way, eat up a frame for the Cute Charm check and determine nature
                        nature = (uint) rng2.GetNext16BitNumber()%25;
                        offset++;
                    }

                    // Seed the hunt rng
                    huntRng.Seed = rng2.Seed;

                    bool found = false;

                    //  Now we are going to have to hunt for the next
                    //  matching method 1 spread that we can display
                    //  to the user.
                    while (!found)
                    {
                        uint pid1 = huntRng.GetNext16BitNumber();
                        uint pid2 = huntRng.GetNext16BitNumber();

                        uint pid = (pid2 << 16) + pid1;

                        if (pid%25 == nature && CuteCheck(pid))
                        {
                            // Wild Pokémon IVs are generally generated by Methods 2 and 4
                            uint iv1;
                            if (frameType == FrameType.MethodH2)
                            {
                                huntRng.GetNext32BitNumber();
                                iv1 = huntRng.GetNext16BitNumber();
                            }
                            else if (frameType == FrameType.MethodH4)
                            {
                                iv1 = huntRng.GetNext16BitNumber();
                                huntRng.GetNext32BitNumber();
                            }
                            else
                            {
                                // Use Method 1, which is what usually happens for stationary Pokémon
                                // Emphasis on "usually".

                                iv1 = huntRng.GetNext16BitNumber();
                            }

                            uint iv2 = huntRng.GetNext16BitNumber();

                            //  We found a match, we need to buid the frame
                            //  as usual now based on the next few RNG calls
                            frame =
                                Frame.GenerateFrame(
                                    seed,
                                    frameType,
                                    EncounterType,
                                    (uint) cnt,
                                    firstRng,
                                    pid1,
                                    pid2,
                                    iv1,
                                    iv2,
                                    id, sid, (uint) offset,
                                    encounterSlot);

                            if (frameCompare.Compare(frame))
                            {
                                frames.Add(frame);
                            }

                            found = true;
                        }

                        offset += 2;
                    }
                }
            }
            else if (frameType == FrameType.MethodJ)
            {
                //  Instantiate our hunt RNG and fail RNG
                var huntRng = new PokeRng(0);

                //  Instantiate our regular RNG
                var rng1 = new PokeRng((uint) InitialSeed);
                var rng2 = new PokeRng(0);

                for (uint cnt = 1; cnt < InitialFrame; cnt++)
                {
                    rng1.Next();
                }

                for (uint cnt = InitialFrame; cnt < maxResults + InitialFrame; cnt++)
                {
                    //  Get our first RNG call.  If we are using a
                    //  syncher this will determine whether we are
                    //  going to honor it.
                    uint seed = rng1.Seed;
                    uint firstRng = rng1.GetNext16BitNumber();
                    uint rngResult = firstRng;

                    //  Basically save our RNG state here
                    //  so that we only advance rng1 once
                    //  per monster.
                    rng2.Seed = rng1.Seed;

                    uint offset = cnt + 1;
                    int encounterSlot = 0;

                    if (EncounterType == EncounterType.Wild)
                    {
                        encounterSlot = EncounterSlotCalc.encounterSlot(rng2.Seed, frameType, EncounterType);
                        firstRng = rng2.GetNext16BitNumber();
                        offset++;
                    }
                    else if (EncounterType == EncounterType.WildSurfing)
                    {
                        encounterSlot = EncounterSlotCalc.encounterSlot(rng2.Seed, frameType, EncounterType);
                        firstRng = rng2.GetNext16BitNumber();
                        firstRng = rng2.GetNext16BitNumber();
                        offset += 2;
                    }
                    else if (EncounterType == EncounterType.WildOldRod || EncounterType == EncounterType.WildGoodRod ||
                             EncounterType == EncounterType.WildSuperRod)
                    {
                        uint threshold;
                        if (EncounterType == EncounterType.WildOldRod)
                        {
                            threshold = EncounterMod == EncounterMod.SuctionCups ? 48u : 24u;
                        }
                        else if (EncounterType == EncounterType.WildGoodRod)
                        {
                            threshold = EncounterMod == EncounterMod.SuctionCups ? 98u : 49u;
                        }
                        else
                        {
                            threshold = EncounterMod == EncounterMod.SuctionCups ? 100u : 74u;
                        }

                        // Skip this call if it an encounter cannot be made
                        if (firstRng/656 > threshold)
                            continue;

                        encounterSlot = EncounterSlotCalc.encounterSlot(rng2.GetNext32BitNumber(), frameType,
                                                                        EncounterType);

                        // one of these is item calc, another is level
                        firstRng = rng2.GetNext16BitNumber();
                        firstRng = rng2.GetNext16BitNumber();

                        offset += 3;
                    }

                    uint nature;
                    if (EncounterMod == EncounterMod.Synchronize)
                    {
                        //  Check for even/odd on the high order bit.
                        if (firstRng >> 15 == 0)
                        {
                            //  Set the hunt to the nature our our syncher
                            nature = (uint) SynchNature;
                        }
                        else
                        {
                            //  Ok, we wanted to synch, but missed it so lets
                            //  get the next RNG call and then go ahead and
                            //  use that for the nature.
                            nature = (uint) rng2.GetNext16BitNumber()/0xA3E;
                            offset++;
                        }
                    }
                    else if (EncounterMod == EncounterMod.CuteCharm)
                    {
                        nature = (uint) rng2.GetNext16BitNumber()/0xA3E;
                    }
                    else
                    {
                        //  Dont want to synch at all, just use the
                        //  RNG call to get our hunt nature,
                        nature = firstRng/0xA3E;
                    }

                    if (EncounterMod == EncounterMod.CuteCharm && firstRng/0x5556 != 0)
                    {
                        uint buffer = 0;
                        if (SynchNature > -1)
                        {
                            switch (SynchNature)
                            {
                                case 1:
                                    buffer = 0x96;
                                    break;
                                case 2:
                                    buffer = 0x4B;
                                    break;
                                case 3:
                                    buffer = 0xC8;
                                    break;
                                case 4:
                                    buffer = 0x32;
                                    break;
                                default:
                                    buffer = 0;
                                    break;
                            }
                        }

                        //  We found a match, we need to buid the frame
                        //  as usual now based on the next few RNG calls
                        frame =
                            Frame.GenerateFrame(
                                seed,
                                FrameType.MethodJ,
                                EncounterType,
                                cnt,
                                rngResult,
                                nature + buffer,
                                0,
                                rng2.GetNext16BitNumber(),
                                rng2.GetNext16BitNumber(),
                                id, sid, offset - 2,
                                encounterSlot);

                        if (frameCompare.Compare(frame))
                        {
                            frames.Add(frame);
                        }
                    }
                    else
                    {
                        // Seed the hunt rng
                        huntRng.Seed = rng2.Seed;

                        bool found = false;
                        //  Now we are going to have to hunt for the next
                        //  matching method 1 spread that we can display
                        //  to the user.
                        while (!found)
                        {
                            uint pid1 = huntRng.GetNext16BitNumber();
                            uint pid2 = huntRng.GetNext16BitNumber();

                            uint pid = (pid2 << 16) + pid1;

                            if (pid%25 == nature)
                            {
                                //  We found a match, we need to buid the frame
                                //  as usual now based on the next few RNG calls
                                frame =
                                    Frame.GenerateFrame(
                                        seed,
                                        FrameType.MethodJ,
                                        EncounterType,
                                        cnt,
                                        rngResult,
                                        pid1,
                                        pid2,
                                        huntRng.GetNext16BitNumber(),
                                        huntRng.GetNext16BitNumber(),
                                        id, sid, offset,
                                        encounterSlot);

                                if (frameCompare.Compare(frame))
                                {
                                    frames.Add(frame);
                                }

                                found = true;
                            }

                            offset += 2;
                        }
                    }
                }
            }
            else if (frameType == FrameType.MethodK)
            {
                //  Instantiate our hunt RNG and fail RNG
                var huntRng = new PokeRng(0);

                //  Instantiate our regular RNG
                var rng1 = new PokeRng((uint) InitialSeed);
                var rng2 = new PokeRng(0);

                for (uint cnt = 1; cnt < InitialFrame; cnt++)
                {
                    rng1.Next();
                }

                for (uint cnt = InitialFrame; cnt < maxResults + InitialFrame; cnt++)
                {
                    //  Get our first RNG call.  If we are using a
                    //  syncher this will determine whether we are
                    //  going to honor it.
                    uint seed = rng1.Seed;
                    uint firstRng = rng1.GetNext16BitNumber();
                    uint rngResult = firstRng;

                    //  Basically save our RNG state here
                    //  so that we only advance rng1 once
                    //  per monster.
                    rng2.Seed = rng1.Seed;

                    uint offset = cnt + 1;
                    int encounterSlot = 0;

                    if (EncounterType == EncounterType.Wild || EncounterType == EncounterType.SafariZone)
                    {
                        encounterSlot = EncounterSlotCalc.encounterSlot(rng2.Seed, frameType, EncounterType);
                        firstRng = rng2.GetNext16BitNumber();
                        offset++;
                    }
                    else if (EncounterType == EncounterType.WildSurfing || EncounterType == EncounterType.Headbutt ||
                             EncounterType == EncounterType.BugCatchingContest)
                    {
                        encounterSlot = EncounterSlotCalc.encounterSlot(rng2.Seed, frameType, EncounterType);
                        firstRng = rng2.GetNext16BitNumber();
                        firstRng = rng2.GetNext16BitNumber();
                        offset += 2;
                    }
                    else if (EncounterType == EncounterType.WildOldRod ||
                             EncounterType == EncounterType.WildGoodRod ||
                             EncounterType == EncounterType.WildSuperRod)
                    {
                        uint threshold;
                        if (EncounterType == EncounterType.WildOldRod)
                        {
                            threshold = EncounterMod == EncounterMod.SuctionCups ? 48u : 24u;
                        }
                        else if (EncounterType == EncounterType.WildGoodRod)
                        {
                            threshold = EncounterMod == EncounterMod.SuctionCups ? 98u : 49u;
                        }
                        else
                        {
                            threshold = EncounterMod == EncounterMod.SuctionCups ? 100u : 74u;
                        }

                        // Skip this call if it an encounter cannot be made
                        if (firstRng%100 > threshold)
                            continue;

                        encounterSlot = EncounterSlotCalc.encounterSlot(rng2.GetNext32BitNumber(), frameType,
                                                                        EncounterType);

                        // one of these is item calc, another is level
                        firstRng = rng2.GetNext16BitNumber();
                        firstRng = rng2.GetNext16BitNumber();

                        offset += 3;
                    }

                    uint nature;
                    if (EncounterMod == EncounterMod.Synchronize)
                    {
                        //  Check for even/odd on the low order bit
                        if ((firstRng & 1) == 0)
                        {
                            //  Set the hunt to the nature our our syncher
                            nature = (uint) SynchNature;
                        }
                        else
                        {
                            //  Ok, we wanted to synch, but missed it so lets
                            //  get the next RNG call and then go ahead and
                            //  use that for the nature.
                            nature = (uint) rng2.GetNext16BitNumber()%25;
                            offset++;
                        }
                    }
                    else if (EncounterMod == EncounterMod.CuteCharm)
                    {
                        nature = (uint) rng2.GetNext16BitNumber()%25;
                    }
                    else
                    {
                        //  Dont want to synch at all, just use the
                        //  RNG call to get our hunt nature,
                        nature = firstRng%25;
                    }

                    if (EncounterMod == EncounterMod.CuteCharm && firstRng%3 != 0)
                    {
                        uint buffer = 0;
                        if (SynchNature > -1)
                        {
                            switch (SynchNature)
                            {
                                case 1:
                                    buffer = 0x96;
                                    break;
                                case 2:
                                    buffer = 0x4B;
                                    break;
                                case 3:
                                    buffer = 0xC8;
                                    break;
                                case 4:
                                    buffer = 0x32;
                                    break;
                                default:
                                    buffer = 0;
                                    break;
                            }
                        }

                        //  We found a match, we need to buid the frame
                        //  as usual now based on the next few RNG calls
                        frame =
                            Frame.GenerateFrame(
                                seed,
                                FrameType.MethodK,
                                EncounterType,
                                cnt,
                                rngResult,
                                nature + buffer,
                                0,
                                rng2.GetNext16BitNumber(),
                                rng2.GetNext16BitNumber(),
                                id, sid, offset - 2,
                                encounterSlot);

                        if (EncounterType == EncounterType.BugCatchingContest ||
                            EncounterType == EncounterType.SafariZone)
                            frame.Synchable = true;

                        if (frameCompare.Compare(frame))
                        {
                            frames.Add(frame);
                        }
                    }
                    else
                    {
                        // Seed the hunt rng
                        huntRng.Seed = rng2.Seed;

                        bool found = false;
                        //  Now we are going to have to hunt for the next
                        //  matching method 1 spread that we can display
                        //  to the user.
                        while (!found)
                        {
                            uint pid1 = huntRng.GetNext16BitNumber();
                            uint pid2 = huntRng.GetNext16BitNumber();

                            uint pid = (pid2 << 16) + pid1;

                            if (pid%25 == nature)
                            {
                                //  We found a match, we need to buid the frame
                                //  as usual now based on the next few RNG calls
                                frame =
                                    Frame.GenerateFrame(
                                        seed,
                                        FrameType.MethodK,
                                        EncounterType,
                                        cnt,
                                        rngResult,
                                        pid1,
                                        pid2,
                                        huntRng.GetNext16BitNumber(),
                                        huntRng.GetNext16BitNumber(),
                                        id, sid, offset,
                                        encounterSlot);

                                if (frameCompare.Compare(frame))
                                {
                                    frames.Add(frame);
                                }

                                found = true;
                            }
                            offset += 2;
                        }
                    }
                }
            }
            else if (frameType == FrameType.ColoXD)
            {
                var rng = new XdRng((uint) InitialSeed);

                for (uint cnt = 1; cnt < InitialFrame - 1; cnt++)
                    rng.GetNext32BitNumber();

                rngArray = new uint[maxResults + 5];

                for (uint cnt = 0; cnt < maxResults; cnt++)
                    rngArray[cnt] = rng.GetNext16BitNumber();

                for (uint cnt = 0; cnt < maxResults; cnt++)
                {
                    frame = Frame.GenerateFrame(
                        0,
                        FrameType.ColoXD,
                        cnt + InitialFrame,
                        rngArray[0 + cnt],
                        rngArray[4 + cnt],
                        rngArray[3 + cnt],
                        rngArray[0 + cnt],
                        rngArray[1 + cnt],
                        id, sid);

                    if (frameCompare.Compare(frame))
                    {
                        frames.Add(frame);
                    }
                }
            }
            else
            {
                //  We are going to grab our initial set of rngs here and
                //  then start our loop so that we can iterate as many
                //  times as we have to.
                var rng = new PokeRng((uint) InitialSeed);

                for (uint cnt = 1; cnt < InitialFrame; cnt++)
                    rng.GetNext32BitNumber();

                rngArray = new uint[maxResults + 20];
                for (uint cnt = 0; cnt < maxResults + 20; cnt++)
                    rngArray[cnt] = rng.GetNext16BitNumber();
                lastseed = rng.Seed;

                for (uint cnt = 0; cnt < maxResults; cnt++)
                {
                    Frame frameSplit = null;

                    switch (frameType)
                    {
                        case FrameType.Method1:
                            frame =
                                Frame.GenerateFrame(
                                    0,
                                    FrameType.Method1,
                                    cnt + InitialFrame,
                                    rngArray[0 + cnt],
                                    rngArray[0 + cnt],
                                    rngArray[1 + cnt],
                                    rngArray[2 + cnt],
                                    rngArray[3 + cnt],
                                    0, 0, 0, 0, 0, 0,
                                    id, sid, cnt);

                            break;

                        case FrameType.Method2:
                            frame =
                                Frame.GenerateFrame(
                                    0,
                                    FrameType.Method2,
                                    cnt + InitialFrame,
                                    rngArray[0 + cnt],
                                    rngArray[0 + cnt],
                                    rngArray[1 + cnt],
                                    rngArray[3 + cnt],
                                    rngArray[4 + cnt],
                                    0, 0, 0, 0, 0, 0,
                                    id, sid, cnt);

                            break;

                        case FrameType.Method3:
                            frame =
                                Frame.GenerateFrame(
                                    0,
                                    FrameType.Method3,
                                    cnt + InitialFrame,
                                    rngArray[0 + cnt],
                                    rngArray[0 + cnt],
                                    rngArray[2 + cnt],
                                    rngArray[3 + cnt],
                                    rngArray[4 + cnt],
                                    0, 0, 0, 0, 0, 0,
                                    id, sid, cnt);

                            break;

                        case FrameType.Method4:
                            frame =
                                Frame.GenerateFrame(
                                    0,
                                    FrameType.Method4,
                                    cnt + InitialFrame,
                                    rngArray[0 + cnt],
                                    rngArray[0 + cnt],
                                    rngArray[1 + cnt],
                                    rngArray[2 + cnt],
                                    rngArray[4 + cnt],
                                    0, 0, 0, 0, 0, 0,
                                    id, sid, cnt);

                            break;

                        case FrameType.ChainedShiny:
                            uint chainedPIDLower = Functions.ChainedPIDLower(
                                rngArray[1 + cnt],
                                rngArray[15 + cnt],
                                rngArray[14 + cnt],
                                rngArray[13 + cnt],
                                rngArray[12 + cnt],
                                rngArray[11 + cnt],
                                rngArray[10 + cnt],
                                rngArray[9 + cnt],
                                rngArray[8 + cnt],
                                rngArray[7 + cnt],
                                rngArray[6 + cnt],
                                rngArray[5 + cnt],
                                rngArray[4 + cnt],
                                rngArray[3 + cnt]);

                            frame = Frame.GenerateFrame(
                                0,
                                FrameType.ChainedShiny,
                                cnt + InitialFrame,
                                rngArray[0 + cnt],
                                chainedPIDLower,
                                Functions.ChainedPIDUpper(rngArray[2 + cnt], chainedPIDLower, id, sid),
                                rngArray[16 + cnt],
                                rngArray[17 + cnt],
                                0, 0, 0, 0, 0, 0,
                                id, sid, cnt);
                            break;
                        case FrameType.EBredPID:
                            uint total;
                            uint pid = GetEPid(cnt, out total);
                            if (pid == 0)
                            {
                                continue;
                            }
                            //generate frame with bogus RNG result
                            frame = Frame.GenerateFrame(FrameType.EBredPID, cnt + InitialFrame, 0, pid, id, sid);
                            frame.Advances = total;
                            //new Frame {FrameType = FrameType.EBredPID, Number = cnt + InitialFrame, Pid = pid};
                            break;

                        case FrameType.RSBredLower:
                            frame =
                                Frame.GenerateFrame(
                                    FrameType.RSBredLower,
                                    cnt + InitialFrame,
                                    rngArray[0 + cnt],
                                    rngArray[1 + cnt],
                                    Compatibility
                                    );
                            break;

                        case FrameType.RSBredUpper:
                            frame =
                                Frame.GenerateFrame(
                                    FrameType.RSBredUpper,
                                    cnt + InitialFrame,
                                    rngArray[0 + cnt],
                                    StaticPID,
                                    rngArray[1 + cnt],
                                    rngArray[2 + cnt],
                                    rngArray[3 + cnt],
                                    // vblank
                                    rngArray[5 + cnt],
                                    rngArray[6 + cnt],
                                    rngArray[7 + cnt],
                                    rngArray[8 + cnt],
                                    rngArray[9 + cnt],
                                    rngArray[10 + cnt],
                                    ParentA,
                                    ParentB,
                                    id, sid);
                            break;
                        case FrameType.RSBredUpperSplit:
                            frame =
                                frame =
                                Frame.GenerateFrame(
                                    FrameType.RSBredUpperSplit,
                                    cnt + InitialFrame,
                                    rngArray[0 + cnt],
                                    StaticPID,
                                    // vblank
                                    rngArray[2 + cnt],
                                    rngArray[3 + cnt],
                                    rngArray[4 + cnt],
                                    // another vblank
                                    rngArray[6 + cnt],
                                    rngArray[7 + cnt],
                                    rngArray[8 + cnt],
                                    rngArray[9 + cnt],
                                    rngArray[10 + cnt],
                                    rngArray[11 + cnt],
                                    ParentA,
                                    ParentB,
                                    id, sid);
                            break;
                            // untested needs further research
                        case FrameType.RSBredUpperAlt:
                            frame =
                                Frame.GenerateFrame(
                                    FrameType.RSBredUpperAlt,
                                    cnt + InitialFrame,
                                    rngArray[0 + cnt],
                                    StaticPID,
                                    // vblank
                                    rngArray[2 + cnt],
                                    rngArray[3 + cnt],
                                    // vblank
                                    rngArray[5 + cnt],
                                    // vblank
                                    rngArray[5 + cnt],
                                    rngArray[6 + cnt],
                                    rngArray[7 + cnt],
                                    rngArray[8 + cnt],
                                    rngArray[9 + cnt],
                                    rngArray[10 + cnt],
                                    ParentA,
                                    ParentB,
                                    id, sid);
                            break;

                        case FrameType.Bred:

                            frame =
                                Frame.GenerateFrame(
                                    FrameType.Bred,
                                    cnt + InitialFrame,
                                    rngArray[0 + cnt],
                                    StaticPID,
                                    rngArray[0 + cnt],
                                    rngArray[1 + cnt],
                                    rngArray[3 + cnt],
                                    rngArray[4 + cnt],
                                    rngArray[5 + cnt],
                                    rngArray[6 + cnt],
                                    rngArray[7 + cnt],
                                    rngArray[8 + cnt],
                                    ParentA,
                                    ParentB,
                                    id, sid, cnt);

                            break;

                        case FrameType.BredSplit:
                            //  This is going to add both of the frames and
                            //  the logic below will decide whether to add
                            //  it to the output.

                            frame =
                                Frame.GenerateFrame(
                                    FrameType.Bred,
                                    cnt + InitialFrame,
                                    rngArray[0 + cnt],
                                    StaticPID,
                                    rngArray[0 + cnt],
                                    rngArray[1 + cnt],
                                    //  Garbage
                                    rngArray[3 + cnt],
                                    rngArray[4 + cnt],
                                    rngArray[5 + cnt],
                                    rngArray[6 + cnt],
                                    rngArray[7 + cnt],
                                    rngArray[8 + cnt],
                                    ParentA,
                                    ParentB,
                                    id, sid, cnt);

                            frameSplit =
                                Frame.GenerateFrame(
                                    FrameType.BredSplit,
                                    cnt + InitialFrame,
                                    rngArray[0 + cnt],
                                    StaticPID,
                                    rngArray[0 + cnt],
                                    rngArray[2 + cnt],
                                    //  Garbage
                                    rngArray[4 + cnt],
                                    rngArray[5 + cnt],
                                    rngArray[6 + cnt],
                                    rngArray[7 + cnt],
                                    rngArray[8 + cnt],
                                    rngArray[9 + cnt],
                                    ParentA,
                                    ParentB,
                                    id, sid, cnt);

                            break;

                        case FrameType.BredAlternate:

                            frame =
                                Frame.GenerateFrame(
                                    FrameType.Bred,
                                    cnt + InitialFrame,
                                    rngArray[0 + cnt],
                                    StaticPID,
                                    rngArray[0 + cnt],
                                    rngArray[1 + cnt],
                                    rngArray[4 + cnt],
                                    rngArray[5 + cnt],
                                    rngArray[6 + cnt],
                                    rngArray[7 + cnt],
                                    rngArray[8 + cnt],
                                    rngArray[9 + cnt],
                                    ParentA,
                                    ParentB,
                                    id, sid, cnt);

                            break;

                        case FrameType.DPPtBred:

                            frame =
                                Frame.GenerateFrame(
                                    FrameType.DPPtBred,
                                    cnt + InitialFrame,
                                    rngArray[0 + cnt],
                                    rngArray[0 + cnt],
                                    rngArray[1 + cnt],
                                    rngArray[2 + cnt],
                                    rngArray[3 + cnt],
                                    rngArray[4 + cnt],
                                    rngArray[5 + cnt],
                                    rngArray[6 + cnt],
                                    rngArray[7 + cnt],
                                    ParentA,
                                    ParentB,
                                    id, sid, cnt);

                            break;

                        case FrameType.HGSSBred:

                            frame =
                                Frame.GenerateFrame(
                                    FrameType.HGSSBred,
                                    cnt + InitialFrame,
                                    rngArray[0 + cnt],
                                    rngArray[0 + cnt],
                                    rngArray[1 + cnt],
                                    rngArray[2 + cnt],
                                    rngArray[3 + cnt],
                                    rngArray[4 + cnt],
                                    rngArray[5 + cnt],
                                    rngArray[6 + cnt],
                                    rngArray[7 + cnt],
                                    ParentA,
                                    ParentB,
                                    id, sid, cnt);

                            break;

                        case FrameType.WondercardIVs:

                            if (EncounterType == EncounterType.Manaphy)
                            {
                                uint pid1 = rngArray[0 + cnt];
                                uint pid2 = rngArray[1 + cnt];

                                while ((pid1 ^ pid2 ^ id ^ sid) < 8)
                                {
                                    uint testPID = pid1 | (pid2 << 16);

                                    // Call the ARNG to change the PID
                                    testPID = testPID*0x6c078965 + 1;

                                    pid1 = testPID & 0xFFFF;
                                    pid2 = testPID >> 16;
                                }

                                frame =
                                    Frame.GenerateFrame(
                                        0,
                                        FrameType.WondercardIVs,
                                        cnt + InitialFrame,
                                        rngArray[0 + cnt],
                                        pid1,
                                        pid2,
                                        rngArray[2 + cnt],
                                        rngArray[3 + cnt],
                                        0, 0, 0, 0, 0, 0,
                                        id, sid, cnt);
                            }
                            else
                            {
                                frame =
                                    Frame.GenerateFrame(
                                        0,
                                        FrameType.WondercardIVs,
                                        cnt + InitialFrame,
                                        rngArray[0 + cnt],
                                        0,
                                        0,
                                        rngArray[0 + cnt],
                                        rngArray[1 + cnt],
                                        rngArray[2 + cnt],
                                        rngArray[3 + cnt],
                                        rngArray[4 + cnt],
                                        rngArray[5 + cnt],
                                        rngArray[6 + cnt],
                                        rngArray[7 + cnt],
                                        id, sid, cnt);
                            }

                            break;
                    }

                    //  Now we need to filter and decide if we are going
                    //  to add this to our collection for display to the
                    //  user.

                    if (frameCompare.Compare(frame))
                    {
                        frames.Add(frame);
                    }

                    if (frameType == FrameType.BredSplit)
                    {
                        if (frameCompare.Compare(frameSplit))
                        {
                            frames.Add(frameSplit);
                        }
                    }
                }
            }

            return frames;
        }
Beispiel #4
0
        //  We need a function to return a list of monster seeds,
        //  which will be updated to include a method.

        public static List <Seed> GetXDSeeds(
            uint hp,
            uint atk,
            uint def,
            uint spa,
            uint spd,
            uint spe,
            uint nature,
            uint id)
        {
            var seeds = new List <Seed>();

            uint ivs1     = hp + (atk << 5) + (def << 10);
            uint ivs2     = spe | (spa << 5) | (spd << 10);
            uint x_testXD = ivs1 << 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_testXD | cnt;
                var  rngXD  = new XdRng(seed);
                uint rng1XD = rngXD.GetNext16BitNumber();

                //Check if ivs line up
                if ((rng1XD & 0x7FFF) == ivs2)
                {
                    var  rngXDR     = new XdRngR(seed);
                    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.
                    uint rng2XD = rngXD.GetNext16BitNumber();
                    uint rng3XD = rngXD.GetNext16BitNumber();
                    uint rng4XD = rngXD.GetNext16BitNumber();
                    uint pid    = (rng3XD << 16) | rng4XD;

                    //  Check Colosseum\XD
                    // [IVs] [IVs] [xxx] [PID] [PID]
                    // [START] [rng1] [rng3] [rng4]

                    if (pid % 25 == nature)
                    {
                        var newSeed = new Seed
                        {
                            Method      = "Colosseum/XD",
                            Pid         = pid,
                            MonsterSeed = XDColoSeed
                        };
                        seeds.Add(newSeed);
                    }

                    //  Check Colosseum\XD XOR
                    // [IVs] [IVs] [xxx] [PID] [PID]
                    // [START] [rng1] [rng3] [rng4]
                    pid ^= 0x80008000;
                    if (pid % 25 == nature)
                    {
                        var newSeed = new Seed
                        {
                            Method      = "Colosseum/XD",
                            Pid         = pid,
                            MonsterSeed = XDColoSeed ^ 0x80000000
                        };
                        seeds.Add(newSeed);
                    }
                }
            }
            return(seeds);
        }
        // This is the smarter way of generating spreads
        // Takes a desired spread and derives the seed
        // Rather than searching all spreads for a match
        public List<Frame> Generate(
            uint minhp,
            uint maxhp,
            uint minatk,
            uint maxatk,
            uint mindef,
            uint maxdef,
            uint minspa,
            uint maxspa,
            uint minspd,
            uint maxspd,
            uint minspe,
            uint maxspe,
            uint nature)
        {
            var frames = new List<Frame>();
            var rngXD = new XdRng(0);

            for (uint hp = minhp; hp <= maxhp; hp++)
            {
                for (uint atk = minatk; atk <= maxatk; atk++)
                {
                    for (uint def = mindef; def <= maxdef; def++)
                    {
                        for (uint spa = minspa; spa <= maxspa; spa++)
                        {
                            for (uint spd = minspd; spd <= maxspd; spd++)
                            {
                                for (uint spe = minspe; spe <= maxspe; spe++)
                                {
                                    frame = null;

                                    uint x_test = hp | (atk << 5) | (def << 10);
                                    uint y_test = spe | (spa << 5) | (spd << 10);

                                    //  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++)
                                    {
                                        //  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;

                                        rngXD.Seed = seed;

                                        //  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 rng1XD = rngXD.GetNext16BitNumber();
                                        if ((rng1XD & 0x7FFF) != y_test)
                                            continue;

                                        // this second call isn't used for anything we know of
                                        ushort rng2XD = rngXD.GetNext16BitNumber();
                                        ushort rng3XD = rngXD.GetNext16BitNumber();
                                        ushort rng4XD = rngXD.GetNext16BitNumber();

                                        uint XDColoSeed = seed*0xB9B33155 + 0xA170F641;

                                        //  Check Colosseum\XD
                                        // [IVs] [IVs] [xxx] [PID] [PID]
                                        // [START] [rng1] [rng3] [rng4]

                                        for (int highBit = 0; highBit < 2; highBit++)
                                        {
                                            XDColoSeed = XDColoSeed ^ 0x80000000;
                                            rng3XD = (ushort) (rng3XD ^ 0x8000);
                                            rng4XD = (ushort) (rng4XD ^ 0x8000);

                                            if (IVtoSeed.Check(rng1XD, rng3XD, rng4XD, spe, spa, spd, nature))
                                            {
                                                frame = Frame.GenerateFrame
                                                    (XDColoSeed,
                                                     FrameType.ColoXD,
                                                     0,
                                                     XDColoSeed,
                                                     rng4XD,
                                                     rng3XD,
                                                     x_test,
                                                     rng1XD,
                                                     0, 0, 0, 0, 0, 0, 0, 0, 0);
                                                frame.DisplayPrep();

                                                frames.Add(frame);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return frames;
        }
Beispiel #6
0
        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;
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        //  We need a function to return a list of monster seeds,
        //  which will be updated to include a method.
        public static List<Seed> GetXDSeeds(
            uint hp,
            uint atk,
            uint def,
            uint spa,
            uint spd,
            uint spe,
            uint nature,
            uint id)
        {
            var seeds = new List<Seed>();

            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++)
            {
                //  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.
                uint 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_testXD << 16) + (cnt%0xFFFF);

                var rngXD = new XdRng(seed);
                var rngXDR = new XdRngR(seed);
                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 rng1XD = rngXD.GetNext16BitNumber();
                ushort rng2XD = rngXD.GetNext16BitNumber();
                ushort rng3XD = rngXD.GetNext16BitNumber();
                ushort rng4XD = rngXD.GetNext16BitNumber();

                //  Check Colosseum\XD
                // [IVs] [IVs] [xxx] [PID] [PID]
                // [START] [rng1] [rng3] [rng4]

                if (Check(rng1XD, rng3XD, rng4XD, spe, spa, spd, nature))
                {
                    var newSeed = new Seed
                        {
                            Method = "Colosseum/XD",
                            Pid = ((uint) rng3XD << 16) + rng4XD,
                            MonsterSeed = XDColoSeed
                        };

                    seeds.Add(newSeed);
                }
            }
            return seeds;
        }
Beispiel #9
0
        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();
        }
Beispiel #10
0
        // 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);
        }
Beispiel #11
0
        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);
        }
Beispiel #12
0
        //  We need a function to return a list of monster seeds,
        //  which will be updated to include a method.

        public static List <Seed> GetXDSeeds(
            uint hp,
            uint atk,
            uint def,
            uint spa,
            uint spd,
            uint spe,
            uint nature,
            uint id)
        {
            var seeds = new List <Seed>();

            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++)
            {
                //  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.
                uint 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_testXD << 16) + (cnt % 0xFFFF);

                var  rngXD      = new XdRng(seed);
                var  rngXDR     = new XdRngR(seed);
                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 rng1XD = rngXD.GetNext16BitNumber();
                ushort rng2XD = rngXD.GetNext16BitNumber();
                ushort rng3XD = rngXD.GetNext16BitNumber();
                ushort rng4XD = rngXD.GetNext16BitNumber();

                //  Check Colosseum\XD
                // [IVs] [IVs] [xxx] [PID] [PID]
                // [START] [rng1] [rng3] [rng4]

                if (Check(rng1XD, rng3XD, rng4XD, spe, spa, spd, nature))
                {
                    var newSeed = new Seed
                    {
                        Method      = "Colosseum/XD",
                        Pid         = ((uint)rng3XD << 16) + rng4XD,
                        MonsterSeed = XDColoSeed
                    };


                    seeds.Add(newSeed);
                }
            }
            return(seeds);
        }