コード例 #1
0
ファイル: UIAMain.cs プロジェクト: DestroyedClone/PoseHelper
 private void BossGroup_DropRewards(On.RoR2.BossGroup.orig_DropRewards orig, BossGroup self)
 {
     if (self.dropPosition)
     {
         List <PickupIndex> list = Run.instance.availableTier2DropList;
         if (self.forceTier3Reward)
         {
             list = Run.instance.availableTier3DropList;
         }
         PickupIndex pickupIndex = self.rng.NextElementUniform <PickupIndex>(list);
         int         num         = 1 + self.bonusRewardCount;
         float       angle       = 360f / (float)num;
         Vector3     vector      = Quaternion.AngleAxis((float)UnityEngine.Random.Range(0, 360), Vector3.up) * (Vector3.up * 40f + Vector3.forward * 5f);
         Quaternion  rotation    = Quaternion.AngleAxis(angle, Vector3.up);
         int         i           = 0;
         while (i < num)
         {
             PickupIndex pickupIndex2 = pickupIndex;
             if (self.bossDrops.Count > 0 && self.rng.nextNormalizedFloat <= self.bossDropChance)
             {
                 pickupIndex2 = self.rng.NextElementUniform <PickupIndex>(self.bossDrops);
                 self.bossDrops.Remove(pickupIndex2);
             }
             PickupDropletController.CreatePickupDroplet(pickupIndex2, self.dropPosition.position, vector);
             i++;
             vector = rotation * vector;
         }
     }
 }
コード例 #2
0
ファイル: Class1.cs プロジェクト: DestroyedClone/PoseHelper
        private void BossGroup_DropRewards(On.RoR2.BossGroup.orig_DropRewards orig, BossGroup self)
        {
            orig(self);
            var teleporter = TeleporterInteraction.instance;

            if (teleporter && self == teleporter.bossGroup)
            {
                SayMountainShrineAmount();
            }
        }
コード例 #3
0
            void DropRewards(On.RoR2.BossGroup.orig_DropRewards orig, BossGroup bossGroup)
            {
                System.Reflection.FieldInfo info     = typeof(BossGroup).GetField("bossDrops", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                ICollection        collection        = info.GetValue(bossGroup) as ICollection;
                List <PickupIndex> bossDrops         = new List <PickupIndex>();
                List <PickupIndex> bossDropsAdjusted = new List <PickupIndex>();

                foreach (object bossDrop in collection)
                {
                    PickupIndex pickupIndex = (PickupIndex)bossDrop;
                    bossDrops.Add(pickupIndex);
                    if (PickupCatalog.GetPickupDef(pickupIndex).itemIndex != ItemIndex.None && playerItems.Contains(pickupIndex))
                    {
                        bossDropsAdjusted.Add(pickupIndex);
                    }
                }
                int normalCount = Run.instance.availableTier2DropList.Count;

                if (bossGroup.forceTier3Reward)
                {
                    normalCount = Run.instance.availableTier3DropList.Count;
                }
                if (normalCount != 0 || bossDropsAdjusted.Count != 0)
                {
                    float bossDropChanceOld = bossGroup.bossDropChance;
                    if (normalCount == 0)
                    {
                        DropList.SetDropLists(new List <PickupIndex>(), new List <PickupIndex>(), new List <PickupIndex>(), new List <PickupIndex>());
                        bossGroup.bossDropChance = 1;
                    }
                    else if (bossDropsAdjusted.Count == 0)
                    {
                        bossGroup.bossDropChance = 0;
                    }
                    info.SetValue(bossGroup, bossDropsAdjusted);
                    orig(bossGroup);
                    info.SetValue(bossGroup, bossDrops);
                    bossGroup.bossDropChance = bossDropChanceOld;
                    if (normalCount == 0)
                    {
                        DropList.RevertDropLists();
                    }
                }
            }
コード例 #4
0
 private static void BossGroup_DropRewards(On.RoR2.BossGroup.orig_DropRewards orig, BossGroup self)
 {
     ItemDropAPI.BossDropParticipatingPlayerCount = BossItems;
     orig(self);
 }
コード例 #5
0
        private void BossGroup_DropRewards(On.RoR2.BossGroup.orig_DropRewards orig, BossGroup self)
        {
            if (Run.instance.participatingPlayerCount > 0 && self.dropPosition)
            {
                Stack <PickupIndex> itemDrops = new Stack <PickupIndex>();                                                                                  //one entry per item to be dropped.
                int baseDropCount             = (1 + self.bonusRewardCount) * (self.scaleRewardsByPlayerCount ? Run.instance.participatingPlayerCount : 1); //base drop count

                //Add items to the drop table;

                PickupIndex t1, t2, t3, tboss;
                t1 = self.rng.NextElementUniform <PickupIndex>(Run.instance.availableTier1DropList);
                t2 = self.rng.NextElementUniform <PickupIndex>(Run.instance.availableTier2DropList);
                t3 = self.rng.NextElementUniform <PickupIndex>(Run.instance.availableTier3DropList);
                if (self.bossDrops.Count > 0)   //Boss drops not guaranteed.
                {
                    tboss = self.rng.NextElementUniform <PickupIndex>(self.bossDrops);
                }
                else
                {
                    tboss = t2;
                }

#if DEBUG
                Logger.LogWarning($"TELEPDROP::BossGroup..()| t1.Value: {t1.pickupDef.nameToken}");
                Logger.LogWarning($"TELEPDROP::BossGroup..()| t2.Value: {t2.pickupDef.nameToken}");
                Logger.LogWarning($"TELEPDROP::BossGroup..()| t3.Value: {t3.pickupDef.nameToken}");
                Logger.LogWarning($"TELEPDROP::BossGroup..()| tboss.Value: {tboss.pickupDef.nameToken}");
#endif

                if (TeleporterConfig.DropUniformity)    //only one item type
                {
#if DEBUG
                    Logger.LogWarning($"TELEPDROP::BossGroup..()| Using DropUniformity");
#endif
                    PickupIndex itemPI;
                    int         mult = 0;
                    switch (GetWeightedChance(WeightedTiers))
                    {
                    case ItemTier.Tier1:
                        itemPI = t1;
                        mult   = TeleporterConfig.Tier1DropMultiplier;
                        break;

                    case ItemTier.Tier2:
                        itemPI = t2;
                        mult   = TeleporterConfig.Tier2DropMultiplier;
                        break;

                    case ItemTier.Tier3:
                        itemPI = t3;
                        mult   = TeleporterConfig.Tier3DropMultiplier;
                        break;

                    case ItemTier.Boss:
                        itemPI = tboss;
                        mult   = TeleporterConfig.TierBossDropMultiplier;
                        break;

                    default:
                        itemPI = t2;
                        mult   = TeleporterConfig.Tier2DropMultiplier;
                        break;
                    }


                    for (int i = 0; i < baseDropCount * mult; i++)
                    {
                        itemDrops.Push(itemPI);
                    }
                }
                else
                {
#if DEBUG
                    Logger.LogWarning($"TELEPDROP::BossGroup...()| Not-using DropUniformity.");
#endif
                    for (int i = 0; i < baseDropCount; i++)
                    {
                        PickupIndex itemPI;
                        int         mult = 0;
                        switch (GetWeightedChance(WeightedTiers))
                        {
                        case ItemTier.Tier1:
                            itemPI = t1;
                            mult   = TeleporterConfig.Tier1DropMultiplier;
                            break;

                        case ItemTier.Tier2:
                            itemPI = t2;
                            mult   = TeleporterConfig.Tier2DropMultiplier;
                            break;

                        case ItemTier.Tier3:
                            itemPI = t3;
                            mult   = TeleporterConfig.Tier3DropMultiplier;
                            break;

                        case ItemTier.Boss:
                            itemPI = tboss;
                            mult   = TeleporterConfig.TierBossDropMultiplier;
                            break;

                        default:
                            itemPI = t2;
                            mult   = TeleporterConfig.Tier2DropMultiplier;
                            break;
                        }
                        for (int j = 0; j < mult; j++)
                        {
                            itemDrops.Push(itemPI);
                        }
                    }
                }

                float      angle    = 360f / (float)itemDrops.Count;
                Vector3    vector   = Quaternion.AngleAxis((float)UnityEngine.Random.Range(0, 360), Vector3.up) * (Vector3.up * 40f + Vector3.forward * 5f);
                Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.up);

                while (itemDrops.Count > 0)
                {
#if DEBUG
                    Logger.LogWarning($"TELEPDROP::BossGroup...()| Item to spawn: {itemDrops.Peek().pickupDef.nameToken}");
#endif
                    PickupDropletController.CreatePickupDroplet(itemDrops.Pop(), self.dropPosition.position, vector);
                    vector = rotation * vector;
                }
            }
        }
コード例 #6
0
        private void BossGroupDropRewards(On.RoR2.BossGroup.orig_DropRewards orig, BossGroup self)
        {
            //NOTE: We're overwriting the behavior entirely here, so no need to call back to orig

            //If no players, nothing to do
            int participatingPlayerCount = R2API.ItemDropAPI.BossDropParticipatingPlayerCount ?? Run.instance.participatingPlayerCount;

            if (participatingPlayerCount == 0)
            {
                return;
            }

            //More items for more players and for more mountain shrines
            int itemCount = (1 + self.bonusRewardCount);

            if (self.scaleRewardsByPlayerCount)
            {
                itemCount *= participatingPlayerCount;
            }

            for (int i = 0; i < itemCount; i++)
            {
                var rng = new Xoroshiro128Plus(Run.instance.stageRng.nextUlong);

                //Create spawn card for a free green-item shop
                var spawnCard  = Resources.Load <InteractableSpawnCard>("SpawnCards/InteractableSpawnCard/iscTripleShopLarge");
                var controller = spawnCard.prefab.GetComponent <MultiShopController>();

                //Slowly increasing chance of red items, capping at 20%
                var maxChance      = RaincoatConfig.BossDropRedsMaxChance.Value;
                var chancePerStage = RaincoatConfig.BossDropRedsChancePerStage.Value;
                var minStage       = RaincoatConfig.BossDropRedsMinStage.Value;
                var redChance      = Mathf.Min(maxChance, chancePerStage * (Run.instance.stageClearCount - minStage - 1));
                controller.itemTier = rng.nextNormalizedFloat < redChance || self.forceTier3Reward ? ItemTier.Tier3 : ItemTier.Tier2;

                //Determine where to place the shop (randomly relative to the drop position)
                var placementRule = new DirectorPlacementRule();
                placementRule.maxDistance   = 60f;
                placementRule.minDistance   = 10f;
                placementRule.placementMode = DirectorPlacementRule.PlacementMode.Approximate;
                placementRule.position      = self.dropPosition.position;
                placementRule.spawnOnTarget = self.dropPosition;

                var spawnRequest = new DirectorSpawnRequest(spawnCard, placementRule, rng);

                var oldBaseCost = controller.baseCost;
                controller.baseCost = 0;
                var spawnedObj = DirectorCore.instance.TrySpawnObject(spawnRequest);
                controller.baseCost = oldBaseCost;
                if (spawnedObj != null)
                {
                    //Replace first terminal with special boss item, if applicable
                    var bossDrops = self.GetFieldValue <List <PickupIndex> >("bossDrops");
                    if (bossDrops?.Count > 0 && rng.nextNormalizedFloat <= self.bossDropChance)
                    {
                        controller = spawnedObj.GetComponent <MultiShopController>();
                        var terminal = controller.GetFieldValue <GameObject[]>("terminalGameObjects")[0];
                        var behavior = terminal.GetComponent <ShopTerminalBehavior>();
                        behavior.SetPickupIndex(rng.NextElementUniform(bossDrops));
                    }
                }
            }
        }
コード例 #7
0
 private static void BossGroup_DropRewards(On.RoR2.BossGroup.orig_DropRewards orig, BossGroup group)
 {
     group.scaleRewardsByPlayerCount = false;
     group.bonusRewardCount         += _bossItems - 1; // Rewards are 1 + bonusRewardCount, so we subtract one
     orig(group);
 }