Example #1
0
        private void GlobalEventManager_OnHitEnemy(On.RoR2.GlobalEventManager.orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, UnityEngine.GameObject victim)
        {
            GameObject attacker = damageInfo.attacker;

            if (self && attacker)
            {
                var attackerBody = attacker.GetComponent <CharacterBody>();
                var victimBody   = victim.GetComponent <CharacterBody>();
                int thalCount    = GetCount(attackerBody);
                if (thalCount > 0)
                {
                    bool flag = (damageInfo.damageType & DamageType.PoisonOnHit) > DamageType.Generic;
                    if ((thalCount > 0 || flag) && (flag || Util.CheckRoll((procChance + (stackChance * (thalCount - 1))))))
                    {
                        ProcChainMask procChainMask = damageInfo.procChainMask;
                        procChainMask.AddProc(ProcType.BleedOnHit);
                        var dotInfo = new InflictDotInfo()
                        {
                            attackerObject   = attacker,
                            victimObject     = victim,
                            dotIndex         = poisonDot,
                            duration         = duration,
                            damageMultiplier = dmgCoefficient
                        };
                        DotController.InflictDot(ref dotInfo);
                    }
                }
            }
            orig(self, damageInfo, victim);
        }
        public void OnDamageInflictedServer(DamageReport damageReport)
        {
            CharacterBody victim = damageReport.victimBody;

            if (victim)
            {
                InflictDotInfo inflictDotInfo = default(InflictDotInfo);
                inflictDotInfo.dotIndex         = String.IsNullOrEmpty(dotName) ? dotIndex : FindDot(dotName);
                inflictDotInfo.attackerObject   = damageReport.attacker;
                inflictDotInfo.damageMultiplier = this.damageCoefficient;
                inflictDotInfo.duration         = this.duration;
                inflictDotInfo.victimObject     = damageReport.victimBody.gameObject;
            }
        }
Example #3
0
        void InflictBurn(int count, DamageReport report)
        {
            var dot = new InflictDotInfo {
                victimObject     = report.victim.gameObject,
                attackerObject   = report.attacker,
                totalDamage      = new float?(((float)(count - 1) * procStackDamage + procBaseDamage) * report.attackerBody.damage),
                dotIndex         = DotController.DotIndex.Burn,
                damageMultiplier = 1f
            };

            if (report.attackerMaster)
            {
                StrengthenBurnUtils.CheckDotForUpgrade(report.attackerMaster.inventory, ref dot);
            }
            isInternalIgnite = true;
            DotController.InflictDot(ref dot);
            isInternalIgnite = false;
        }
        ////// Hooks //////

        private void HealthComponent_TakeDamage(On.RoR2.HealthComponent.orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
        {
            orig(self, damageInfo);

            if (damageInfo == null || !damageInfo.attacker || (damageInfo.damageType & DamageType.DoT) != 0)
            {
                return;
            }

            var dc = DotController.FindDotController(self.gameObject);

            if (!dc || dc.dotStackList.Count <= 0)
            {
                return;
            }

            var body  = damageInfo.attacker.GetComponent <CharacterBody>();
            var count = GetCount(body);

            if (count <= 0)
            {
                return;
            }

            var enemies = GatherEnemies(body.teamComponent.teamIndex, TeamIndex.Neutral)
                          .Select(x => MiscUtil.GetRootWithLocators(x.gameObject))
                          .Where(obj => {
                var hc = obj.GetComponent <HealthComponent>();
                if (!hc || !hc.alive || hc == self)
                {
                    return(false);
                }
                var dvec  = (obj.transform.position - self.transform.position);
                var ddist = dvec.magnitude;
                if (ddist > range)
                {
                    return(false);
                }
                return(true);
            })
                          .ToArray();

            if (enemies.Length <= 0)
            {
                return;
            }

            for (var i = 0; i < count; i++)
            {
                if (!Util.CheckRoll(procChance, body.master))
                {
                    continue;
                }
                var tgt = rng.NextElementUniform(enemies);
                var dot = rng.NextElementUniform(dc.dotStackList);
                var idi = new InflictDotInfo {
                    attackerObject   = damageInfo.attacker,
                    victimObject     = tgt,
                    duration         = dot.timer,
                    dotIndex         = dot.dotIndex,
                    totalDamage      = dot.damage,
                    damageMultiplier = 1f
                };
                DotController.InflictDot(ref idi);
            }
        }
Example #5
0
        private void DotController_InflictDot_refInflictDotInfo(On.RoR2.DotController.orig_InflictDot_refInflictDotInfo orig, ref InflictDotInfo inflictDotInfo)
        {
            orig(ref inflictDotInfo);
            if (isInternalIgnite || !inflictDotInfo.attackerObject || !inflictDotInfo.victimObject)
            {
                return;
            }
            var victimBody = inflictDotInfo.victimObject.GetComponent <CharacterBody>();
            var victimSSOH = inflictDotInfo.victimObject.GetComponent <SetStateOnHurt>();
            var atkb       = inflictDotInfo.attackerObject.GetComponent <CharacterBody>();
            var count      = GetCount(atkb);

            if (count <= 0 || !victimBody || !victimSSOH || (preventSelfProc && victimBody == atkb))
            {
                return;
            }
            if (!Util.CheckRoll(procBaseChance + (float)(count - 1) * procStackChance, atkb.master))
            {
                return;
            }
            bool isStun = rng.nextBool;

            if (!victimBody.healthComponent.isInFrozenState)
            {
                if (isStun)
                {
                    if (victimSSOH.canBeStunned)
                    {
                        victimSSOH.SetStun(1f);
                    }
                }
                else
                {
                    if (victimSSOH.canBeFrozen)
                    {
                        victimSSOH.SetFrozen(2f);
                    }
                }
            }
            var attackerDamage = 1f;

            if (inflictDotInfo.attackerObject)
            {
                var body = inflictDotInfo.attackerObject.GetComponent <CharacterBody>();
                if (body)
                {
                    attackerDamage = body.damage;
                }
            }
            else if (inflictDotInfo.totalDamage != null)
            {
                attackerDamage = inflictDotInfo.totalDamage.Value;
            }
            victimBody.healthComponent.TakeDamage(new DamageInfo {
                attacker         = inflictDotInfo.attackerObject,
                crit             = false,
                damage           = ((float)(count - 1) * procStackDamage + procBaseDamage) * attackerDamage,
                damageColorIndex = DamageColorIndex.Item,
                damageType       = DamageType.Generic,
                force            = Vector3.zero,
                position         = victimBody.corePosition,
                procChainMask    = default,
        private void GenericGameEvents_OnHitEnemy(DamageInfo damageInfo, MysticsRisky2UtilsPlugin.GenericCharacterInfo attackerInfo, MysticsRisky2UtilsPlugin.GenericCharacterInfo victimInfo)
        {
            if (attackerInfo.body && victimInfo.body && attackerInfo.inventory && !damageInfo.rejected)
            {
                var isAshDamage = DamageAPI.HasModdedDamageType(damageInfo, ashDamageType);

                var itemCount = 0;
                var itemLevel = 1;
                var ashHelper = attackerInfo.body.GetComponent <MysticsItemsMarwanAshHelper>();
                if (ashHelper)
                {
                    itemCount = ashHelper.itemCount;
                    itemLevel = ashHelper.itemLevel;
                }

                if (!isAshDamage && victimInfo.healthComponent && attackerInfo.gameObject && damageInfo.procCoefficient > 0f)
                {
                    if (itemCount > 0)
                    {
                        var _damage = damage + damagePerLevel * (attackerInfo.body.level - 1f) * itemCount;
                        if (attackerInfo.teamIndex != TeamIndex.Player)
                        {
                            _damage = Mathf.Min(_damage, enemyExtraDamageCap);
                        }
                        var _crit = attackerInfo.body.RollCrit();
                        if (itemLevel < 3)
                        {
                            DamageInfo extraDamageInfo = new DamageInfo();
                            extraDamageInfo.damage           = _damage;
                            extraDamageInfo.attacker         = attackerInfo.gameObject;
                            extraDamageInfo.procCoefficient  = procCoefficient;
                            extraDamageInfo.position         = damageInfo.position;
                            extraDamageInfo.crit             = _crit;
                            extraDamageInfo.damageColorIndex = ashDamageColor;
                            extraDamageInfo.procChainMask    = damageInfo.procChainMask;
                            extraDamageInfo.damageType       = DamageType.Silent;
                            DamageAPI.AddModdedDamageType(extraDamageInfo, ashDamageType);
                            victimInfo.healthComponent.TakeDamage(extraDamageInfo);
                            GlobalEventManager.instance.OnHitEnemy(extraDamageInfo, victimInfo.healthComponent.gameObject);
                        }
                        else
                        {
                            var _radius = radius + radiusPerLevel * (attackerInfo.body.level - (float)upgradeLevel23) * itemCount;
                            if (attackerInfo.teamIndex != TeamIndex.Player)
                            {
                                _radius = Mathf.Min(_radius, enemySpreadRadiusCap);
                            }
                            var blastAttack = new BlastAttack
                            {
                                radius            = _radius,
                                baseDamage        = _damage,
                                procCoefficient   = procCoefficient,
                                crit              = _crit,
                                damageColorIndex  = ashDamageColor,
                                attackerFiltering = AttackerFiltering.Default,
                                falloffModel      = BlastAttack.FalloffModel.None,
                                attacker          = attackerInfo.gameObject,
                                teamIndex         = attackerInfo.teamIndex,
                                position          = damageInfo.position,
                            };
                            DamageAPI.AddModdedDamageType(blastAttack, ashDamageType);
                            blastAttack.Fire();
                        }
                    }
                }
                if (isAshDamage)
                {
                    EffectManager.SimpleImpactEffect(ashHitVFX, damageInfo.position, Vector3.Normalize(Random.onUnitSphere), true);

                    if (itemLevel >= 2)
                    {
                        var dotInfo = new InflictDotInfo
                        {
                            victimObject     = victimInfo.gameObject,
                            attackerObject   = attackerInfo.gameObject,
                            dotIndex         = Buffs.MarwanAshBurn.ashDotIndex,
                            duration         = dotDuration,
                            damageMultiplier = 1f,
                            totalDamage      = null
                        };

                        var strengthenBurnCount = attackerInfo.inventory.GetItemCount(DLC1Content.Items.StrengthenBurn);
                        if (strengthenBurnCount > 0)
                        {
                            dotInfo.dotIndex = Buffs.MarwanAshBurnStrong.ashDotIndex;
                            var multiplier = 1f + 3f * (float)strengthenBurnCount;
                            dotInfo.damageMultiplier *= multiplier;
                            dotInfo.duration         *= multiplier;
                        }

                        DotController.InflictDot(ref dotInfo);
                    }
                }
            }
        }