示例#1
0
文件: Horde.cs 项目: wuyaz/3DSRNGTool
        public Horde(uint[] src, int PKMNUM, bool IsORAS)
        {
            rng = new TinyMT(src);

            for (int i = 3 * PKMNUM + (IsORAS ? 15 : 27); i > 0; i--)
            {
                rng.Next();
            }

            Lead = Rand(100);
            Slot = getSlot(Rand(100), 3);
            if (Rand(100) < 20)           // 78de5c
            {
                HA = (byte)(Rand(5) + 1); // 78de70
            }
            if (IsORAS)                   // 78df18
            {
                for (int i = 0; i < 5; i++)
                {
                    FluteBoosts[i] = getFluteBoost(Rand(100));
                }
            }
            rng.Next();
            for (int i = 0; i < 5; i++)
            {
                HeldItems[i] = Rand(100);
            }
        }
示例#2
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();
            }
        }
示例#3
0
 public bool Trigger()
 {
     // Normal step trigger
     rng.Next();     // sync
     rng.Next();     // Encounter Rate
     // DexNav trigger
     return(Rand(100) < 50);
 }
示例#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);
 }
示例#5
0
        private void Search7_Egg()
        {
            var rng = new TinyMT(Status);
            int min = (int)Frame_min.Value;
            int max = (int)Frame_max.Value;

            bool CheckRandomNumber(uint rn)
            {
                int sv = (int)Pokemon.getTSV(rn);

                return(sv == TSV.Value || ConsiderOtherTSV.Checked && OtherTSVList.Contains(sv));
            }

            // Advance
            for (int i = 0; i < min; i++)
            {
                rng.Next();
            }
            // Prepare
            getsetting(rng);
            // Start
            for (int i = min; i <= max; i++, RNGPool.AddNext(rng))
            {
                var result = RNGPool.GenerateEgg7() as EggResult;
                if (!(filter.CheckResult(result) || ShinyRemind.Checked && CheckRandomNumber(result.RandNum)))
                {
                    continue;
                }
                Frames.Add(new Frame(result, frame: i));
                if (Frames.Count > MAX_RESULTS_NUM)
                {
                    return;
                }
            }
        }
示例#6
0
        private void Search6_ID()
        {
            var rng = new TinyMT(new uint[] { ID_Tiny0.Value, ID_Tiny1.Value, ID_Tiny2.Value, ID_Tiny3.Value });
            int min = (int)Frame_min.Value;
            int max = (int)Frame_max.Value;

            IDFrames.Clear();
            IDFrames            = new List <Frame_ID>();
            Frame_ID.correction = 0xFF;
            IDFilters idfilter = getIDFilter();

            for (int i = 0; i < min; i++)
            {
                rng.Next();
            }
            for (int i = min; i <= max; i++)
            {
                var result = new ID6(rng);
                if (!idfilter.CheckResult(result))
                {
                    continue;
                }
                IDFrames.Add(new Frame_ID(result, i));
            }
        }
示例#7
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]);
        }
示例#8
0
        private void Search7_Egg()
        {
            var rng = new TinyMT(Status);
            int min = (int)Frame_min.Value;
            int max = (int)Frame_max.Value;

            // Advance
            for (int i = 0; i < min; i++)
            {
                rng.Next();
            }
            // Prepare
            getsetting(rng);
            // Start
            for (int i = min; i <= max; i++, RNGPool.AddNext(rng))
            {
                var result = RNGPool.GenerateEgg7() as EggResult;
                if (!(filter.CheckResult(result) || ShinyRemind.Checked && CheckRandomNumber(result.RandNum)))
                {
                    continue;
                }
                Frames.Add(new Frame(result, frame: i));
                if (Frames.Count > 100000)
                {
                    return;
                }
            }
        }
示例#9
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,
            };
        }
示例#10
0
        private void Search7_EggList()
        {
            var  rng       = new TinyMT(Status);
            int  min       = (int)Egg_min.Value - 1;
            int  max       = (int)Egg_max.Value - 1;
            int  target    = (int)TargetFrame.Value;
            bool gotresult = false;

            // Advance
            for (int i = 0; i < min; i++)
            {
                rng.Next();
            }
            TinyMT Seedrng = new TinyMT(rng.status);

            // Prepare
            getsetting(rng);
            // Start
            int frame   = 0;
            int advance = 0;

            for (int i = 0; i <= max; i++)
            {
                var result = RNGPool.GenerateEgg7() as EggResult;
                advance = result.FramesUsed;
                if (!gotresult && frame <= target && target < frame + advance)
                {
                    Egg_Instruction.Text = getEggListString(i, target - frame);
                    gotresult            = true;
                }
                frame += advance;
                for (int j = advance; j > 0; j--)
                {
                    RNGPool.AddNext(rng);
                }
                if (i < min || !filter.CheckResult(result))
                {
                    continue;
                }
                Frames.Add(new Frame(result, frame: frame - advance, eggnum: i + 1));
                if (Frames.Count > MAX_RESULTS_NUM)
                {
                    break;
                }
            }
            if (!gotresult)
            {
                Egg_Instruction.Text = getEggListString(-1, -1);
            }
        }
示例#11
0
        private void Search6_Battle()
        {
            TinyMT tiny      = TTT.Checked ? new TinyMT(Program.mainform.TinySeeds) : new TinyMT(Seed.Value);
            int    frame     = (int)StartingFrame.Value;
            int    loopcount = (int)MaxResults.Value;
            int    delay     = (int)Delay.Value;
            ulong  N         = (ulong)Range.Value;

            CaptureResult.Details = CB_Detail.Checked || Filters.SelectedTab == TP_Misc;
            var capture6 = new Capture();

            if (Filters.SelectedTab == TP_Capture)
            {
                capture6.Gen6        = true;
                capture6.HPCurr      = (uint)HPCurr.Value;
                capture6.HPMax       = (uint)HPMax.Value;
                capture6.CatchRate   = (byte)CatchRate.Value;
                capture6.StatusBonus = (uint)(int)Status.SelectedValue;
                capture6.BallBonus   = (uint)(int)BallBonus.SelectedValue;
                capture6.DexBonus    = (uint)(int)DexBonus.SelectedValue;
                capture6.OPowerBonus = OPowerList[OPower.SelectedIndex];
                capture6.Calc();
                var criticalchance = capture6.CriticalRate / 256.0;
                var shakechance    = capture6.ShakeRate / 65536.0;
                var capturechance  = criticalchance * shakechance + (1 - criticalchance) * Math.Pow(shakechance, 4);
                L_output.Text = CB_Detail.Checked ? string.Format("Critical {0:P}  \tShake {1:P}", criticalchance, shakechance)
                    : string.Format("Critical {0:P}  \tSuccess {1:P}", criticalchance, capturechance);
            }

            for (int i = 0; i < frame; i++)
            {
                tiny.Next();
            }

            RNGPool.CreateBuffer(tiny);

            for (int i = 0; i < loopcount; i++, RNGPool.AddNext(tiny, AutoCheck: false))
            {
                var f = new Frame_Misc();
                f.Frame  = frame++;
                f.Rand32 = RNGPool.getcurrent;
                f.st     = RNGPool.getcurrentstate;

                RNGPool.Rewind(0);
                RNGPool.Advance(delay);
                if (filter.Random)
                {
                    f.RandN = (int)((RNGPool.getrand * N) >> 32);
                }
                if (ShowCapture)
                {
                    RNGPool.Rewind(0);
                    f.Crt = capture6.Catch();
                }

                if (!filter.check(f))
                {
                    continue;
                }

                Frames.Add(f);
            }
        }
示例#12
0
 public void Next() => Tinyrng.Next();
示例#13
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);
        }