Beispiel #1
0
        private void GenerateRest(TinyMT tiny)
        {
            // Ability
            tiny.Next();

            // IVs Random Advancement
            // Hard to read but efficient
            uint tmp;

            uint[] InheritIV = new uint[2];
            InheritIV[0] = tiny.Nextuint() % 6;
            tiny.Next();
            do
            {
                tmp = tiny.Nextuint() % 6;
            }while (tmp == InheritIV[0]);
            tiny.Next(); InheritIV[1] = tmp;
            do
            {
                tmp = tiny.Nextuint() % 6;
            }while (tmp == InheritIV[0] || tmp == InheritIV[1]);

            // Rest
            for (int i = Advance; i > 0; i--) // IVs * 7 + EC + PID * 0/2 + 2
            {
                tiny.Next();
            }
        }
Beispiel #2
0
        private bool Check(uint seed)
        {
            TinyMT tiny = new TinyMT(seed);

            for (int i = 0; i < 7; i++)
            {
                tiny.Next(); // Gender
                if (tiny.Nextuint() % 25 != NatureList[i])
                {
                    return(false);
                }
                GenerateRest(tiny);
            }
            tiny.Next();
            return(tiny.Nextuint() % 25 == NatureList[7]);
        }
Beispiel #3
0
 public ID6(TinyMT rng)
 {
     Status  = rng.CurrentState();
     RandNum = rng.Nextuint();
     TID     = (ushort)(RandNum & 0xFFFF);
     SID     = (ushort)(RandNum >> 16);
     TSV     = (ushort)((TID ^ SID) >> 4);
 }
Beispiel #4
0
 public HordeResults(TinyMT rng, int PKMNUM)
 {
     for (int i = 3 * PKMNUM + (IsXY ? 27 : 15); i > 0; i--)
         rng.Next();
     Sync = rng.Nextuint() < 0x80000000;
     Slot = HordeSlot(Rand(rng, 100));
     if (Rand(rng, 100) < 20) // 78de5c
         HA = (byte)(Rand(rng, 5) + 1); // 78de70
     for (int i = IsXY ? 1 : 6; i > 0; i--)
         rng.Next();
     for (int i = 0; i < 5; i++)
         HeldItems[i] = (byte)Rand(rng, 100);
 }
Beispiel #5
0
        public PokeRadar(uint[] src, int PKMNUM, int Chainlength, bool Boost)
        {
            rng = new TinyMT(src);

            for (int i = 3 * PKMNUM; i > 0; i--)
            {
                rng.Next();
            }

            music  = Rand(100);
            Boost &= music >= 50;

            // 4 Pokemon patches
            byte ring = 0;

            for (; ring < 4; ring++)
            {
                patches[ring] = new Patch
                {
                    Ring      = ring,
                    Direction = Rand(4),
                    Location  = Rand(ring * 2ul + 3ul),
                };
                if (Rand(100) < GoodRate[ring])
                {
                    rng.Next();
                    ulong Chance = Boost || Chainlength >= 40 ? 100 : (ulong)(8100 - Chainlength * 200);
                    patches[ring].state = (byte)(rng.Nextuint() * Chance <= uint.MaxValue ? 2 : 1);
                }
            }

            // 1 empty patch
            ring       = Rand(3);
            patches[4] = new Patch
            {
                Ring      = ring,
                Direction = Rand(4),
                Location  = Rand(ring * 2ul + 3ul),
                state     = 3,
            };
        }
Beispiel #6
0
 public uint Nextuint() => Tinyrng.Nextuint();
Beispiel #7
0
 private static byte Rand(ulong n) => (byte)((rng.Nextuint() * n) >> 32);
 private static uint Rand(TinyMT rng, ulong n) => (uint)((rng.Nextuint() * n) >> 32);
Beispiel #9
0
        public static DexNavResult Generate(TinyMT rng)
        {
            var rt = new DexNavResult();

            // Something
            rng.Next();

            // Boost
            bool Boost = ChainLength > 0 && (ChainLength + 1) % 5 == 0 || (rng.Nextuint() * 100ul) >> 32 < 4;  // sub_40295C
            byte Grade = GetGrade;

            // Sync
            rt.Lead = (byte)((rng.Nextuint() * 100ul) >> 32);

            // Something
            rng.Next();

            // Level
            rt.LevelBoost = ChainLength / 5 + (Boost ? 10 : 0);
            rt.FluteBoost = Wild6.getFluteBoost((rng.Nextuint() * 100ul) >> 32);

            // Hidden Ability
            rt.HA = ((rng.Nextuint() * 100ul) >> 32) < HARate[Grade];

            // IVs
            int Index;

            for (Index = 2; Index >= 0; Index--)
            {
                if (((rng.Nextuint() * 100ul) >> 32) < IVRate[3 * Grade + Index])
                {
                    break;
                }
            }
            Index       += Boost ? 2 : 1;
            rt.Potential = (byte)Math.Min(3, Index);

            // Egg Move
            rt.EggMove = ((rng.Nextuint() * 100ul) >> 32) < EggMoveRate[Grade] || Boost;

            // Held Item
            int tmp = (int)((rng.Nextuint() * 100ul) >> 32);

            for (Index = 0; Index < 2; Index++)
            {
                tmp -= HeldItemRate[Grade * 2 + Index];
                if (CompoundEyes)
                {
                    tmp -= 5;
                }
                if (tmp < 0)
                {
                    break;
                }
            }
            if (Index >= 2)
            {
                Index = 3;
            }
            rt.HeldItem = (byte)Index;

            // Shiny Checks
            int CheckCount = ShinyCharm ? 3 : 1;

            if (Boost)
            {
                CheckCount += 4;
            }
            if (ChainLength == 49)
            {
                CheckCount += 5;
            }
            else if (ChainLength == 99)
            {
                CheckCount += 10;
            }

            int TargetValue = 0;

            if (SearchLevel > 200)
            {
                TargetValue = SearchLevel + 600;
            }
            else if (SearchLevel > 100)
            {
                TargetValue = 2 * SearchLevel + 400;
            }
            else
            {
                TargetValue = 6 * SearchLevel;
            }

            for (int i = 0; i < CheckCount; i++)
            {
                if (((rng.Nextuint() * 10000ul) >> 32) < TargetValue * 0.01)
                {
                    rt.ForcedShiny = true;
                }
            }

            return(rt);
        }
Beispiel #10
0
 private static int Rand(ulong n) => (int)((rng.Nextuint() * n) >> 32);