Esempio n. 1
0
    private void AddAbilities(HealthComponent healthComponent)
    {
        var abilitySetupComp = healthComponent.GetComponent <AbilitySetupComponent>();

        if (abilitySetupComp == null)
        {
            return;
        }
        var config = healthComponent.GetComponent <AIShipConfigurationComponent>();

        List <AbilitySetupInfo> abilities = new List <AbilitySetupInfo>();
        int randomSpotNumberOffset        = UnityEngine.Random.Range(0, abilitySetupComp.abilitySpots.Length);

        for (int i = 0; i < abilitySetupComp.abilitySpots.Length && i < config.maxAbilities; i++)
        {
            abilities.Add(
                new AbilitySetupInfo()
            {
                abilitySpotNumber = new List <int>()
                {
                    (randomSpotNumberOffset + i) % abilitySetupComp.abilitySpots.Length
                },
                uniqueNameID = itemAbilities[UnityEngine.Random.Range(0, itemAbilities.Length)]
            }
                );
        }

        abilitySetupComp.InstantiateAbilities(abilities);
    }
Esempio n. 2
0
    public void HandleOnDamagedByWeapon(WeaponComponent weapon, HealthComponent target)
    {
        Vector3 hitDirection = target.transform.position - weapon.transform.position;
        var     body         = target.GetComponent <Rigidbody2D>();

        if (body != null)
        {
            body.AddForce(hitDirection.normalized * weapon.PushPower);
        }

        StunWalking(target.GetComponent <MovementComponent>());

        target.Health = Mathf.Max(0, target.Health - weapon.Damage);
        _hitSound.PlayMutated();

        var flash = target.GetComponentInChildren <SpriteFlash>();

        if (flash != null)
        {
            DOTween.Sequence()
            .AppendCallback(() => flash.WhiteSprite())
            .Append(Camera.main.transform.DOShakePosition(0.1f, 0.1f))
            .AppendCallback(() => flash.NormalSprite());
        }
        Thread.Sleep(30);
    }
Esempio n. 3
0
        private void OnTakeDamage(On.RoR2.HealthComponent.orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
        {
            // If a character was killed by the world, we shouldn't do anything.
            if (!damageInfo.attacker || !damageInfo.inflictor)
            {
                orig(self, damageInfo);
                return;
            }

            // We need an inventory to do check for our item
            var count = ItemCount(this, self.body);

            if (count > 0)
            {
                //Chat.AddMessage("Reflecting projectile");
                var body   = self.GetComponent <RoR2.CharacterBody>();
                var damage = damageInfo.damage * (DamageFactor + AdditionalDamagePerStack * count) * 100;

                if (Helpers.InDebugMode())
                {
                    ModLogger.LogInfo($"Got {damageInfo.damage} damage, sending back {damage}");
                }

                // Generate projectile
                var projectileInfo = new FireProjectileInfo
                {
                    owner            = body.gameObject,
                    projectilePrefab = AspectProjectile,
                    //speedOverride = 100.0f,
                    damage             = damage,
                    damageTypeOverride = null,
                    damageColorIndex   = DamageColorIndex.Default,
                    procChainMask      = default,
Esempio n. 4
0
        private void HealthComponent_TakeDamage(On.RoR2.HealthComponent.orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
        {
            var crowbarTracker = self.GetComponent <FragileCrowbarTracker>();

            if (!crowbarTracker || crowbarTracker.attackerObjects.Contains(damageInfo.attacker))
            {
                var attackerBody = damageInfo.attacker.GetComponent <CharacterBody>();
                if (attackerBody)
                {
                    var master = attackerBody.master;
                    if (master)
                    {
                        var stacks = GetCount(master);
                        if (stacks > 0)
                        {
                            var damageModifier = 1f + stacks * damagePerStack;

                            if (self.combinedHealth >= self.fullCombinedHealth * 0.9f)
                            {
                                damageModifier *= 2f;
                                EffectManager.SimpleImpactEffect(HealthComponent.AssetReferences.crowbarImpactEffectPrefab, damageInfo.position, -damageInfo.force, true);
                            }
                            damageInfo.damage *= damageModifier;
                            if (!crowbarTracker)
                            {
                                crowbarTracker = self.gameObject.AddComponent <FragileCrowbarTracker>();
                            }
                            crowbarTracker.attackerObjects.Add(damageInfo.attacker);
                        }
                    }
                }
            }

            orig(self, damageInfo);
        }
Esempio n. 5
0
        private void HealthComponent_TakeDamage1(On.RoR2.HealthComponent.orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
        {
            var crowbarTracker = self.GetComponent <FragileCrowbarTracker>();

            if (!crowbarTracker || !crowbarTracker.attackerObjects.Contains(damageInfo.attacker))
            {
                var attackerBody = damageInfo.attacker.GetComponent <CharacterBody>();
                if (attackerBody)
                {
                    var master = attackerBody.master;
                    if (master)
                    {
                        var stacks = GetCount(master);
                        if (stacks > 0)
                        {
                            damageInfo.damage *= 1f + 0.75f * (float)stacks;
                            EffectManager.SimpleImpactEffect(HealthComponent.AssetReferences.crowbarImpactEffectPrefab, damageInfo.position, -damageInfo.force, true);

                            if (!crowbarTracker)
                            {
                                crowbarTracker = self.gameObject.AddComponent <FragileCrowbarTracker>();
                            }
                            crowbarTracker.attackerObjects.Add(damageInfo.attacker);
                        }
                    }
                }
            }

            orig(self, damageInfo);
        }
 // Token: 0x06001D6A RID: 7530 RVA: 0x0007D540 File Offset: 0x0007B740
 public override void OnArrival()
 {
     if (this.target)
     {
         HealthComponent healthComponent = this.target.healthComponent;
         if (healthComponent)
         {
             if (this.damageOrbType == DamageOrb.DamageOrbType.ClayGooOrb)
             {
                 CharacterBody component = healthComponent.GetComponent <CharacterBody>();
                 if (component && (component.bodyFlags & CharacterBody.BodyFlags.ImmuneToGoo) != CharacterBody.BodyFlags.None)
                 {
                     healthComponent.Heal(this.damageValue, default(ProcChainMask), true);
                     return;
                 }
             }
             DamageInfo damageInfo = new DamageInfo();
             damageInfo.damage           = this.damageValue;
             damageInfo.attacker         = this.attacker;
             damageInfo.inflictor        = null;
             damageInfo.force            = Vector3.zero;
             damageInfo.crit             = this.isCrit;
             damageInfo.procChainMask    = this.procChainMask;
             damageInfo.procCoefficient  = this.procCoefficient;
             damageInfo.position         = this.target.transform.position;
             damageInfo.damageColorIndex = this.damageColorIndex;
             damageInfo.damageType       = this.orbDamageType;
             healthComponent.TakeDamage(damageInfo);
             GlobalEventManager.instance.OnHitEnemy(damageInfo, healthComponent.gameObject);
             GlobalEventManager.instance.OnHitAll(damageInfo, healthComponent.gameObject);
         }
     }
 }
Esempio n. 7
0
        private void HealthComponent_TakeDamage(On.RoR2.HealthComponent.orig_TakeDamage orig, HealthComponent self, DamageInfo di)
        {
            if (di.attacker != null && self != null)
            {
                CharacterBody body = self.GetComponent <CharacterBody>();
                if (body != null)
                {
                    if (di.damageType.HasFlag(RoR2.DamageType.BonusToLowHealth) && di.damageType.HasFlag(RoR2.DamageType.ResetCooldownsOnKill))
                    {
                        di.damage *= Mathf.Lerp(1f + BanditLightsOutLevel * 0.3f, 1.0f, self.combinedHealthFraction);
                    }
                    else if (di.damageType.HasFlag(RoR2.DamageType.GiveSkullOnKill))
                    {
                        float remainingHealth = (self.combinedHealth - di.damage);
                        if (remainingHealth / self.fullCombinedHealth < BanditDesperadoLevel * 0.01f && remainingHealth > 0)
                        {
                            di.damage     += remainingHealth;
                            di.damageType |= DamageType.BypassArmor;
                        }
                    }

                    //TODO: Integrate this to From The Shadows alternate skill mod
                    //Chat.AddMessage("Shadow buff count: " + body.GetBuffCount(BanditSkills.BanditShadowsBuff));
                    //di.damage = di.damage * (1 + (body.GetBuffCount(BanditShadowsBuff) * 0.15f));
                }
            }

            orig.Invoke(self, di);
        }
        private void InitializePull()
        {
            if (this.pulling)
            {
                return;
            }
            this.pulling = true;
            Collider[] array = Physics.OverlapSphere(((this.pullOrigin) ? this.pullOrigin.position : base.transform.position), pullRadius, LayerIndex.defaultLayer.mask);
            int        num   = 0;
            int        num2  = 0;

            while (num < array.Length && num2 < this.maximumPullCount)
            {
                HealthComponent component = array[num].GetComponent <HealthComponent>();
                if (component)
                {
                    TeamComponent component2 = component.GetComponent <TeamComponent>();
                    bool          flag       = false;
                    if (component2)
                    {
                        flag = (component2.teamIndex == base.GetTeam());
                    }
                    if (!flag)
                    {
                        this.AddToPullList(component.gameObject);
                        num2++;
                    }
                }
                num++;
            }
        }
Esempio n. 9
0
 // Token: 0x06001E3D RID: 7741 RVA: 0x0008274C File Offset: 0x0008094C
 public void OnTriggerEnter(Collider collider)
 {
     if (NetworkServer.active)
     {
         if (collider)
         {
             HurtBox component = collider.GetComponent <HurtBox>();
             if (component)
             {
                 HealthComponent healthComponent = component.healthComponent;
                 if (healthComponent)
                 {
                     TeamComponent component2 = healthComponent.GetComponent <TeamComponent>();
                     if (component2 && component2.teamIndex == this.myTeamFilter.teamIndex)
                     {
                         return;
                     }
                     UnityEvent unityEvent = this.triggerEvents;
                     if (unityEvent == null)
                     {
                         return;
                     }
                     unityEvent.Invoke();
                 }
             }
         }
         return;
     }
 }
 private void InitHealthComponent()
 {
     if (HealthComponent == null)
     {
         HealthComponent.GetComponent <HealthComponent>();
     }
     HealthComponent.OnHealthDepleted.AddListener(HandleDeath);
 }
Esempio n. 11
0
 private static void HealthComponent_Awake(On.RoR2.HealthComponent.orig_Awake orig, HealthComponent self)
 {
     orig(self);
     if (!self.GetComponent <TrackDebrisShield>())
     {
         self.gameObject.AddComponent <TrackDebrisShield>().healthComponent = self;
     }
 }
Esempio n. 12
0
 private static void HealthComponent_AddBarrier(On.RoR2.HealthComponent.orig_AddBarrier orig, HealthComponent self, float value)
 {
     orig(self, value);
     if (value > 0)
     {
         self.GetComponent <TrackDebrisShield>()?.OnAddBarrier(value);
     }
 }
 private void SetupShipFaction(HealthComponent healthComponent)
 {
     if (factionConfigurations.Count > 0)
     {
         FactionConfiguration randomFaction = factionConfigurations[UnityEngine.Random.Range(0, factionConfigurations.Count)];
         var shipConfig = healthComponent.GetComponent <ShipConfigurationComponent>();
         shipConfig.healthComponent.health += shipConfig.healthComponent.health * randomFaction.healthMultiplierIncrease;
         shipConfig.accelerateSpeed        += shipConfig.accelerateSpeed * randomFaction.accelerateSpeedMultiplierIncrease;
         shipConfig.maxSpeed += shipConfig.maxSpeed * randomFaction.maxSpeedMultiplierIncrease;
         // to prevent firing each second, a small safety check is put in places, though this is still a dirty implementation
         var aiShipConfig = healthComponent.GetComponent <AIShipConfigurationComponent>();
         aiShipConfig.fireSpeed = Mathf.Max(0.25f, aiShipConfig.fireSpeed / (1 + randomFaction.fireSpeedMultiplierIncrease));
         foreach (var item in shipConfig.flags)
         {
             item.sprite = randomFaction.flagSprite;
         }
     }
 }
Esempio n. 14
0
 // Token: 0x06002251 RID: 8785 RVA: 0x000945B4 File Offset: 0x000927B4
 private CombatHealthBarViewer.HealthBarInfo GetHealthBarInfo(HealthComponent victimHealthComponent)
 {
     CombatHealthBarViewer.HealthBarInfo healthBarInfo;
     if (!this.victimToHealthBarInfo.TryGetValue(victimHealthComponent, out healthBarInfo))
     {
         healthBarInfo = new CombatHealthBarViewer.HealthBarInfo();
         healthBarInfo.healthBarRootObject          = UnityEngine.Object.Instantiate <GameObject>(this.healthBarPrefab, this.container);
         healthBarInfo.healthBarRootObjectTransform = healthBarInfo.healthBarRootObject.transform;
         healthBarInfo.healthBar            = healthBarInfo.healthBarRootObject.GetComponent <HealthBar>();
         healthBarInfo.healthBar.source     = victimHealthComponent;
         healthBarInfo.healthBar.viewerBody = this.viewerBody;
         healthBarInfo.healthBarRootObject.GetComponentInChildren <BuffDisplay>().source = victimHealthComponent.body;
         healthBarInfo.sourceHealthComponent = victimHealthComponent;
         healthBarInfo.verticalOffset        = 0f;
         Collider component = victimHealthComponent.GetComponent <Collider>();
         if (component)
         {
             healthBarInfo.verticalOffset = component.bounds.extents.y;
         }
         healthBarInfo.sourceTransform = (victimHealthComponent.body.coreTransform ?? victimHealthComponent.transform);
         ModelLocator component2 = victimHealthComponent.GetComponent <ModelLocator>();
         if (component2)
         {
             Transform modelTransform = component2.modelTransform;
             if (modelTransform)
             {
                 ChildLocator component3 = modelTransform.GetComponent <ChildLocator>();
                 if (component3)
                 {
                     Transform transform = component3.FindChild("HealthBarOrigin");
                     if (transform)
                     {
                         healthBarInfo.sourceTransform = transform;
                         healthBarInfo.verticalOffset  = 0f;
                     }
                 }
             }
         }
         this.victimToHealthBarInfo.Add(victimHealthComponent, healthBarInfo);
         this.trackedVictims.Add(victimHealthComponent);
     }
     return(healthBarInfo);
 }
Esempio n. 15
0
        // Token: 0x06001DEB RID: 7659 RVA: 0x0008CA74 File Offset: 0x0008AC74
        public void OnProjectileImpact(ProjectileImpactInfo impactInfo)
        {
            EffectManager.instance.SimpleImpactEffect(this.impactSpark, impactInfo.estimatedPointOfImpact, -base.transform.forward, true);
            if (this.hookState != HookProjectileImpact.HookState.Flying)
            {
                return;
            }
            HurtBox component = impactInfo.collider.GetComponent <HurtBox>();

            if (component)
            {
                HealthComponent healthComponent = component.healthComponent;
                if (healthComponent)
                {
                    TeamComponent component2 = healthComponent.GetComponent <TeamComponent>();
                    TeamFilter    component3 = base.GetComponent <TeamFilter>();
                    if (healthComponent.gameObject == this.projectileController.owner || component2.teamIndex == component3.teamIndex)
                    {
                        return;
                    }
                    this.Networkvictim        = healthComponent.gameObject;
                    this.victimSetStateOnHurt = this.victim.GetComponent <SetStateOnHurt>();
                    if (this.victimSetStateOnHurt)
                    {
                        this.victimSetStateOnHurt.SetPain();
                    }
                    DamageInfo damageInfo = new DamageInfo();
                    if (this.projectileDamage)
                    {
                        damageInfo.damage           = this.projectileDamage.damage;
                        damageInfo.crit             = this.projectileDamage.crit;
                        damageInfo.attacker         = (this.projectileController.owner ? this.projectileController.owner.gameObject : null);
                        damageInfo.inflictor        = base.gameObject;
                        damageInfo.position         = impactInfo.estimatedPointOfImpact;
                        damageInfo.force            = this.projectileDamage.force * base.transform.forward;
                        damageInfo.procChainMask    = this.projectileController.procChainMask;
                        damageInfo.procCoefficient  = this.projectileController.procCoefficient;
                        damageInfo.damageColorIndex = this.projectileDamage.damageColorIndex;
                    }
                    else
                    {
                        Debug.Log("No projectile damage component!");
                    }
                    Debug.Log(damageInfo.damage);
                    healthComponent.TakeDamage(damageInfo);
                    GlobalEventManager.instance.OnHitEnemy(damageInfo, healthComponent.gameObject);
                    this.NetworkhookState = HookProjectileImpact.HookState.HitDelay;
                    EffectManager.instance.SimpleImpactEffect(this.impactSuccess, impactInfo.estimatedPointOfImpact, -base.transform.forward, true);
                }
            }
            if (!this.victim)
            {
                this.NetworkhookState = HookProjectileImpact.HookState.ReelFail;
            }
        }
Esempio n. 16
0
        public void Initialize(HealthComponent health)
        {
            AlwaysShowChanged += SetAlwaysShow;
            SettingsChanged   += OnSettingsChanged;
            CombatEncounter.AnyCombatTurnStarted += OnAnyCombatTurnStartedOrEnded;
            CombatEncounter.AnyCombatTurnEnded   += OnAnyCombatTurnStartedOrEnded;

            this.shiny.color = Color.white;

            this.health                = health;
            this.health.Damaged       += OnDamage;
            this.health.HealthChanged += OnHealthChanged;
            this.health.ShieldChanged += OnHealthChanged;
            this.health.Terminated    += OnTerminated;

            this.resources = health.GetComponent <ResourcesComponent>();
            this.resources.ActionPointsChanged += OnActionPointsChanged;

            this.behaviours = health.GetComponent <BehavioursComponent>();
            this.behaviours.BehaviourApplied += OnBehaviourApplied;
            this.behaviours.BehaviourRemoved += OnBehaviourRemoved;

            foreach (var behaviour in this.behaviours.Behaviours)
            {
                OnBehaviourApplied(behaviour);
            }

            this.unit = this.health.GetComponent <UnitComponent>();
            this.unit.OwnerChanged += OnOwnerChanged;

            var actor = this.health.GetComponent <ActorComponent>();

            Initialize(alwaysShow, alwaysHide, AttachmentPoint.OverHead, actor, this.health);

            OnSettingsChanged();
            OnOwnerChanged(this.unit);
            OnHealthChanged(health);
            OnActionPointsChanged(this.resources.Get(ResourceType.ActionPoint));
        }
Esempio n. 17
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Player") && PlayerAttack.canDeflect && !Block)
     {
         playerVie.PlayerDeflected();
         asBeenDeflected = true;
         Block           = true;
     }
     else if (other.CompareTag("Player") && !PlayerAttack.canDeflect)
     {
         Vector3 direction = transform.position - player.transform.position;
         playerVie.PlayerGetHit(damage);
         playerVie.GetComponent <Rigidbody>().AddForce(-direction * knockback, ForceMode.Impulse);
     }
 }
        // Token: 0x06001E0D RID: 7693 RVA: 0x000815A4 File Offset: 0x0007F7A4
        public void OnProjectileImpact(ProjectileImpactInfo impactInfo)
        {
            HurtBox component = impactInfo.collider.GetComponent <HurtBox>();

            if (component)
            {
                HealthComponent healthComponent = component.healthComponent;
                if (healthComponent)
                {
                    if (!this.canHitCharacters)
                    {
                        return;
                    }
                    TeamComponent component2 = healthComponent.GetComponent <TeamComponent>();
                    TeamFilter    component3 = base.GetComponent <TeamFilter>();
                    if (healthComponent.gameObject == this.projectileController.owner || component2.teamIndex == component3.teamIndex)
                    {
                        return;
                    }
                    GameObject gameObject = healthComponent.gameObject;
                    DamageInfo damageInfo = new DamageInfo();
                    if (this.projectileDamage)
                    {
                        damageInfo.damage           = this.projectileDamage.damage * this.damageCoefficient;
                        damageInfo.crit             = this.projectileDamage.crit;
                        damageInfo.attacker         = (this.projectileController.owner ? this.projectileController.owner.gameObject : null);
                        damageInfo.inflictor        = base.gameObject;
                        damageInfo.position         = impactInfo.estimatedPointOfImpact;
                        damageInfo.force            = this.projectileDamage.force * base.transform.forward;
                        damageInfo.procChainMask    = this.projectileController.procChainMask;
                        damageInfo.procCoefficient  = this.projectileController.procCoefficient;
                        damageInfo.damageColorIndex = this.projectileDamage.damageColorIndex;
                        damageInfo.damageType       = this.projectileDamage.damageType;
                    }
                    healthComponent.TakeDamage(damageInfo);
                    GlobalEventManager.instance.OnHitEnemy(damageInfo, healthComponent.gameObject);
                    this.NetworkboomerangState = BoomerangProjectile.BoomerangState.FlyBack;
                }
            }
            if (!this.canHitWorld)
            {
                return;
            }
            this.NetworkboomerangState = BoomerangProjectile.BoomerangState.FlyBack;
            EffectManager.SimpleImpactEffect(this.impactSpark, impactInfo.estimatedPointOfImpact, -base.transform.forward, true);
        }
Esempio n. 19
0
        public override void OnExit()
        {
            if (NetworkServer.active)
            {
                base.characterBody.RemoveBuff(RoR2Content.Buffs.HiddenInvincibility);
                base.characterBody.AddTimedBuff(RoR2Content.Buffs.HiddenInvincibility, 0.5f);

                //no succ
                Ray     aimRay  = base.GetAimRay();
                Vector3 theSpot = aimRay.origin + 2 * aimRay.direction;

                Collider[] array = Physics.OverlapSphere(theSpot, CaveIn.blastRadius + 8f, LayerIndex.defaultLayer.mask);
                for (int i = 0; i < array.Length; i++)
                {
                    HealthComponent healthComponent = array[i].GetComponent <HealthComponent>();
                    if (healthComponent)
                    {
                        TeamComponent component2 = healthComponent.GetComponent <TeamComponent>();
                        if (component2.teamIndex != TeamIndex.Player)
                        {
                            var charb = healthComponent.body;
                            if (charb)
                            {
                                var motor = charb.characterMotor;
                                var rb    = charb.rigidbody;

                                if (motor)
                                {
                                    motor.velocity *= 0.1f;
                                }
                                if (rb)
                                {
                                    rb.velocity *= 0.1f;
                                }
                            }
                        }
                    }
                }
            }

            base.characterMotor.velocity *= 0.1f;

            base.OnExit();
        }
Esempio n. 20
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        HealthComponent target = collision.transform.root.GetComponent <HealthComponent>();

        if (target != null && !hasHit.Contains(target))
        {
            int direction = 1;
            if (knockBack != Vector2.zero)
            {
                direction = (int)Mathf.Sign(target.transform.position.x - moveHandler.transform.position.x);
            }
            Vector2 kb = knockBack;
            kb.x *= direction;
            float hitStun = moveHandler.GetHitStun();

            if (target.Damage(damage, kb, hitStun))
            {
                hasHit.Add(target);
                MoveHandler enemyHandler = target.GetComponent <MoveHandler>();
                moveHandler.HitEnemy(enemyHandler);
                if (enemyHandler != null)
                {
                    enemyHandler.HitDirection = direction;
                }
            }
        }

        /*EntityController target = collision.transform.root.GetComponent<EntityController>();
         * if (target != null)
         * {
         *      if (!entitiesHit.Contains(target.EntityID))
         *      {
         *              entityController.HitEnemy(target);
         *              int direction = 1;
         *              if (knockBack != Vector2.zero)
         *              {
         *                      direction = (int)Mathf.Sign(target.transform.position.x - entityController.transform.position.x);
         *              }
         *              target.Damage(damage,knockBack*direction);
         *              entitiesHit.Add(target.EntityID);
         *      }
         * }*/
    }
Esempio n. 21
0
 private void HealthComponent_TakeDamage(On.RoR2.HealthComponent.orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
 {
     if (self && self.body)
     {
         var count = GetCount(self.body);
         var cpt   = self.GetComponent <SkeinTracker>();
         if (count > 0 && cpt)
         {
             var fac = 1f - (1f - Mathf.Pow(highMassFrac, count)) * cpt.GetResistanceScalar();
             damageInfo.damage *= fac;
             if (damageInfo.canRejectForce)
             {
                 damageInfo.force *= fac;
             }
             cpt.ForceResetStopped();
         }
     }
     orig(self, damageInfo);
 }
Esempio n. 22
0
        private void getHitList(BlastAttack ba)
        {
            Collider[] array = Physics.OverlapSphere(ba.position, ba.radius, LayerIndex.defaultLayer.mask);
            int        num   = 0;
            int        num2  = 0;

            while (num < array.Length && num2 < 12)
            {
                HealthComponent component = array[num].GetComponent <HealthComponent>();
                if (component)
                {
                    TeamComponent component2 = component.GetComponent <TeamComponent>();
                    if (component2.teamIndex != TeamIndex.Player)
                    {
                        this.AddToList(component.gameObject);
                        num2++;
                    }
                }
                num++;
            }
        }
Esempio n. 23
0
    public void HandleOutOfBounds(HealthComponent health)
    {
        if (health == null)
        {
            return;
        }

        Debug.Log(health.gameObject.name + " out of bounds.");
        health.Health        = 0;
        health.IsOutOfBounds = true;

        foreach (var collider in health.GetComponentsInChildren <Collider2D>())
        {
            collider.enabled = false;
        }

        foreach (var particle in health.GetComponentsInChildren <ParticleSystem>())
        {
            particle.Stop();
        }

        FallBody(health.GetComponent <Rigidbody2D>());
        SetRenderOrdering(health.GetComponentsInChildren <SpriteRenderer>());
    }
Esempio n. 24
0
        private void PushEnemiesServer()
        {
            if (!NetworkServer.active)
            {
                return;
            }
            List <HealthComponent> hcList = new List <HealthComponent>();

            Collider[] array = Physics.OverlapBox(base.transform.position + aimRay.direction * HeatWave.hitboxOffset, HeatWave.hitboxDimensions, Quaternion.LookRotation(aimRay.direction, Vector3.up), LayerIndex.entityPrecise.mask);
            for (int i = 0; i < array.Length; i++)
            {
                HurtBox hurtBox = array[i].GetComponent <HurtBox>();
                if (hurtBox)
                {
                    HealthComponent      healthComponent = hurtBox.healthComponent;
                    ProjectileController pc = array[i].GetComponentInParent <ProjectileController>();
                    if (healthComponent && !pc && !hcList.Contains(healthComponent))
                    {
                        hcList.Add(healthComponent);
                        TeamComponent component2 = healthComponent.GetComponent <TeamComponent>();
                        if (component2.teamIndex != base.teamComponent.teamIndex)
                        {
                            CharacterBody cb = healthComponent.body;
                            if (cb)
                            {
                                Vector3   forceVector = HeatWave.force * aimRay.direction;
                                Rigidbody rb          = cb.rigidbody;
                                if (rb)
                                {
                                    forceVector *= Mathf.Min(Mathf.Max(rb.mass / 100f, 1f), maxForceScale);
                                }

                                healthComponent.TakeDamageForce(new DamageInfo
                                {
                                    attacker         = base.gameObject,
                                    inflictor        = base.gameObject,
                                    damage           = 0f,
                                    damageColorIndex = DamageColorIndex.Default,
                                    damageType       = DamageType.NonLethal,
                                    crit             = false,
                                    dotIndex         = DotController.DotIndex.None,
                                    force            = forceVector,
                                    position         = base.transform.position,
                                    procChainMask    = default(ProcChainMask),
                                    procCoefficient  = 0f
                                }, true, true);

                                if (this.hasHeat)   //only deal damage if there is sufficient heat
                                {
                                    float heatMult = this.heatLevel / HeatWave.heatCost;
                                    healthComponent.TakeDamage(new DamageInfo
                                    {
                                        attacker         = base.gameObject,
                                        inflictor        = base.gameObject,
                                        damage           = this.damageStat * HeatWave.damageCoefficient * heatMult,
                                        damageColorIndex = DamageColorIndex.Default,
                                        damageType       = DamageType.IgniteOnHit,
                                        crit             = base.RollCrit(),
                                        dotIndex         = DotController.DotIndex.None,
                                        force            = Vector3.zero,
                                        position         = base.transform.position,
                                        procChainMask    = default(ProcChainMask),
                                        procCoefficient  = 1f
                                    });

                                    GlobalEventManager.instance.OnHitEnemy(new DamageInfo
                                    {
                                        attacker         = base.gameObject,
                                        inflictor        = base.gameObject,
                                        damage           = this.damageStat * HeatWave.damageCoefficient * heatMult,
                                        damageColorIndex = DamageColorIndex.Default,
                                        damageType       = DamageType.IgniteOnHit,
                                        crit             = base.RollCrit(),
                                        dotIndex         = DotController.DotIndex.None,
                                        force            = Vector3.zero,
                                        position         = base.transform.position,
                                        procChainMask    = default(ProcChainMask),
                                        procCoefficient  = 1f
                                    }, healthComponent.gameObject);
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 25
0
        public override void OnEnter()
        {
            base.OnEnter();
            Ray aimRay = base.GetAimRay();

            this.duration     = this.baseDuration;
            this.childLocator = base.GetModelChildLocator();

            Util.PlaySound(DiggerPlugin.Sounds.Backblast, base.gameObject);
            base.StartAimMode(0.8f, true);

            base.characterMotor.disableAirControlUntilCollision = false;

            base.PlayAnimation("FullBody, Override", "CaveIn");

            if (NetworkServer.active)
            {
                base.characterBody.AddBuff(RoR2Content.Buffs.HiddenInvincibility);
            }

            if (base.isAuthority)
            {
                Vector3 theSpot = aimRay.origin + 2 * aimRay.direction;

                BlastAttack blastAttack = new BlastAttack();
                blastAttack.radius            = CaveIn.blastRadius;
                blastAttack.procCoefficient   = 1f;
                blastAttack.position          = theSpot;
                blastAttack.attacker          = base.gameObject;
                blastAttack.crit              = Util.CheckRoll(base.characterBody.crit, base.characterBody.master);
                blastAttack.baseDamage        = base.characterBody.damage * CaveIn.damageCoefficient;
                blastAttack.falloffModel      = BlastAttack.FalloffModel.None;
                blastAttack.baseForce         = 0f;
                blastAttack.teamIndex         = TeamComponent.GetObjectTeam(blastAttack.attacker);
                blastAttack.damageType        = DamageType.Stun1s;
                blastAttack.attackerFiltering = AttackerFiltering.NeverHit;
                blastAttack.Fire();

                EffectData effectData = new EffectData();
                effectData.origin = theSpot;
                effectData.scale  = 15;

                EffectManager.SpawnEffect(DiggerPlugin.DiggerPlugin.backblastEffect, effectData, false);

                base.characterMotor.velocity = -80 * aimRay.direction;

                //succ
                if (NetworkServer.active)
                {
                    Collider[] array = Physics.OverlapSphere(theSpot, CaveIn.blastRadius, LayerIndex.defaultLayer.mask);
                    for (int i = 0; i < array.Length; i++)
                    {
                        HealthComponent healthComponent = array[i].GetComponent <HealthComponent>();
                        if (healthComponent)
                        {
                            TeamComponent component2 = healthComponent.GetComponent <TeamComponent>();
                            if (component2.teamIndex != TeamIndex.Player)
                            {
                                var charb = healthComponent.body;
                                if (charb)
                                {
                                    Vector3 pushForce = (theSpot - charb.corePosition) * CaveIn.succForce;
                                    var     motor     = charb.GetComponent <CharacterMotor>();
                                    var     rb        = charb.GetComponent <Rigidbody>();

                                    float mass = 1;
                                    if (motor)
                                    {
                                        mass = motor.mass;
                                    }
                                    else if (rb)
                                    {
                                        mass = rb.mass;
                                    }
                                    if (mass < 100)
                                    {
                                        mass = 100;
                                    }

                                    pushForce *= mass;

                                    DamageInfo info = new DamageInfo
                                    {
                                        attacker         = base.gameObject,
                                        inflictor        = base.gameObject,
                                        damage           = 0,
                                        damageColorIndex = DamageColorIndex.Default,
                                        damageType       = DamageType.Generic,
                                        crit             = false,
                                        dotIndex         = DotController.DotIndex.None,
                                        force            = pushForce,
                                        position         = base.transform.position,
                                        procChainMask    = default(ProcChainMask),
                                        procCoefficient  = 0
                                    };

                                    charb.healthComponent.TakeDamageForce(info, true, true);
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 26
0
        // Token: 0x06001F21 RID: 7969 RVA: 0x00087164 File Offset: 0x00085364
        public void OnProjectileImpact(ProjectileImpactInfo impactInfo)
        {
            if (!this.alive)
            {
                return;
            }
            Collider collider = impactInfo.collider;

            if (collider)
            {
                DamageInfo damageInfo = new DamageInfo();
                if (this.projectileDamage)
                {
                    damageInfo.damage           = this.projectileDamage.damage;
                    damageInfo.crit             = this.projectileDamage.crit;
                    damageInfo.attacker         = (this.projectileController.owner ? this.projectileController.owner.gameObject : null);
                    damageInfo.inflictor        = base.gameObject;
                    damageInfo.position         = impactInfo.estimatedPointOfImpact;
                    damageInfo.force            = this.projectileDamage.force * base.transform.forward;
                    damageInfo.procChainMask    = this.projectileController.procChainMask;
                    damageInfo.procCoefficient  = this.projectileController.procCoefficient;
                    damageInfo.damageColorIndex = this.projectileDamage.damageColorIndex;
                    damageInfo.damageType       = this.projectileDamage.damageType;
                }
                else
                {
                    Debug.Log("No projectile damage component!");
                }
                HurtBox component = collider.GetComponent <HurtBox>();
                if (component)
                {
                    HealthComponent healthComponent = component.healthComponent;
                    if (healthComponent)
                    {
                        if (healthComponent.gameObject == this.projectileController.owner)
                        {
                            return;
                        }
                        TeamComponent component2 = healthComponent.GetComponent <TeamComponent>();
                        TeamFilter    component3 = base.GetComponent <TeamFilter>();
                        bool          flag       = false;
                        if (component2 && component3)
                        {
                            flag = (component2.teamIndex == component3.teamIndex);
                        }
                        if (!flag)
                        {
                            Util.PlaySound(this.enemyHitSoundString, base.gameObject);
                            if (NetworkServer.active)
                            {
                                damageInfo.ModifyDamageInfo(component.damageModifier);
                                healthComponent.TakeDamage(damageInfo);
                                GlobalEventManager.instance.OnHitEnemy(damageInfo, component.healthComponent.gameObject);
                            }
                        }
                        this.alive = false;
                    }
                }
                else if (this.destroyOnWorld)
                {
                    this.alive = false;
                }
                damageInfo.position = base.transform.position;
                if (NetworkServer.active)
                {
                    GlobalEventManager.instance.OnHitAll(damageInfo, collider.gameObject);
                }
            }
            if (!this.alive)
            {
                if (NetworkServer.active && this.impactEffect)
                {
                    EffectManager.SimpleImpactEffect(this.impactEffect, impactInfo.estimatedPointOfImpact, -base.transform.forward, !this.projectileController.isPrediction);
                }
                Util.PlaySound(this.hitSoundString, base.gameObject);
                if (this.destroyWhenNotAlive)
                {
                    UnityEngine.Object.Destroy(base.gameObject);
                }
            }
        }
        private void HealthComponent_TakeDamage(On.RoR2.HealthComponent.orig_TakeDamage orig, HealthComponent self, DamageInfo di)
        {
            orig(self, di);
            if (di.inflictor)
            {
                if (self)
                {
                    var selfCharacterBody = self.GetComponent <CharacterBody>();
                    if (selfCharacterBody)
                    {
                        if (di.attacker)
                        {
                            var attackerCharacterBody = di.attacker.GetComponent <CharacterBody>();
                            if (attackerCharacterBody)
                            {
                                bool attackerIsTemplar = di.attacker.GetComponent <CharacterBody>().baseNameToken == "TEMPLAR_NAME";
                                if (attackerIsTemplar)
                                {
                                    bool validDamageType = di.damageType.HasFlag(DamageType.BypassOneShotProtection);
                                    if (validDamageType)
                                    {
                                        di.damageType = DamageType.AOE;

                                        //var buff21 = ArrayUtils.GetSafe<int>(characterBody.buffs, 21) > 0;
                                        //TODO: https://discordapp.com/channels/562704639141740588/562704639569428506/832713043158892596
                                        bool flag15 = selfCharacterBody.HasBuff((BuffIndex)21) && !selfCharacterBody.HasBuff(Modules.Buffs.igniteDebuff);
                                        if (flag15)
                                        {
                                            selfCharacterBody.AddTimedBuff(Modules.Buffs.igniteDebuff, 16f);

                                            var modelLocator = self.GetComponent <CharacterBody>().modelLocator;
                                            if (modelLocator)
                                            {
                                                Transform modelTransform = modelLocator.modelTransform;
                                                var       characterModel = modelTransform.GetComponent <CharacterModel>();
                                                if (characterModel)
                                                {
                                                    TemporaryOverlay temporaryOverlay = modelTransform.gameObject.AddComponent <TemporaryOverlay>();
                                                    temporaryOverlay.duration              = 16f;
                                                    temporaryOverlay.animateShaderAlpha    = true;
                                                    temporaryOverlay.alphaCurve            = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f);
                                                    temporaryOverlay.destroyComponentOnEnd = true;
                                                    temporaryOverlay.originalMaterial      = Resources.Load <Material>("Materials/matDoppelganger");
                                                    temporaryOverlay.AddToCharacerModel(characterModel);
                                                }
                                            }
                                            BlastAttack blastAttack = new BlastAttack
                                            {
                                                attacker        = di.attacker,
                                                inflictor       = di.inflictor,
                                                teamIndex       = attackerCharacterBody.teamComponent ? attackerCharacterBody.teamComponent.teamIndex : TeamIndex.Player,
                                                baseForce       = 0f,
                                                position        = self.transform.position,
                                                radius          = 12f,
                                                falloffModel    = BlastAttack.FalloffModel.None,
                                                crit            = di.crit,
                                                baseDamage      = di.damage * 0.2f,
                                                procCoefficient = di.procCoefficient,
                                            };
                                            blastAttack.damageType |= DamageType.Stun1s;
                                            blastAttack.Fire();
                                            BlastAttack blastAttack2 = new BlastAttack
                                            {
                                                attacker        = di.attacker,
                                                inflictor       = di.inflictor,
                                                teamIndex       = attackerCharacterBody.teamComponent ? attackerCharacterBody.teamComponent.teamIndex : TeamIndex.Player,
                                                baseForce       = 0f,
                                                position        = self.transform.position,
                                                radius          = 16f,
                                                falloffModel    = BlastAttack.FalloffModel.None,
                                                crit            = false,
                                                baseDamage      = 0f,
                                                procCoefficient = 0f,
                                                damageType      = DamageType.BypassOneShotProtection
                                            };
                                            blastAttack2.Fire();
                                            EffectManager.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/MagmaOrbExplosion"), new EffectData
                                            {
                                                origin = self.transform.position,
                                                scale  = 16f
                                            }, true);
                                        }
                                    }
                                    else
                                    {
                                        bool hasGoo = di.damageType.HasFlag(DamageType.ClayGoo);
                                        if (hasGoo)
                                        {
                                            di.damageType = DamageType.Generic;
                                            self.GetComponent <CharacterBody>().AddTimedBuff((BuffIndex)21, 4f);
                                        }
                                        bool flag21 = di.procCoefficient == Modules.Config.rifleProcCoefficient.Value;
                                        bool flag22 = flag21;
                                        if (flag22)
                                        {
                                            self.GetComponent <CharacterBody>().AddTimedBuff((BuffIndex)21, 4f);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
 // Token: 0x06002BB7 RID: 11191 RVA: 0x000B8C98 File Offset: 0x000B6E98
 public override void FixedUpdate()
 {
     base.FixedUpdate();
     if (base.fixedAge >= this.duration)
     {
         this.outer.SetNextStateToMain();
         return;
     }
     if (base.isAuthority)
     {
         if (base.characterBody)
         {
             base.characterBody.isSprinting = true;
         }
         if (base.skillLocator.special && base.inputBank.skill4.down)
         {
             base.skillLocator.special.ExecuteIfReady();
         }
         this.UpdateDirection();
         if (!this.inHitPause)
         {
             if (base.characterDirection)
             {
                 base.characterDirection.moveVector = this.idealDirection;
                 if (base.characterMotor && !base.characterMotor.disableAirControlUntilCollision)
                 {
                     base.characterMotor.rootMotion += this.GetIdealVelocity() * Time.fixedDeltaTime;
                 }
             }
             this.attack.damage = this.damageStat * (ToolbotDash.chargeDamageCoefficient * this.GetDamageBoostFromSpeed());
             if (this.attack.Fire(this.victimsStruck))
             {
                 Util.PlaySound(ToolbotDash.impactSoundString, base.gameObject);
                 this.inHitPause    = true;
                 this.hitPauseTimer = ToolbotDash.hitPauseDuration;
                 base.AddRecoil(-0.5f * ToolbotDash.recoilAmplitude, -0.5f * ToolbotDash.recoilAmplitude, -0.5f * ToolbotDash.recoilAmplitude, 0.5f * ToolbotDash.recoilAmplitude);
                 base.PlayAnimation("Gesture, Additive", "BoxModeImpact", "BoxModeImpact.playbackRate", ToolbotDash.hitPauseDuration);
                 for (int i = 0; i < this.victimsStruck.Count; i++)
                 {
                     float           num             = 0f;
                     HealthComponent healthComponent = this.victimsStruck[i];
                     CharacterMotor  component       = healthComponent.GetComponent <CharacterMotor>();
                     if (component)
                     {
                         num = component.mass;
                     }
                     else
                     {
                         Rigidbody component2 = healthComponent.GetComponent <Rigidbody>();
                         if (component2)
                         {
                             num = component2.mass;
                         }
                     }
                     if (num >= ToolbotDash.massThresholdForKnockback)
                     {
                         healthComponent.TakeDamage(new DamageInfo
                         {
                             attacker         = base.gameObject,
                             damage           = this.damageStat * ToolbotDash.knockbackDamageCoefficient * this.GetDamageBoostFromSpeed(),
                             crit             = this.attack.isCrit,
                             procCoefficient  = 1f,
                             damageColorIndex = DamageColorIndex.Item,
                             damageType       = DamageType.Stun1s,
                             position         = base.characterBody.corePosition
                         });
                         base.AddRecoil(-0.5f * ToolbotDash.recoilAmplitude * 3f, -0.5f * ToolbotDash.recoilAmplitude * 3f, -0.5f * ToolbotDash.recoilAmplitude * 8f, 0.5f * ToolbotDash.recoilAmplitude * 3f);
                         base.healthComponent.TakeDamageForce(this.idealDirection * -ToolbotDash.knockbackForce, true, false);
                         EffectManager.SimpleImpactEffect(ToolbotDash.knockbackEffectPrefab, base.characterBody.corePosition, base.characterDirection.forward, true);
                         this.outer.SetNextStateToMain();
                         return;
                     }
                 }
                 return;
             }
         }
         else
         {
             base.characterMotor.velocity = Vector3.zero;
             this.hitPauseTimer          -= Time.fixedDeltaTime;
             if (this.hitPauseTimer < 0f)
             {
                 this.inHitPause = false;
             }
         }
     }
 }
Esempio n. 29
0
        ////// Hooks //////

        private void HealthComponent_UpdateLastHitTime(On.RoR2.HealthComponent.orig_UpdateLastHitTime orig, HealthComponent self, float damageValue, Vector3 damagePosition, bool damageIsSilent, GameObject attacker)
        {
            orig(self, damageValue, damagePosition, damageIsSilent, attacker);
            if (NetworkServer.active && self.body && damageValue > 0f)
            {
                var cpt = self.GetComponent <KleinBottleTimeTracker>();
                if (!cpt)
                {
                    cpt = self.gameObject.AddComponent <KleinBottleTimeTracker>();
                }

                if (Time.fixedTime - cpt.LastTimestamp < PROC_ICD)
                {
                    return;
                }
                else
                {
                    cpt.LastTimestamp = Time.fixedTime;
                }
                var count   = GetCount(self.body);
                var pChance = (1f - Mathf.Pow(1 - procChance / 100f, count)) * 100f;
                var proc    = Util.CheckRoll(pChance, self.body.master);
                if (proc)
                {
                    RoR2.Projectile.ProjectileManager.instance.FireProjectile(
                        blackHolePrefab,
                        self.body.corePosition, Quaternion.identity,
                        self.body.gameObject,
                        0f, 0f, false);

                    var  teamMembers = new List <TeamComponent>();
                    bool isFF        = FriendlyFireManager.friendlyFireMode != FriendlyFireManager.FriendlyFireMode.Off;
                    var  scan        = ((TeamIndex[])Enum.GetValues(typeof(TeamIndex)));
                    var  myTeam      = TeamComponent.GetObjectTeam(self.body.gameObject);
                    foreach (var ind in scan)
                    {
                        if (isFF || myTeam != ind)
                        {
                            teamMembers.AddRange(TeamComponent.GetTeamMembers(ind));
                        }
                    }
                    teamMembers.Remove(self.body.teamComponent);
                    float sqrad  = PULL_RADIUS * PULL_RADIUS;
                    var   isCrit = self.body.RollCrit();
                    foreach (TeamComponent tcpt in teamMembers)
                    {
                        var velVec = tcpt.transform.position - self.transform.position;
                        if (velVec.sqrMagnitude <= sqrad)
                        {
                            bool shouldPull = meleeSurvivorBodyNames.Contains(self.body.name);
                            if (self.body.name == "ToolbotBody(Clone)")
                            {
                                shouldPull &= self.body.skillLocator.primary.skillDef.skillName == "FireBuzzsaw";
                            }

                            if (invertBodyNames)
                            {
                                shouldPull = !shouldPull;
                            }

                            if (shouldPull)
                            {
                                var(vInitial, _) = CalculateVelocityForFinalPosition(tcpt.transform.position, self.transform.position, 0f);
                                velVec           = vInitial;
                            }
                            else
                            {
                                float theta;

                                if (velVec.x == 0 && velVec.z == 0)
                                {
                                    theta = UnityEngine.Random.value * Mathf.PI * 2f;
                                }
                                else
                                {
                                    theta = Mathf.Atan2(velVec.z, velVec.x);
                                }

                                float mag = velVec.magnitude;
                                if (mag == 0)
                                {
                                    mag = velVec.y;
                                }

                                var pitch = Mathf.Asin(velVec.y / mag);
                                pitch  = Remap(pitch, -1, 1, 0.325f, 0.675f);
                                velVec = new Vector3(Mathf.Cos(theta) * Mathf.Cos(pitch), Mathf.Sin(pitch), Mathf.Sin(theta) * Mathf.Cos(pitch));
                            }

                            if (tcpt.body && tcpt.body.isActiveAndEnabled)
                            {
                                if (tcpt.body.healthComponent)
                                {
                                    tcpt.body.healthComponent.TakeDamage(new DamageInfo {
                                        attacker         = self.gameObject,
                                        canRejectForce   = true,
                                        crit             = isCrit,
                                        damage           = self.body.damage * damageFrac,
                                        damageColorIndex = DamageColorIndex.Item,
                                        damageType       = DamageType.AOE,
                                        force            = Vector3.zero,
                                        inflictor        = null,
                                        position         = tcpt.body.corePosition,
                                        procChainMask    = default,