Exemplo n.º 1
0
        private void Inventory_GiveItem_ItemIndex_int(On.RoR2.Inventory.orig_GiveItem_ItemIndex_int orig, Inventory self, ItemIndex itemIndex, int count)
        {
            var newCount = AdjustItemCount(itemIndex);

            if (count > 0 && count < newCount)
            {
                count = newCount;
            }
            orig(self, itemIndex, count);
            ModifyDropList(itemIndex, false);
        }
Exemplo n.º 2
0
        public void Inventory_GiveItem_ItemIndex_int(On.RoR2.Inventory.orig_GiveItem_ItemIndex_int orig, Inventory self, ItemIndex itemIndex, int count)
        {
            MysticsItemsManuscript component = self.GetComponent <MysticsItemsManuscript>();

            if (!component)
            {
                component = self.gameObject.AddComponent <MysticsItemsManuscript>();
            }
            orig(self, itemIndex, count);
            if (NetworkServer.active && itemIndex == itemDef.itemIndex)
            {
                for (var i = 0; i < count; i++)
                {
                    component.AddBuff();
                }
            }
        }
Exemplo n.º 3
0
        ////// Hooks //////

        private void On_InvGiveItemByIndex(On.RoR2.Inventory.orig_GiveItem_ItemIndex_int orig, Inventory self, ItemIndex itemIndex, int count)
        {
            orig(self, itemIndex, count);
            if (count <= 0 || !self || !NetworkServer.active)
            {
                return;
            }
            var minv = self.gameObject.GetComponent <MimicInventory>();

            if (minv || itemIndex == itemDef.itemIndex)
            {
                if (!minv)
                {
                    minv = self.gameObject.AddComponent <MimicInventory>();
                    if (!minv)
                    {
                        return;       //happens if object is being destroyed this frame
                    }
                    minv.LocateOrCreateComponentsServer();
                }
                minv.totalMimics = minv.fakeInv.GetRealItemCount(catalogIndex);
            }
        }
Exemplo n.º 4
0
        static void EnforceBannedItems(On.RoR2.Inventory.orig_GiveItem_ItemIndex_int orig, Inventory self, ItemIndex itemIndex, int count)
        {
            ItemIndex item = itemIndex;

            if (NetworkServer.active)
            {
                //Ban check
                bool isBanned = Settings.BannedItems.ContainsKey(item) ? true : false;

                //Reroll if banned
                if (isBanned)
                {
                    Chat.SendBroadcastChat(new Chat.SimpleChatMessage
                    {
                        baseToken = Util.GenerateColoredString("Banned item detected! rerolling...", new Color32(255, 106, 0, 255))
                    });

                    bool    assigned = false;
                    ItemDef itemDef  = ItemCatalog.GetItemDef(item);
                    if (itemDef != null)
                    {
                        if (itemDef.tier == ItemTier.Tier1)
                        {
                            if (Run.instance.availableTier1DropList.Count != 0)
                            {
                                item     = Tools.TryGetRandomItem(Run.instance.availableTier1DropList, Run.instance.treasureRng);
                                assigned = true;
                            }
                        }
                        else if (itemDef.tier == ItemTier.Tier2)
                        {
                            if (Run.instance.availableTier2DropList.Count != 0)
                            {
                                item     = Tools.TryGetRandomItem(Run.instance.availableTier2DropList, Run.instance.treasureRng);
                                assigned = true;
                            }
                        }
                        else if (itemDef.tier == ItemTier.Tier3)
                        {
                            if (Run.instance.availableTier3DropList.Count != 0)
                            {
                                item     = Tools.TryGetRandomItem(Run.instance.availableTier3DropList, Run.instance.treasureRng);
                                assigned = true;
                            }
                        }
                        else if (itemDef.tier == ItemTier.Lunar)
                        {
                            if (Run.instance.availableLunarDropList.Count != 0)
                            {
                                item     = Tools.TryGetRandomItem(Run.instance.availableLunarDropList, Run.instance.treasureRng);
                                assigned = true;
                            }
                        }
                        else if (itemDef.tier == ItemTier.Boss)
                        {
                            if (Run.instance.availableBossDropList.Count != 0)
                            {
                                item     = Tools.TryGetRandomItem(Run.instance.availableBossDropList, Run.instance.treasureRng);
                                assigned = true;
                            }
                        }
                        else
                        {
                            item     = ItemIndex.None;
                            assigned = true;
                        }
                    }
                    if (!assigned)
                    {
                        item = ItemIndex.None;
                    }
                }
            }
            if (item == ItemIndex.None)
            {
                return;
            }
            orig(self, item, count);
        }