Пример #1
0
 private void CharacterBody_onBodyStartGlobal(CharacterBody obj)
 {
     if (obj.isPlayerControlled)
     {
         obj.AddBuff(BuffIndex.HealingDisabled);
         obj.AddBuff(BuffIndex.Weak);
         obj.AddBuff(BuffIndex.Cripple);
         obj.AddBuff(BuffIndex.Pulverized);
         obj.AddBuff(BuffIndex.Nullified);
     }
 }
        private void CharacterMaster_RespawnExtraLife(On.RoR2.CharacterMaster.orig_RespawnExtraLife orig, CharacterMaster self)
        {
            orig(self);

            if (playersToRespawn.Contains(self))
            {
                playersToRespawn.Remove(self);
                var characterBody = self.GetBody();

                CharacterBody component = characterBody;
                if (component)
                {
                    var count       = component.GetBuffCount(InitBuffs.maxHPDownStage);
                    var added_count = (int)Mathf.Ceil(((100f - (float)component.GetBuffCount(InitBuffs.maxHPDownStage)) / 100f) * (float)purchaseInteraction.cost);
                    //Debug.Log(count + added_count);
                    if (count + added_count < 100)
                    {
                        for (var i = 0; i < added_count; i++)
                        {
                            component.AddBuff(InitBuffs.maxHPDownStage);
                        }
                    }
                }
            }
        }
        private void applySavedTokens(Object source, System.Timers.ElapsedEventArgs e)
        {
            // This will stay in for now
            Logger.LogInfo("Hello my name timer");
            // Keep waiting for players to load
            if (PlayerCharacterMasterController.instances.Count > PlayerCharacterMasterController.GetPlayersWithBodiesCount())
            {
                return;
            }
            // All players are loaded
            // Stop the timer
            timer.Enabled = false;
            ReadOnlyCollection <PlayerCharacterMasterController> players = PlayerCharacterMasterController.instances;

            for (int i = 0; i < players.Count; i++)
            {
                if (players[i].master.hasBody)
                {
                    CharacterBody body = players[i].master.GetBody();
                    for (int j = 0; j < stackCount[i]; j++)
                    {
                        body.AddBuff(RoR2Content.Buffs.BanditSkull);
                    }
                }
            }
        }
Пример #4
0
        private void GenericSkill_OnExecute(On.RoR2.GenericSkill.orig_OnExecute orig, GenericSkill self)
        {
            var           invCount = GetCount(self.characterBody);
            CharacterBody vBody    = self.characterBody;

            if (vBody.skillLocator.FindSkill(self.skillName))
            {
                if (invCount > 0)
                {
                    if (vBody.skillLocator.utility.Equals(self)) //is this redundant?
                    {
                        if (vBody.HasBuff(MachoBrace_Boost))     //should prevent weird stacking
                        {
                            vBody.RemoveBuff(MachoBrace_Boost);
                        }
                        vBody.AddBuff(MachoBrace_Boost);
                    }
                    else
                    {
                        if (vBody.HasBuff(MachoBrace_Boost))
                        {
                            vBody.RemoveBuff(MachoBrace_Boost);
                        }
                    }
                }
            }
            orig(self);
        }
Пример #5
0
 public static void AddBuffStacks(CharacterBody characterBody, BuffDef buffDef, int stacks = 1)
 {
     for (int i = 0; i < stacks; i++)
     {
         characterBody.AddBuff(buffDef);
     }
 }
Пример #6
0
        protected override bool PerformEquipmentAction(EquipmentSlot slot)
        {
            CharacterBody body = slot.characterBody;

            if (!body)
            {
                return(false);
            }
            HealthComponent health = body.healthComponent;

            if (!health)
            {
                return(false);
            }

            int MeatBunBoostCount = body.GetBuffCount(MeatbunBoost);

            if (MeatBunBoostCount < MaxBuffLimit)
            {
                body.AddBuff(MeatbunBoost);
            }

            if (PercentMaxHealthHealAmount > 0)
            {
                health.HealFraction(PercentMaxHealthHealAmount, default);
            }
            return(true);
        }
Пример #7
0
        void hook_HealthComponent_TakeDamage(On.RoR2.HealthComponent.orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
        {
            if (damageInfo.attacker)
            {
                CharacterBody attackerBody = damageInfo.attacker.GetComponent <CharacterBody>();
                if (damageInfo.crit && attackerBody && attackerBody.master && attackerBody.master.inventory)
                {
                    if (attackerBody.master.inventory.GetItemCount(this.ItemIndex) > 0)
                    {
                        attackerBody.AddBuff(this.buffIndex);
                    }
                }

                if (attackerBody && self.body.HasBuff(this.buffIndex))
                {
                    HealthComponent attackerHealthComponent = attackerBody.healthComponent;
                    if (attackerHealthComponent)
                    {
                        attackerHealthComponent.TakeDamage(new DamageInfo()
                        {
                            attacker        = self.body.gameObject,
                            crit            = Util.CheckRoll(self.body.crit, self.body.master),
                            damage          = self.body.damage * self.body.GetBuffCount(this.buffIndex) * 0.05f,
                            procCoefficient = 1,
                            damageType      = DamageType.Shock5s
                        });
                        self.body.SetBuffCount(buffIndex, 0);
                    }
                }
            }
            orig(self, damageInfo);
        }
Пример #8
0
        static void HealthComponent_TakeDamage(Action <RoR2.HealthComponent, DamageInfo> orig, HealthComponent self, DamageInfo damageInfo)
        {
            if (damageInfo.attacker && damageInfo.attacker != self.gameObject)
            {
                CharacterBody attackerBody = damageInfo.attacker.GetComponent <CharacterBody>();
                if (damageInfo.crit && attackerBody && attackerBody.master && attackerBody.master.inventory)
                {
                    if (attackerBody.master.inventory.GetItemCount(itemDef) > 0)
                    {
                        attackerBody.AddBuff(buffDef);
                    }
                }

                if (attackerBody && self.body.HasBuff(buffDef))
                {
                    HealthComponent attackerHealthComponent = attackerBody.healthComponent;
                    if (attackerHealthComponent)
                    {
                        var zapDamageInfo = new DamageInfo()
                        {
                            attacker        = self.body.gameObject,
                            crit            = Util.CheckRoll(self.body.crit, self.body.master),
                            damage          = self.body.damage * self.body.GetBuffCount(buffDef) * 0.05f,
                            procCoefficient = 1,
                            damageType      = DamageType.Shock5s
                        };
                        self.body.SetBuffCount(buffDef.buffIndex, 0);
                        attackerHealthComponent.TakeDamage(zapDamageInfo);
                    }
                }
            }
            orig(self, damageInfo);
        }
Пример #9
0
            void OnEnable()
            {
                //ContactDamageCooldown = ContactDamageCooldownFull;
                characterBody = gameObject.GetComponent <CharacterBody>();
                if (!characterBody)
                {
                    _logger.LogError("No characterbody found for jammed enemy!");
                    return;
                }
                if (!characterBody.HasBuff(Shared.Buffs.BuffsController.Jammed))
                {
                    characterBody.AddBuff(Shared.Buffs.BuffsController.Jammed);
                }
                if (characterBody.inventory && characterBody.inventory.GetItemCount(CurseController.isJammedItem) == 0)
                {
                    characterBody.inventory.GiveItem(CurseController.isJammedItem);
                }
                ModelLocator modelLocator = gameObject.GetComponent <ModelLocator>();

                if (modelLocator)
                {
                    if (!fireEffect)
                    {
                        fireEffect = Object.Instantiate <GameObject>(instance.jammedFire, modelLocator.modelTransform.Find("ROOT").transform);
                        //fireEffect.transform.parent = modelLocator.modelTransform;
                    }
                }
                var deathBehaviour = gameObject.GetComponent <CharacterDeathBehavior>();

                if (deathBehaviour)
                {
                    characterDeathBehavior = deathBehaviour;
                }
            }
Пример #10
0
        private void AddShellPlateStats(CharacterBody sender, StatHookEventArgs args)
        {
            var inventoryCount = GetCount(sender);

            if (inventoryCount > 0)
            {
                var shellStackTrackerComponent = sender.gameObject.GetComponent <ShellStackTracker>();
                if (!shellStackTrackerComponent)
                {
                    sender.gameObject.AddComponent <ShellStackTracker>();
                }

                var currentShellStackMax = (((inventoryCount - 1) * (addMaxArmorGain / armorOnKillAmount)) + (baseMaxArmorGain / armorOnKillAmount));
                if (shellStackTrackerComponent.shellStacks >= currentShellStackMax && sender.GetBuffCount(ShellStackMax) <= 0)
                {
                    sender.AddBuff(ShellStackMax);
                }

                if (shellStackTrackerComponent.shellStacks < currentShellStackMax && sender.GetBuffCount(ShellStackMax) > 0)
                {
                    sender.RemoveBuff(ShellStackMax);
                }
                var currentShellStack = shellStackTrackerComponent.shellStacks;
                args.armorAdd += (armorOnKillAmount * currentShellStack);
            }
        }
Пример #11
0
        private static void CharacterBody_OnEquipmentGained(On.RoR2.CharacterBody.orig_OnEquipmentGained orig, CharacterBody self, EquipmentDef equipmentDef)
        {
            orig(self, equipmentDef);

            if (equipmentDef.equipmentIndex == _equipIndex)
            {
                self.AddBuff(_buffIndex);
            }
        }
        public void RecalculateTokenAmount(CharacterBody body)
        {
            if (body.isPlayerControlled && body.teamComponent.teamIndex == TeamIndex.Player)
            {
                int currentTokenAmount = body.GetBuffCount(RoR2Content.Buffs.BanditSkull);
                int newTokenAmount     = (int)Math.Floor(_lastStageTokenAmount * TokenMultiplier.Value);

                if (currentTokenAmount < newTokenAmount)
                {
                    for (int i = 0; i < newTokenAmount - currentTokenAmount; i++)
                    {
                        body.AddBuff(RoR2Content.Buffs.BanditSkull);
                    }
                }
            }
        }
Пример #13
0
 //Stolen Inventory Functions
 void AddToStolenInventory(CharacterBody body, GameObject obj, ItemIndex item, int count)
 {
     if (body.master)
     {
         body.AddBuff(Thief.BuffDef.buffIndex);
         StolenInventory inventory = obj.GetComponent <StolenInventory>();
         if (!inventory)
         {
             obj.AddComponent <StolenInventory>().amount[(int)item] += count;
         }
         else
         {
             inventory.amount[(int)item] += count;
         }
     }
 }
Пример #14
0
 private void cbApplyBuff(bool failed, CharacterBody tgtBody)
 {
     if (tgtBody == null)
     {
         return;
     }
     if (failed)
     {
         if (GetCount(tgtBody) > 0 && tgtBody.GetBuffCount(snakeEyesBuff) < stackCap)
         {
             tgtBody.AddBuff(snakeEyesBuff);
         }
         if (!inclDeploys)
         {
             return;
         }
         var dplist = tgtBody.master?.deployablesList;
         if (dplist != null)
         {
             foreach (DeployableInfo d in dplist)
             {
                 var dplBody = d.deployable.gameObject.GetComponent <CharacterMaster>()?.GetBody();
                 if (dplBody && GetCount(dplBody) > 0 && dplBody.GetBuffCount(snakeEyesBuff) < stackCap)
                 {
                     dplBody.AddBuff(snakeEyesBuff);
                 }
             }
         }
     }
     else
     {
         tgtBody.SetBuffCount(snakeEyesBuff.buffIndex, 0);
         if (!inclDeploys)
         {
             return;
         }
         var dplist = tgtBody.master?.deployablesList;
         if (dplist != null)
         {
             foreach (DeployableInfo d in dplist)
             {
                 d.deployable.gameObject.GetComponent <CharacterMaster>()?.GetBody()?.SetBuffCount(snakeEyesBuff.buffIndex, 0);
             }
         }
     }
 }
Пример #15
0
 static void AddBuff(CharacterBody body, BuffIndex buff, Int32 stacks = 1)
 {
     if (body == null)
     {
         return;
     }
     if (NetworkServer.active)
     {
         for (Int32 i = 0; i < stacks; ++i)
         {
             body.AddBuff(buff);
         }
     }
     else
     {
         new BuffMessage(body, buff, stacks).Send(ReinNetMessage.Dest.Server);
     }
 }
Пример #16
0
        private void AddShellPlateStats(CharacterBody sender, StatHookEventArgs args)
        {
            var inventoryCount = GetCount(sender);

            if (inventoryCount > 0)
            {
                var currentShellStackMax = (((inventoryCount - 1) * 50) + 50);
                if (sender.inventory.GetItemCount(shellStack) >= currentShellStackMax && sender.GetBuffCount(ShellStackMax) <= 0)
                {
                    sender.AddBuff(ShellStackMax);
                }

                if (sender.inventory.GetItemCount(shellStack) < currentShellStackMax && sender.GetBuffCount(ShellStackMax) > 0)
                {
                    sender.RemoveBuff(ShellStackMax);
                }
                var currentShellStack = sender.inventory.GetItemCount(shellStack);
                args.armorAdd += (.2f * currentShellStack);
            }
        }
Пример #17
0
        private void AddShellPlateStats(CharacterBody sender, StatHookEventArgs args)
        {
            var inventoryCount = GetCount(sender);

            if (inventoryCount > 0)
            {
                var currentShellStackMax = (((inventoryCount - 1) * (addMaxArmorGain / armorOnKillAmount)) + (baseMaxArmorGain / armorOnKillAmount));
                if (sender.inventory.GetItemCount(shellStack) >= currentShellStackMax && sender.GetBuffCount(ShellStackMax) <= 0)
                {
                    sender.AddBuff(ShellStackMax);
                }

                if (sender.inventory.GetItemCount(shellStack) < currentShellStackMax && sender.GetBuffCount(ShellStackMax) > 0)
                {
                    sender.RemoveBuff(ShellStackMax);
                }
                var currentShellStack = sender.inventory.GetItemCount(shellStack);
                args.armorAdd += (armorOnKillAmount * currentShellStack);
            }
        }
Пример #18
0
 void UpdateThiefBuff(CharacterBody body)
 {
     if (body.master)
     {
         int             buffcount = 0;
         GameObject      obj       = body.master.gameObject;
         StolenInventory inventory = obj.GetComponent <StolenInventory>();
         if (inventory)
         {
             for (int i = 0; i < inventory.amount.Length; i++)
             {
                 if (inventory.amount[i] > 0)
                 {
                     buffcount += inventory.amount[i];
                 }
             }
             body.RemoveBuff(Thief.BuffDef.buffIndex);
             for (; body.GetBuffCount(Thief.BuffDef.buffIndex) != buffcount;)
             {
                 body.AddBuff(Thief.BuffDef.buffIndex);
             }
         }
     }
 }
Пример #19
0
        public override void OnArrival()
        {
            try
            {
                switch (bonusType)
                {
                    #region DamageBoost
                case 1 when targetTeam == TeamIndex.Player:
                    targetInventory.GiveItem(Items.DamageBoostIndex);
                    targetBody.baseDamage *= (ConfigHandler.DamageValue * 0.01f) + 1f;
                    break;

                case 1 when targetTeam == TeamIndex.Monster:
                    targetBody.AddBuff(Buffs.DamageBoostIndex);
                    targetBody.baseDamage *= (ConfigHandler.DamageValue * 0.1f) + 1f;
                    break;

                    #endregion
                    #region HealthBoost
                case 2 when targetTeam == TeamIndex.Player:
                    targetInventory.GiveItem(Items.HealthBoostIndex);
                    targetBody.baseMaxHealth *= (ConfigHandler.HealthValue * 0.01f) + 1f;
                    break;

                case 2 when targetTeam == TeamIndex.Monster:
                    targetBody.AddBuff(Buffs.HealthBoostIndex);
                    targetBody.baseMaxHealth *= (ConfigHandler.HealthValue * 0.1f) + 1f;
                    break;

                    #endregion
                case 3:
                    targetHealth.HealFraction(ConfigHandler.HealingValue * 0.01f, new ProcChainMask());
                    break;

                case 4:
                    ulong exp = (targetTeamManager.GetTeamNextLevelExperience(targetTeam) - targetTeamManager.GetTeamCurrentLevelExperience(targetTeam)) * (ulong)(ConfigHandler.ExpValue * 0.01f);
                    targetTeamManager.GiveTeamExperience(targetTeam, exp);
                    break;

                case 5:
                    switch (affixType)
                    {
                    case 0:                                     //Nothing
                        break;

                    case 1:                                     //Blue
                        if (targetTeam == TeamIndex.Player && ConfigHandler.AffixOverride)
                        {
                            targetInventory.SetEquipmentIndex(EquipmentIndex.AffixBlue);
                        }
                        else
                        {
                            targetBody.AddBuff(BuffIndex.AffixBlue);
                        }
                        break;

                    case 2:                                     //Red
                        if (targetTeam == TeamIndex.Player && ConfigHandler.AffixOverride)
                        {
                            targetInventory.SetEquipmentIndex(EquipmentIndex.AffixRed);
                        }
                        else
                        {
                            targetBody.AddBuff(BuffIndex.AffixRed);
                        }
                        break;

                    case 3:                                     //White
                        if (targetTeam == TeamIndex.Player && ConfigHandler.AffixOverride)
                        {
                            targetInventory.SetEquipmentIndex(EquipmentIndex.AffixWhite);
                        }
                        else
                        {
                            targetBody.AddBuff(BuffIndex.AffixWhite);
                        }
                        break;

                    case 4:                                     //Ghost
                        if (targetTeam == TeamIndex.Player && ConfigHandler.AffixOverride)
                        {
                            targetInventory.SetEquipmentIndex(EquipmentIndex.AffixHaunted);
                        }
                        else
                        {
                            targetBody.AddBuff(BuffIndex.AffixHaunted);
                        }
                        break;

                    case 5:                                     //Poison
                        if (targetTeam == TeamIndex.Player && ConfigHandler.AffixOverride)
                        {
                            targetInventory.SetEquipmentIndex(EquipmentIndex.AffixPoison);
                        }
                        else
                        {
                            targetBody.AddBuff(BuffIndex.AffixPoison);
                        }
                        break;
                    }
                    break;

                    #region SpeedBoost
                case 6 when targetTeam == TeamIndex.Player:
                    targetInventory.GiveItem(Items.SpeedBoostIndex);
                    targetBody.baseMoveSpeed *= (ConfigHandler.SpeedValue * 0.01f) + 1f;
                    break;

                case 6 when targetTeam == TeamIndex.Monster:
                    targetBody.AddBuff(Buffs.SpeedBoostIndex);
                    targetBody.baseMoveSpeed *= (ConfigHandler.SpeedValue * 0.1f) + 1f;
                    break;

                    #endregion
                    #region DexBoost
                case 7 when targetTeam == TeamIndex.Player:
                    targetInventory.GiveItem(Items.DexBoostIndex);
                    targetBody.baseAttackSpeed *= (ConfigHandler.DexValue * 0.01f) + 1f;
                    break;

                case 7 when targetTeam == TeamIndex.Monster:
                    targetBody.AddBuff(Buffs.DexBoostIndex);
                    targetBody.baseAttackSpeed *= (ConfigHandler.DexValue * 0.1f) + 1f;
                    break;

                    #endregion
                    #region ArmorBoost
                case 8 when targetTeam == TeamIndex.Player:
                    targetInventory.GiveItem(Items.ArmorBoostIndex);
                    targetBody.baseArmor *= (ConfigHandler.ArmorValue * 0.01f) + 1f;
                    break;

                case 8 when targetTeam == TeamIndex.Monster:
                    targetBody.AddBuff(Buffs.ArmorBoostIndex);
                    targetBody.baseArmor *= (ConfigHandler.ArmorValue * 0.1f) + 1f;
                    break;
                    #endregion
                }
                targetBody.RecalculateStats();
            }
            catch { }
        }
Пример #20
0
        internal static void Init()
        {
            On.RoR2.HealthComponent.TakeDamage += (orig, self, damageInfo) =>
            {
                try
                {
                    if (damageInfo.attacker)
                    {
                        Inventory Inv              = damageInfo.attacker.GetComponent <CharacterBody>().inventory;
                        Inventory EnemyInventory   = self.GetComponent <CharacterBody>().inventory;
                        float     BoxingGloveCount = Inv.GetItemCount(Assets.BiscoLeashItemIndex);


                        //if(!self.body.isPlayerControlled&&BoxingGloveCount>0)
                        //{
                        //    var count = Inv.GetItemCount(ItemIndex.ExtraLife);
                        //    if(count >0)
                        //        Inv.RemoveItem(ItemIndex.ExtraLife,count);
                        //}
                        //DamageInfo bla = new DamageInfo
                        //{
                        //    damage = 0f,
                        //    damageColorIndex = DamageColorIndex.Default,
                        //    damageType = DamageType.Generic,
                        //    attacker = null,
                        //    crit = damageInfo.crit,
                        //    force = damageInfo.force,
                        //    inflictor = null,
                        //    position = damageInfo.position,
                        //    procChainMask = damageInfo.procChainMask,
                        //    procCoefficient = 0f,
                        //
                        //};


                        var   cb     = damageInfo.attacker.GetComponent <CharacterBody>();
                        float chance = (float)((BoxingGloveCount) * CustomItem.PlayerChanceToStealItem.Value);

                        bool shouldTrigger = Util.CheckRoll(chance, cb.master);
                        if (shouldTrigger)
                        {
                            CharacterBody currentBody = self.body;
                            for (int i = 0; i < BoxingGloveCount; i++)
                            {
                                Vector3          corePos      = Util.GetCorePosition(currentBody);
                                List <ItemIndex> lstItemIndex = new List <ItemIndex>();
                                foreach (var element in ItemCatalog.allItems)
                                {
                                    if (currentBody.inventory.GetItemCount(element) > 0)
                                    {
                                        lstItemIndex.Add(element);
                                    }
                                }
                                var       rand           = new System.Random();
                                int       randomPosition = rand.Next(0, lstItemIndex.Count - 1);
                                ItemIndex itemToRemove   = lstItemIndex[randomPosition];
                                currentBody.inventory.RemoveItem(itemToRemove, 1);

                                //ChatMessage.Send("Removed from enemy" +  RoR2.ItemCatalog.GetItemDef(itemToRemove).name + " from " + currentBody.GetUserName());



                                currentBody.AddBuff(CustomItem.indexNoHealBuff);
                                currentBody = Util.GetFriendlyEasyTarget(currentBody, new Ray(corePos, new Vector3(0, 0, 0)), 20, 100);

                                //if(!additionalEnemy != null)
                                //    additionalEnemy.AddBuff(CustomItem.indexNoHealBuff);
                                //else
                                //    RoR2.Console.print("Addional enemy null");
                            }

                            //Chat.AddMessage("Removed " + itemToRemove);



                            //var thisThingsGonnaX = GlobalEventManager.instance.chainLightingPrefab;
                            //var chainLightingPrefab = (GameObject)Resources.Load("prefabs/projectiles/chainlightning");
                            //
                            //var x = thisThingsGonnaX.GetComponent<LightIntensityCurve>();
                            //EffectManager.SpawnEffect(x.gameObject,new EffectData {
                            //    origin = currentBody.corePosition,
                            //    color = Color.black
                            //},true);
                            //EffectManager.SpawnEffect(x.explosionEffect,new EffectData {
                            //    origin = corePos,
                            //    rotation = Quaternion.identity,
                            //    scale = 15
                            //},true);
                            //new BlastAttack
                            //{
                            //    position = corePos,
                            //    baseDamage = 1,
                            //    baseForce = 2000f,
                            //    bonusForce = Vector3.up * 1000f,
                            //    radius = 15,
                            //    attacker = self.gameObject,
                            //    inflictor = null,
                            //    crit = Util.CheckRoll(self.body.crit, self.body.master),
                            //    damageColorIndex = DamageColorIndex.Poison,
                            //    falloffModel = BlastAttack.FalloffModel.Linear,
                            //    attackerFiltering = AttackerFiltering.NeverHit,
                            //    teamIndex = self.body.teamComponent?.teamIndex ?? default,
                            //    damageType = DamageType.AOE,
                            //    procCoefficient=1
                            //};



                            //EnemyInventory.RemoveItem(ItemIndex.ExtraLife, 1);

                            //self.GetComponent<CharacterBody>().AddTimedBuff(CustomItem.indexNoHealBuff,60);
                            //self.TakeDamage(bla);
                        }
                    }
                    if (damageInfo.inflictor)
                    {
                        Inventory Inv              = damageInfo.attacker.GetComponent <CharacterBody>().inventory;
                        Inventory EnemyInventory   = self.GetComponent <CharacterBody>().inventory;
                        float     BoxingGloveCount = EnemyInventory.GetItemCount(Assets.BiscoLeashItemIndex);
                        var       cb     = damageInfo.attacker.GetComponent <CharacterBody>();
                        float     chance = (float)(BoxingGloveCount * 0.5);

                        int totalItemCount = 0;
                        totalItemCount += EnemyInventory.GetTotalItemCountOfTier(ItemTier.Tier1);
                        totalItemCount += EnemyInventory.GetTotalItemCountOfTier(ItemTier.Tier2);
                        totalItemCount += EnemyInventory.GetTotalItemCountOfTier(ItemTier.Tier3);
                        bool shouldTrigger = Util.CheckRoll(((float)CustomItem.EnemyChanceToStealItem.Value * (totalItemCount / CustomItem.EnemyItemDivisor.Value)), cb.master);

                        RoR2.Console.print(chance * (totalItemCount / 20));
                        if (shouldTrigger)
                        {
                            List <ItemIndex> lstItemIndex = new List <ItemIndex>();
                            foreach (var element in ItemCatalog.allItems)
                            {
                                if (EnemyInventory.GetItemCount(element) > 0)
                                {
                                    lstItemIndex.Add(element);
                                }
                            }
                            var       rand           = new System.Random();
                            int       randomPosition = rand.Next(0, lstItemIndex.Count - 1);
                            ItemIndex itemToRemove   = lstItemIndex[randomPosition];
                            if (itemToRemove != Assets.BiscoLeashItemIndex)
                            {
                                EnemyInventory.RemoveItem(itemToRemove, 1);
                                ChatMessage.Send("Removed " + RoR2.ItemCatalog.GetItemDef(itemToRemove).name + " from " + self.GetComponent <CharacterBody>().GetUserName());
                                //Chat.AddMessage("Removed " +  RoR2.ItemCatalog.GetItemDef(itemToRemove).name + " from " + self.GetComponent<CharacterBody>().GetUserName());
                                self.GetComponent <CharacterBody>().AddBuff(CustomItem.indexNoHealBuff);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    RoR2.Console.print(e);
                }

                orig(self, damageInfo); // dont forget this !
            };
            On.RoR2.UI.ItemInventoryDisplay.OnInventoryChanged += (On.RoR2.UI.ItemInventoryDisplay.orig_OnInventoryChanged orig, RoR2.UI.ItemInventoryDisplay self) =>
            {
                orig(self);
            };
            On.RoR2.GlobalEventManager.OnInteractionBegin += (On.RoR2.GlobalEventManager.orig_OnInteractionBegin orig, global::RoR2.GlobalEventManager self, global::RoR2.Interactor interactor, IInteractable interactable, GameObject interactableObject) =>
            {
                orig(self, interactor, interactable, interactableObject);
            };
            On.RoR2.GenericPickupController.GrantItem += (On.RoR2.GenericPickupController.orig_GrantItem orig, global::RoR2.GenericPickupController self, global::RoR2.CharacterBody body, global::RoR2.Inventory inventory) =>
            {
                //RoR2.Console.print("----------------grant item---------------");
                if (inventory.GetItemCount(Assets.BiscoLeashItemIndex) > 0)
                {
                    if (inventory.GetItemCount(ItemIndex.ExtraLife) > 0)
                    {
                        inventory.RemoveItem(ItemIndex.ExtraLife, inventory.GetItemCount(ItemIndex.ExtraLife));
                    }
                    if (self.pickupIndex.itemIndex == ItemIndex.ExtraLife)
                    {
                        return;
                    }
                    if (self.pickupIndex.itemIndex == Assets.BiscoLeashItemIndex)
                    {
                        inventory.RemoveItem(ItemIndex.ExtraLife, inventory.GetItemCount(ItemIndex.ExtraLife));
                    }
                }
                if (self.pickupIndex.itemIndex == Assets.BiscoLeashItemIndex)
                {
                    inventory.RemoveItem(ItemIndex.ExtraLife, inventory.GetItemCount(ItemIndex.ExtraLife));
                }
                orig(self, body, inventory);
            };
        }
Пример #21
0
        public void Combine(CongregateController other)
        {
            isCombining       = true;
            other.isCombining = true;

            count += other.count;
            float scale = (CombineScale - 1) * count + 1;

            // set stats, recalculate
            body.baseMaxHealth   = baseStats.baseMaxHealth * count * HealthMultiplier;
            body.baseRegen       = baseStats.baseRegen * count * RegenMultiplier;
            body.baseMoveSpeed   = baseStats.baseMoveSpeed * count * MoveSpeedMultiplier;
            body.baseDamage      = baseStats.baseDamage * count * DamageMultiplier;
            body.baseAttackSpeed = baseStats.baseAttackSpeed * count * AttackSpeedMultiplier;
            body.baseCrit        = baseStats.baseCrit * count * CritMultiplier;
            body.baseArmor       = baseStats.baseArmor * count * ArmorMultiplier;

            // if is a boss or champion
            if (body.isBoss || body.isChampion)
            {
                body.baseMaxHealth   *= BossMultiplier;
                body.baseRegen       *= BossMultiplier;
                body.baseMoveSpeed   *= BossMultiplier;
                body.baseDamage      *= BossMultiplier;
                body.baseAttackSpeed *= BossMultiplier;
                body.baseCrit        *= BossMultiplier;
                body.baseArmor       *= BossMultiplier;
            }

            body.RecalculateStats();

            // kill experience, gold gain, and health/shields
            body.healthComponent.health =
                Mathf.Clamp(body.healthComponent.health + other.body.healthComponent.health, 0, body.maxHealth);
            body.healthComponent.shield =
                Mathf.Clamp(body.healthComponent.shield + other.body.healthComponent.shield, 0, body.maxShield);

            rewards.expReward  += other.rewards.expReward;
            rewards.goldReward += other.rewards.goldReward;

            SendCombine(
                initialScale * scale,
                body.baseMaxHealth,
                body.baseRegen,
                body.baseMoveSpeed,
                body.baseDamage,
                body.baseAttackSpeed,
                body.baseCrit,
                body.baseArmor,
                body.healthComponent.health,
                body.healthComponent.shield
                );

            // combine elite types
            foreach (var index in BuffCatalog.eliteBuffIndices)
            {
                if (other.body.HasBuff(index) && !body.HasBuff(index))
                {
                    body.AddBuff(index);
                }
            }

            other.TrueDestroy();
            isCombining = false;
        }
        public override void OnLoad()
        {
            base.OnLoad();
            itemDef.name = "MysticsItems_CoffeeBoostOnItemPickup";
            SetItemTierWhenAvailable(ItemTier.Tier2);
            itemDef.tags = new ItemTag[]
            {
                ItemTag.Utility,
                ItemTag.AIBlacklist
            };
            itemDef.pickupModelPrefab = PrepareModel(Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Coffee/Model.prefab"));
            itemDef.pickupIconSprite  = Main.AssetBundle.LoadAsset <Sprite>("Assets/Items/Coffee/Icon.png");
            HopooShaderToMaterial.Standard.Gloss(itemDef.pickupModelPrefab.transform.Find("÷илиндр").Find("÷илиндр.001").GetComponent <Renderer>().sharedMaterial, 0f);
            itemDisplayPrefab = PrepareItemDisplayModel(PrefabAPI.InstantiateClone(itemDef.pickupModelPrefab, itemDef.pickupModelPrefab.name + "Display", false));
            itemDef.pickupModelPrefab.transform.Find("÷илиндр").Rotate(new Vector3(-30f, 0f, 0f), Space.Self);
            onSetupIDRS += () =>
            {
                AddDisplayRule("CommandoBody", "HandR", new Vector3(-0.016F, 0.214F, -0.111F), new Vector3(33.043F, 10.378F, 286.615F), new Vector3(0.072F, 0.072F, 0.072F));
                AddDisplayRule("HuntressBody", "Muzzle", new Vector3(-0.397F, -0.017F, -0.251F), new Vector3(0.509F, 134.442F, 184.268F), new Vector3(0.037F, 0.037F, 0.037F));
                AddDisplayRule("Bandit2Body", "MuzzleShotgun", new Vector3(-0.006F, 0.103F, -0.765F), new Vector3(46.857F, 3.395F, 94.648F), new Vector3(0.065F, 0.065F, 0.065F));
                AddDisplayRule("ToolbotBody", "Chest", new Vector3(-0.925F, 2.116F, 2.185F), new Vector3(0F, 324.78F, 0F), new Vector3(0.448F, 0.448F, 0.448F));
                AddDisplayRule("EngiBody", "HandR", new Vector3(0.014F, 0.165F, 0.065F), new Vector3(21.189F, 152.963F, 68.785F), new Vector3(0.072F, 0.072F, 0.072F));
                AddDisplayRule("MageBody", "HandR", new Vector3(-0.098F, -0.054F, -0.102F), new Vector3(15.816F, 19.399F, 81.6F), new Vector3(0.059F, 0.059F, 0.059F));
                AddDisplayRule("MercBody", "HandR", new Vector3(0.006F, 0.202F, 0.125F), new Vector3(21.174F, 173.671F, 87.267F), new Vector3(0.08F, 0.08F, 0.08F));
                AddDisplayRule("TreebotBody", "FlowerBase", new Vector3(1.119F, -0.997F, -0.433F), new Vector3(304.283F, 287.341F, 136.374F), new Vector3(0.189F, 0.189F, 0.189F));
                AddDisplayRule("LoaderBody", "MechLowerArmR", new Vector3(-0.002F, 0.311F, 0.171F), new Vector3(78.649F, 219.923F, 309.488F), new Vector3(0.055F, 0.054F, 0.055F));
                AddDisplayRule("CrocoBody", "Head", new Vector3(0.919F, 4.774F, -1.755F), new Vector3(25.068F, 0.938F, 231.2F), new Vector3(1F, 1F, 1F));
                AddDisplayRule("CaptainBody", "HandR", new Vector3(-0.09F, 0.124F, 0.046F), new Vector3(352.642F, 118.248F, 97.772F), new Vector3(0.076F, 0.069F, 0.076F));
                AddDisplayRule("BrotherBody", "HandR", BrotherInfection.green, new Vector3(0.002F, 0.109F, 0.031F), new Vector3(72.72F, 119.024F, 264.129F), new Vector3(0.043F, 0.043F, 0.043F));
                if (SoftDependencies.SoftDependenciesCore.itemDisplaysSniper)
                {
                    AddDisplayRule("SniperClassicBody", "Muzzle", new Vector3(-3.90342F, 0.4645F, -0.00028F), new Vector3(90F, 90F, 0F), new Vector3(0.24699F, 0.41591F, 0.24699F));
                }
                AddDisplayRule("RailgunnerBody", "GunScope", new Vector3(-0.0692F, -0.13973F, 0.22722F), new Vector3(278.7664F, 90F, 90F), new Vector3(0.05291F, 0.10893F, 0.05291F));
                AddDisplayRule("VoidSurvivorBody", "Hand", new Vector3(-0.14745F, 0.20297F, 0.04337F), new Vector3(31.68131F, 74.82335F, 46.28517F), new Vector3(0.09265F, 0.09265F, 0.09265F));
            };

            visualEffect = PrefabAPI.InstantiateClone(new GameObject(), "MysticsItems_CoffeeBoostEffect", false);
            EffectComponent effectComponent = visualEffect.AddComponent <EffectComponent>();

            effectComponent.applyScale = true;
            effectComponent.parentToReferencedTransform = true;
            VFXAttributes vfxAttributes = visualEffect.AddComponent <VFXAttributes>();

            vfxAttributes.vfxPriority  = VFXAttributes.VFXPriority.Medium;
            vfxAttributes.vfxIntensity = VFXAttributes.VFXIntensity.Medium;
            visualEffect.AddComponent <DestroyOnTimer>().duration = 2f;

            GameObject particles = PrefabAPI.InstantiateClone(Main.AssetBundle.LoadAsset <GameObject>("Assets/Items/Coffee/CoffeeBoostEffect.prefab"), "Particles", false);

            particles.transform.localScale *= 0.5f;
            particles.transform.SetParent(visualEffect.transform);

            MysticsItemsContent.Resources.effectPrefabs.Add(visualEffect);

            On.RoR2.Inventory.GiveItem_ItemIndex_int += (orig, self, itemIndex, count) =>
            {
                CharacterBody body = CharacterBody.readOnlyInstancesList.ToList().Find(body2 => body2.inventory == self);
                if (body && self.GetItemCount(itemDef) > 0)
                {
                    for (int i = 0; i < count * GetBuffCountFromTier(ItemCatalog.GetItemDef(itemIndex).tier); i++)
                    {
                        if (body.GetBuffCount(MysticsItemsContent.Buffs.MysticsItems_CoffeeBoost) < (maxBuffs + maxBuffsPerStack * (self.GetItemCount(itemDef) - 1)))
                        {
                            if (NetworkServer.active)
                            {
                                body.AddBuff(MysticsItemsContent.Buffs.MysticsItems_CoffeeBoost);
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                orig(self, itemIndex, count);
            };

            On.RoR2.Inventory.RemoveItem_ItemIndex_int += (orig, self, itemIndex, count) =>
            {
                orig(self, itemIndex, count);
                if (NetworkServer.active && itemIndex == itemDef.itemIndex && self.GetItemCount(itemIndex) <= 0)
                {
                    CharacterBody body = CharacterBody.readOnlyInstancesList.ToList().Find(body2 => body2.inventory == self);
                    if (body)
                    {
                        while (body.GetBuffCount(MysticsItemsContent.Buffs.MysticsItems_CoffeeBoost) > 0)
                        {
                            body.RemoveBuff(MysticsItemsContent.Buffs.MysticsItems_CoffeeBoost);
                        }
                    }
                }
            };

            On.RoR2.Language.GetLocalizedStringByToken += Language_GetLocalizedStringByToken;
        }
Пример #23
0
        // Token: 0x06002B85 RID: 11141 RVA: 0x000B79E4 File Offset: 0x000B5BE4
        private void RootPulse()
        {
            Vector3 position = base.transform.position;

            foreach (HurtBox hurtBox in new SphereSearch
            {
                origin = position,
                radius = TreebotFlower2Projectile.radius,
                mask = LayerIndex.entityPrecise.mask
            }.RefreshCandidates().FilterCandidatesByHurtBoxTeam(TeamMask.AllExcept(this.teamIndex)).OrderCandidatesByDistance().FilterCandidatesByDistinctHurtBoxEntities().GetHurtBoxes())
            {
                CharacterBody body = hurtBox.healthComponent.body;
                if (!this.rootedBodies.Contains(body))
                {
                    this.rootedBodies.Add(body);
                    body.AddBuff(BuffIndex.Entangle);
                    body.RecalculateStats();
                    Vector3   a         = hurtBox.transform.position - position;
                    float     magnitude = a.magnitude;
                    Vector3   a2        = a / magnitude;
                    Rigidbody component = hurtBox.healthComponent.GetComponent <Rigidbody>();
                    float     num       = component ? component.mass : 1f;
                    float     num2      = magnitude - TreebotFlower2Projectile.yankIdealDistance;
                    float     num3      = TreebotFlower2Projectile.yankSuitabilityCurve.Evaluate(num);
                    Vector3   vector    = component ? component.velocity : Vector3.zero;
                    if (HGMath.IsVectorNaN(vector))
                    {
                        vector = Vector3.zero;
                    }
                    Vector3 a3 = -vector;
                    if (num2 > 0f)
                    {
                        a3 = a2 * -Trajectory.CalculateInitialYSpeedForHeight(num2, -body.acceleration);
                    }
                    Vector3    force      = a3 * (num * num3);
                    DamageInfo damageInfo = new DamageInfo
                    {
                        attacker         = this.owner,
                        inflictor        = base.gameObject,
                        crit             = this.crit,
                        damage           = this.damage,
                        damageColorIndex = DamageColorIndex.Default,
                        damageType       = this.damageType,
                        force            = force,
                        position         = hurtBox.transform.position,
                        procChainMask    = this.procChainMask,
                        procCoefficient  = this.procCoefficient
                    };
                    hurtBox.healthComponent.TakeDamage(damageInfo);
                    HurtBox      hurtBoxReference = hurtBox;
                    HurtBoxGroup hurtBoxGroup     = hurtBox.hurtBoxGroup;
                    int          num4             = 0;
                    while ((float)num4 < Mathf.Min(4f, body.radius * 2f))
                    {
                        EffectData effectData = new EffectData
                        {
                            scale        = 1f,
                            origin       = position,
                            genericFloat = Mathf.Max(0.2f, TreebotFlower2Projectile.duration - base.fixedAge)
                        };
                        effectData.SetHurtBoxReference(hurtBoxReference);
                        EffectManager.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/OrbEffects/EntangleOrbEffect"), effectData, true);
                        hurtBoxReference = hurtBoxGroup.hurtBoxes[UnityEngine.Random.Range(0, hurtBoxGroup.hurtBoxes.Length)];
                        num4++;
                    }
                }
            }
        }
        private static void doMultiElite(GameObject gameObject, CombatDirector self)
        {
            DirectorCard card = self.lastAttemptedMonsterCard;

            float credit = self.monsterCredit;

            CharacterBody body = gameObject.GetComponentInChildren <CharacterMaster>().GetBody();

            CombatDirector.EliteTierDef[] eliteDefs = typeof(CombatDirector).GetFieldValue <CombatDirector.EliteTierDef[]>("eliteTiers");

            int currentEliteTypes = 1;

            foreach (BuffIndex buff in BuffCatalog.eliteBuffIndices)
            {
                BuffDef buffDef = BuffCatalog.GetBuffDef(buff);
                if (body.HasBuff(buff))
                {
                    currentEliteTypes += 1;
                }
            }
            if (currentEliteTypes > 1)
            {
                foreach (CombatDirector.EliteTierDef tierDef in eliteDefs)
                {
                    foreach (EliteIndex eliteIndex in tierDef.eliteTypes)
                    {
                        if (credit > card.cost * tierDef.costMultiplier * currentEliteTypes)
                        {
                            BuffDef buffDef = BuffCatalog.GetBuffDef(BuffIndex.None);

                            foreach (BuffIndex buff in BuffCatalog.eliteBuffIndices)
                            {
                                BuffDef tempDef = BuffCatalog.GetBuffDef(buff);

                                if (tempDef.eliteIndex == eliteIndex)
                                {
                                    buffDef = tempDef;
                                }
                            }

                            if (buffDef != null)
                            {
                                if (!(body.HasBuff(buffDef.buffIndex)))
                                {
                                    body.AddBuff(buffDef.buffIndex);
                                    self.monsterCredit -= card.cost * tierDef.costMultiplier * currentEliteTypes;
                                    credit             -= card.cost * tierDef.costMultiplier * currentEliteTypes;
                                    currentEliteTypes++;

                                    float num3 = tierDef.healthBoostCoefficient;
                                    float damageBoostCoefficient = tierDef.damageBoostCoefficient;
                                    if (self.combatSquad)
                                    {
                                        int livingPlayerCount = Run.instance.livingPlayerCount;
                                        num3 *= Mathf.Pow((float)livingPlayerCount, 1f);
                                    }
                                    body.inventory.GiveItem(ItemIndex.BoostHp, Mathf.RoundToInt((num3 - 1f) * 10f));
                                    body.inventory.GiveItem(ItemIndex.BoostDamage, Mathf.RoundToInt((damageBoostCoefficient - 1f) * 10f));

                                    EliteDef       eliteDef       = EliteCatalog.GetEliteDef(eliteIndex);
                                    EquipmentIndex equipmentIndex = (eliteDef != null) ? eliteDef.eliteEquipmentIndex : EquipmentIndex.None;
                                    if (equipmentIndex != EquipmentIndex.None)
                                    {
                                        if (body.inventory.GetEquipmentIndex() == EquipmentIndex.None)
                                        {
                                            body.inventory.SetEquipmentIndex(equipmentIndex);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }