コード例 #1
0
        public static ShrineCanvas addCanvasToShrine(ShrineChanceBehavior shrine)
        {
            ShrineCanvas shrineCanvas = shrine.gameObject.AddComponent <ShrineCanvas>();

            shrineCanvas.self = shrine;
            shrineCanvas.Init();
            return(shrineCanvas);
        }
コード例 #2
0
        public ShrineChanceData(ShrineChanceBehavior shrine)
        {
            var purchaseInteraction = shrine.GetComponent <PurchaseInteraction>();

            transform = new SerializableTransform(shrine.transform);
            successfulPurchaseCount = shrine.GetFieldValue <int>("successfulPurchaseCount");
            cost      = purchaseInteraction.cost;
            available = purchaseInteraction.available;
        }
コード例 #3
0
        private void CalculateSuccess(ShrineChanceBehavior instance)
        {
            var p = Convert.ToSingle(PercentageConfig.Value);

            // Turn mod off if value has no effect
            if (p == 100)
            {
                return;
            }

            ++count;
            var success    = instance.GetFieldValue <int>("successfulPurchaseCount");
            var fail       = count - success;
            var percentage = p / 100f;
            var chance     = instance.failureWeight / (instance.failureWeight + 12.2f) * 100;
            var chancemsg  = Mathf.Round(chance).ToString();

            if (p < 100 && instance.maxPurchaseCount < 3)
            {
                var newfailureWeight = 10.1f * Mathf.Pow(percentage, fail);

                if (MessageConfig.Value)
                {
                    if (instance.failureWeight != newfailureWeight)
                    {
                        sendChatMessage("<color=#e7543a>Lose! </color><color=#8296ae>with a </color><color=#ffffff>" + chancemsg + "% </color><color=#8296ae>chance to fail.</color>");
                    }
                    else
                    {
                        sendChatMessage("<color=#efeb1c>Win! </color><color=#8296ae>with a </color><color=#ffffff>" + chancemsg + "% </color><color=#8296ae>chance to fail.</color>");
                    }
                }

                instance.failureWeight = newfailureWeight;
            }
            // InfiniteChance support
            else
            {
                if (MessageConfig.Value)
                {
                    sendChatMessage("<color=#efeb1c>" + chancemsg + "% </color><color=#8296ae>chance to fail.</color>");
                }

                instance.failureWeight *= percentage;
            }

            if (success >= instance.maxPurchaseCount)
            {
                count = 0;
            }
        }
コード例 #4
0
        /*
         *  This will update the subset odds for the interactables that utilize ShrineChanceBehavior.
         */
        public static void UpdateShrineTierOdds(DirectorCard directorCard, string interactableName)
        {
            if (ShrineInteractables.Contains(interactableName))
            {
                ShrineChanceBehavior shrineBehavior = directorCard.spawnCard.prefab.GetComponent <ShrineChanceBehavior>();
                if (!ShrineTierOdds.ContainsKey(interactableName))
                {
                    ShrineTierOdds.Add(interactableName, new List <float>());
                    ShrineTierOdds[interactableName].Add(shrineBehavior.tier1Weight);
                    ShrineTierOdds[interactableName].Add(shrineBehavior.tier2Weight);
                    ShrineTierOdds[interactableName].Add(shrineBehavior.tier3Weight);
                    ShrineTierOdds[interactableName].Add(shrineBehavior.equipmentWeight);
                }

                if (ShrineTierOdds.ContainsKey(interactableName))
                {
                    shrineBehavior.tier1Weight     = ShrineTierOdds[interactableName][0];
                    shrineBehavior.tier2Weight     = ShrineTierOdds[interactableName][1];
                    shrineBehavior.tier3Weight     = ShrineTierOdds[interactableName][2];
                    shrineBehavior.equipmentWeight = ShrineTierOdds[interactableName][3];
                }

                if (!ItemDropAPI.PlayerInteractables.TiersPresent[InteractableCalculator.DropType.tier1])
                {
                    shrineBehavior.tier1Weight = 0;
                }
                if (!ItemDropAPI.PlayerInteractables.TiersPresent[InteractableCalculator.DropType.tier2])
                {
                    shrineBehavior.tier2Weight = 0;
                }
                if (!ItemDropAPI.PlayerInteractables.TiersPresent[InteractableCalculator.DropType.tier3])
                {
                    shrineBehavior.tier3Weight = 0;
                }
                if (!ItemDropAPI.PlayerInteractables.TiersPresent[InteractableCalculator.DropType.equipment])
                {
                    shrineBehavior.equipmentWeight = 0;
                }
            }
        }
コード例 #5
0
            static public void UpdateShrineTierOdds(DirectorCard directorCard, string interactableName)
            {
                if (InteractableCalculator.shrineInteractables.Contains(interactableName))
                {
                    ShrineChanceBehavior shrineBehavior = directorCard.spawnCard.prefab.GetComponent <ShrineChanceBehavior>();
                    if (!ItemDropAPIFixes.playerInteractables.shrineTierOdds.ContainsKey(interactableName))
                    {
                        ItemDropAPIFixes.playerInteractables.shrineTierOdds.Add(interactableName, new List <float>());
                        ItemDropAPIFixes.playerInteractables.shrineTierOdds[interactableName].Add(shrineBehavior.tier1Weight);
                        ItemDropAPIFixes.playerInteractables.shrineTierOdds[interactableName].Add(shrineBehavior.tier2Weight);
                        ItemDropAPIFixes.playerInteractables.shrineTierOdds[interactableName].Add(shrineBehavior.tier3Weight);
                        ItemDropAPIFixes.playerInteractables.shrineTierOdds[interactableName].Add(shrineBehavior.equipmentWeight);
                    }

                    if (ItemDropAPIFixes.playerInteractables.shrineTierOdds.ContainsKey(interactableName))
                    {
                        shrineBehavior.tier1Weight     = ItemDropAPIFixes.playerInteractables.shrineTierOdds[interactableName][0];
                        shrineBehavior.tier2Weight     = ItemDropAPIFixes.playerInteractables.shrineTierOdds[interactableName][1];
                        shrineBehavior.tier3Weight     = ItemDropAPIFixes.playerInteractables.shrineTierOdds[interactableName][2];
                        shrineBehavior.equipmentWeight = ItemDropAPIFixes.playerInteractables.shrineTierOdds[interactableName][3];
                    }

                    if (!ItemDropAPIFixes.playerInteractables.tiersPresent["tier1"])
                    {
                        shrineBehavior.tier1Weight = 0;
                    }
                    if (!ItemDropAPIFixes.playerInteractables.tiersPresent["tier2"])
                    {
                        shrineBehavior.tier2Weight = 0;
                    }
                    if (!ItemDropAPIFixes.playerInteractables.tiersPresent["tier3"])
                    {
                        shrineBehavior.tier3Weight = 0;
                    }
                    if (!ItemDropAPIFixes.playerInteractables.tiersPresent["equipment"])
                    {
                        shrineBehavior.equipmentWeight = 0;
                    }
                }
            }
コード例 #6
0
 void AddShrineStack(On.RoR2.ShrineChanceBehavior.orig_AddShrineStack orig, ShrineChanceBehavior shrineChangeBehavior, Interactor interactor)
 {
     DropList.SetDropLists(RoR2.Run.instance.availableTier1DropList, RoR2.Run.instance.availableTier2DropList, RoR2.Run.instance.availableTier3DropList, RoR2.Run.instance.availableEquipmentDropList);
     orig(shrineChangeBehavior, interactor);
     DropList.RevertDropLists();
 }
コード例 #7
0
        //Chance Shrine
        private static void ShrineChanceBehavior_AddShrineStack(On.RoR2.ShrineChanceBehavior.orig_AddShrineStack orig, ShrineChanceBehavior self, Interactor activator)
        {
            orig(self, activator);
            var characterBody = activator.GetComponent <CharacterBody>();

            if (characterBody)
            {
                var inv = characterBody.inventory;
                if (inv)
                {
                    if (inv.GetItemCount(ExtraShrineRollItemIndex) > 0 && Util.CheckRoll(ItemProcChance * inv.GetItemCount(ExtraShrineRollItemIndex), characterBody.master))
                    {
                        Xoroshiro128Plus rng    = new Xoroshiro128Plus(Run.instance.treasureRng.nextUlong);
                        PickupIndex      none   = PickupIndex.none;
                        PickupIndex      value  = rng.NextElementUniform <PickupIndex>(Run.instance.availableTier1DropList);
                        PickupIndex      value2 = rng.NextElementUniform <PickupIndex>(Run.instance.availableTier2DropList);
                        PickupIndex      value3 = rng.NextElementUniform <PickupIndex>(Run.instance.availableTier3DropList);
                        PickupIndex      value4 = rng.NextElementUniform <PickupIndex>(Run.instance.availableEquipmentDropList);
                        WeightedSelection <PickupIndex> weightedSelection = new WeightedSelection <PickupIndex>(8);
                        weightedSelection.AddChoice(none, self.failureWeight);
                        weightedSelection.AddChoice(value, self.tier1Weight);
                        weightedSelection.AddChoice(value2, self.tier2Weight);
                        weightedSelection.AddChoice(value3, self.tier3Weight);
                        weightedSelection.AddChoice(value4, self.equipmentWeight);
                        PickupIndex pickupIndex = weightedSelection.Evaluate(rng.nextNormalizedFloat);
                        bool        flag        = pickupIndex == PickupIndex.none;
                        if (flag)
                        {
                            Chat.AddMessage("<color=\"green\">Lucky Default Sphere <style=cShrine>has rolled the shrine an additional time for:</style><color=\"white\"> Nothing.");
                        }
                        else
                        {
                            Chat.AddMessage($"<color=\"green\">Lucky Default Sphere <style=cShrine>has rolled the shrine an additional time for:</style><color=\"white\"> {Language.GetString(PickupCatalog.GetPickupDef(pickupIndex).nameToken)}");
                            PickupDropletController.CreatePickupDroplet(pickupIndex, self.dropletOrigin.position, self.dropletOrigin.forward * 20f);
                        }
                    }
                }
            }
        }