Example #1
0
        // Ghost inheritance
        public static void spookyGhosts()
        {
            if (DII.GhostInherit.Value)
            {
                On.RoR2.Util.TryToCreateGhost += (orig, targetBody, ownerBody, duration) =>
                {
                    CharacterBody characterBody = orig(targetBody, ownerBody, duration);
                    if (characterBody == null)
                    {
                        return(null);
                    }
                    CharacterMaster cm         = characterBody.master;
                    AIOwnership     component2 = cm.gameObject.GetComponent <AIOwnership>();
                    CharacterMaster master     = ownerBody.master;
                    DII.checkConfig(cm, master);

                    CustomBlacklist.customItem(cm, DII.CBItemGhosts.Value);
                    CustomBlacklist.customItemCap(cm, DII.CBItemCapGhosts.Value);
                    CustomBlacklist.customEquip(cm, DII.CBEquipGhosts.Value);
                    cm.inventory.GiveItem(RoR2Content.Items.Ghost, 1);
                    cm.inventory.ResetItem(RoR2Content.Items.HealthDecay);
                    cm.inventory.GiveItem(RoR2Content.Items.HealthDecay, duration);
                    return(characterBody);
                };
            }
        }
        public static void updateInventory(CharacterMaster child, CharacterMaster player)
        {
            Inventory inventory = child.inventory;

            inventory.CopyItemsFrom(player.inventory);
            if (!Tier1Items.Value)
            {
                foreach (ItemIndex index in ItemCatalog.tier1ItemList)
                {
                    inventory.ResetItem(index);
                }
            }
            if (!Tier2Items.Value)
            {
                foreach (ItemIndex index in ItemCatalog.tier2ItemList)
                {
                    inventory.ResetItem(index);
                }
            }
            if (!Tier3Items.Value)
            {
                foreach (ItemIndex index in ItemCatalog.tier3ItemList)
                {
                    inventory.ResetItem(index);
                }
            }
            if (!BossItems.Value)
            {
                foreach (ItemDef index in BossItemList)
                {
                    inventory.ResetItem(index);
                }
            }
            if (!LunarItems.Value)
            {
                foreach (ItemIndex index in ItemCatalog.lunarItemList)
                {
                    inventory.ResetItem(index);
                }
            }
            if (!InheritDio.Value)
            {
                inventory.ResetItem(RoR2Content.Items.ExtraLife);
            }
            if (!InheritHappiestMask.Value)
            {
                inventory.ResetItem(RoR2Content.Items.GhostOnKill);
            }
            float itemMultiplier = ConfigToFloat(ItemMultiplier.Value);

            if (itemMultiplier != 1f)
            {
                int count = 0;
                if (Tier1Items.Value)
                {
                    foreach (ItemIndex index in ItemCatalog.tier1ItemList)
                    {
                        giveResetItem(count, inventory, index, itemMultiplier);
                    }
                }
                if (Tier2Items.Value)
                {
                    foreach (ItemIndex index in ItemCatalog.tier2ItemList)
                    {
                        giveResetItem(count, inventory, index, itemMultiplier);
                    }
                }
                if (Tier3Items.Value)
                {
                    foreach (ItemIndex index in ItemCatalog.tier3ItemList)
                    {
                        giveResetItem(count, inventory, index, itemMultiplier);
                    }
                }
                if (BossItems.Value)
                {
                    foreach (ItemDef item in BossItemList)
                    {
                        giveResetItem(count, inventory, item.itemIndex, itemMultiplier);
                    }
                }
                if (LunarItems.Value)
                {
                    foreach (ItemIndex index in ItemCatalog.lunarItemList)
                    {
                        giveResetItem(count, inventory, index, itemMultiplier);
                    }
                }
            }

            if (ItemRandomizer.Value)
            {
                int count = 0;
                if (Tier1Items.Value)
                {
                    foreach (ItemIndex index in ItemCatalog.tier1ItemList)
                    {
                        giveResetItem(count, inventory, index);
                    }
                }
                if (Tier2Items.Value)
                {
                    foreach (ItemIndex index in ItemCatalog.tier2ItemList)
                    {
                        giveResetItem(count, inventory, index);
                    }
                }
                if (Tier3Items.Value)
                {
                    foreach (ItemIndex index in ItemCatalog.tier3ItemList)
                    {
                        giveResetItem(count, inventory, index);
                    }
                }
                if (BossItems.Value)
                {
                    foreach (ItemDef item in BossItemList)
                    {
                        giveResetItem(count, inventory, item.itemIndex);
                    }
                }
                if (LunarItems.Value)
                {
                    foreach (ItemIndex index in ItemCatalog.lunarItemList)
                    {
                        giveResetItem(count, inventory, index);
                    }
                }
            }

            if (EquipItems.Value)
            {
                inventory.ResetItem(RoR2Content.Items.AutoCastEquipment);
                inventory.GiveItem(RoR2Content.Items.AutoCastEquipment, 1);
                inventory.CopyEquipmentFrom(player.inventory);
                if (!LunarEquips.Value)
                {
                    for (int i = 0; i < LunarEquipmentList.Length; i++)
                    {
                        if (inventory.GetEquipmentIndex() == LunarEquipmentList[i].equipmentIndex)
                        {
                            child.inventory.SetEquipmentIndex(RoR2Content.Equipment.Fruit.equipmentIndex); // default to fruit
                            break;
                        }
                    }
                }
            }

            // Items that will never be used by the NPCs.
            foreach (ItemDef item in ItemsNeverUsed)
            {
                child.inventory.ResetItem(item);
            }

            CustomBlacklist.customBlacklistChecker(child);
        }