//override because i dunno IL
        private void DuplicateDrops(On.RoR2.ChestBehavior.orig_ItemDrop orig, ChestBehavior self)
        {
            if (self.tier3Chance != 1)
            {
                orig(self);
                return;
            }
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.ChestBehavior::ItemDrop()' called on client");
                return;
            }
            if (self.dropPickup == PickupIndex.none)
            {
                return;
            }

            int        participatingPlayerCount = Run.instance.participatingPlayerCount != 0 ? Run.instance.participatingPlayerCount : 1;
            float      angle         = 360f / participatingPlayerCount;
            var        chestVelocity = Vector3.up * self.dropUpVelocityStrength + self.dropTransform.forward * self.dropForwardVelocityStrength;
            Quaternion rotation      = Quaternion.AngleAxis(angle, Vector3.up);
            int        i             = 0;

            while (i < participatingPlayerCount)
            {
                PickupDropletController.CreatePickupDroplet(self.dropPickup, self.dropTransform.position + Vector3.up * 1.5f, chestVelocity);
                i++;
                chestVelocity = rotation * chestVelocity;
            }
            self.dropPickup = PickupIndex.none;
        }
 void Start()
 {
     audioSource   = GetComponent <AudioSource>();
     questActive   = questManager.GetComponent <QuestManager>();
     chestBehavior = chestObjective.GetComponent <ChestBehavior>();
     discovery     = DiscoveryObjective.GetComponent <DiscoveryManager>();
 }
Beispiel #3
0
        private void ChestBehavior_Open(On.RoR2.ChestBehavior.orig_Open orig, ChestBehavior self)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.ChestBehavior::Open()' called on client");
                return;
            }

            if (self.gameObject.name.StartsWith("LunarChest"))
            {
                orig(self);
                return;
            }

            FieldInfo dropPickup      = self.GetType().GetField("dropPickup", BindingFlags.Instance | BindingFlags.NonPublic);
            var       dropPickupValue = (PickupIndex)dropPickup.GetValue(self);

            if (dropPickupValue == PickupIndex.none)
            {
                self.ItemDrop();
            }
            else
            {
                orig(self);
            }
        }
Beispiel #4
0
        private void DuplicateDropChest(On.RoR2.ChestBehavior.orig_ItemDrop orig, ChestBehavior self)
        {
            orig(self);
            if (GetCountFromPlayers(ItemDef, true) > 0)
            {
                //chestPickup = Reflection.GetFieldValue<PickupIndex>(self, "dropPickup");
                chestPickup = dropTable.GenerateDrop(treasureRng);
                var HighestChance = GetCountHighestFromPlayers(ItemDef, true);                   //Doesn't work well across multiple players, but I don't really want to make clover but lunar and it f*****g kills you dont know?
                var DupeChance    = dupeChanceInitial + ((HighestChance - 1) * dupeChanceStack); //Also I do not know how to get the cb that interacted and opened the chest
#if DEBUG
                Chat.AddMessage("Turbo Edition: " + ItemName + " duplication taking place, check logs.");
                TurboEdition._logger.LogWarning(ItemName + " duplication chance of: " + DupeChance + ", duplicating pickup index: " + chestPickup);
#endif
                if (Util.CheckRoll(DupeChance)) //hopefully this rolls only the chance WITHOUT luck
                {
                    if (chestPickup == PickupIndex.none)
                    {
#if DEBUG
                        Chat.AddMessage("Turbo Edition: " + ItemName + " Chest didn't have a pickup, how did this happen?");
#endif
                        return;
                    }
#if DEBUG
                    Chat.AddMessage("Turbo Edition: " + ItemName + " Duplicated a chest drop.");
#endif
                    PickupDropletController.CreatePickupDroplet(chestPickup, self.dropTransform.position + Vector3.up * 1.5f, Vector3.up * self.dropUpVelocityStrength + self.dropTransform.forward * self.dropForwardVelocityStrength);
                    //Reflection.SetFieldValue(self, "dropPickup", PickupIndex.none); //I actually dont know what or why is this here?
                }
            }
        }
        /// <summary>
        /// Adds text labels for various interactables to a <see cref="PingIndicator"/>
        /// </summary>
        /// <param name="pingIndicator">Target <see cref="PingIndicator"/> that should have the text added</param>
        private static void AddLootText(RoR2.UI.PingIndicator pingIndicator)
        {
            const string         textStart    = "<size=70%>\n";
            string               price        = GetPrice(pingIndicator.pingTarget);
            ShopTerminalBehavior shopTerminal = pingIndicator.pingTarget.GetComponent <ShopTerminalBehavior>();

            if (shopTerminal && _config.ShowShopText.Value)
            {
                string      text        = textStart;
                PickupIndex pickupIndex = shopTerminal.CurrentPickupIndex();
                PickupDef   pickup      = PickupCatalog.GetPickupDef(pickupIndex);
                text += shopTerminal.pickupIndexIsHidden
                    ? "?"
                    : $"{Language.GetString(pickup.nameToken)}";
                pingIndicator.pingText.text += $"{text} ({price})";
                return;
            }

            GenericPickupController pickupController = pingIndicator.pingTarget.GetComponent <GenericPickupController>();

            if (pickupController && _config.ShowPickupText.Value)
            {
                PickupDef pickup = PickupCatalog.GetPickupDef(pickupController.pickupIndex);
                pingIndicator.pingText.text += $"{textStart}{Language.GetString(pickup.nameToken)}";
            }

            ChestBehavior chest = pingIndicator.pingTarget.GetComponent <ChestBehavior>();

            if (chest && _config.ShowChestText.Value)
            {
                pingIndicator.pingText.text += $"{textStart}{Util.GetBestBodyName(pingIndicator.pingTarget)} ({price})";
                return;
            }

            string name = "";

            PurchaseInteraction purchaseInteraction = pingIndicator.pingTarget.GetComponent <PurchaseInteraction>();

            if (purchaseInteraction)
            {
                name = Language.GetString(purchaseInteraction.displayNameToken);
            }

            // Drones
            SummonMasterBehavior summonMaster = pingIndicator.pingTarget.GetComponent <SummonMasterBehavior>();

            if (summonMaster && _config.ShowDroneText.Value)
            {
                pingIndicator.pingText.text += $"{textStart}{name} ({price})";
                return;
            }

            if (_config.ShowShrineText.Value)
            {
                pingIndicator.pingText.text += $"{textStart}{name}";
            }
        }
Beispiel #6
0
        public void Check(On.RoR2.ChestBehavior.orig_Open orig, ChestBehavior self)
        {
            if (self && self.tier3Chance >= 1f)
            {
                base.Grant();
            }

            orig(self);
        }
Beispiel #7
0
        private void On_CBOpen(On.RoR2.ChestBehavior.orig_Open orig, ChestBehavior self)
        {
            orig(self);
            var dot = self.GetComponentInParent <CaptainsBroochDroppod>();

            if (dot)
            {
                dot.ServerUnlaunch();
            }
        }
Beispiel #8
0
        /*
         *  This will update the subset odds for the interactables that utilize ChestBehavior.
         */
        public static void UpdateChestTierOdds(SpawnCard spawnCard, string interactableName)
        {
            if (ChestInteractables.Contains(interactableName))
            {
                ChestBehavior chestBehavior = spawnCard.prefab.GetComponent <ChestBehavior>();
                if (!ChestTierOdds.ContainsKey(interactableName))
                {
                    ChestTierOdds.Add(interactableName, new List <float>());
                    ChestTierOdds[interactableName].Add(chestBehavior.tier1Chance);
                    ChestTierOdds[interactableName].Add(chestBehavior.tier2Chance);
                    ChestTierOdds[interactableName].Add(chestBehavior.tier3Chance);
                }

                if (ChestTierOdds.ContainsKey(interactableName))
                {
                    chestBehavior.tier1Chance = ChestTierOdds[interactableName][0];
                    chestBehavior.tier2Chance = ChestTierOdds[interactableName][1];
                    chestBehavior.tier3Chance = ChestTierOdds[interactableName][2];
                }

                if (ItemDropAPI.PlayerInteractables.SubsetTiersPresent.ContainsKey(interactableName))
                {
                    //  This is for damage, healing and utility chests
                    if (!ItemDropAPI.PlayerInteractables.SubsetTiersPresent[interactableName][InteractableCalculator.DropType.tier1])
                    {
                        chestBehavior.tier1Chance = 0;
                    }
                    if (!ItemDropAPI.PlayerInteractables.SubsetTiersPresent[interactableName][InteractableCalculator.DropType.tier2])
                    {
                        chestBehavior.tier2Chance = 0;
                    }
                    if (!ItemDropAPI.PlayerInteractables.SubsetTiersPresent[interactableName][InteractableCalculator.DropType.tier3])
                    {
                        chestBehavior.tier3Chance = 0;
                    }
                }
                else
                {
                    //  This is for everything else
                    if (!ItemDropAPI.PlayerInteractables.TiersPresent[InteractableCalculator.DropType.tier1])
                    {
                        chestBehavior.tier1Chance = 0;
                    }
                    if (!ItemDropAPI.PlayerInteractables.TiersPresent[InteractableCalculator.DropType.tier2])
                    {
                        chestBehavior.tier2Chance = 0;
                    }
                    if (!ItemDropAPI.PlayerInteractables.TiersPresent[InteractableCalculator.DropType.tier3])
                    {
                        chestBehavior.tier3Chance = 0;
                    }
                }
            }
        }
Beispiel #9
0
        IEnumerator WaitForStart(ChestBehavior chest)
        {
            yield return(null);

            if (opened)
            {
                chest.Open();
                chest.GetComponent <PurchaseInteraction>().SetAvailable(false);
            }
            chest.transform.position = transform.position.GetVector3();
        }
Beispiel #10
0
        private PickupIndex RollVoteItem(ChestBehavior self)
        {
            WeightedSelection <List <PickupIndex> > weightedSelection = new WeightedSelection <List <PickupIndex> >(8);

            weightedSelection.AddChoice(Run.instance.availableTier1DropList, self.tier1Chance);
            weightedSelection.AddChoice(Run.instance.availableTier2DropList, self.tier2Chance);
            weightedSelection.AddChoice(Run.instance.availableTier3DropList, self.tier3Chance);
            weightedSelection.AddChoice(Run.instance.availableLunarDropList, self.lunarChance);
            List <PickupIndex> dropList = weightedSelection.Evaluate(Run.instance.treasureRng.nextNormalizedFloat);

            return(dropList[Run.instance.treasureRng.RangeInt(0, dropList.Count)]);
        }
            static public void UpdateChestTierOdds(SpawnCard spawnCard, string interactableName)
            {
                if (InteractableCalculator.chestInteractables.Contains(interactableName))
                {
                    ChestBehavior chestBehavior = spawnCard.prefab.GetComponent <ChestBehavior>();
                    if (!ItemDropAPIFixes.playerInteractables.chestTierOdds.ContainsKey(interactableName))
                    {
                        ItemDropAPIFixes.playerInteractables.chestTierOdds.Add(interactableName, new List <float>());
                        ItemDropAPIFixes.playerInteractables.chestTierOdds[interactableName].Add(chestBehavior.tier1Chance);
                        ItemDropAPIFixes.playerInteractables.chestTierOdds[interactableName].Add(chestBehavior.tier2Chance);
                        ItemDropAPIFixes.playerInteractables.chestTierOdds[interactableName].Add(chestBehavior.tier3Chance);
                    }

                    if (ItemDropAPIFixes.playerInteractables.chestTierOdds.ContainsKey(interactableName))
                    {
                        chestBehavior.tier1Chance = ItemDropAPIFixes.playerInteractables.chestTierOdds[interactableName][0];
                        chestBehavior.tier2Chance = ItemDropAPIFixes.playerInteractables.chestTierOdds[interactableName][1];
                        chestBehavior.tier3Chance = ItemDropAPIFixes.playerInteractables.chestTierOdds[interactableName][2];
                    }
                    if (ItemDropAPIFixes.playerInteractables.subsetTiersPresent.ContainsKey(interactableName))
                    {
                        if (!ItemDropAPIFixes.playerInteractables.subsetTiersPresent[interactableName]["tier1"])
                        {
                            chestBehavior.tier1Chance = 0;
                        }
                        if (!ItemDropAPIFixes.playerInteractables.subsetTiersPresent[interactableName]["tier2"])
                        {
                            chestBehavior.tier2Chance = 0;
                        }
                        if (!ItemDropAPIFixes.playerInteractables.subsetTiersPresent[interactableName]["tier3"])
                        {
                            chestBehavior.tier3Chance = 0;
                        }
                    }
                    else
                    {
                        if (!ItemDropAPIFixes.playerInteractables.tiersPresent["tier1"])
                        {
                            chestBehavior.tier1Chance = 0;
                        }
                        if (!ItemDropAPIFixes.playerInteractables.tiersPresent["tier2"])
                        {
                            chestBehavior.tier2Chance = 0;
                        }
                        if (!ItemDropAPIFixes.playerInteractables.tiersPresent["tier3"])
                        {
                            chestBehavior.tier3Chance = 0;
                        }
                    }
                }
            }
    private void action()
    {
        if (playerInputs.action)
        {
            // If near ladder and have enough gold, win.
            if (Vector2.Distance(GameObject.FindGameObjectWithTag("Ladder").transform.position, transform.position) <= searchRadius)
            {
                if (gold >= 100)
                {
                    win();
                }
                else
                {
                    soundController.playErrorSound();
                }
                return;
            }

            // Otherwise if near closed chest, open it.
            ChestBehavior chestBehavior = findNearbyClosedChest();
            if (chestBehavior != null)
            {
                chestBehavior.Open();
                return;
            }

            // Otherwise, if near kindling, pick it up.
            KindlingBehavior kindlingBehavior = findNearbyUnlitKindling();
            if (kindlingBehavior != null)
            {
                // if (kindling == 0) {
                //     torchLightFg.intensity = startingFgIntensity;
                //     torchLightBg.intensity = startingBgIntensity;
                //     globalLight.intensity = startingGIntensity;
                //     material.color = startingColor;
                // }
                soundController.playPickupSound();
                kindling++;
                kindlingText.text = kindling.ToString();
                Destroy(kindlingBehavior.gameObject);

                return;
            }

            // Otherwise, if have kindling, drop it.
            if (kindling > 0)
            {
                dropKindling();
            }
        }
    }
Beispiel #13
0
        public void Update()
        {
            //This if statement checks if the player has currently pressed F2, and then proceeds into the statement:
            if (Input.GetKeyDown(KeyCode.F2))
            {
                var index  = PickupCatalog.FindPickupIndex(ItemIndex.Mushroom);
                var player = PlayerCharacterMasterController.instances[0];
                player.master.inventory.GiveEquipmentString(EquipmentIndex.Scanner.ToString());
                var trans = player.master.GetBodyObject().transform;
                PickupDropletController.CreatePickupDroplet(index, trans.position, trans.forward * 20f);

                var index2 = PickupCatalog.FindPickupIndex(ItemIndex.Hoof);
                PickupDropletController.CreatePickupDroplet(index2, trans.position, trans.right * 20f);
            }

            if (Input.GetKeyDown(KeyCode.F3))
            {
                showAugmentMenu = !showAugmentMenu;
            }

            if (Input.GetKeyDown(KeyCode.F4))
            {
                var trans = PlayerCharacterMasterController.instances[0].master.GetBodyObject().transform;

                var index = PickupCatalog.FindPickupIndex(ItemIndex.TreasureCache);
                PickupDropletController.CreatePickupDroplet(index, trans.position, trans.forward * 40f);

                Xoroshiro128Plus xoroshiro128Plus = new Xoroshiro128Plus((ulong)12);
                GameObject       gameObject3      = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(Resources.Load <SpawnCard>("SpawnCards/InteractableSpawnCard/iscLockbox"), new DirectorPlacementRule
                {
                    placementMode = DirectorPlacementRule.PlacementMode.Direct,
                    position      = trans.position,
                }, xoroshiro128Plus));
                if (gameObject3)
                {
                    // ReSharper disable once Unity.PerformanceCriticalCodeInvocation
                    ChestBehavior component5 = gameObject3.GetComponent <ChestBehavior>();
                    if (component5)
                    {
                        component5.tier3Chance *= Mathf.Pow((float)10, 2f);
                    }
                }
            }

            if (Input.GetKeyDown(KeyCode.F5))
            {
                var scene = RoR2.Run.instance.nextStageScene;
                RoR2.Run.instance.AdvanceStage(scene);
            }
        }
Beispiel #14
0
        public ChestData(ChestBehavior chest)
        {
            var stateMachine        = chest.GetComponent <EntityStateMachine>();
            var purchaseInteraction = chest.GetComponent <PurchaseInteraction>();

            name      = chest.name.Replace("(Clone)", "");
            transform = new SerializableTransform(chest.transform);

            index       = chest.GetFieldValue <PickupIndex>("dropPickup").value;
            isEquipment = index >= (int)ItemIndex.Count;

            opened   = stateMachine.state.GetType().IsEquivalentTo(typeof(EntityStates.Barrel.Opened)) ? true : false;
            cost     = purchaseInteraction.cost;
            costType = (int)purchaseInteraction.costType;
        }
        private void ChestBehavior_Awake(On.RoR2.ChestBehavior.orig_Awake orig, ChestBehavior self)
        {
            orig(self);
            var mimicSpawnChance = GetMimicSpawnChance();
            var gameObject       = self.gameObject;

            if (Util.CheckRoll(mimicSpawnChance))
            {
                var component = gameObject.GetComponent <MimicComponent>();
                if (!component)
                {
                    component = gameObject.AddComponent <MimicComponent>();
                }
                component.heldItemIndex = PickupCatalog.GetPickupDef(self.dropPickup).itemIndex;
                self.Invoke("Open", 0);
            }
        }
Beispiel #16
0
        private void ChestBehavior_Open(On.RoR2.ChestBehavior.orig_Open orig, ChestBehavior self)
        {
            if (NetworkServer.active)
            {
                if (isCurrentStageBazaar())
                {
                    bool isCreatingDroplet = false;
                    if (!ModConfig.isShareSuiteLoaded || !ModConfig.isShareSuiteActive())
                    {
                        isCreatingDroplet = true;
                    }
                    else
                    {
                        if (ModConfig.ShareSuiteItemSharingEnabled.Value)
                        {
                            isCreatingDroplet = true;
                        }
                    }
                    if (isCreatingDroplet)
                    {
                        List <BazaarItem> bazaarItems = bazaar.GetBazaarItems();
                        for (int i = 0; i < bazaar.GetBazaarItemAmount(); i++)
                        {
                            if (bazaarItems[i].chestBehavior.Equals(self))
                            {
                                PickupDropletController.CreatePickupDroplet(bazaarItems[i].pickupIndex, self.transform.position + Vector3.up * 1.5f, Vector3.up * 20f + self.transform.forward * 2f);
                                bazaarItems[i].purchaseCount++;
                                if (bazaar.IsChestStillAvailable(bazaarItems[i]))
                                {
                                    self.GetComponent <PurchaseInteraction>().SetAvailable(true);
                                }

                                return;
                            }
                        }
                    }
                }
                ;
            }
            orig(self);
        }
Beispiel #17
0
            static bool Prefix(ChestBehavior __instance)
            {
                if (!NetworkServer.active)
                {
                    Debug.LogWarning("[Server] function 'System.Void RoR2.ChestBehavior::ItemDrop()' called on client");
                    return(false);
                }

                var dropPickup = new Traverse(__instance).Field <PickupIndex>("dropPickup");

                if (dropPickup.Value == PickupIndex.none)
                {
                    return(false);
                }

                for (int i = 0; i < ChestStacksInVar.Stacks; i++)
                {
                    PickupDropletController.CreatePickupDroplet(dropPickup.Value, __instance.transform.position + Vector3.up * 1.5f, Vector3.up * 20f + __instance.transform.forward * 2f);
                }

                dropPickup.Value = PickupIndex.none;

                return(false);
            }
            public static bool Prefix(ChestBehavior __instance)
            {
                if (!NetworkServer.active)
                {
                    return(false);
                }
                PickupIndex dropPickup = Traverse.Create(__instance).Field("dropPickup").GetValue <PickupIndex>();

                if (dropPickup == PickupIndex.none)
                {
                    return(false);
                }
                for (int i = 0; i < configDropCount.Value; i++)
                {
                    dropPickup = Traverse.Create(__instance).Field("dropPickup").GetValue <PickupIndex>();
                    PickupDropletController.CreatePickupDroplet(dropPickup, __instance.dropTransform.position + Vector3.up * 1.5f, Vector3.up * __instance.dropUpVelocityStrength + __instance.dropTransform.forward * __instance.dropForwardVelocityStrength);
                    if (configRandom.Value)
                    {
                        __instance.RollItem();
                    }
                }
                Traverse.Create(__instance).Field("dropPickup").SetValue(PickupIndex.none);
                return(false);
            }
 private void ChestBehavior_ItemDrop(On.RoR2.ChestBehavior.orig_ItemDrop orig, ChestBehavior self)
 {
     if (NetworkServer.active && self.dropPickup != PickupIndex.none)
     {
         var component = self.GetComponent <MysticsItemsOmarHackToolHackingManager>();
         if (component)
         {
             component.PlayFX(3f);
         }
     }
     orig(self);
 }
Beispiel #20
0
 private void ChestBehavior_PickFromList(On.RoR2.ChestBehavior.orig_PickFromList orig, ChestBehavior self, List <PickupIndex> dropList)
 {
     if (NetworkServer.active)
     {
         if (isCurrentStageBazaar())
         {
             foreach (BazaarItem bazaarItem in bazaar.GetBazaarItems())
             {
                 if (bazaarItem.chestBehavior == self)
                 {
                     List <PickupIndex> newList = new List <PickupIndex> {
                         bazaarItem.pickupIndex
                     };
                     orig(self, newList);
                     return;
                 }
             }
             if (bazaar.IsMoneyLunarPod(self.gameObject))
             {
                 List <PickupIndex> newList = new List <PickupIndex> {
                     PickupIndex.none
                 };
                 orig(self, newList);
                 return;
             }
         }
     }
     orig(self, dropList);
 }
Beispiel #21
0
        private void ChestBehavior_ItemDrop(On.RoR2.ChestBehavior.orig_ItemDrop orig, ChestBehavior self)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.ChestBehavior::ItemDrop()' called on client");
                return;
            }

            var chestName = self.gameObject.name.ToLower();

            if (chestName.StartsWith("lunarchest"))
            {
                orig(self);
                return;
            }

            FieldInfo dropPickup      = self.GetType().GetField("dropPickup", BindingFlags.Instance | BindingFlags.NonPublic);
            var       dropPickupValue = (PickupIndex)dropPickup.GetValue(self);

            if (dropPickupValue != PickupIndex.none)
            {
                if (!DropItems && (chestName.StartsWith("chest") || chestName.StartsWith("goldchest")))
                {
                    var pickupController = gameObject.GetComponent <GenericPickupController>();

                    if (pickupController == null)
                    {
                        pickupController = this.gameObject.AddComponent <GenericPickupController>();
                    }

                    var characterBody = LocalUserManager.GetFirstLocalUser().cachedBody;

                    characterBody.inventory.GiveItem(dropPickupValue.itemIndex, 1);

                    pickupController.GetType().GetMethod("SendPickupMessage", BindingFlags.Static | BindingFlags.NonPublic)
                    .Invoke(pickupController, new object[] { characterBody.inventory.GetComponent <CharacterMaster>(), dropPickupValue });

                    dropPickup.SetValue(self, PickupIndex.none);
                    return;
                }

                orig(self);
                return;
            }

            // Steal opening sound from timed chest without changing to a problematic state
            EntityStateMachine component = self.GetComponent <EntityStateMachine>();

            if (component)
            {
                component.SetNextState(EntityState.Instantiate(new SerializableEntityStateType(typeof(EntityStates.TimedChest.Opening))));
            }

            // Generate list of 3 random item indexes
            var randomItemList = new List <PickupIndex>();

            randomItemList.Add(RollVoteItem(self));
            randomItemList.Add(RollVoteItem(self));
            randomItemList.Add(RollVoteItem(self));

            // Create a new vote, by passing valid poll options and vote duration
            var vote = new Vote(new List <string>(new string[] { "1", "2", "3" }), VoteDuration);

            vote.StartEventHandler += (_, __) =>
            {
                var characterBody = LocalUserManager.GetFirstLocalUser().cachedBody;

                var notificationQueue = characterBody.gameObject.GetComponent <VoteNotificationQueue>();

                if (notificationQueue == null)
                {
                    notificationQueue = characterBody.gameObject.AddComponent <VoteNotificationQueue>();
                }

                notificationQueue.OnVoteStart(randomItemList, VoteDuration);

                // Notify the event in chat
                SendChatMessage(
                    string.Format("Vote for the next item! (1) {0} | (2) {1} | (3) {2}",
                                  Language.GetString(randomItemList[0].GetPickupNameToken()),
                                  Language.GetString(randomItemList[1].GetPickupNameToken()),
                                  Language.GetString(randomItemList[2].GetPickupNameToken())
                                  )
                    );
            };

            vote.EndEventHandler += (_, e) =>
            {
                var votedItemName = Language.GetString(randomItemList[e.VotedIndex].GetPickupNameToken());

                float totalVotesCount = 1f;
                int   winnerCount     = 1;

                if (e.VoteCounter.Keys.Count > 0)
                {
                    totalVotesCount = e.VoteCounter.Sum(el => el.Value);
                    winnerCount     = e.VoteCounter[(e.VotedIndex + 1).ToString()];
                }

                SendChatMessage(
                    string.Format(
                        "({0}) {1} won! ({2})",
                        e.VotedIndex + 1,
                        votedItemName,
                        (winnerCount / totalVotesCount).ToString("P1", CultureInfo.InvariantCulture).Replace(" %", "%")
                        )
                    );

                var votedItem = randomItemList[e.VotedIndex];

                dropPickup.SetValue(self, votedItem);
                self.Open();
            };

            VoteManager.AddVote(vote);
        }
Beispiel #22
0
 private bool IsScavBag(ChestBehavior chest)
 {
     return(chest.name.StartsWith("ScavBackpack"));
 }
Beispiel #23
0
        private void ChestBehavior_RollItem(On.RoR2.ChestBehavior.orig_RollItem orig, ChestBehavior self)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.ChestBehavior::RollItem()' called on client");
                return;
            }
            WeightedSelection <List <PickupIndex> > weightedSelection = new WeightedSelection <List <PickupIndex> >(8);

            weightedSelection.AddChoice(Run.instance.availableTier1DropList, self.tier1Chance);
            weightedSelection.AddChoice(Run.instance.availableTier2DropList, self.tier2Chance);
            weightedSelection.AddChoice(Run.instance.availableTier3DropList, self.tier3Chance);
            weightedSelection.AddChoice(Run.instance.availableLunarDropList, self.lunarChance);
            List <PickupIndex> dropList = weightedSelection.Evaluate(Run.instance.treasureRng.nextNormalizedFloat);

            if (self.gameObject.name.StartsWith("LunarChest"))
            {
                self.GetType().GetMethod("PickFromList", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(self, new object[] { dropList });
            }
        }
Beispiel #24
0
 public static void Track_ChestBehavior(On.RoR2.ChestBehavior.orig_Awake orig, ChestBehavior self)
 {
     orig(self);
     InstanceTracker.Add(self);
     if (!self.GetComponent <InstanceTrackerRemover>())
     {
         self.gameObject.AddComponent <InstanceTrackerRemover>().chestBehavior = self;
     }
 }
Beispiel #25
0
 private bool ShouldIgnoreChestBehaviour(ChestBehavior chest)
 {
     return(!chest || (IsLunarPod(chest) && !config.affectLunarPods.Value) || IsScavBag(chest));
 }
Beispiel #26
0
 private bool IsLunarPod(ChestBehavior chest)
 {
     return(chest.name.StartsWith("LunarChest") && chest.lunarChance == 1f);
 }
 private void ChestBehavior_Open(On.RoR2.ChestBehavior.orig_Open orig, ChestBehavior self)
 {
     throw new NotImplementedException();
 }
Beispiel #28
0
        private Composite CreateTree()
        {
            return(new PrioritySelector(

                       new Decorator(x => GameController.Game.IsPreGame == true, LoginBehavior.TryEnterGameFromLoginScreen(x => 3)),
                       new Decorator(x => TreeHelper.CanTickTown(), CommonBehavior.TownToHideout()),

                       new Decorator(x => TreeHelper.CanTickHideout(), new PrioritySelector(
                                         new Decorator(x => (DateTime.Now.Subtract(previousBreakTime) > breakInterval), new Action(delegate
            {
                previousBreakTime = DateTime.Now;
                var breakLength = new TimeSpan(hours: 0, minutes: MathHepler.Randomizer.Next(8, 15), seconds: 0);
                Thread.Sleep(breakLength);
                return RunStatus.Failure;
            }
                                                                                                                                   )),
                                         //new Inverter(CommonBehavior.CloseOpenPanels()),
                                         CommonBehavior.HandleDestroyItemPopup(),
                                         CharacterAbilityTrees.ActivateNecroAuras(),
                                         new Action(delegate
            {
                CommonBehavior.CouldNotFindValidPositionToExplore = false;
                WillBot.Me.enemies.LastKilledMonsterTime = DateTime.Now;
                return RunStatus.Failure;
            }),
                                         SellBehavior.SellItems(sellUnidCrItems: true),
                                         TownBehavior.IdentifyUniquesInPlayerInventory(),
                                         TownBehavior.Stashie(),
                                         //ChaosRecipeBehavior.ChaosRecipeHandler(),



                                         // TownBehavior.EnterBloodAquaducts())),
                                         MapPrepBehavior.GetOpenAndEnterMap())),
                       new Decorator(x => TreeHelper.CanTickDead(),
                                     AreaBehavior.DiedBehavior()),
                       new Decorator(x => TreeHelper.CanTickMap(),// !PlayerHelper.isPlayerDead(),
                                     new PrioritySelector(

                                         //new Inverter(CommonBehavior.CloseOpenPanels()),
                                         new Inverter(CommonBehavior.CloseOpenPanelsIfOpenPanels()),
                                         new Decorator(delegate
            {
                // if not killed a monster in the last x seconds -> exit map
                if (DateTime.Now.Subtract(WillBot.Me.enemies.LastKilledMonsterTime).TotalSeconds > 60)
                {
                    return true;
                }
                return false;
            },
                                                       CommonBehavior.OpenAndEnterTownPortal()
                                                       ),
                                         CharacterAbilityTrees.CreateNecroBuffTree(),
                                         new Decorator(ret => CommonBehavior.DoCombat(), NecroCombat.NecroCombatComposite()),
                                         LevelGemsBehavior.LevelGems(),
                                         LootBehavior.BuildLootComposite(),
                                         ChestBehavior.DoOpenNearbyChest(),
                                         AreaBehavior.InteractWithLabelOnGroundOpenable(() => WillBot.Me.TimelessMonolith),
                                         AreaBehavior.InteractWithLabelOnGroundOpenable(() => WillBot.Me.EssenceMonsterMonolith),
                                         AreaBehavior.InteractWithLabelOnGroundOpenable(() => WillBot.Me.HarvestChest),
                                         AreaBehavior.InteractWithLabelOnGroundOpenable(() => WillBot.Me.StrongBox),
                                         AreaBehavior.InteractWithLabelOnGroundOpenable(() => WillBot.Me.BlightPumpInMap),
                                         //AreaBehavior.DefendBlightPumpMap(),

                                         AreaBehavior.OpenDeliriumMirror(),
                                         CommonBehavior.MoveToUnkillableUniqueMonster(),
                                         //CommonBehavior.MoveToDeliriumPause(),
                                         new Decorator(x => CommonBehavior.DoMoveToMonster(),
                                                       CommonBehavior.MoveTo(ret => WillBot.Me.enemies.ClosestMonsterEntity?.GridPos, x => WillBot.Me.enemies.ClosestMonsterEntity?.Pos,
                                                                             CommonBehavior.DefaultMovementSpec)),
                                         new Action(delegate
            {
                AreaBehavior.UpdateAreaTransitions();
                return RunStatus.Failure;
            }),

                                         new Decorator(delegate
            {
                if (CommonBehavior.DoMoveToMonster() == false && CommonBehavior.DoCombat() == false && CommonBehavior.DoMoveToNonKillableUniqueMonster() == false)
                {
                    WillBot.LogMessageCombo($"Checking for exit/area transitions");
                    return true;
                }
                return false;
            },
                                                       new PrioritySelector(
                                                           CommonBehavior.HandleDestroyItemPopup(),
                                                           AreaBehavior.TryDoAreaTransition(),
                                                           new Decorator(delegate
            {
                if (CommonBehavior.MapComplete())
                {
                    WillBot.LogMessageCombo($"Exiting map due to map complete criterias fulfilled, explored more than {WillBot.Settings.MapAreaExploration}");
                    return true;
                }
                return false;
            },
                                                                         CommonBehavior.OpenAndEnterTownPortal()
                                                                         ),
                                                           new Decorator(delegate
            {
                if (CommonBehavior.CouldNotFindValidPositionToExplore == true)
                {
                    WillBot.LogMessageCombo("Exiting map due to not finding a valid position to explore");
                    return true;
                }
                return false;
            },
                                                                         CommonBehavior.OpenAndEnterTownPortal()
                                                                         ),
                                                           new Decorator(
                                                               delegate
            {
                if (WillBot.Me.IsPlayerInventoryFull == true)
                {
                    WillBot.LogMessageCombo("Exiting map due to inventory full.");
                    return true;
                }
                return false;
            },
                                                               CommonBehavior.OpenAndEnterTownPortal())
                                                           )),
                                         CommonBehavior.DoExploringComposite()
                                         ))));
        }
Beispiel #29
0
 internal static void RollItemPrefix(ref ChestBehavior __instance)
 {
     __instance.requiredItemTag = ItemTag.Any;
 }
Beispiel #30
0
        private void ChestBehavior_ItemDrop(On.RoR2.ChestBehavior.orig_ItemDrop orig, ChestBehavior self)
        {
            string goName = self.gameObject.name.ToLower();

            if (!goName.Contains("chest"))
            {
                orig.Invoke(self);
            }


            PickupIndex pickup;

            if (goName.Contains("chest1"))
            {
                pickup = GetRandomItem(Chest_Percantage_Modifier.Config.ChestType.Normal);
                if (pickup != PickupIndex.none)
                {
                    self.SetFieldValue("dropPickup", pickup);
                }
            }
            else if (goName.Contains("chest2"))
            {
                pickup = GetRandomItem(Chest_Percantage_Modifier.Config.ChestType.Large);
                if (pickup != PickupIndex.none)
                {
                    self.SetFieldValue("dropPickup", pickup);
                }
            }
            else if (goName.Contains("goldchest"))
            {
                pickup = GetRandomItem(Chest_Percantage_Modifier.Config.ChestType.Golden);
                if (pickup != PickupIndex.none)
                {
                    self.SetFieldValue("dropPickup", pickup);
                }
            }

            orig.Invoke(self);
        }