Example #1
0
        private void TakeDamage(On.RoR2.HealthComponent.orig_TakeDamage orig, RoR2.HealthComponent self, RoR2.DamageInfo damageInfo)
        {
            if (!damageInfo.rejected || damageInfo == null)
            {
                var bleedComponent = self.GetComponent <BleedTrackerComponent>();
                if (!bleedComponent)
                {
                    bleedComponent = self.gameObject.AddComponent <BleedTrackerComponent>();
                }
                var inventoryCount = GetCount(self.body.inventory);
                //var healthBefore = self.health; //debug
                if (damageInfo.inflictor != SharkTeeth.instance.BleedInflictor && inventoryCount > 0)
                {
                    //Chat.AddMessage($"Damage Before: {damageInfo.damage}"); //debug
                    var percentage = baseDamageSpreadPercentage + (maxDamageSpreadPercentage - maxDamageSpreadPercentage / (1 + additionalDamageSpreadPercentage * (inventoryCount - 1)));
                    var damage     = damageInfo.damage * percentage;
                    var time       = durationOfDamageSpread;
                    var segments   = ticksOfDamageDuringDuration;
                    damageInfo.damage -= damage;
                    bleedComponent.BleedStacks.Add(new BleedStack(time / segments, damage / segments, segments, damageInfo.attacker, damageInfo.damageType));
                }
            }

            orig(self, damageInfo);
            //if (inventoryCount > 0) {Chat.AddMessage($"Actual Damage: {healthBefore - self.health}");} //debug
        }
Example #2
0
        private float Voidheart30PercentTimebomb(On.RoR2.HealthComponent.orig_Heal orig, RoR2.HealthComponent self, float amount, RoR2.ProcChainMask procChainMask, bool nonRegen)
        {
            var InventoryCount = GetCount(self.body);

            if (self.body && InventoryCount > 0)
            {
                if (self.combinedHealth <= self.fullCombinedHealth * Mathf.Clamp((voidHeartBaseTickingTimeBombHealthThreshold + (voidHeartAdditionalTickingTimeBombHealthThreshold * InventoryCount - 1)), voidHeartBaseTickingTimeBombHealthThreshold, voidHeartMaxTickingTimeBombHealthThreshold) &&
                    //This check is for the timer to determine time since spawn, at <= 10f it'll only activate after the tenth second
                    self.GetComponent <VoidHeartPrevention>().internalTimer >= 7f)
                {
                    RoR2.DamageInfo damageInfo = new RoR2.DamageInfo();
                    damageInfo.crit             = false;
                    damageInfo.damage           = amount;
                    damageInfo.force            = Vector3.zero;
                    damageInfo.position         = self.transform.position;
                    damageInfo.procChainMask    = procChainMask;
                    damageInfo.procCoefficient  = 0f;
                    damageInfo.damageColorIndex = DamageColorIndex.Default;
                    damageInfo.damageType       = DamageType.Generic;
                    self.TakeDamage(damageInfo);
                    return(orig(self, 0, procChainMask, nonRegen));
                }
            }
            return(orig(self, amount, procChainMask, nonRegen));
        }
Example #3
0
        // Token: 0x060010A0 RID: 4256 RVA: 0x00048EF4 File Offset: 0x000470F4
        public void InitializePull()
        {
            if (this.pulling)
            {
                return;
            }
            this.pulling = true;
            Collider[] array = Physics.OverlapSphere(base.transform.position, this.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 && this.teamFilter)
                    {
                        flag = (component2.teamIndex == this.teamFilter.teamIndex);
                    }
                    if (!flag)
                    {
                        this.AddToList(component.gameObject);
                        num2++;
                    }
                }
                num++;
            }
        }
Example #4
0
 // Token: 0x060010CD RID: 4301 RVA: 0x0004987C File Offset: 0x00047A7C
 private void FixedUpdate()
 {
     Collider[] array = Physics.OverlapSphere(base.transform.position, this.radius, LayerIndex.defaultLayer.mask);
     for (int i = 0; i < array.Length; i++)
     {
         HealthComponent component  = array[i].GetComponent <HealthComponent>();
         CharacterMotor  component2 = array[i].GetComponent <CharacterMotor>();
         if (component)
         {
             TeamComponent component3 = component.GetComponent <TeamComponent>();
             bool          flag       = false;
             if (component3 && this.teamFilter)
             {
                 flag = (component3.teamIndex == this.teamFilter.teamIndex);
             }
             if (!flag)
             {
                 this.AddToList(component.gameObject);
                 if (NetworkServer.active)
                 {
                     Vector3 a   = array[i].transform.position - this._transform.position;
                     float   num = 1f - Mathf.Clamp(a.magnitude / this.radius, 0f, 1f - this.forceCoefficientAtEdge);
                     a = a.normalized * this.forceMagnitude * (1f - num);
                     Vector3 velocity;
                     float   mass;
                     if (component2)
                     {
                         velocity = component2.velocity;
                         mass     = component2.mass;
                     }
                     else
                     {
                         Rigidbody component4 = component.GetComponent <Rigidbody>();
                         velocity = component4.velocity;
                         mass     = component4.mass;
                     }
                     velocity.y += Physics.gravity.y * Time.fixedDeltaTime;
                     component.TakeDamageForce(a - velocity * (this.damping * mass * num), true, false);
                 }
             }
         }
     }
 }
Example #5
0
        // Token: 0x06000A0E RID: 2574 RVA: 0x00046974 File Offset: 0x00044B74
        public void Fire()
        {
            Collider[] array = Physics.OverlapSphere(this.position, this.radius, LayerIndex.entityPrecise.mask);
            int        num   = array.Length;

            for (int i = 0; i < num; i++)
            {
                Collider collider  = array[i];
                HurtBox  component = collider.GetComponent <HurtBox>();
                if (component)
                {
                    HealthComponent healthComponent = component.healthComponent;
                    if (healthComponent && ((this.canHurtAttacker && healthComponent.gameObject == this.attacker) || healthComponent.GetComponent <TeamComponent>().teamIndex != this.teamIndex))
                    {
                        BlastAttack.HitPoint hitPoint   = default(BlastAttack.HitPoint);
                        RaycastHit           raycastHit = default(RaycastHit);
                        hitPoint.hurtBox = component;
                        Vector3 direction = collider.transform.position - this.position;
                        if (direction.sqrMagnitude > 0f && collider.Raycast(new Ray(this.position, direction), out raycastHit, this.radius))
                        {
                            hitPoint.hitPosition = raycastHit.point;
                            hitPoint.hitNormal   = raycastHit.normal;
                        }
                        else
                        {
                            hitPoint.hitPosition = collider.transform.position;
                            hitPoint.hitNormal   = this.position - hitPoint.hitPosition;
                        }
                        hitPoint.distanceSqr = (hitPoint.hitPosition - this.position).sqrMagnitude;
                        if (!BlastAttack.bestHitPoints.ContainsKey(healthComponent) || BlastAttack.bestHitPoints[healthComponent].distanceSqr > hitPoint.distanceSqr)
                        {
                            BlastAttack.bestHitPoints[healthComponent] = hitPoint;
                        }
                    }
                }
            }
            BlastAttack.HitPoint[] array2 = new BlastAttack.HitPoint[BlastAttack.bestHitPoints.Count];
            int num2 = 0;

            foreach (KeyValuePair <HealthComponent, BlastAttack.HitPoint> keyValuePair in BlastAttack.bestHitPoints)
            {
                array2[num2++] = keyValuePair.Value;
            }
            BlastAttack.bestHitPoints.Clear();
            Array.Sort <BlastAttack.HitPoint>(array2, new Comparison <BlastAttack.HitPoint>(BlastAttack.HitPoint.DistanceSort));
            foreach (BlastAttack.HitPoint hitPoint2 in array2)
            {
                float num3 = Mathf.Sqrt(hitPoint2.distanceSqr);
                float num4 = 0f;
                switch (this.falloffModel)
                {
                case BlastAttack.FalloffModel.None:
                    num4 = 1f;
                    break;

                case BlastAttack.FalloffModel.Linear:
                    num4 = 1f - Mathf.Clamp01(num3 / this.radius);
                    break;

                case BlastAttack.FalloffModel.SweetSpot:
                    num4 = 1f - ((num3 > this.radius / 2f) ? 0.75f : 0f);
                    break;
                }
                DamageInfo damageInfo = new DamageInfo();
                damageInfo.attacker         = this.attacker;
                damageInfo.inflictor        = this.inflictor;
                damageInfo.damage           = this.baseDamage * num4;
                damageInfo.crit             = this.crit;
                damageInfo.force            = this.bonusForce * num4 + this.baseForce * num4 * (hitPoint2.hitPosition - this.position).normalized;
                damageInfo.procChainMask    = this.procChainMask;
                damageInfo.procCoefficient  = this.procCoefficient;
                damageInfo.damageType       = this.damageType;
                damageInfo.damageColorIndex = this.damageColorIndex;
                damageInfo.position         = hitPoint2.hitPosition;
                damageInfo.ModifyDamageInfo(hitPoint2.hurtBox.damageModifier);
                hitPoint2.hurtBox.healthComponent.TakeDamage(damageInfo);
                GlobalEventManager.instance.OnHitEnemy(damageInfo, hitPoint2.hurtBox.healthComponent.gameObject);
                GlobalEventManager.instance.OnHitAll(damageInfo, hitPoint2.hurtBox.healthComponent.gameObject);
            }
        }
        // Token: 0x06000BF9 RID: 3065 RVA: 0x0003B218 File Offset: 0x00039418
        private void UpdateCrosshair(Vector3 raycastStartPlanePoint)
        {
            this.lastAimAssist = this.aimAssist;
            Vector2 zero = Vector2.zero;
            Ray     crosshairRaycastRay = this.GetCrosshairRaycastRay(zero, raycastStartPlanePoint);
            bool    flag = false;

            this.lastCrosshairHurtBox = null;
            RaycastHit raycastHit = default(RaycastHit);

            RaycastHit[] array = Physics.RaycastAll(crosshairRaycastRay, this.maxAimRaycastDistance, LayerIndex.world.mask | LayerIndex.entityPrecise.mask, QueryTriggerInteraction.Ignore);
            float        num   = float.PositiveInfinity;
            int          num2  = -1;

            for (int i = 0; i < array.Length; i++)
            {
                RaycastHit raycastHit2 = array[i];
                HurtBox    component   = raycastHit2.collider.GetComponent <HurtBox>();
                float      distance    = raycastHit2.distance;
                if (distance < num && distance > 3f && (!component || !component.healthComponent || !component.healthComponent.body || component.healthComponent.body.teamComponent.teamIndex != this.targetTeamIndex))
                {
                    num  = distance;
                    num2 = i;
                    this.lastCrosshairHurtBox = component;
                }
            }
            if (num2 != -1)
            {
                flag       = true;
                raycastHit = array[num2];
            }
            this.aimAssist.aimAssistHurtbox = null;
            if (flag)
            {
                this.crosshairWorldPosition = raycastHit.point;
                float num3 = 1000f;
                if (raycastHit.distance < num3)
                {
                    HurtBox component2 = raycastHit.collider.GetComponent <HurtBox>();
                    if (component2)
                    {
                        HealthComponent healthComponent = component2.healthComponent;
                        if (healthComponent)
                        {
                            TeamComponent component3 = healthComponent.GetComponent <TeamComponent>();
                            if (component3 && component3.teamIndex != this.targetTeamIndex && component3.teamIndex != TeamIndex.None)
                            {
                                CharacterBody body    = healthComponent.body;
                                HurtBox       hurtBox = (body != null) ? body.mainHurtBox : null;
                                if (hurtBox)
                                {
                                    this.aimAssist.aimAssistHurtbox       = hurtBox;
                                    this.aimAssist.worldPosition          = raycastHit.point;
                                    this.aimAssist.localPositionOnHurtbox = hurtBox.transform.InverseTransformPoint(raycastHit.point);
                                    return;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                this.crosshairWorldPosition = crosshairRaycastRay.GetPoint(this.maxAimRaycastDistance);
            }
        }
Example #7
0
        // Token: 0x060003D0 RID: 976 RVA: 0x0000EB60 File Offset: 0x0000CD60
        private BlastAttack.HitPoint[] CollectHits()
        {
            Vector3 vector = this.position;

            Collider[] array = Physics.OverlapSphere(vector, this.radius, LayerIndex.entityPrecise.mask);
            int        num   = array.Length;
            int        num2  = 0;

            BlastAttack.< > c__DisplayClass27_0 CS$ < > 8__locals1;
            CS$ < > 8__locals1.encounteredHealthComponentsLength = 0;
            CS$ < > 8__locals1.hitOrderBufferLength = 0;
            HGArrayUtilities.EnsureCapacity <BlastAttack.HitPoint>(ref BlastAttack.hitPointsBuffer, num);
            HGArrayUtilities.EnsureCapacity <int>(ref BlastAttack.hitOrderBuffer, num);
            HGArrayUtilities.EnsureCapacity <HealthComponent>(ref BlastAttack.encounteredHealthComponentsBuffer, num);
            for (int i = 0; i < num; i++)
            {
                Collider collider  = array[i];
                HurtBox  component = collider.GetComponent <HurtBox>();
                if (component)
                {
                    HealthComponent healthComponent = component.healthComponent;
                    if (healthComponent && ((this.canHurtAttacker && healthComponent.gameObject == this.attacker) || healthComponent.GetComponent <TeamComponent>().teamIndex != this.teamIndex))
                    {
                        Vector3 vector2      = collider.transform.position;
                        Vector3 hitNormal    = vector2 - vector;
                        float   sqrMagnitude = hitNormal.sqrMagnitude;
                        BlastAttack.hitPointsBuffer[num2++] = new BlastAttack.HitPoint
                        {
                            hurtBox     = component,
                            hitPosition = vector2,
                            hitNormal   = hitNormal,
                            distanceSqr = sqrMagnitude
                        };
                    }
                }
            }
            if (true)
            {
                for (int j = 0; j < num2; j++)
                {
                    ref BlastAttack.HitPoint ptr = ref BlastAttack.hitPointsBuffer[j];
                    RaycastHit raycastHit;
                    if (ptr.hurtBox != null && ptr.distanceSqr > 0f && ptr.hurtBox.collider.Raycast(new Ray(vector, -ptr.hitNormal), out raycastHit, this.radius))
                    {
                        ptr.hitPosition = raycastHit.point;
                        ptr.hitNormal   = raycastHit.normal;
                    }
                }
            }