コード例 #1
0
        private void ProcMissile(int mNum, CharacterBody attackerBody, ProcChainMask procChainMask, GameObject victim, DamageInfo damageInfo, int stack)
        {
            GameObject    gameObject = attackerBody.gameObject;
            InputBankTest component  = gameObject.GetComponent <InputBankTest>();
            Vector3       position   = component ? component.aimOrigin : gameObject.transform.position;

            float         dmgCoef        = dmgCoefficient + (dmgStack * stack);
            float         damage         = Util.OnHitProcDamage(damageInfo.damage, attackerBody.damage, dmgCoef);
            ProcChainMask procChainMask2 = procChainMask;

            procChainMask2.AddProc(ProcType.Missile);
            FireProjectileInfo fireProjectileInfo = new FireProjectileInfo
            {
                projectilePrefab = GlobalEventManager.instance.missilePrefab,
                position         = position,
                rotation         = Util.QuaternionSafeLookRotation(DetermineFacing(mNum)),
                procChainMask    = procChainMask2,
                target           = victim,
                owner            = gameObject,
                damage           = damage,
                crit             = damageInfo.crit,
                force            = 200f,
                damageColorIndex = DamageColorIndex.Item
            };

            ProjectileManager.instance.FireProjectile(fireProjectileInfo);
        }
コード例 #2
0
        private void ProcMissile(CharacterBody attackerBody, ProcChainMask procChainMask, float damage, bool crit, int stack)
        {
            GameObject    gameObject = attackerBody.gameObject;
            InputBankTest component  = gameObject.GetComponent <InputBankTest>();
            Vector3       position   = component ? component.aimOrigin : gameObject.transform.position;
            float         dmgCoef    = missileDamage + (missileStackDamage * (stack - 1));

            damage *= dmgCoef;
            ProcChainMask procChainMask2 = procChainMask;

            procChainMask2.AddProc(ProcType.Missile);
            FireProjectileInfo fireProjectileInfo = new FireProjectileInfo
            {
                projectilePrefab = GlobalEventManager.instance.missilePrefab,
                position         = position,
                rotation         = Util.QuaternionSafeLookRotation(Vector3.up),
                procChainMask    = procChainMask2,
                owner            = gameObject,
                damage           = damage,
                crit             = crit,
                force            = 200f,
                damageColorIndex = DamageColorIndex.Item
            };

            ProjectileManager.instance.FireProjectile(fireProjectileInfo);
        }
コード例 #3
0
ファイル: Thallium.cs プロジェクト: swuff-star/LostInTransit
        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);
        }
コード例 #4
0
        private static void ProcMissile(int stack, CharacterBody attackerBody, CharacterMaster attackerMaster,
                                        TeamIndex attackerTeamIndex, ProcChainMask procChainMask, GameObject victim, DamageInfo damageInfo)
        {
            if (stack > 0)
            {
                GameObject    gameObject = attackerBody.gameObject;
                InputBankTest component  = gameObject.GetComponent <InputBankTest>();
                Vector3       position   = component ? component.aimOrigin : gameObject.transform.position;
                Vector3       vector     = component ? component.aimDirection : gameObject.transform.forward;
                Vector3       up         = Vector3.up;

                if (Util.CheckRoll(10f * GNCProtoRocketConfig.GNCProtoRocketProcChance.Value, attackerMaster))
                {
                    float         damageCoefficient = 2f * (float)stack;
                    float         damage            = Util.OnHitProcDamage(damageInfo.damage, attackerBody.damage, damageCoefficient);
                    ProcChainMask procChainMask2    = procChainMask;
                    procChainMask2.AddProc(ProcType.Missile);
                    FireProjectileInfo fireProjectileInfo = new FireProjectileInfo
                    {
                        projectilePrefab = GlobalEventManager.instance.daggerPrefab,
                        position         = position,
                        rotation         = Util.QuaternionSafeLookRotation(Vector3.up + Random.insideUnitSphere * 0.1f),
                        procChainMask    = procChainMask2,
                        target           = victim,
                        owner            = gameObject,
                        damage           = damage,
                        crit             = damageInfo.crit,
                        force            = 200f,
                        damageColorIndex = DamageColorIndex.Item
                    };
                    ProjectileManager.instance.FireProjectile(fireProjectileInfo);
                }
            }
        }
コード例 #5
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);
        }
コード例 #6
0
 public static void ArmsRaceItemHook()
 {
     On.RoR2.GlobalEventManager.OnHitEnemy += (orig, self, damage, victim) =>
     {
         if (damage.attacker)
         {
             CharacterBody   Attacker       = damage.attacker.GetComponent <CharacterBody>();
             CharacterMaster AttackerMaster = Attacker.master;
             if (Attacker.name.ToLower().Contains("drone") || Attacker.name.ToLower().Contains("turret"))
             {
                 if (!damage.procChainMask.HasProc(ProcType.Missile))
                 {
                     var inventory = AttackerMaster.minionOwnership.ownerMaster.inventory;
                     int itemCount = inventory.GetItemCount(ArmsRaceItemIndex);
                     if (itemCount > 0)
                     {
                         GameObject    gameObject = Attacker.gameObject;
                         InputBankTest component  = gameObject.GetComponent <InputBankTest>();
                         Vector3       position   = component ? component.aimOrigin : gameObject.transform.position;
                         Vector3       vector     = component ? component.aimDirection : gameObject.transform.forward;
                         Vector3       up         = Vector3.up;
                         if (Util.CheckRoll(15f, AttackerMaster))
                         {
                             float         damageCoefficient = 3f * itemCount;
                             float         dealdamage        = Util.OnHitProcDamage(damage.damage, Attacker.damage, damageCoefficient);
                             ProcChainMask procChainMask2    = damage.procChainMask;
                             procChainMask2.AddProc(ProcType.Missile);
                             FireProjectileInfo fireProjectileInfo = new FireProjectileInfo
                             {
                                 projectilePrefab = GlobalEventManager.instance.missilePrefab,
                                 position         = position,
                                 rotation         = Util.QuaternionSafeLookRotation(up),
                                 procChainMask    = procChainMask2,
                                 target           = victim,
                                 owner            = gameObject,
                                 damage           = dealdamage,
                                 crit             = damage.crit,
                                 force            = 200f,
                                 damageColorIndex = DamageColorIndex.Item
                             };
                             ProjectileManager.instance.FireProjectile(fireProjectileInfo);
                         }
                     }
                 }
             }
             orig(self, damage, victim);
         }
     };
 }
コード例 #7
0
        private void SuperMissileICBMLaunch(Vector3 position, CharacterBody attacker, ProcChainMask procChainMask, GameObject victim, float missileDamage, bool isCrit, GameObject projectilePrefab, DamageColorIndex damageColorIndex)
        {
            Vector3       initialDirection = Vector3.up + UnityEngine.Random.insideUnitSphere * 0.1f;
            float         force            = 200f;
            bool          addMissileProc   = true;
            int           num1             = characterBody.inventory?.GetItemCount(DLC1Content.Items.MoreMissile) ?? 0;
            float         num2             = Mathf.Max(1f, (1 + 0.5f * (num1 - 1)));
            InputBankTest component        = inputBank;
            ProcChainMask procChainMask1   = procChainMask;

            if (addMissileProc)
            {
                procChainMask1.AddProc(ProcType.Missile);
            }
            FireProjectileInfo fireProjectileInfo = new FireProjectileInfo()
            {
                projectilePrefab = projectilePrefab,
                position         = position,
                rotation         = Util.QuaternionSafeLookRotation(gunRay.direction),
                procChainMask    = procChainMask1,
                target           = victim,
                owner            = attacker.gameObject,
                damage           = missileDamage * num2,
                crit             = isCrit,
                force            = force,
                damageColorIndex = damageColorIndex
            };

            ProjectileManager.instance.FireProjectile(fireProjectileInfo);
            if (num1 <= 0)
            {
                return;
            }
            Vector3            axis = component ? component.aimDirection : attacker.transform.position;
            FireProjectileInfo fireProjectileInfo1 = fireProjectileInfo;

            fireProjectileInfo1.rotation         = Util.QuaternionSafeLookRotation(Quaternion.AngleAxis(45f, axis) * initialDirection);
            fireProjectileInfo1.projectilePrefab = sMissileExtraMissiles;
            fireProjectileInfo1.damage           = Modules.StaticValues.missileDamageCoefficient * damageStat;
            FireProjectileInfo fireProjectileInfo2 = fireProjectileInfo;

            fireProjectileInfo2.rotation         = Util.QuaternionSafeLookRotation(Quaternion.AngleAxis(-45f, axis) * initialDirection);
            fireProjectileInfo2.projectilePrefab = sMissileExtraMissiles;
            fireProjectileInfo2.damage           = Modules.StaticValues.missileDamageCoefficient * damageStat;
            ProjectileManager.instance.FireProjectile(fireProjectileInfo1);
            ProjectileManager.instance.FireProjectile(fireProjectileInfo2);
        }
コード例 #8
0
        private void LaunchMortar(CharacterBody attackerBody, ProcChainMask procChainMask, GameObject victim, DamageInfo damageInfo, int stack)
        {
            GameObject    gameObject = attackerBody.gameObject;
            InputBankTest component  = gameObject.GetComponent <InputBankTest>();
            Vector3       position   = component ? component.aimOrigin : gameObject.transform.position;

            float         dmgCoef        = dmgCoefficient + (dmgStack * stack);
            float         damage         = Util.OnHitProcDamage(damageInfo.damage, attackerBody.damage, dmgCoef);
            ProcChainMask procChainMask2 = procChainMask;

            procChainMask2.AddProc(ProcType.Missile);
            FireProjectileInfo fireProjectileInfo = new FireProjectileInfo
            {
                projectilePrefab   = mortarPrefab,
                position           = position,
                procChainMask      = procChainMask2,
                target             = victim,
                owner              = gameObject,
                damage             = damage,
                crit               = damageInfo.crit,
                force              = 500f,
                damageColorIndex   = DamageColorIndex.Item,
                speedOverride      = -1f,
                damageTypeOverride = DamageType.AOE
            };
            int times = (int)(1 + stackAmount * stack);

            for (int t = 0; t < times; t++)
            {
                Vector3 direction;
                if (fixedAim)
                {
                    direction = gameObject.transform.forward;
                }
                else
                {
                    direction = component ? component.aimDirection : gameObject.transform.forward;
                }
                direction  = direction.normalized + new Vector3(0f, launchAngle, 0f);
                direction += new Vector3(Random.Range(-inaccuracyRate, inaccuracyRate),
                                         Random.Range(-inaccuracyRate, inaccuracyRate),
                                         Random.Range(-inaccuracyRate, inaccuracyRate));
                fireProjectileInfo.rotation = Util.QuaternionSafeLookRotation(direction);
                ProjectileManager.instance.FireProjectile(fireProjectileInfo);
            }
        }
コード例 #9
0
        private void LaunchMortar(CharacterBody attackerBody, ProcChainMask procChainMask, float damage, bool crit, int stack)
        {
            GameObject    gameObject = attackerBody.gameObject;
            InputBankTest component  = gameObject.GetComponent <InputBankTest>();
            Vector3       position   = component ? component.aimOrigin : gameObject.transform.position;
            Vector3       direction;

            if (MortarTube.instance.fixedAim)
            {
                direction = gameObject.transform.forward;
            }
            else
            {
                direction = component ? component.aimDirection : gameObject.transform.forward;
            }
            direction = direction.normalized + new Vector3(0f, MortarTube.instance.launchAngle, 0f);
            float inaccuracyRate = MortarTube.instance.inaccuracyRate;

            direction += new Vector3(Random.Range(-inaccuracyRate, inaccuracyRate),
                                     Random.Range(-inaccuracyRate, inaccuracyRate),
                                     Random.Range(-inaccuracyRate, inaccuracyRate));
            float dmgCoef = mortarDamage + (mortarStackDamage * (stack - 1));

            damage *= dmgCoef;
            ProcChainMask procChainMask2 = procChainMask;

            procChainMask2.AddProc(ProcType.Missile);
            FireProjectileInfo fireProjectileInfo = new FireProjectileInfo
            {
                projectilePrefab   = MortarTube.mortarPrefab,
                position           = position,
                procChainMask      = procChainMask2,
                owner              = gameObject,
                damage             = damage,
                crit               = crit,
                force              = 500f,
                damageColorIndex   = DamageColorIndex.Item,
                speedOverride      = -1f,
                damageTypeOverride = DamageType.AOE,
                rotation           = Util.QuaternionSafeLookRotation(direction)
            };

            ProjectileManager.instance.FireProjectile(fireProjectileInfo);
        }
コード例 #10
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;
            }
コード例 #11
0
        private static void LeechHook()
        {
            On.RoR2.EquipmentSlot.PerformEquipmentAction += (orig, self, equipmentIndex) =>
            {
                if (equipmentIndex == MassiveLeechIndex)
                {
                    if (self.characterBody)
                    {
                        self.characterBody.AddTimedBuff(MassiveLeechbuff, 10f);
                        return(true);
                    }
                }
                return(orig(self, equipmentIndex));
            };

            On.RoR2.GlobalEventManager.OnHitEnemy += (orig, self, damage, victim) =>
            {
                if (damage.attacker)
                {
                    CharacterBody   Attacker       = damage.attacker.GetComponent <CharacterBody>();
                    CharacterMaster AttackerMaster = Attacker.master;
                    if (Attacker && AttackerMaster)
                    {
                        if (Attacker.HasBuff(MassiveLeechbuff))
                        {
                            ProcChainMask   procChainMask = damage.procChainMask;
                            HealthComponent component     = Attacker.GetComponent <HealthComponent>();
                            procChainMask.AddProc(ProcType.HealOnHit);
                            float heal = Attacker.level + 10f;
                            component.Heal(heal * damage.procCoefficient, procChainMask, true);
                        }
                    }
                }
                orig(self, damage, victim);
            };
        }