예제 #1
0
        public void Awake()
        {
            On.RoR2.CharacterBody.OnInventoryChanged += (orig, self) =>
            {
                if (self.inventory.GetItemCount((ItemIndex)ItemLib.ItemLib.GetItemId("Ifrits Distinction")) > 0)
                {
                    self.AddBuff(BuffIndex.AffixRed);
                }
                else if (self.HasBuff(BuffIndex.AffixRed) && self.inventory.currentEquipmentIndex != EquipmentIndex.AffixRed)
                {
                    self.RemoveBuff(BuffIndex.AffixRed);
                }
            };

            On.RoR2.GlobalEventManager.OnHitEnemy += (orig, self, damageInfo, victim) =>
            {
                orig(self, damageInfo, victim);
                Debug.Log("Test");
                int count = damageInfo.attacker.GetComponent <CharacterBody>().inventory.GetItemCount((ItemIndex)ItemLib.ItemLib.GetItemId("Ifrits Distinction"));
                if (count > 1)
                {
                    bool flag5 = (damageInfo.damageType & DamageType.PercentIgniteOnHit)
                                 != DamageType.Generic || damageInfo.attacker.GetComponent <CharacterBody>().HasBuff(BuffIndex.AffixRed);
                    CharacterBody bleck = victim.GetComponent <CharacterBody>();
                    for (int i = count - 1; i > 0; i--)
                    {
                        DotController.InflictDot(victim, damageInfo.attacker, flag5 ? DotController.DotIndex.PercentBurn : DotController.DotIndex.Burn, 4f * damageInfo.procCoefficient, 1f);
                    }
                }
            };
        }
예제 #2
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);
        }
예제 #3
0
 private static void GlobalEventManager_OnHitEnemy(On.RoR2.GlobalEventManager.orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
 {
     if (damageInfo.HasModdedDamageType(OriginalPoisonOnHit))
     {
         DotController.InflictDot(victim, damageInfo.attacker, OriginalPoisonDot, 2f, 1f);
     }
     orig(self, damageInfo, victim);
 }
예제 #4
0
 public static void MyCommandName(ConCommandArgs args)
 {
     DotController.DotIndex index = (DotController.DotIndex)Array.FindIndex(DotController.dotDefs, (dotDef) => dotDef.associatedBuff == BuffIndex.OnFire);
     for (int y = 0; y < args.GetArgInt(0); y++)
     {
         DotController.InflictDot(args.senderBody.gameObject, args.senderBody.gameObject, index, args.GetArgInt(1), 0.25f);
         //args.senderBody.AddTimedBuffAuthority(BuffIndex.OnFire, args.GetArgInt(1));
     }
 }
예제 #5
0
        private void On_ESDetonate(On.EntityStates.Engi.Mine.Detonate.orig_Explode orig, Detonate self)
        {
            if (self.outer.name != "FootMine(Clone)")
            {
                orig(self);
            }
            else if (NetworkServer.active)
            {
                List <TeamComponent> teamMembers = new List <TeamComponent>();
                TeamFilter           teamFilter  = self.GetComponent <TeamFilter>();
                float      blastRadius           = Detonate.blastRadius * 1.2f;
                float      sqrad = blastRadius * blastRadius;
                bool       isFF  = FriendlyFireManager.friendlyFireMode != FriendlyFireManager.FriendlyFireMode.Off;
                GameObject owner = self.projectileController.owner;
                int        icnt  = (int)self.GetComponent <ProjectileDamage>().damage; // this is actually the stack number

                if (isFF || teamFilter.teamIndex != TeamIndex.Monster)
                {
                    teamMembers.AddRange(TeamComponent.GetTeamMembers(TeamIndex.Monster));
                }
                if (isFF || teamFilter.teamIndex != TeamIndex.Neutral)
                {
                    teamMembers.AddRange(TeamComponent.GetTeamMembers(TeamIndex.Neutral));
                }
                if (isFF || teamFilter.teamIndex != TeamIndex.Player)
                {
                    teamMembers.AddRange(TeamComponent.GetTeamMembers(TeamIndex.Player));
                }
                if (owner)
                {
                    teamMembers.Remove(owner.GetComponent <TeamComponent>());
                }

                foreach (TeamComponent tcpt in teamMembers)
                {
                    if ((tcpt.transform.position - self.transform.position).sqrMagnitude <= sqrad)
                    {
                        if (tcpt.body && tcpt.body.mainHurtBox && tcpt.body.isActiveAndEnabled)
                        {
                            DotController.InflictDot(tcpt.gameObject, owner, poisonDot, baseTicks + stackTicks * (icnt - 1), baseDmg + stackDmg * (icnt - 1));
                        }
                    }
                }

                if (Detonate.explosionEffectPrefab)
                {
                    EffectManager.SpawnEffect(Detonate.explosionEffectPrefab, new EffectData
                    {
                        origin   = self.transform.position,
                        rotation = self.transform.rotation,
                        scale    = blastRadius
                    }, true);
                }
                EntityState.Destroy(self.gameObject);
            }
        }
예제 #6
0
        private static void GlobalEventManager_ServerDamageDealt(On.RoR2.GlobalEventManager.orig_ServerDamageDealt orig, DamageReport damageReport)
        {
            orig(damageReport);

            if ((damageReport.attackerBody) && damageReport.dotType == DotController.DotIndex.None && damageReport.attackerBody.HasBuff(_buffIndex))
            {
                damageReport.victimBody.AddTimedBuff(BuffIndex.Blight, 2f);
                DotController.InflictDot(damageReport.victimBody.gameObject, damageReport.attacker, DotController.DotIndex.Blight, 2f, 1f);
            }
        }
예제 #7
0
        private static void On_TreebotFlower2RootPulse(On.EntityStates.Treebot.TreebotFlower.TreebotFlower2Projectile.orig_RootPulse orig, TreebotFlower2Projectile self)
        {
            var owner      = self.GetFieldValue <GameObject>("owner");
            var isBoosted  = Scepter.instance.GetCount(owner?.GetComponent <CharacterBody>()) > 0;
            var origRadius = TreebotFlower2Projectile.radius;

            if (isBoosted)
            {
                TreebotFlower2Projectile.radius *= 2f;
            }
            orig(self);
            TreebotFlower2Projectile.radius = origRadius;
            if (!isBoosted)
            {
                return;
            }
            var rb = self.GetFieldValue <List <CharacterBody> >("rootedBodies");

            rb.ForEach(cb => {
                var nbi = Scepter.instance.itemRng.NextElementUniform(new[] {
                    BuffIndex.Bleeding,
                    BuffIndex.ClayGoo,
                    BuffIndex.Cripple,
                    BuffIndex.HealingDisabled,
                    BuffIndex.OnFire,
                    BuffIndex.Weak,
                    BuffIndex.Pulverized,
                    ClassicItemsPlugin.freezeBuff
                });
                if (nbi == ClassicItemsPlugin.freezeBuff)
                {
                    var ssoh = cb.gameObject.GetComponent <SetStateOnHurt>();
                    if (ssoh && ssoh.canBeFrozen)
                    {
                        ssoh.SetFrozen(1.5f);
                    }
                    else
                    {
                        return;
                    }
                }
                if (nbi == BuffIndex.OnFire)
                {
                    DotController.InflictDot(cb.gameObject, owner, DotController.DotIndex.Burn, 1.5f, 1f);
                }
                if (nbi == BuffIndex.Bleeding)
                {
                    DotController.InflictDot(cb.gameObject, owner, DotController.DotIndex.Bleed, 1.5f, 1f);
                }
                cb.AddTimedBuff(nbi, 1.5f);
            });
        }
예제 #8
0
 public static void ApplyDot(this HealthComponent victim, GameObject attacker,
                             DotController.DotIndex dotIndex, float duration = 8f, float damageMultiplier = 1f)
 {
     if (NetworkServer.active)
     {
         DotController.InflictDot(victim.gameObject, attacker, dotIndex, duration, damageMultiplier);
     }
     else
     {
         new DotMessage(victim.gameObject, attacker, dotIndex, duration, damageMultiplier)
         .Send(NetworkDestination.Server);
     }
 }
예제 #9
0
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member

        private void On_GEMOnHitEnemy(On.RoR2.GlobalEventManager.orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
        {
            orig(self, damageInfo, victim);

            if (!NetworkServer.active || !victim || !damageInfo.attacker || damageInfo.procCoefficient <= 0f)
            {
                return;
            }

            var vicb = victim.GetComponent <CharacterBody>();

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

            if (!body || !vicb || !vicb.healthComponent || !vicb.mainHurtBox || vicb.HasBuff(poisonBuff))
            {
                return;
            }

            CharacterMaster chrm = body.master;

            if (!chrm)
            {
                return;
            }

            int icnt = GetCount(body);

            if (icnt == 0)
            {
                return;
            }

            icnt--;
            float m2Proc = procChance;

            if (icnt > 0)
            {
                m2Proc += stackChance * icnt;
            }
            if (m2Proc > capChance)
            {
                m2Proc = capChance;
            }
            if (!Util.CheckRoll(m2Proc * damageInfo.procCoefficient, chrm))
            {
                return;
            }

            DotController.InflictDot(victim, damageInfo.attacker, poisonDot, duration);
        }
예제 #10
0
파일: Hooks.cs 프로젝트: 6len/game-mods
        private static void PoisonOnHit_OnHit(On.RoR2.GlobalEventManager.orig_OnHitEnemy orig, GlobalEventManager gem,
                                              DamageInfo damageInfo, [NotNull] GameObject victim)
        {
            try
            {
                if (damageInfo.procCoefficient == 0f || damageInfo.rejected)
                {
                    return;
                }
                if (!NetworkServer.active)
                {
                    return;
                }
                CharacterBody component     = damageInfo.attacker.GetComponent <CharacterBody>();
                CharacterBody characterBody = victim ? victim.GetComponent <CharacterBody>() : null;
                if (component)
                {
                    CharacterMaster master = component.master;
                    if (master)
                    {
                        Inventory     inventory  = master.inventory;
                        TeamComponent component2 = component.GetComponent <TeamComponent>();
                        TeamIndex     teamIndex  = component2 ? component2.teamIndex : TeamIndex.Neutral;
                        Vector3       aimOrigin  = component.aimOrigin;
                        int           itemCount2 = inventory.GetItemCount(GNCItemSuite.PoisonOnHitItemIndex);
                        int           itemCount3 = inventory.GetItemCount(GNCItemSuite.BlightOnHitItemIndex);


                        if ((itemCount2 > 0) && (Util.CheckRoll(5f * (float)itemCount2 * damageInfo.procCoefficient, master)))
                        {
                            ProcChainMask procChainMask2 = damageInfo.procChainMask;
                            procChainMask2.AddProc(ProcType.BleedOnHit);
                            DotController.InflictDot(victim, damageInfo.attacker, DotController.DotIndex.Poison, 10f * damageInfo.procCoefficient, 1f);
                        }

                        if ((itemCount3 > 0) && (Util.CheckRoll(10f * (float)itemCount3 * damageInfo.procCoefficient, master)))
                        {
                            ProcChainMask procChainMask2 = damageInfo.procChainMask;
                            procChainMask2.AddProc(ProcType.BleedOnHit);
                            DotController.InflictDot(victim, damageInfo.attacker, DotController.DotIndex.Blight, 10f * damageInfo.procCoefficient, 1f);
                        }
                    }
                }
            }
            catch
            {
            }

            orig(gem, damageInfo, victim);
        }
예제 #11
0
        static public void ModdedHitEnemy(On.RoR2.GlobalEventManager.orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
        {
            if (damageInfo.procCoefficient == 0 || !NetworkServer.active || (!(bool)damageInfo.attacker || damageInfo.procCoefficient <= 0))
            {
                return;
            }

            CharacterBody Attacker      = damageInfo.attacker.GetComponent <CharacterBody>();
            CharacterBody characterBody = victim ? victim.GetComponent <CharacterBody>() : null;

            if (!Attacker)
            {
                return;
            }
            CharacterMaster master = Attacker.master;

            if (!master)
            {
                return;
            }
            damageInfo.procChainMask.LinkToManager();

            Inventory     inventory         = master.inventory;
            TeamComponent Team              = Attacker.GetComponent <TeamComponent>();
            TeamIndex     attackerTeamIndex = Team ? Team.teamIndex : TeamIndex.Neutral;

            Vector3 aimOrigin = Attacker.aimOrigin;

            ModItemManager.OnHitEnemyEffects(self, damageInfo, victim);


            //SetOnFire . Can't realy do much for this one
            int  DamageType = (uint)(damageInfo.damageType & RoR2.DamageType.IgniteOnHit) > 0U ? 1 : 0;
            bool CanSetFire = (damageInfo.damageType & RoR2.DamageType.PercentIgniteOnHit) != RoR2.DamageType.Generic || Attacker.HasBuff(BuffIndex.AffixRed);
            int  num2       = CanSetFire ? 1 : 0;

            if ((DamageType | num2) != 0)
            {
                DotController.InflictDot(victim, damageInfo.attacker, CanSetFire ? DotController.DotIndex.PercentBurn : DotController.DotIndex.Burn, 4f * damageInfo.procCoefficient, 1f);
            }

            //Apply Ice Elite (Will have to wait for Buff Change for that)
            if ((Attacker.HasBuff(BuffIndex.AffixWhite) ? 1 : 0) > 0 && (bool)((UnityEngine.Object)characterBody))
            {
                characterBody.AddTimedBuff(BuffIndex.Slow80, 1.5f * damageInfo.procCoefficient);
            }

            damageInfo.procChainMask.UnlinkToManager();
        }
예제 #12
0
 public void AddBuffAndDot(BuffIndex buff, float duration, int stackCount, RoR2.CharacterBody body)
 {
     DotController.DotIndex index = (DotController.DotIndex)Array.FindIndex(DotController.dotDefs, (dotDef) => dotDef.associatedBuff == buff);
     for (int y = 0; y < stackCount; y++)
     {
         if (index != DotController.DotIndex.None)
         {
             DotController.InflictDot(body.gameObject, body.gameObject, index, duration, 0.25f);
         }
         else
         {
             body.AddTimedBuffAuthority(buff, duration);
         }
     }
 }
예제 #13
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;
        }
예제 #14
0
            public static void ThalliumItemHook()
            {
                On.RoR2.GlobalEventManager.OnHitEnemy += (orig, self, damage, victim) =>
                {
                    if (damage.attacker)
                    {
                        CharacterBody   Attacker       = damage.attacker.GetComponent <CharacterBody>();
                        CharacterMaster AttackerMaster = Attacker.master;
                        CharacterBody   VictimBody     = victim ? victim.GetComponent <CharacterBody>() : null;
                        if (Attacker && AttackerMaster)
                        {
                            int itemcount = Attacker.inventory.GetItemCount(ThalliumItemIndex);
                            if ((itemcount > 0) && (Util.CheckRoll(10f * damage.procCoefficient, AttackerMaster)))
                            {
                                ProcChainMask procChainMask = damage.procChainMask;
                                procChainMask.AddProc(ProcType.BleedOnHit);
                                DotController.InflictDot(victim, damage.attacker, DotController.DotIndex.Blight, 3f * damage.procCoefficient, 3.33f * itemcount);
                                VictimBody.AddTimedBuff(ThalliumDebuff, 3f * damage.procCoefficient);
                            }
                        }
                    }
                    orig(self, damage, victim);
                };
                void ThalliumILHook(ILContext il)
                {
                    var c = new ILCursor(il);

                    c.GotoNext(x => x.MatchCallvirt <CharacterBody>("set_moveSpeed"));
                    c.Emit(OpCodes.Ldarg_0);
                    c.EmitDelegate <Func <CharacterBody, float> >((cb) =>
                    {
                        if (cb.HasBuff(ThalliumDebuff))
                        {
                            return(0.5f);
                        }
                        return(1.0f);
                    });
                    c.Emit(OpCodes.Mul);
                }

                IL.RoR2.CharacterBody.RecalculateStats += ThalliumILHook;
            }
예제 #15
0
        private void DoBuff()
        {
            if (!this.hasFired)
            {
                this.hasFired = true;

                base.characterBody.AddSpreadBloom(0.75f);
                Ray aimRay = base.GetAimRay();
                EffectManager.SimpleMuzzleFlash(Commando.CommandoWeapon.FirePistol.effectPrefab, base.gameObject, this.muzzleString, false);


                if (NetworkServer.active)
                {
                    base.characterBody.AddTimedBuff(WispSurvivor.Modules.Buffs.invigorate, 5f);


                    if (grappleHandler.hasGrappleTarget())
                    {
                        List <GrappleTarget> targets = grappleHandler.GetGrappleTargets();
                        foreach (GrappleTarget target in targets)
                        {
                            if (target.grappleTarget.teamIndex == TeamIndex.Monster)
                            {
                                if (NetworkServer.active)
                                {
                                    target.grappleTargetBody.AddTimedBuff(WispSurvivor.Modules.Buffs.regenMinus, 5f);
                                    DotController.InflictDot(target.grappleTargetHealth.gameObject, base.healthComponent.gameObject, WispSurvivor.Modules.Buffs.degenDot);
                                }
                            }
                            else if (target.grappleTarget.teamIndex == TeamIndex.Player)
                            {
                                if (NetworkServer.active)
                                {
                                    target.grappleTargetBody.AddTimedBuff(WispSurvivor.Modules.Buffs.invigorate, 5f);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #16
0
        private void On_TreebotFlower2RootPulse(On.EntityStates.Treebot.TreebotFlower.TreebotFlower2Projectile.orig_RootPulse orig, TreebotFlower2Projectile self)
        {
            var isBoosted  = AncientScepterItem.instance.GetCount(self.owner?.GetComponent <CharacterBody>()) > 0;
            var origRadius = TreebotFlower2Projectile.radius;

            if (isBoosted)
            {
                TreebotFlower2Projectile.radius *= 2f;
            }
            orig(self);
            TreebotFlower2Projectile.radius = origRadius;
            if (!isBoosted)
            {
                return;
            }
            self.rootedBodies.ForEach(cb => {
                var nbi = AncientScepterItem.instance.rng.NextElementUniform(new[] {
                    RoR2Content.Buffs.Bleeding,
                    RoR2Content.Buffs.ClayGoo,
                    RoR2Content.Buffs.Cripple,
                    RoR2Content.Buffs.HealingDisabled,
                    RoR2Content.Buffs.OnFire,
                    RoR2Content.Buffs.Weak,
                    RoR2Content.Buffs.Pulverized
                }); //todo: freezebuff
                if (nbi == RoR2Content.Buffs.OnFire)
                {
                    DotController.InflictDot(cb.gameObject, self.owner, DotController.DotIndex.Burn, 1.5f, 1f);
                }
                if (nbi == RoR2Content.Buffs.Bleeding)
                {
                    DotController.InflictDot(cb.gameObject, self.owner, DotController.DotIndex.Bleed, 1.5f, 1f);
                }
                cb.AddTimedBuff(nbi, 1.5f);
            });
        }
예제 #17
0
        public void Awake()
        {
            Setup();

            On.RoR2.HealthComponent.TakeDamage += (orig, self, damageInfo) =>
            {
                bool isPyro = false;
                if (damageInfo.attacker != null)
                {
                    CharacterBody cb = damageInfo.attacker.GetComponent <CharacterBody>();
                    if (cb && cb.baseNameToken == "PYRO_BODY_NAME")
                    {
                        isPyro = true;
                    }
                }

                //This could be done less hackily once official custom damagetype support is in.
                bool isScorch     = false;
                bool isBlazeborne = false;
                bool isFlaregun   = false;
                if (isPyro)
                {
                    if (damageInfo.procCoefficient == Scorch.procCoefficient && damageInfo.damageColorIndex == DamageColorIndex.Default && damageInfo.damageType == DamageType.IgniteOnHit)
                    {
                        isScorch = true;
                        damageInfo.damageType = DamageType.Generic; //Overwrite scorch attempting to ignite.
                    }
                    else if (damageInfo.damageColorIndex == DamageColorIndex.Default && damageInfo.procCoefficient == 1f)
                    {
                        if (damageInfo.damageType == (DamageType.IgniteOnHit | DamageType.SlowOnHit))
                        {
                            isBlazeborne          = true;
                            damageInfo.damageType = DamageType.IgniteOnHit; //The SlowOnHit damagetype is purely for identification purposes.
                        }
                        else if (damageInfo.damageType == (DamageType.IgniteOnHit | DamageType.AOE))
                        {
                            isFlaregun = true;
                        }
                    }
                }

                if (isBlazeborne)  //Handle Blazeborne reheating.
                {
                    int burnCount = self.body.GetBuffCount(BuffIndex.OnFire);
                    if (self.body && burnCount > 0)
                    {
                        damageInfo.damage *= 1 + burnCount * Blazeborne.ignitedDirectHitMult;

                        PyroHeatController phc = damageInfo.attacker.GetComponent <PyroHeatController>();
                        if (phc)
                        {
                            phc.RpcAddHeatServer(Blazeborne.ignitedHeatPercentRestore);
                        }
                    }
                }
                else if (isFlaregun)
                {
                    int burnCount = self.body.GetBuffCount(BuffIndex.OnFire);
                    if (self.body && burnCount > 0)
                    {
                        damageInfo.damage *= 1 + burnCount * Flaregun.ignitedDirectHitMult;

                        PyroHeatController phc = damageInfo.attacker.GetComponent <PyroHeatController>();
                        if (phc)
                        {
                            phc.RpcAddHeatServer(Flaregun.ignitedHeatPercentRestore);
                        }
                    }
                }

                orig(self, damageInfo);

                //For Scorch, manually apply a burn DoT so that it will last longer, because Scorch has a low proc coefficient.
                if (isScorch)
                {
                    DotController.InflictDot(self.gameObject, damageInfo.attacker, DotController.DotIndex.Burn, 4.5f, 1f);
                }
            };
        }
        ////// 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);
            }
        }
예제 #19
0
 public override void Effect(GlobalEventManager globalEventManager, DamageInfo damageInfo, GameObject victim, int itemCount)
 {
     damageInfo.procChainMask.SetProcValue(ProcType.BleedOnHit, true);
     DotController.InflictDot(victim, damageInfo.attacker, DotController.DotIndex.Bleed, 3f * damageInfo.procCoefficient, 1f);
 }
예제 #20
0
        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);
                    }
                }
            }
        }
예제 #21
0
        private void GlobalEventManager_onCharacterDeathGlobal(DamageReport damageReport)
        {
            if (NetworkServer.active)
            {
                if (damageReport.attackerBody && damageReport.attackerBody.inventory)
                {
                    var itemCount = damageReport.attackerBody.inventory.GetItemCount(itemDef);
                    if (itemCount > 0 && damageReport.victimIsElite)
                    {
                        var radius     = ElitePotion.radius + ElitePotion.radiusPerStack * (itemCount - 1);
                        var duration   = ElitePotion.duration + ElitePotion.durationPerStack * (itemCount - 1);
                        var damageMult = 1f + 0.8f * (itemCount - 1);

                        foreach (var buffIndex in BuffCatalog.eliteBuffIndices.Where(x => damageReport.victimBody.HasBuff(x)))
                        {
                            foreach (var spreadEffectInfo in spreadEffectInfos.Where(x => x.eliteBuffDef.buffIndex == buffIndex))
                            {
                                if (spreadEffectInfo.vfx)
                                {
                                    EffectManager.SpawnEffect(spreadEffectInfo.vfx, new EffectData
                                    {
                                        origin = damageReport.victimBody.corePosition,
                                        scale  = radius * (spreadEffectInfo.vfxScaleMultiplier != 0f ? spreadEffectInfo.vfxScaleMultiplier : 1f)
                                    }, true);
                                }

                                sphereSearch.origin = damageReport.victimBody.corePosition;
                                sphereSearch.mask   = LayerIndex.entityPrecise.mask;
                                sphereSearch.radius = radius;
                                sphereSearch.RefreshCandidates();
                                sphereSearch.FilterCandidatesByHurtBoxTeam(TeamMask.GetUnprotectedTeams(damageReport.attackerTeamIndex));
                                sphereSearch.FilterCandidatesByDistinctHurtBoxEntities();
                                sphereSearch.OrderCandidatesByDistance();
                                sphereSearch.GetHurtBoxes(hurtBoxes);
                                sphereSearch.ClearCandidates();
                                foreach (var hurtBox in hurtBoxes)
                                {
                                    if (hurtBox.healthComponent)
                                    {
                                        if (spreadEffectInfo.debuff)
                                        {
                                            hurtBox.healthComponent.body.AddTimedBuff(spreadEffectInfo.debuff, duration);
                                        }
                                        if (spreadEffectInfo.dot != default(DotController.DotIndex) && spreadEffectInfo.dot != DotController.DotIndex.None)
                                        {
                                            DotController.InflictDot(hurtBox.healthComponent.gameObject, damageReport.attacker, spreadEffectInfo.dot, duration, 1f);
                                        }
                                    }
                                }

                                if (spreadEffectInfo.damage != 0 || spreadEffectInfo.damageType != default)
                                {
                                    new BlastAttack
                                    {
                                        radius            = radius,
                                        baseDamage        = damageReport.attackerBody.damage * spreadEffectInfo.damage * damageMult,
                                        procCoefficient   = spreadEffectInfo.procCoefficient,
                                        crit              = Util.CheckRoll(damageReport.attackerBody.crit, damageReport.attackerMaster),
                                        damageType        = spreadEffectInfo.damageType,
                                        damageColorIndex  = DamageColorIndex.Item,
                                        attackerFiltering = AttackerFiltering.Default,
                                        falloffModel      = BlastAttack.FalloffModel.None,
                                        attacker          = damageReport.attacker,
                                        teamIndex         = damageReport.attackerTeamIndex,
                                        position          = damageReport.victimBody.corePosition
                                    }
                                }
예제 #22
0
파일: DotMessage.cs 프로젝트: zkitX/R2API
 public void OnReceived() => DotController.InflictDot(_victim, _attacker, _dotIndex, _duration, _damageMultiplier);
예제 #23
0
 internal static void Apply(CharacterBody target, CharacterBody attacker, Single damageMultiplier, Single duration, Single procCoef, Boolean crit, Vector3 localPos, Vector3 normal, HurtBox hit)
 {
     DotController <PlasmaDot, PlasmaStack, PlasmaUpdate, PlasmaPersist> .InflictDot(target, new(damageMultiplier, duration, procCoef, crit, localPos, normal, attacker, hit));
 }