Ejemplo n.º 1
0
        public static void GetShinyIVs(Xoroshiro128Plus rng, out uint[,] frameIVs)
        {
            frameIVs = new uint[5, 6];
            Xoroshiro128Plus origrng = rng;

            for (int ivcount = 0; ivcount < 5; ivcount++)
            {
                int   i   = 0;
                int[] ivs = { -1, -1, -1, -1, -1, -1 };

                while (i < ivcount + 1)
                {
                    var stat = (int)rng.NextInt(6);
                    if (ivs[stat] == -1)
                    {
                        ivs[stat] = 31;
                        i++;
                    }
                }

                for (int j = 0; j < 6; j++)
                {
                    if (ivs[j] == -1)
                    {
                        ivs[j] = (int)rng.NextInt(32);
                    }
                    frameIVs[ivcount, j] = (uint)ivs[j];
                }
                rng = origrng;
            }
        }
Ejemplo n.º 2
0
        private IEnumerator Coroutine_SpawnTripleShops()
        {
            int shopCount = 0;

            if (ModConfig.GameMode.Value == 0)
            {
                shopCount = ModConfig.MultiShopAmount.Value;
            }
            else if (ModConfig.GameMode.Value == 1)
            {
                shopCount = ModConfig.tierWeights.Count;
            }
            int tripleShopAmount = 0;

            switch (ModConfig.GameMode.Value)
            {
            case 0:
                tripleShopAmount = ModConfig.MultiShopAmount.Value;
                break;

            case 1:
                tripleShopAmount = ModConfig.tierWeights.Count;
                break;
            }
            Xoroshiro128Plus xoroshiro128Plus = new Xoroshiro128Plus((ulong)Run.instance.stageRng.nextUint);

            for (int i = 0; i < tripleShopAmount; i++)
            {
                yield return(new WaitForSeconds(2f / shopCount));

                SpawnShop(xoroshiro128Plus);
            }
            //isAnimating = true;
        }
Ejemplo n.º 3
0
    public static void TestMagby()
    {
        const ulong s0   = 0xE12DDECBDFC64AA1ul;
        PA8         test = new() { Species = (int)Species.Magby };

        var param = new OverworldParam8a
        {
            FlawlessIVs = 3,
            IsAlpha     = true,
            Shiny       = Shiny.Random,
            RollCount   = 17,
            GenderRatio = 0x7F,
        };

        var xoro = new Xoroshiro128Plus(s0);

        var(EntitySeed, _) = Overworld8aRNG.ApplyDetails(test, param, true, ref xoro);

        test.IV_HP.Should().Be(31);
        test.IV_ATK.Should().Be(31);
        test.IV_DEF.Should().Be(7);
        test.IV_SPA.Should().Be(31);
        test.IV_SPD.Should().Be(20);
        test.IV_SPE.Should().Be(10);

        test.AlphaMove.Should().Be((ushort)Move.Flamethrower);

        var verify = Overworld8aRNG.Verify(test, EntitySeed, param);

        verify.Should().BeTrue();
    }
}
Ejemplo n.º 4
0
        public static bool ValidateOverworldEncounter(PKM pk, uint seed, Shiny shiny = Shiny.FixedValue, int flawless = -1)
        {
            // is the seed Xoroshiro determined, or just truncated state?
            if (seed == uint.MaxValue)
            {
                return(false);
            }

            var xoro = new Xoroshiro128Plus(seed);
            var ec   = (uint)xoro.NextInt(uint.MaxValue);

            if (ec != pk.EncryptionConstant)
            {
                return(false);
            }

            var pid = (uint)xoro.NextInt(uint.MaxValue);

            if (!IsPIDValid(pk, pid, shiny))
            {
                return(false);
            }

            var actualCount = flawless == -1 ? GetIsMatchEnd(pk, xoro) : GetIsMatchEnd(pk, xoro, flawless, flawless);

            return(actualCount != NoMatchIVs);
        }
Ejemplo n.º 5
0
        private static int GetIsMatchEnd(PKM pk, Xoroshiro128Plus xoro, int start = 0, int end = 3)
        {
            bool skip1 = start == 0 && end == 3;
            for (int iv_count = start; iv_count <= end; iv_count++)
            {
                if (skip1 && iv_count == 1)
                    continue;

                var copy = xoro;
                int[] ivs = { UNSET, UNSET, UNSET, UNSET, UNSET, UNSET };
                const int MAX = 31;
                for (int i = 0; i < iv_count; i++)
                {
                    int index;
                    do { index = (int)copy.NextInt(6); } while (ivs[index] != UNSET);
                    ivs[index] = MAX;
                }

                if (!IsValidSequence(pk, ivs, ref copy))
                    continue;

                if (pk is not IScaledSize s)
                    continue;
                var height = (int) copy.NextInt(0x81) + (int) copy.NextInt(0x80);
                if (s.HeightScalar != height)
                    continue;
                var weight = (int) copy.NextInt(0x81) + (int) copy.NextInt(0x80);
                if (s.WeightScalar != weight)
                    continue;

                return iv_count;
            }
            return NoMatchIVs;
        }
Ejemplo n.º 6
0
 private void Awake()
 {
     if (_rng == null)
     {
         _rng = new Xoroshiro128Plus((ulong)DateTime.Now.Ticks);
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Spawn an item of the given tier at the position of the given CharacterBody.
        /// </summary>
        /// <param name="src">The body to spawn an item from.</param>
        /// <param name="tier">The tier of item to spawn. Must be within 0 and 5, inclusive (Tier 1, Tier 2, Tier 3, Lunar, Equipment, Lunar Equipment).</param>
        /// <param name="rng">An instance of Xoroshiro128Plus to use for random item selection.</param>
        public static void SpawnItemFromBody(CharacterBody src, int tier, Xoroshiro128Plus rng)
        {
            List <PickupIndex> spawnList;

            switch (tier)
            {
            case 1:
                spawnList = Run.instance.availableTier2DropList;
                break;

            case 2:
                spawnList = Run.instance.availableTier3DropList;
                break;

            case 3:
                spawnList = Run.instance.availableLunarDropList;
                break;

            case 4:
                spawnList = Run.instance.availableNormalEquipmentDropList;
                break;

            case 5:
                spawnList = Run.instance.availableLunarEquipmentDropList;
                break;

            case 0:
                spawnList = Run.instance.availableTier1DropList;
                break;

            default:
                throw new ArgumentOutOfRangeException("tier", tier, "spawnItemFromBody: Item tier must be between 0 and 5 inclusive");
            }
            PickupDropletController.CreatePickupDroplet(spawnList[rng.RangeInt(0, spawnList.Count)], src.transform.position, new Vector3(UnityEngine.Random.Range(-5.0f, 5.0f), 20f, UnityEngine.Random.Range(-5.0f, 5.0f)));
        }
Ejemplo n.º 8
0
        public HailstormPlugin()
        {
            HailstormConfig.Init(Config);
            HailstormAssets.Init();

            if (HailstormConfig.EnableDarkElites.Value)
            {
                _darkElites = new DarkElitesManager();
            }

            if (HailstormConfig.EnableBarrierElites.Value)
            {
                _barrierElites = new BarrierElitesManager();
            }

            if (HailstormConfig.EnableStormElites.Value)
            {
                _stormElites = new StormElitesManager();
            }

            if (HailstormConfig.EnableMimics.Value)
            {
                _mimics = new Mimics();
            }

            _rng = new Xoroshiro128Plus((ulong)DateTime.Now.Ticks);

            R2API.Utils.CommandHelper.AddToConsoleWhenReady();
        }
Ejemplo n.º 9
0
    public static void TryGenerateShinyOutbreakZorua()
    {
        PA8         test = new() { Species = (int)Species.Zorua, Form = 1 };
        const ulong s0   = 0xDF440DA44EEC4FFB;

        var rand  = new Xoroshiro128Plus(s0);
        var param = new OverworldParam8a
        {
            FlawlessIVs = 0, IsAlpha = false,
            Shiny       = Shiny.Random, RollCount = 30,
            GenderRatio = 0x7F,
        };

        var result = Overworld8aRNG.TryApplyFromSeed(test, EncounterCriteria.Unrestricted, param, rand);

        result.Should().BeTrue();

        test.IV_HP.Should().Be(10);
        test.IV_ATK.Should().Be(13);
        test.IV_DEF.Should().Be(8);
        test.IV_SPA.Should().Be(0);
        test.IV_SPD.Should().Be(17);
        test.IV_SPE.Should().Be(25);
        test.HeightScalar.Should().Be(99);
        test.WeightScalar.Should().Be(153);

        var verify = Overworld8aRNG.Verify(test, s0, param);

        verify.Should().BeTrue();
    }
}
Ejemplo n.º 10
0
        public JestersDice()
        {
            _rng = new Xoroshiro128Plus((ulong)DateTime.Now.Ticks);

            var equipDef = new EquipmentDef
            {
                cooldown         = 30f,
                pickupModelPath  = UmbrellaAssets.PrefabJestersDice,
                pickupIconPath   = UmbrellaAssets.IconJestersDice,
                pickupToken      = "Jester's Dice",
                nameToken        = EquipNames.JestersDice,
                descriptionToken = "Jester's Dice",
                canDrop          = true,
                enigmaCompatible = true,
                isLunar          = true
            };

            var prefab = UmbrellaAssets.JestersDicePrefab;
            var rule   = new ItemDisplayRule
            {
                ruleType       = ItemDisplayRuleType.ParentedPrefab,
                followerPrefab = prefab,
                childName      = "Chest",
                localScale     = new Vector3(0.15f, 0.15f, 0.15f),
                localAngles    = new Vector3(0f, 180f, 0f),
                localPos       = new Vector3(-0.35f, -0.1f, 0f)
            };

            var equip = new CustomEquipment(equipDef, new[] { rule });

            EquipIndex = (EquipmentIndex)ItemAPI.AddCustomEquipment(equip);
        }
Ejemplo n.º 11
0
        public void Xoroshiro128Plus_Distribution_Similar_To_Std_Random(bool useRandomSeed)
        {
            var rnd = new Random();
            var xoroshiro128plus = new Xoroshiro128Plus(useRandomSeed ? new Random() : null);

            var iterations = 10_000_000;

            var stdRand  = new double[iterations];
            var testRand = new double[iterations];

            for (int i = 0; i < iterations; i++)
            {
                stdRand[i]  = rnd.NextDouble();
                testRand[i] = xoroshiro128plus.NextDouble();
            }

            var stdAvg  = stdRand.Average();
            var testAvg = testRand.Average();

            var avgDiff = Math.Abs(stdAvg - testAvg);

            Assert.True(avgDiff < 0.001d, "RNG should have simular distributions as BCL version. Diff: " + avgDiff);

            Test_Uniform_Distribution(stdRand);
            Test_Uniform_Distribution(testRand);
Ejemplo n.º 12
0
            public void Start()
            {
                RoR2.EntityLogic.DelayedEvent delayedEvent = GetComponent <RoR2.EntityLogic.DelayedEvent>();
                delayedEvent.action = new UnityEvent();
                delayedEvent.action.AddListener(() =>
                {
                    AddShrineStack(purchaseInteraction.lastActivator);
                });
                delayedEvent.timeStepType = RoR2.EntityLogic.DelayedEvent.TimeStepType.FixedTime;

                purchaseInteraction = GetComponent <PurchaseInteraction>();
                purchaseInteraction.onPurchase.AddListener((interactor) =>
                {
                    purchaseInteraction.SetAvailable(false);
                    delayedEvent.CallDelayed(1.5f);
                });

                availableItems = new List <ItemIndex>();
                if (NetworkServer.active)
                {
                    rng = new Xoroshiro128Plus(Run.instance.stageRng.nextUlong);
                    foreach (PickupIndex pickupIndex in Run.instance.availableTier3DropList)
                    {
                        availableItems.Add(PickupCatalog.GetPickupDef(pickupIndex).itemIndex);
                    }
                }
            }
Ejemplo n.º 13
0
        private static void CreateEclipseDoppelganger(CharacterMaster master, Xoroshiro128Plus rng)
        {
            var card = DoppelgangerSpawnCard.FromMaster(master);

            if (card is null)
            {
                return;
            }
            if (card.prefab is null)
            {
                card.prefab = MasterCatalog.GetMasterPrefab(defaultMasterIndex);
            }

            Transform spawnOnTarget;

            DirectorCore.MonsterSpawnDistance input;
            if (TeleporterInteraction.instance)
            {
                spawnOnTarget = TeleporterInteraction.instance.transform;
                input         = DirectorCore.MonsterSpawnDistance.Close;
            }
            else
            {
                spawnOnTarget = master.GetBody().coreTransform;
                input         = DirectorCore.MonsterSpawnDistance.Far;
            }
            DirectorPlacementRule directorPlacementRule = new DirectorPlacementRule
            {
                spawnOnTarget = spawnOnTarget,
                placementMode = DirectorPlacementRule.PlacementMode.NearestNode
            };

            DirectorCore.GetMonsterSpawnDistance(input, out directorPlacementRule.minDistance, out directorPlacementRule.maxDistance);
            DirectorSpawnRequest directorSpawnRequest = new DirectorSpawnRequest(card, directorPlacementRule, rng);

            directorSpawnRequest.teamIndexOverride     = new TeamIndex?(TeamIndex.Monster);
            directorSpawnRequest.ignoreTeamMemberLimit = true;

            CombatSquad squad = null;

            DirectorSpawnRequest directorSpawnRequest2 = directorSpawnRequest;

            directorSpawnRequest2.onSpawnedServer = DelegateHelper.Combine(directorSpawnRequest2.onSpawnedServer, (res) =>
            {
                if (squad is null)
                {
                    squad = UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/NetworkedObjects/Encounters/ShadowCloneEncounter")).GetComponent <CombatSquad>();
                }
                squad.AddMember(res.spawnedInstance.GetComponent <CharacterMaster>());
            });

            DirectorCore.instance.TrySpawnObject(directorSpawnRequest);

            if (squad is not null)
            {
                NetworkServer.Spawn(squad.gameObject);
            }
            UnityEngine.Object.Destroy(card);
        }
Ejemplo n.º 14
0
 public static void GetNature(Xoroshiro128Plus rng, uint species, uint altform, out uint nature)
 {
     nature = species switch
     {
         849 => altform == 0 ? (uint)TradeExtensions.Amped[rng.NextInt(13)] : (uint)TradeExtensions.LowKey[rng.NextInt(12)],
         _ => (uint)rng.NextInt(25),
     };
 }
Ejemplo n.º 15
0
        private void Start()
        {
            _soundEvent1 = AkSoundEngine.PostEvent(SoundEvents.PlayTornado, gameObject);
            var refTop = gameObject.transform.GetChild(gameObject.transform.childCount - 1).gameObject;

            _soundEvent2 = AkSoundEngine.PostEvent(SoundEvents.PlayTornado, refTop);
            _startTime   = Time.fixedTime;
            _rng         = new Xoroshiro128Plus((ulong)DateTime.Now.Ticks);
        }
        // Token: 0x060003CC RID: 972 RVA: 0x0000EA98 File Offset: 0x0000CC98
        public override PickupIndex GenerateDrop(Xoroshiro128Plus rng)
        {
            List <PickupIndex> list = this.selector.Evaluate(rng.nextNormalizedFloat);

            if (list.Count <= 0)
            {
                return(PickupIndex.none);
            }
            return(rng.NextElementUniform <PickupIndex>(list));
        }
Ejemplo n.º 17
0
 // Token: 0x06001C3C RID: 7228 RVA: 0x0008414C File Offset: 0x0008234C
 public static void ShuffleList <T>(List <T> list, Xoroshiro128Plus rng)
 {
     for (int i = 0; i < list.Count; i++)
     {
         int index = rng.RangeInt(0, list.Count);
         T   value = list[i];
         list[i]     = list[index];
         list[index] = value;
     }
 }
Ejemplo n.º 18
0
 public static Xoroshiro128Plus GetAbility(Xoroshiro128Plus rng, uint nestAbility, out uint ability)
 {
     ability = nestAbility switch
     {
         4 => (uint)rng.NextInt(3),
         3 => (uint)rng.NextInt(2),
         _ => nestAbility,
     };
     return(rng);
 }
Ejemplo n.º 19
0
 // Token: 0x06001C3E RID: 7230 RVA: 0x000841DC File Offset: 0x000823DC
 public static void ShuffleArray <T>(T[] array, Xoroshiro128Plus rng)
 {
     for (int i = 0; i < array.Length; i++)
     {
         int num = rng.RangeInt(0, array.Length);
         T   t   = array[i];
         array[i]   = array[num];
         array[num] = t;
     }
 }
        /// <summary>
        /// Takes a collection and shuffle sorts it around randomly.
        /// </summary>
        /// <typeparam name="T">The type of the collection</typeparam>
        /// <param name="toShuffle">The collection to shuffle.</param>
        /// <param name="random">The random to shuffle the collection with.</param>
        /// <returns>The shuffled collection.</returns>
        public static IEnumerable <T> Shuffle <T>(this IEnumerable <T> toShuffle, Xoroshiro128Plus random)
        {
            List <T> shuffled = new List <T>();

            foreach (T value in toShuffle)
            {
                shuffled.Insert(random.RangeInt(0, shuffled.Count + 1), value);
            }
            return(shuffled);
        }
Ejemplo n.º 21
0
        private static void On_RunStart(On.RoR2.Run.orig_Start orig, Run self)
        {
            orig(self);
            if (!NetworkServer.active)
            {
                return;
            }
            var itemRngGenerator = new Xoroshiro128Plus(self.seed);

            AncientScepterItem.instance.rng = new Xoroshiro128Plus(itemRngGenerator.nextUlong);
        }
Ejemplo n.º 22
0
 private static void PerformEclipseInvasion(Xoroshiro128Plus rng)
 {
     for (int i = CharacterMaster.readOnlyInstancesList.Count - 1; i >= 0; i--)
     {
         CharacterMaster characterMaster = CharacterMaster.readOnlyInstancesList[i];
         if (characterMaster.teamIndex == TeamIndex.Player && characterMaster.playerCharacterMasterController)
         {
             EclipseDoppelgangerInvasionManager.CreateDoppelganger(characterMaster, rng);
         }
     }
 }
Ejemplo n.º 23
0
    // Token: 0x06000217 RID: 535 RVA: 0x0000A53C File Offset: 0x0000873C
    public ulong Next()
    {
        ulong num    = this.state0;
        ulong num2   = this.state1;
        ulong result = num + num2;

        num2       ^= num;
        this.state0 = (Xoroshiro128Plus.RotateLeft(num, 24) ^ num2 ^ num2 << 16);
        this.state1 = Xoroshiro128Plus.RotateLeft(num2, 37);
        return(result);
    }
Ejemplo n.º 24
0
        public static void RepopulateTerminals(MultiShopController multiShopController, ItemTierShopConfig itemTierConfig)
        {
            GameObject[] terminalGameObjects = multiShopController.GetFieldValue <GameObject[]>("terminalGameObjects");
            for (int i = 0; i < multiShopController.terminalPositions.Length; i++)
            {
                List <PickupIndex> otherItemsList = new List <PickupIndex>();
                PickupIndex        newPickupIndex = PickupIndex.none;
                Xoroshiro128Plus   treasureRng    = Run.instance.treasureRng;
                switch (itemTierConfig.itemTier)
                {
                case ItemTier.Tier1:
                    newPickupIndex = treasureRng.NextElementUniform <PickupIndex>(Run.instance.availableTier1DropList);
                    break;

                case ItemTier.Tier2:
                    newPickupIndex = treasureRng.NextElementUniform <PickupIndex>(Run.instance.availableTier2DropList);
                    break;

                case ItemTier.Tier3:
                    newPickupIndex = treasureRng.NextElementUniform <PickupIndex>(Run.instance.availableTier3DropList);
                    break;

                case ItemTier.Lunar:
                    newPickupIndex = treasureRng.NextElementUniform <PickupIndex>(Run.instance.availableLunarDropList);
                    break;

                case ItemTier.Boss:
                    otherItemsList = new List <PickupIndex>();
                    var bossItemIndexList = R2API.ItemDropAPI.GetDefaultDropList(ItemTier.Boss);
                    foreach (var itemIndex in bossItemIndexList)
                    {
                        otherItemsList.Add(new PickupIndex(itemIndex));
                    }
                    newPickupIndex = treasureRng.NextElementUniform <PickupIndex>(otherItemsList);
                    break;

                case ItemTier.NoTier:
                    if (itemTierConfig.isEquipment)
                    {
                        otherItemsList = new List <PickupIndex>();
                        var equipmentIndexList = R2API.ItemDropAPI.GetDefaultEquipmentDropList();
                        foreach (var itemIndex in equipmentIndexList)
                        {
                            otherItemsList.Add(new PickupIndex(itemIndex));
                        }
                        newPickupIndex = treasureRng.NextElementUniform <PickupIndex>(otherItemsList);
                        //self.itemTier = ItemTier.Tier1;
                    }
                    break;
                }
                bool newHidden = Run.instance.treasureRng.nextNormalizedFloat < 0.2f;
                terminalGameObjects[i].GetComponent <ShopTerminalBehavior>().SetPickupIndex(newPickupIndex, newHidden);
            }
        }
Ejemplo n.º 25
0
        public static void GetShinyFrames(ulong seed, out int[] frames, out uint[] type, out List <uint[, ]> IVs, SeedCheckResults mode)
        {
            int shinyindex = 0;

            frames = new int[3];
            type   = new uint[3];
            IVs    = new List <uint[, ]>();
            bool foundStar   = false;
            bool foundSquare = false;

            var rng = new Xoroshiro128Plus(seed);

            for (int i = 0; ; i++)
            {
                uint _         = (uint)rng.NextInt(0xFFFFFFFF); // EC
                uint SIDTID    = (uint)rng.NextInt(0xFFFFFFFF);
                uint PID       = (uint)rng.NextInt(0xFFFFFFFF);
                var  shinytype = GetShinyType(PID, SIDTID);

                // If we found a shiny, record it and return if we got everything we wanted.
                if (shinytype != 0)
                {
                    if (shinytype == 1)
                    {
                        foundStar = true;
                    }
                    else if (shinytype == 2)
                    {
                        foundSquare = true;
                    }

                    if (shinyindex == 0 || mode == SeedCheckResults.FirstThree || (foundStar && foundSquare))
                    {
                        frames[shinyindex] = i;
                        type[shinyindex]   = shinytype;
                        GetShinyIVs(rng, out uint[,] frameIVs);
                        IVs.Add(frameIVs);

                        shinyindex++;
                    }

                    if (mode == SeedCheckResults.ClosestOnly || (mode == SeedCheckResults.FirstStarAndSquare && foundStar && foundSquare) || shinyindex >= 3)
                    {
                        return;
                    }
                }

                // Get the next seed, and reset for the next iteration
                rng  = new Xoroshiro128Plus(seed);
                seed = rng.Next();
                rng  = new Xoroshiro128Plus(seed);
            }
        }
Ejemplo n.º 26
0
 public static Xoroshiro128Plus GetGender(Xoroshiro128Plus rng, GenderRatio ratio, uint genderIn, out uint gender)
 {
     gender = genderIn switch
     {
         0 => ratio == GenderRatio.Genderless ? 2 : ratio == GenderRatio.Female ? 1 : ratio == GenderRatio.Male ? 0 : ((rng.NextInt(253) + 1) < (uint)ratio ? (uint)GenderType.Female : (uint)GenderType.Male),
         1 => 0,
         2 => 1,
         3 => 2,
         _ => (rng.NextInt(253) + 1) < (uint)ratio ? (uint)GenderType.Female : (uint)GenderType.Male,
     };
     return(rng);
 }
Ejemplo n.º 27
0
 private void Awake()
 {
     _rng          = new Xoroshiro128Plus((ulong)DateTime.Now.Ticks);
     AsteroidSwarm = new AsteroidSwarmSettings();
     _phases.Add(BossPhase.Inactive, null);
     _phases.Add(BossPhase.Introduction, new IntroductionPhase(this));
     _phases.Add(BossPhase.ChargeLaser, new ChargeLaserPhase(this));
     _phases.Add(BossPhase.RunLaser, new RunLaserPhase(this));
     _phases.Add(BossPhase.TheHatching, new TheHatchingPhase(this));
     _phases.Add(BossPhase.Voidspawn, new VoidspawnPhase(this));
     _phases.Add(BossPhase.Finale, new FinalePhase(this));
     _phases.Add(BossPhase.Reward, new RewardPhase(this));
 }
Ejemplo n.º 28
0
        static bool Prefix(Xoroshiro128Plus rng, ref PickupIndex __result)
        {
            var perfectFuelCellChance  = Precipitation.RainServer.GetToggle("perfect_fuel_cell_chance");
            var perfectProcItemChance  = Precipitation.RainServer.GetToggle("perfect_proc_item_chance");
            var perfectLegendaryChance = Precipitation.RainServer.GetToggle("perfect_legendary_chance");
            var onlyForgiveMePlease    = Precipitation.RainServer.GetToggle("only_forgive_me_please");

            if (perfectFuelCellChance)
            {
                __result = rng.NextElementUniform(new List <PickupIndex>()
                {
                    PickupCatalog.FindPickupIndex("ItemIndex.EquipmentMagazine"),
                    PickupCatalog.FindPickupIndex("ItemIndex.AutoCastEquipment"),
                });
                return(false);
            }
            else if (perfectProcItemChance)
            {
                __result = rng.NextElementUniform(new List <PickupIndex>()
                {
                    PickupCatalog.FindPickupIndex("ItemIndex.ChainLightning"),
                    PickupCatalog.FindPickupIndex("ItemIndex.Missile"),
                    PickupCatalog.FindPickupIndex("ItemIndex.Dagger"),
                    PickupCatalog.FindPickupIndex("ItemIndex.ShockNearby"),
                    PickupCatalog.FindPickupIndex("ItemIndex.BounceNearby"),
                    PickupCatalog.FindPickupIndex("ItemIndex.Icicle"),
                    PickupCatalog.FindPickupIndex("ItemIndex.LaserTurbine"),
                    PickupCatalog.FindPickupIndex("ItemIndex.NovaOnHeal"),
                    PickupCatalog.FindPickupIndex("ItemIndex.Thorns"),
                    PickupCatalog.FindPickupIndex("ItemIndex.BurnNearby")
                });
                return(false);
            }
            else if (perfectLegendaryChance)
            {
                __result = rng.NextElementUniform(Run.instance.availableTier3DropList);
                return(false);
            }
            else if (onlyForgiveMePlease)
            {
                __result = rng.NextElementUniform(new List <PickupIndex>()
                {
                    PickupCatalog.FindPickupIndex("EquipmentIndex.SoulCorruptor"),
                    PickupCatalog.FindPickupIndex("EquipmentIndex.QuestVolatileBattery"),
                    PickupCatalog.FindPickupIndex("EquipmentIndex.CrippleWard"),
                    PickupCatalog.FindPickupIndex("EquipmentIndex.DeathProjectile")
                });
                return(false);
            }
            return(true);
        }
Ejemplo n.º 29
0
        private static void GearUp(ConCommandArgs args)
        {
            int whites = 80;
            int greens = 20;
            int reds   = 5;

            if (args.Count == 3)
            {
                bool success = int.TryParse(args[0], out whites);
                success &= int.TryParse(args[1], out greens);
                success &= int.TryParse(args[2], out reds);

                if (!success)
                {
                    Debug.LogWarning("Invalid parameters: specify space delivered number of items for [white] [green] [red].");
                    return;
                }
            }

            var rng = new Xoroshiro128Plus((ulong)DateTime.Now.Ticks);

            //Gearing applies to all players
            foreach (var controller in PlayerCharacterMasterController.instances)
            {
                //Get inventory, accommodating case where body doesn't exist yet
                var inv = controller.master.GetBody()?.inventory;
                if (inv != null)
                {
                    //Start by clearing existing inventory
                    for (var item = ItemIndex.Syringe; item < (ItemIndex)ItemCatalog.itemCount; item++)
                    {
                        inv.RemoveItem(item, int.MaxValue);
                    }

                    //Grant items of each rarity
                    for (int i = 0; i < whites; i++)
                    {
                        inv.GiveItem(PickupCatalog.GetPickupDef(rng.NextElementUniform(Run.instance.availableTier1DropList)).itemIndex);
                    }
                    for (int i = 0; i < greens; i++)
                    {
                        inv.GiveItem(PickupCatalog.GetPickupDef(rng.NextElementUniform(Run.instance.availableTier2DropList)).itemIndex);
                    }
                    for (int i = 0; i < reds; i++)
                    {
                        inv.GiveItem(PickupCatalog.GetPickupDef(rng.NextElementUniform(Run.instance.availableTier3DropList)).itemIndex);
                    }
                }
            }
        }
Ejemplo n.º 30
0
    private static int GetFramesForward(ulong s0, ulong s1, ulong n0, ulong n1, int loop)
    {
        var rand = new Xoroshiro128Plus(s0, s1);

        for (int i = 0; i < loop; i++)
        {
            _ = rand.Next();
            if (rand.GetState() == (n0, n1))
            {
                return(i);
            }
        }
        return(-1);
    }