コード例 #1
0
 private void ConvertSpecItemsToArray()
 {
     if (Config_Debug.Value)
     {
         Logger.LogInfo("Building Custom list.");
     }
     string[] items = Config_SpecificItems.Value.Split(',');
     Config_Array_SpecificItems = new ItemIndex[0];
     for (int i = 0; i < items.GetLength(0); i++)
     {
         if (!items[i].IsNullOrWhiteSpace())
         {
             items[i] = items[i].Trim();
             ItemIndex item = ItemCatalog.FindItemIndex(items[i]);
             if (item != ItemIndex.None)
             {
                 Array.Resize <ItemIndex>(ref Config_Array_SpecificItems, Config_Array_SpecificItems.Length + 1);
                 Config_Array_SpecificItems[Config_Array_SpecificItems.Length - 1] = item;
                 if (Config_Debug.Value)
                 {
                     Logger.LogInfo("Added " + items[i] + " to Custom list.");
                 }
             }
         }
     }
     if (Config_Debug.Value)
     {
         Logger.LogInfo("Custom list built with a total of " + Config_Array_SpecificItems.Length + " items.");
     }
 }
コード例 #2
0
        /// <summary>
        /// Add an item to the item pool from a string.
        /// </summary>
        /// <param name="unlockableRewardIdentifier">The AchievementDef.unlockableRewardIdentifier, e.g. "Item.Bear"</param>
        public void AddItemFromString(string unlockableRewardIdentifier)
        {
            string pattern   = @"\w+\."; //this just means "[infinite letters until]."
            bool   equipment = false;

            unlockableRewardIdentifier = Regex.Replace(unlockableRewardIdentifier, pattern, ""); //remove "[infinite letters until]." so we have the itemname remaining

            foreach (EquipmentIndex i in EquipmentCatalog.equipmentList)
            {
                EquipmentDef EqDef           = EquipmentCatalog.GetEquipmentDef(i);
                string       equipmentString = EqDef.name;
                if (unlockableRewardIdentifier == equipmentString)
                {
                    Run.instance.availableEquipment.Add(EquipmentCatalog.FindEquipmentIndex(unlockableRewardIdentifier));
                    equipment = true;
                    break; //So we don't search everything if we already have it
                }
            }
            if (!equipment)                                                                             //it doesn't matter if we try to find itemindex for characters or logs, due to the fact that they won't have the same name as an available item, and will not result in an ItemIndex that we can use
            {
                Run.instance.availableItems.Add(ItemCatalog.FindItemIndex(unlockableRewardIdentifier)); //Add the item from this string into the available items
            }
            Run.instance.BuildDropTable();                                                              //Makes it so that everything we added actually gets put into the game pool so we can get it on the next items, you can see it that old items do not have it with command, but hopefully that won't matter :]
            UpdateDroppedCommandDroplets();
        }
コード例 #3
0
 private static void GiveStartingItems(CharacterMaster owner, CharacterMaster master)
 {
     master.GiveMoney(owner.money);
     master.inventory.CopyItemsFrom(owner.inventory);
     master.inventory.RemoveItem(ItemCatalog.FindItemIndex("CaptainDefenseMatrix"), owner.inventory.GetItemCount(ItemCatalog.FindItemIndex("CaptainDefenseMatrix")));
     master.inventory.GiveItem(ItemCatalog.FindItemIndex("DrizzlePlayerHelper"), 1);
 }
コード例 #4
0
 public static void customItemCap(CharacterMaster cm)
 {
     // Custom item caps
     string[] customItemCaps = DII.CustomItemCapsAll.Value.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
     foreach (string item in customItemCaps)
     {
         string[] temp = item.Split(new[] { '-' });
         if (temp.Length == 2)
         {
             if (Int32.TryParse(temp[0], out int itemId) && Int32.TryParse(temp[1], out int cap))
             {
                 if (cm.inventory.GetItemCount((ItemIndex)itemId) > cap)
                 {
                     cm.inventory.ResetItem((ItemIndex)itemId);
                     cm.inventory.GiveItem((ItemIndex)itemId, cap);
                 }
             }
             else if (Int32.TryParse(temp[1], out cap))
             {
                 ItemIndex index = ItemCatalog.FindItemIndex(temp[0]);
                 if (index != ItemIndex.None)
                 {
                     if (cm.inventory.GetItemCount(index) > cap)
                     {
                         cm.inventory.ResetItem(index);
                         cm.inventory.GiveItem(index, cap);
                     }
                 }
             }
         }
     }
 }
コード例 #5
0
        public void Update()
        {
            if (Utils.Cfg_PlantsForHire)
            {
                if (Input.GetKeyDown(KeyCode.F2))
                {
                    TestSpawnItem((int)ItemCatalog.FindItemIndex("CritGlasses"));//ItemIndex.CritGlasses);
                }

                //if (Input.GetKeyDown(KeyCode.F3))
                //{
                //    Chat.AddMessage("kek");
                //    TestSpawnItem((int)ItemIndex.TreasureCache);
                //}

                if (Input.GetKeyDown(KeyCode.F6))
                {
                    TestSpawnItem();
                }

                if (Input.GetKeyDown(KeyCode.F7))
                {
                    TestSpawnItem(Utils.Cfg_CheatItem);
                }

                if (Input.GetKeyDown(KeyCode.F9))
                {
                    TestSpawnItemRed();
                }
            }
        }
コード例 #6
0
 public static void GetEquipmentDefs()
 {
     if (!bannedItems.Value.IsNullOrWhiteSpace())
     {
         string[]            subs          = bannedItems.Value.Split(',');
         List <EquipmentDef> equipmentDefs = new List <EquipmentDef>();
         foreach (var sub in subs)
         {
             var itemIndex = ItemCatalog.FindItemIndex(sub);
             if (itemIndex != ItemIndex.None)
             {
                 itemDefs.Add(ItemCatalog.GetItemDef(itemIndex));
             }
         }
         bannedItemDefs = itemDefs.ToArray();
     }
     if (!defaultItem.Value.IsNullOrWhiteSpace())
     {
         var itemIndexDefault = ItemCatalog.FindItemIndex(defaultItem.Value);
         if (itemIndexDefault != ItemIndex.None)
         {
             defaultItemDef = ItemCatalog.GetItemDef(itemIndexDefault);
         }
     }
 }
コード例 #7
0
        private void CharacterMaster_OnBodyStart(On.RoR2.CharacterMaster.orig_OnBodyStart orig, CharacterMaster self, CharacterBody body)
        {
            orig(self, body);
            CharacterBody body2 = PlayerCharacterMasterController.instances[0].master.GetBody();

            if (body == body2)
            {
                if (body.inventory.GetItemCount(ItemCatalog.FindItemIndex("LunarPrimaryReplacement")) == 0)
                {
                    body.inventory.GiveItem(ItemCatalog.FindItemIndex("LunarPrimaryReplacement"));
                }
                if (body.inventory.GetItemCount(ItemCatalog.FindItemIndex("LunarSecondaryReplacement")) == 0)
                {
                    body.inventory.GiveItem(ItemCatalog.FindItemIndex("LunarSecondaryReplacement"));
                }
                if (body.inventory.GetItemCount(ItemCatalog.FindItemIndex("LunarUtilityReplacement")) == 0)
                {
                    body.inventory.GiveItem(ItemCatalog.FindItemIndex("LunarUtilityReplacement"));
                }
                if (body.inventory.GetItemCount(ItemCatalog.FindItemIndex("LunarSpecialReplacement")) == 0)
                {
                    body.inventory.GiveItem(ItemCatalog.FindItemIndex("LunarSpecialReplacement"));
                }
            }
        }
コード例 #8
0
 private bool CheckForBlasterSword(Inventory inventory)
 {
     if (inventory.GetItemCount(ItemCatalog.FindItemIndex("ITEM_BLASTER_SWORD")) > 0)
     {
         return(true);
     }
     return(false);
 }
コード例 #9
0
        public static void DebugDropLunarPostfix(CharacterBody __instance)
        {
            var def        = LunarScrapProvider.LunarScrapDef;
            var otherIndex = ItemCatalog.FindItemIndex("ScrapLunar");
            var index      = PickupCatalog.FindPickupIndex(def.itemIndex);

            PickupDropletController.CreatePickupDroplet(index, __instance.transform.position, new UnityEngine.Vector3());
        }
コード例 #10
0
        private static void BrittleCrownDamageHook(On.RoR2.HealthComponent.orig_TakeDamage orig, HealthComponent self,
                                                   DamageInfo info)
        {
            if (!NetworkServer.active)
            {
                orig(self, info); //It is not our place to fix faulty mods calling this.
                return;
            }

            if (!ShareSuite.MoneyIsShared.Value || !GeneralHooks.IsMultiplayer() ||
                !(bool)self.body ||
                !(bool)self.body.inventory
                )
            {
                orig(self, info);
                return;
            }

            #region Sharedmoney

            // The idea here is that we track amount of money pre and post function evaluation.
            // We can subsequently apply the difference to the shared pool.
            var body = self.body;

            var preDamageMoney = self.body.master.money;

            orig(self, info);

            if (!self.alive)
            {
                return;
            }

            var postDamageMoney = self.body.master.money;

            // Ignore all of this if we do not actually have the item
            if (body.inventory.GetItemCount(ItemCatalog.FindItemIndex("GoldOnHit")) <= 0)
            {
                return;
            }

            // Apply the calculation to the shared money pool
            SharedMoneyValue += (int)postDamageMoney - (int)preDamageMoney;

            // Add impact effect
            foreach (var player in PlayerCharacterMasterController.instances)
            {
                if (!(bool)player.master.GetBody() || player.master.GetBody() == body)
                {
                    continue;
                }
                EffectManager.SimpleImpactEffect(Resources.Load <GameObject>(
                                                     "Prefabs/Effects/ImpactEffects/CoinImpact"),
                                                 player.master.GetBody().corePosition, Vector3.up, true);
            }

            #endregion
        }
コード例 #11
0
        private static ItemIndex StringToItemIndex(string indexStr)
        {
            ItemIndex index = ItemCatalog.FindItemIndex(indexStr);

            if (index == ItemIndex.None)
            {
                AIBlacklister.Logger.LogWarning($"Tried to add item to blacklist but '{indexStr}' is not a valid ItemIndex.");
            }

            return(index);
        }
コード例 #12
0
 private bool CheckForBlasterSword(Inventory inventory)
 {
     if (Aetherium.Items.BlasterSword.instance == null)
     {
         return(false);                                              // this should work? idk
     }
     if (inventory.GetItemCount(ItemCatalog.FindItemIndex("ITEM_BLASTER_SWORD")) > 0)
     {
         return(true);
     }
     return(false);
 }
コード例 #13
0
        private void GlobalEventManager_onCharacterDeathGlobal(DamageReport report)
        {
            if (!report.attacker || !report.attackerBody)
            {
                return;
            }
            int itemCount = report.attackerBody.inventory.GetItemCount(ItemCatalog.FindItemIndex("FlatHealth"));

            if (itemCount > 0)
            {
                report.attackerBody.AddTimedBuff(JunkContent.Buffs.MeatRegenBoost, 3f * (float)itemCount);
            }
        }
コード例 #14
0
ファイル: ProcItemCatalog.cs プロジェクト: ethall/BetterUI
 static ProcItemsCatalog()
 {
     AddEffect(ItemCatalog.FindItemIndex("BleedOnHit"), 0.1f, effectFormatter: ChanceFormatter, stackingFormula: LinearStacking, capFormula: LinearCap);
     AddEffect(ItemCatalog.FindItemIndex("StunChanceOnHit"), 0.05f, effectFormatter: ChanceFormatter, stackingFormula: HyperbolicStacking);
     AddEffect(ItemCatalog.FindItemIndex("StickyBomb"), 0.05f, effectFormatter: ChanceFormatter, stackingFormula: LinearStacking, capFormula: LinearCap);
     AddEffect(ItemCatalog.FindItemIndex("Missile"), 0.1f, effectFormatter: ChanceFormatter, stackingFormula: NoStacking);
     AddEffect(ItemCatalog.FindItemIndex("ChainLightning"), 0.25f, effectFormatter: ChanceFormatter, stackingFormula: NoStacking);
     AddEffect(ItemCatalog.FindItemIndex("Seed"), 1, effectFormatter: HPFormatter, stackingFormula: LinearStacking);
     AddEffect(ItemCatalog.FindItemIndex("HealOnCrit"), 8, effectFormatter: HPFormatter, stackingFormula: LinearStacking);
     AddEffect(ItemCatalog.FindItemIndex("Behemoth"), 4, 2.5f, effectFormatter: RangeFormatter, stackingFormula: LinearStacking);
     AddEffect(ItemCatalog.FindItemIndex("BounceNearby"), 0.2f, effectFormatter: ChanceFormatter, stackingFormula: HyperbolicStacking);
     AddEffect(ItemCatalog.FindItemIndex("GoldOnHit"), 0.3f, effectFormatter: ChanceFormatter, stackingFormula: NoStacking);
 }
コード例 #15
0
        private static void FindIndexes()
        {
            ItemIndex index = ItemCatalog.FindItemIndex("ScrapLunar");

            if (index != ItemIndex.None)
            {
                LunarScrapIndex = index;
            }
            index = ItemCatalog.FindItemIndex("ArtifactKey");
            if (index != ItemIndex.None)
            {
                ArtifactKeyIndex = index;
            }
        }
コード例 #16
0
ファイル: Player.cs プロジェクト: Acher0ns/Umbra-Menu-Source
        public static void DisabledGodMode()
        {
            switch (UmbraMenu.GodVersion)
            {
            case 0:
            {
                UmbraMenu.LocalHealth.godMode = false;
                break;
            }

            case 1:
            {
                RemoveAllBuffs();
                break;
            }

            case 3:
            {
                if (UmbraMenu.LocalHealth.health < 0)
                {
                    UmbraMenu.LocalHealth.health = 1;
                }
                UmbraMenu.LocalHealth.SetField <bool>("wasAlive", true);
                break;
            }

            case 4:
            {
                if (UmbraMenu.LocalHealth.health < 0)
                {
                    UmbraMenu.LocalHealth.health = 1;
                }
                UmbraMenu.LocalHealth.SetField <bool>("wasAlive", true);
                int itemELCount  = UmbraMenu.LocalPlayerInv.GetItemCount(ItemCatalog.FindItemIndex("ExtraLife"));
                int itemELCCount = UmbraMenu.LocalPlayerInv.GetItemCount(ItemCatalog.FindItemIndex("ExtraLifeConsumed"));
                if (itemELCCount > 0)
                {
                    UmbraMenu.LocalPlayerInv.RemoveItem(ItemCatalog.FindItemIndex("ExtraLifeConsumed"), itemELCCount);
                }
                if (itemELCount > 0)
                {
                    UmbraMenu.LocalPlayerInv.RemoveItem(ItemCatalog.FindItemIndex("ExtraLifeConsumed"), itemELCount);
                }
                break;
            }

            default:
                break;
            }
        }
コード例 #17
0
        private static void LoadBlackListItems()
        {
            _items = new ItemMask();
            foreach (var piece in ShareSuite.ItemBlacklist.Value.Split(','))
            {
                // if (int.TryParse(piece.Trim(), out var itemIndex))
                //     _items.Add((ItemIndex) itemIndex);
                var item = ItemCatalog.FindItemIndex(piece);
                if (item == ItemIndex.None)
                {
                    continue;
                }

                _items.Add(item);
            }
        }
コード例 #18
0
        private static void CacheWhitelistedItems()
        {
            //_logger.LogMessage("Caching whitelisted items for Recycler.");
            var testStringArray = Recycler_Items.Value.Split(',');

            if (testStringArray.Length > 0)
            {
                foreach (string stringToTest in testStringArray)
                {
                    if (ItemCatalog.FindItemIndex(stringToTest) == ItemIndex.None)
                    {
                        continue;
                    }
                    allowedItemIndices.Add(ItemCatalog.FindItemIndex(stringToTest));
                    //_logger.LogMessage("Adding whitelisted item: " + stringToTest);
                }
            }
            _logger.LogMessage(allowedItemIndices);
        }
コード例 #19
0
        public static void customItem(CharacterMaster cm, string customItemList)
        {
            // Custom Items Blacklist
            string[] customItemlist = customItemList.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string item in customItemlist)
            {
                if (Int32.TryParse(item, out int x))
                {
                    cm.inventory.ResetItem((ItemIndex)x);
                }
                else
                {
                    ItemIndex index = ItemCatalog.FindItemIndex(item);
                    if (index != ItemIndex.None)
                    {
                        cm.inventory.ResetItem(index);
                    }
                }
            }
        }
コード例 #20
0
        private static void BrittleCrownOnHitHook(On.RoR2.GlobalEventManager.orig_OnHitEnemy orig,
                                                  GlobalEventManager self, DamageInfo info, GameObject victim)
        {
            if (!ShareSuite.MoneyIsShared.Value || !GeneralHooks.IsMultiplayer() ||
                !(bool)info.attacker ||
                !(bool)info.attacker.GetComponent <CharacterBody>() ||
                !(bool)info.attacker.GetComponent <CharacterBody>().master
                )
            {
                orig(self, info, victim);
                return;
            }

            #region Sharedmoney

            // The idea here is that we track amount of money pre and post function evaluation.
            // We can subsequently apply the difference to the shared pool.
            var body = info.attacker.GetComponent <CharacterBody>();

            var preDamageMoney = body.master.money;

            orig(self, info, victim);

            var postDamageMoney = body.master.money;

            // Ignore all of this if we do not actually have the item
            if (!body.inventory || body.inventory.GetItemCount(ItemCatalog.FindItemIndex("GoldOnHit")) <= 0)
            {
                return;
            }

            // Apply the calculation to the shared money pool
            SharedMoneyValue += (int)postDamageMoney - (int)preDamageMoney;

            #endregion
        }
コード例 #21
0
            public static void PopulateItemCatalog()
            {
                if (!Loaded)
                {
                    Pearls.Add(ItemCatalog.FindItemIndex("Pearl"));
                    Pearls.Add(ItemCatalog.FindItemIndex("ShinyPearl"));
                    foreach (var itemIndex in ItemCatalog.allItems)
                    {
                        var itemDef = ItemCatalog.GetItemDef(itemIndex);
                        if (itemDef.tier != ItemTier.NoTier && itemDef.pickupIconSprite != null && itemDef.pickupIconSprite.name != DropList.NullIconTextureName)
                        {
                            if (itemDef.ContainsTag(ItemTag.Scrap))
                            {
                                if (!ScrapItems.ContainsKey(itemDef.tier))
                                {
                                    ScrapItems.Add(itemDef.tier, itemIndex);
                                }
                            }
                            else if (itemDef.ContainsTag(ItemTag.WorldUnique))
                            {
                                SpecialItems.Add(itemIndex);
                            }
                        }
                    }

                    foreach (var equipmentIndex in EquipmentCatalog.allEquipment)
                    {
                        var equipmentDef = EquipmentCatalog.GetEquipmentDef(equipmentIndex);
                        if (!EquipmentCatalog.equipmentList.Contains(equipmentIndex))
                        {
                            if (equipmentDef.pickupIconSprite != null &&
                                equipmentDef.pickupIconSprite.name != DropList.NullIconTextureName)
                            {
                                EliteEquipment.Add(equipmentIndex);
                            }
                        }
                    }

                    foreach (var itemIndex in ItemCatalog.lunarItemList)
                    {
                        var itemDef    = ItemCatalog.GetItemDef(itemIndex);
                        var cleansable = false;
                        foreach (var itemTag in itemDef.tags)
                        {
                            if (itemTag == ItemTag.Cleansable)
                            {
                                cleansable = true;
                            }
                        }
                        if (!cleansable)
                        {
                            if (!ScrapItems.ContainsValue(itemIndex) && itemDef.tier != ItemTier.NoTier &&
                                itemDef.pickupIconSprite != null &&
                                itemDef.pickupIconSprite.name != DropList.NullIconTextureName)
                            {
                                //print(itemIndex);
                            }
                        }
                    }

                    Loaded = true;
                }
            }
コード例 #22
0
    public void TargetAddLostItemsOfPlayers(NetworkConnection target, string QueueLostItemSpriteToString)
    {
        if (!ArtifactOfDoomConfig.disableSideBars.Value)
        {
            string[] QueueLostItemSprite = QueueLostItemSpriteToString.Split(' ');

            int i = 0;
            foreach (var element in QueueLostItemSprite)
            {
                if (element != "")
                {
                    if (ArtifactOfDoomUI.listLostImages[i].GetComponent <Image>() == null)
                    {
                        ArtifactOfDoomUI.listLostImages[i].AddComponent <Image>();
                    }
                    ArtifactOfDoomUI.listLostImages[i].GetComponent <Image>().sprite = ItemCatalog.GetItemDef(ItemCatalog.FindItemIndex(element)).pickupIconSprite;

                    i++;
                }
            }
        }
    }
コード例 #23
0
        public static bool IsAnyoneDead()
        {
            var isAnyoneDead = false;

            foreach (var instance in PlayerCharacterMasterController.instances)
            {
                if (instance.master)
                {
                    CharacterBody body = instance.master.GetBody();
                    if ((!body || !body.healthComponent.alive) && instance.master.inventory.GetItemCount(ItemCatalog.FindItemIndex("ExtraLife")) <= 0)
                    {
                        isAnyoneDead = true;
                    }
                }
            }
            ;
            return(isAnyoneDead);
        }
コード例 #24
0
ファイル: AdvancedIcons.cs プロジェクト: ethall/BetterUI
        internal void EquipmentIcon_Update(On.RoR2.UI.EquipmentIcon.orig_Update orig, EquipmentIcon self)
        {
            orig(self);

            if (!this.EquipmentIconDirty.ContainsKey(self))
            {
                this.EquipmentIconDirty.Add(self, true);
                this.lastEquipment.Add(self, null);
            }
            if ((mod.config.AdvancedIconsEquipementAdvancedDescriptions.Value ||
                 mod.config.AdvancedIconsEquipementShowBaseCooldown.Value ||
                 mod.config.AdvancedIconsEquipementShowCalculatedCooldown.Value) &&
                (self.currentDisplayData.equipmentDef != this.lastEquipment[self] || this.EquipmentIconDirty[self]) &&
                self.currentDisplayData.hasEquipment && self.tooltipProvider)
            {
                this.lastEquipment[self]      = self.currentDisplayData.equipmentDef;
                this.EquipmentIconDirty[self] = false;
                BetterUI.sharedStringBuilder.Clear();
                BetterUI.sharedStringBuilder.Append(Language.GetString(mod.config.AdvancedIconsEquipementAdvancedDescriptions.Value ? self.currentDisplayData.equipmentDef.descriptionToken : self.currentDisplayData.equipmentDef.pickupToken));
                if (mod.config.AdvancedIconsEquipementShowBaseCooldown.Value || mod.config.AdvancedIconsEquipementShowCalculatedCooldown.Value)
                {
                    BetterUI.sharedStringBuilder.Append("\n");
                }
                if (mod.config.AdvancedIconsEquipementShowBaseCooldown.Value)
                {
                    BetterUI.sharedStringBuilder.Append("\nBase Cooldown: <style=cIsDamage>");
                    BetterUI.sharedStringBuilder.Append(self.currentDisplayData.equipmentDef.cooldown);
                    BetterUI.sharedStringBuilder.Append("</style> second");
                    if (self.currentDisplayData.equipmentDef.cooldown != 1)
                    {
                        BetterUI.sharedStringBuilder.Append("s");
                    }
                }
                if (mod.config.AdvancedIconsEquipementShowCalculatedCooldown.Value)
                {
                    inventory = self.targetInventory;
                    if (!inventory && mod.HUD.targetBodyObject)
                    {
                        targetbody = mod.HUD.targetBodyObject.GetComponent <CharacterBody>();
                        if (targetbody)
                        {
                            inventory = targetbody.inventory;
                        }
                    }
                    if (inventory)
                    {
                        float reduction = (float)Math.Pow(0.85, inventory.itemStacks[(int)ItemCatalog.FindItemIndex("EquipmentMagazine")]);
                        if (inventory.itemStacks[(int)ItemCatalog.FindItemIndex("AutoCastEquipment")] > 0)
                        {
                            reduction *= 0.5f * (float)Math.Pow(0.85, inventory.itemStacks[(int)ItemCatalog.FindItemIndex("AutoCastEquipment")] - 1);
                        }
                        if (reduction < 1)
                        {
                            BetterUI.sharedStringBuilder.Append("\nEffective Cooldown: <style=cIsHealing>");
                            BetterUI.sharedStringBuilder.Append((self.currentDisplayData.equipmentDef.cooldown * reduction).ToString("0.###"));
                            BetterUI.sharedStringBuilder.Append("</style> second");
                            if (self.currentDisplayData.equipmentDef.cooldown != 1)
                            {
                                BetterUI.sharedStringBuilder.Append("s");
                            }
                        }
                    }
                }


                self.tooltipProvider.overrideBodyText = BetterUI.sharedStringBuilder.ToString();
            }

            if (mod.config.AdvancedIconsEquipementShowCooldownStacks.Value && self.cooldownText && self.currentDisplayData.cooldownValue > 0)
            {
                self.cooldownText.gameObject.SetActive(true);
            }
        }
コード例 #25
0
        public override void InjectSkills(GameObject gameObject, BaseAI ai)
        {
            // Add items
            ai.master.inventory.GiveItem(ItemCatalog.FindItemIndex("LunarPrimaryReplacement"), 1);
            ai.master.inventory.GiveItem(ItemCatalog.FindItemIndex("LunarSecondaryReplacement"), 1);
            ai.master.inventory.GiveItem(ItemCatalog.FindItemIndex("LunarUtilityReplacement"), 1);
            ai.master.inventory.GiveItem(ItemCatalog.FindItemIndex("LunarSpecialReplacement"), 1);
            ai.master.inventory.GiveItem(ItemCatalog.FindItemIndex("HealWhileSafe"), 3);

            // Skills
            AISkillDriver skill3 = gameObject.AddComponent <AISkillDriver>() as AISkillDriver;

            skill3.customName        = "Utility";
            skill3.skillSlot         = RoR2.SkillSlot.Utility;
            skill3.requireSkillReady = true;
            skill3.moveTargetType    = AISkillDriver.TargetType.CurrentEnemy;
            skill3.minDistance       = 0;
            skill3.maxDistance       = 20;
            //skill3.maxUserHealthFraction = .25f;
            skill3.selectionRequiresTargetLoS        = true;
            skill3.activationRequiresTargetLoS       = false;
            skill3.activationRequiresAimConfirmation = false;
            skill3.movementType    = AISkillDriver.MovementType.FleeMoveTarget;
            skill3.aimType         = AISkillDriver.AimType.MoveDirection;
            skill3.ignoreNodeGraph = false;
            skill3.resetCurrentEnemyOnNextDriverSelection = false;
            skill3.noRepeat        = false;
            skill3.shouldSprint    = true;
            skill3.buttonPressType = AISkillDriver.ButtonPressType.TapContinuous;

            AISkillDriver skill2 = gameObject.AddComponent <AISkillDriver>() as AISkillDriver;

            skill2.customName                        = "Secondary";
            skill2.skillSlot                         = RoR2.SkillSlot.Secondary;
            skill2.requireSkillReady                 = true;
            skill2.moveTargetType                    = AISkillDriver.TargetType.CurrentEnemy;
            skill2.minDistance                       = 0;
            skill2.maxDistance                       = 50;
            skill2.selectionRequiresTargetLoS        = true;
            skill2.activationRequiresTargetLoS       = true;
            skill2.activationRequiresAimConfirmation = true;
            skill2.movementType                      = AISkillDriver.MovementType.StrafeMovetarget;
            skill2.aimType         = AISkillDriver.AimType.AtMoveTarget;
            skill2.ignoreNodeGraph = false;
            skill2.resetCurrentEnemyOnNextDriverSelection = false;
            skill2.noRepeat        = false;
            skill2.shouldSprint    = false;
            skill2.buttonPressType = AISkillDriver.ButtonPressType.TapContinuous;

            // Skills
            AISkillDriver skill1 = gameObject.AddComponent <AISkillDriver>() as AISkillDriver;

            skill1.customName                        = "Shoot";
            skill1.skillSlot                         = RoR2.SkillSlot.Primary;
            skill1.requireSkillReady                 = true;
            skill1.moveTargetType                    = AISkillDriver.TargetType.CurrentEnemy;
            skill1.minDistance                       = 0;
            skill1.maxDistance                       = 50;
            skill1.selectionRequiresTargetLoS        = true;
            skill1.activationRequiresTargetLoS       = true;
            skill1.activationRequiresAimConfirmation = true;
            skill1.movementType                      = AISkillDriver.MovementType.StrafeMovetarget;
            skill1.aimType         = AISkillDriver.AimType.AtMoveTarget;
            skill1.ignoreNodeGraph = false;
            skill1.resetCurrentEnemyOnNextDriverSelection = false;
            skill1.noRepeat        = false;
            skill1.shouldSprint    = false;
            skill1.buttonPressType = AISkillDriver.ButtonPressType.TapContinuous;

            AISkillDriver skill4 = gameObject.AddComponent <AISkillDriver>() as AISkillDriver;

            skill4.customName                        = "Special";
            skill4.skillSlot                         = RoR2.SkillSlot.Special;
            skill4.requireSkillReady                 = true;
            skill4.moveTargetType                    = AISkillDriver.TargetType.CurrentEnemy;
            skill4.minDistance                       = 0;
            skill4.maxDistance                       = 50;
            skill4.selectionRequiresTargetLoS        = false;
            skill4.activationRequiresTargetLoS       = false;
            skill4.activationRequiresAimConfirmation = false;
            skill4.movementType                      = AISkillDriver.MovementType.StrafeMovetarget;
            skill4.aimType         = AISkillDriver.AimType.AtMoveTarget;
            skill4.ignoreNodeGraph = false;
            skill4.resetCurrentEnemyOnNextDriverSelection = false;
            skill4.noRepeat        = false;
            skill4.shouldSprint    = false;
            skill4.buttonPressType = AISkillDriver.ButtonPressType.TapContinuous;

            // Add default skills
            AddDefaultSkills(gameObject, ai, 20);
        }
コード例 #26
0
ファイル: NModLoader.cs プロジェクト: Jeffersah/NMod
        public static void InitItems(AssetBundle bundle)
        {
            Dictionary <string, string> loreText = new Dictionary <string, string>();

            using (var reader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("NMod.itemText.txt")))
            {
                StringBuilder loreTextBuilder = new StringBuilder();
                string        loreKey         = null;
                while (!reader.EndOfStream)
                {
                    var line = reader.ReadLine();
                    if (line.StartsWith("@lore"))
                    {
                        if (loreKey != null)
                        {
                            loreText.Add(loreKey, loreTextBuilder.ToString().Trim());
                            loreTextBuilder.Clear();
                        }
                        loreKey = line.Substring(6).Trim();
                    }
                    else
                    {
                        loreTextBuilder.AppendLine(line.Trim());
                    }
                }
                if (loreKey != null)
                {
                    loreText.Add(loreKey, loreTextBuilder.ToString().Trim());
                }
            }

            LoadedCustomItems = new Dictionary <string, CustomItemBase>();
            var customItemTypes = typeof(NModLoader).Assembly.GetTypes().Where(t => t.GetCustomAttribute <NModItemAttribute>() != null);
            var customItems     = customItemTypes.Select(t =>
            {
                try
                {
                    return((CustomItemBase)Activator.CreateInstance(t));
                }
                catch (Exception e)
                {
                    NModMain.Log.LogError("ERROR Initializing " + t.FullName + ":");
                    NModMain.Log.LogError(e.ToString());
                    return(null);
                }
            });

            foreach (var customItem in customItems)
            {
                if (customItem == null)
                {
                    continue;
                }
                LoadAssetsAndInit(customItem, bundle, loreText);
            }

            NModMain.Log.LogMessage($"CustomItemManager added {customItems.Count()} items");

            On.RoR2.ItemCatalog.Init += (orig) =>
            {
                orig();

                NModMain.Log.LogWarning($"Item catalog init");

                // ItemCatalog has itemdefs now

                foreach (var customItem in customItems)
                {
                    if (customItem != null)
                    {
                        customItem.Index = ItemCatalog.FindItemIndex(customItem.InternalName);
                        customItem.RegisterHooks(customItem.Index);
                        LoadedCustomItems.Add(customItem.InternalName, customItem);
                    }
                }
            };
        }
コード例 #27
0
 private void PickupCatalog_Init(On.RoR2.PickupCatalog.orig_Init orig)
 {
     orig();
     HonoredItem = ItemCatalog.FindItemIndex(HonoredItemString.Value);
     Debug.Log("Index: " + HonoredItem);
 }
コード例 #28
0
            public static void PopulateCatalog()
            {
                SpecialItems.Clear();
                ScrapItems.Clear();
                EliteEquipment.Clear();
                Pearls.Clear();

                Pearls.Add(ItemCatalog.FindItemIndex("Pearl"));
                Pearls.Add(ItemCatalog.FindItemIndex("ShinyPearl"));
                foreach (var itemIndex in ItemCatalog.allItems)
                {
                    var itemDef = ItemCatalog.GetItemDef(itemIndex);
                    if (itemDef.tier != ItemTier.NoTier && itemDef.pickupIconSprite != null && itemDef.pickupIconSprite.name != NullIconTextureName)
                    {
                        if (itemDef.ContainsTag(ItemTag.Scrap))
                        {
                            if (!ScrapItems.ContainsKey(itemDef.tier))
                            {
                                ScrapItems.Add(itemDef.tier, itemIndex);
                            }
                        }
                        else if (itemDef.ContainsTag(ItemTag.WorldUnique))
                        {
                            SpecialItems.Add(itemIndex);
                        }
                    }
                }

                foreach (var eliteDef in EliteCatalog.eliteDefs)
                {
                    if (eliteDef.eliteEquipmentDef != null)
                    {
                        var equipmentIndex = eliteDef.eliteEquipmentDef.equipmentIndex;
                        if (equipmentIndex != EquipmentIndex.None && !EliteEquipment.Contains(equipmentIndex))
                        {
                            EliteEquipment.Add(equipmentIndex);
                        }
                    }
                }

                /*
                 * //  This was something I was experimenting with but have abandoned for now.
                 *
                 * foreach (var itemIndex in ItemCatalog.lunarItemList) {
                 *  var itemDef = ItemCatalog.GetItemDef(itemIndex);
                 *  var cleansable = false;
                 *  foreach (var itemTag in itemDef.tags) {
                 *      if (itemTag == ItemTag.Cleansable) {
                 *          cleansable = true;
                 *      }
                 *  }
                 *  if (!cleansable) {
                 *      if (!ScrapItems.ContainsValue(itemIndex) && itemDef.tier != ItemTier.NoTier &&
                 *          itemDef.pickupIconSprite != null &&
                 *          itemDef.pickupIconSprite.name != DropList.NullIconTextureName) {
                 *          //print(itemIndex);
                 *      }
                 *  }
                 * }
                 */
                CatalogGenerated.Invoke();
            }
コード例 #29
0
        public PlayerCharacterMasterController getRandomDeadPlayer()
        {
            var deadPlayers = new List <PlayerCharacterMasterController>();

            foreach (var instance in PlayerCharacterMasterController.instances)
            {
                if (instance.master)
                {
                    CharacterBody body = instance.master.GetBody();
                    if ((!body || !body.healthComponent.alive) && instance.master.inventory.GetItemCount(ItemCatalog.FindItemIndex("ExtraLife")) <= 0)
                    {
                        deadPlayers.Add(instance);
                    }
                }
            }
            ;
            if (deadPlayers.Count == 0)
            {
                return(null);
            }
            var player = MoreShrines.EvaRng.NextElementUniform <PlayerCharacterMasterController>(deadPlayers);

            return(player);
        }
コード例 #30
0
        private void SetUpMiniRPC()
        {
            // Fix the damn in-game console stealing our not-in-game consoles output.
            // Not related to the demo, just very useful.
            //On.RoR2.RoR2Application.UnitySystemConsoleRedirector.Redirect += orig => { };

            // Create a MiniRpcInstance that automatically registers all commands to our ModGuid
            // This lets us support multiple mods using the same command ID
            // We could also just generate new command ID's without "isolating" them by mod as well, so it would break if mod load order was different for different clients
            // I opted for the ModGuid instead of an arbitrary number or GUID to encourage mods not to set the same ID
            var miniRpc = MiniRpc.CreateInstance(ModGuid);

            AddGainedItemsToPlayers = miniRpc.RegisterFunc(Target.Client, (NetworkUser user, string QueueGainedItemSpriteToString) => //--------------------HierSTuffMachen!!
            {
                if (!ArtifactOfDoomConfig.disableSideBars.Value)
                {
                    string[] QueueGainedItemSprite = QueueGainedItemSpriteToString.Split(' ');

                    int i = 0;
                    foreach (var element in QueueGainedItemSprite)
                    {
                        if (element != "")
                        {
                            if (ArtifactOfDoomUI.listGainedImages[i].GetComponent <Image>() == null)
                            {
                                ArtifactOfDoomUI.listGainedImages[i].AddComponent <Image>();
                            }
                            ArtifactOfDoomUI.listGainedImages[i].GetComponent <Image>().sprite = ItemCatalog.GetItemDef(ItemCatalog.FindItemIndex(element)).pickupIconSprite;

                            i++;
                        }
                    }
                }
                return("dummie");
            });
            AddLostItemsOfPlayers = miniRpc.RegisterFunc(Target.Client, (NetworkUser user, string QueueLostItemSpriteToString) => //--------------------HierSTuffMachen!!
            {
                if (!ArtifactOfDoomConfig.disableSideBars.Value)
                {
                    string[] QueueLostItemSprite = QueueLostItemSpriteToString.Split(' ');

                    int i = 0;
                    foreach (var element in QueueLostItemSprite)
                    {
                        if (element != "")
                        {
                            if (ArtifactOfDoomUI.listLostImages[i].GetComponent <Image>() == null)
                            {
                                ArtifactOfDoomUI.listLostImages[i].AddComponent <Image>();
                            }
                            ArtifactOfDoomUI.listLostImages[i].GetComponent <Image>().sprite = ItemCatalog.GetItemDef(ItemCatalog.FindItemIndex(element)).pickupIconSprite;

                            i++;
                        }
                    }
                }
                return("dummie");
            });
            UpdateProgressBar = miniRpc.RegisterFunc(Target.Client, (NetworkUser user, string killedNeededEnemies) => //--------------------HierSTuffMachen!!
            {
                //Debug.LogWarning("in UpdateProgressBar");
                //Debug.LogError("ArtifactOfDoomConfig.disableItemProgressBar.Value"+ ArtifactOfDoomConfig.disableItemProgressBar.Value);
                //Debug.LogError("ArtifactOfDoomConfig.useArtifactOfSacreficeCalculation.Value"+ ArtifactOfDoomConfig.useArtifactOfSacreficeCalculation.Value);
                if (ArtifactOfDoomConfig.disableItemProgressBar.Value || calculationSacrifice)
                {
                    return("Disabled Progress Bar");
                }

                if (killedNeededEnemies == null)
                {
                    Debug.Log("killedNeededEnemies == null");
                    return("error");
                }

                //Debug.LogWarning("string killedNeededEnemies für rpc: " + killedNeededEnemies);
                string[] stringkilledNeededEnemies = killedNeededEnemies.Split(',');
                //Debug.LogError("in line 276");
                if (stringkilledNeededEnemies == null)
                {
                    Debug.LogError("stringkilledneededEnemies=null");
                }

                int enemiesKilled = Convert.ToInt32(stringkilledNeededEnemies[0]);
                int enemiesNeeded = Convert.ToInt32(stringkilledNeededEnemies[1]) + 2;

                //Debug.LogError("in line 279");
                if (itemGainBar == null)
                {
                    return("error");
                }
                double progress = (double)enemiesKilled / ((double)enemiesNeeded);

                //                  Debug.LogError("in line 2282");
                if (itemGainBar.GetComponent <RectTransform>() == null)
                {
                    return("Error while excecuting Update progress bar");
                }

                if ((0.35f + (float)(progress * 0.3)) > 0.65f)
                {
                    if (itemGainBar.GetComponent <RectTransform>().anchorMax == null)
                    {
                        Debug.LogError("itemGainBar.GetComponent<RectTransform>().anchorMax==null");
                    }

                    itemGainBar.GetComponent <RectTransform>().anchorMax = new Vector2(0.65f, 0.06f);
                }
                else
                {
                    itemGainBar.GetComponent <RectTransform>().anchorMin = new Vector2(0.35f, 0.05f);
                    //                    Debug.LogError("in line 288");

                    itemGainBar.GetComponent <RectTransform>().anchorMax = new Vector2(0.35f + (float)(progress * 0.3), 0.06f);
                }
                return("dummie");
            });
            IsArtifactActive = miniRpc.RegisterFunc(Target.Client, (NetworkUser user, bool isActive) => //--------------------HierSTuffMachen!!
            {
                ArtifactIsActive = isActive;
                return("");
            });
            IsCalculationSacrifice = miniRpc.RegisterFunc(Target.Client, (NetworkUser user, bool isActive) => //--------------------HierSTuffMachen!!
            {
                //Debug.LogError("Set CalculationSacrifice to " + isActive);
                calculationSacrifice = isActive;
                return("");
            });

            Debug.LogWarning("minirpc succsessfull set up");

            // The "_ ="'s above mean that the return value will be ignored. In your code you should assign the return value to something to be able to call the function.
        }