// Token: 0x060012F1 RID: 4849 RVA: 0x0005136C File Offset: 0x0004F56C
        public void OnTakeDamageServer(DamageReport damageReport)
        {
            DamageInfo damageInfo = damageReport.damageInfo;

            if (this.targetStateMachine && base.isServer && this.characterBody)
            {
                bool  flag = damageInfo.procCoefficient >= Mathf.Epsilon;
                float num  = damageInfo.crit ? (damageInfo.damage * 2f) : damageInfo.damage;
                if (flag && this.canBeFrozen && (damageInfo.damageType & DamageType.Freeze2s) != DamageType.Generic)
                {
                    this.SetFrozen(2f * damageInfo.procCoefficient);
                    return;
                }
                if (!this.characterBody.healthComponent.isInFrozenState)
                {
                    if (flag && this.canBeStunned && (damageInfo.damageType & DamageType.Stun1s) != DamageType.Generic)
                    {
                        this.SetStun(1f);
                        return;
                    }
                    if (this.canBeHitStunned && num > this.characterBody.maxHealth * this.hitThreshold)
                    {
                        this.SetPain();
                    }
                }
            }
        }
示例#2
0
        // Token: 0x06000A02 RID: 2562 RVA: 0x0002BD0C File Offset: 0x00029F0C
        public void OnKilledServer(DamageReport damageReport)
        {
            CharacterBody attackerBody = damageReport.attackerBody;

            if (attackerBody)
            {
                Vector3 corePosition = this.characterBody.corePosition;
                TeamManager.instance.GiveTeamMoney(damageReport.attackerTeamIndex, this.goldReward);
                EffectManager.SpawnEffect(DeathRewards.coinEffectPrefab, new EffectData
                {
                    origin       = corePosition,
                    genericFloat = this.goldReward,
                    scale        = this.characterBody.radius
                }, true);
                float num = 1f + (this.characterBody.level - 1f) * 0.3f;
                ExperienceManager.instance.AwardExperience(corePosition, attackerBody, (ulong)((uint)(this.expReward * num)));
                if (this.logUnlockableName != "" && Run.instance.CanUnlockableBeGrantedThisRun(this.logUnlockableName) && Util.CheckRoll(this.characterBody.isChampion ? 3f : 1f, damageReport.attackerMaster))
                {
                    GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(DeathRewards.logbookPrefab, corePosition, UnityEngine.Random.rotation);
                    gameObject.GetComponentInChildren <UnlockPickup>().unlockableName = this.logUnlockableName;
                    gameObject.GetComponent <TeamFilter>().teamIndex = TeamIndex.Player;
                    NetworkServer.Spawn(gameObject);
                }
            }
        }
 // Token: 0x06000DDA RID: 3546 RVA: 0x0003E2F7 File Offset: 0x0003C4F7
 private void OnCharacterDeathGlobalServer(DamageReport damageReport)
 {
     if (damageReport.attacker == this.genericOwnership.ownerObject && damageReport.attacker != null)
     {
         this.OnOwnerKilledOtherServer();
     }
 }
 // Token: 0x06000847 RID: 2119 RVA: 0x00023CA8 File Offset: 0x00021EA8
 public void OnBodyDamaged(DamageReport damageReport)
 {
     BaseAI[] array = this.aiComponents;
     for (int i = 0; i < array.Length; i++)
     {
         array[i].OnBodyDamaged(damageReport);
     }
 }
        // Token: 0x06000691 RID: 1681 RVA: 0x0001AD08 File Offset: 0x00018F08
        private void OnMemberDeathServer(CharacterMaster memberMaster, DamageReport damageReport)
        {
            GameObject   bodyObject   = memberMaster.GetBodyObject();
            DeathRewards deathRewards = (bodyObject != null) ? bodyObject.GetComponent <DeathRewards>() : null;

            if (deathRewards)
            {
                PickupIndex pickupIndex = (PickupIndex)deathRewards.bossPickup;
                if (pickupIndex != PickupIndex.none)
                {
                    this.bossDrops.Add(pickupIndex);
                }
            }
        }
        // Token: 0x06001015 RID: 4117 RVA: 0x00050E2C File Offset: 0x0004F02C
        private static void SendDamageDealt(DamageReport damageReport)
        {
            DamageInfo damageInfo = damageReport.damageInfo;

            NetworkServer.SendToAll(60, new DamageDealtMessage
            {
                victim           = damageReport.victim.gameObject,
                damage           = damageInfo.damage,
                attacker         = damageInfo.attacker,
                position         = damageInfo.position,
                crit             = damageInfo.crit,
                damageType       = damageInfo.damageType,
                damageColorIndex = damageInfo.damageColorIndex
            });
        }
示例#7
0
        private void OnCharacterDeathCallback(DamageReport damageReport)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.CombatSquad::OnCharacterDeathCallback(RoR2.DamageReport)' called on client");
                return;
            }
            DamageInfo    damageInfo = damageReport.damageInfo;
            CharacterBody component  = damageReport.victim.gameObject.GetComponent <CharacterBody>();

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

            if (!master)
            {
                return;
            }
            GameObject gameObject = master.gameObject;
            int        num        = this.membersList.IndexOf(master);

            if (num >= 0)
            {
                Action <CharacterMaster, DamageReport> action = this.onMemberDeathServer;
                if (action != null)
                {
                    action(master, damageReport);
                }
                this.RemoveMemberAt(num);
                if (!this.defeatedServer && this.membersList.Count == 0)
                {
                    this.defeatedServer = true;
                    Action action2 = this.onDefeatedServer;
                    if (action2 != null)
                    {
                        action2();
                    }
                    UnityEvent unityEvent = this.onDefeatedServerLogicEvent;
                    if (unityEvent == null)
                    {
                        return;
                    }
                    unityEvent.Invoke();
                }
            }
        }
 // Token: 0x0600130C RID: 4876 RVA: 0x00051A18 File Offset: 0x0004FC18
 public void OnTakeDamageServer(DamageReport damageReport)
 {
     if (this.consumed)
     {
         return;
     }
     if (this.targetStateMachine && base.isServer && this.characterBody)
     {
         DamageInfo damageInfo = damageReport.damageInfo;
         float      num        = damageInfo.crit ? (damageInfo.damage * 2f) : damageInfo.damage;
         if ((damageInfo.damageType & DamageType.WeakPointHit) != DamageType.Generic)
         {
             this.accumulatedDamage += num;
             if (this.accumulatedDamage > this.characterBody.maxHealth * this.weakenPercentage)
             {
                 this.consumed = true;
                 this.SetWeak(damageInfo);
             }
         }
     }
 }
 // Token: 0x06000F16 RID: 3862 RVA: 0x0004A958 File Offset: 0x00048B58
 private void OnCharacterDeath(DamageReport damageReport)
 {
     if (damageReport.victimBody)
     {
         for (int i = 0; i < this.bodyNames.Length; i++)
         {
             if (damageReport.victimBody.name.Contains(this.bodyNames[i]))
             {
                 this.currentDeathCount++;
                 break;
             }
         }
     }
     if (this.currentDeathCount >= this.targetDeathCount)
     {
         UnityEvent unityEvent = this.onAchieved;
         if (unityEvent == null)
         {
             return;
         }
         unityEvent.Invoke();
     }
 }
示例#10
0
        private void On_SSOHOnTakeDamageServer(On.RoR2.SetStateOnHurt.orig_OnTakeDamageServer orig, SetStateOnHurt self, RoR2.DamageReport damageReport)
        {
            orig(self, damageReport);
            int icnt = GetCount(damageReport.attackerMaster);

            if (icnt < 1)
            {
                return;
            }
        }
        //private void GrantBaseShield(ILContext il)
        //{
        //    //Provided by Harb from their HarbCrate mod. Thanks Harb!
        //    ILCursor c = new ILCursor(il);
        //    int shieldsLoc = 33;
        //    c.GotoNext(
        //        MoveType.Before,
        //        x => x.MatchLdloc(out shieldsLoc),
        //        x => x.MatchCallvirt<CharacterBody>("set_maxShield")
        //    );
        //    c.Emit(OpCodes.Ldloc, shieldsLoc);
        //    c.EmitDelegate<Func<CharacterBody, float, float>>((self, shields) =>
        //    {
        //        var InventoryCount = GetCount(self);
        //        if (InventoryCount > 0)
        //        {
        //            shields += self.maxHealth * 0.08f;
        //        }
        //        return shields;
        //    });
        //    c.Emit(OpCodes.Stloc, shieldsLoc);
        //    c.Emit(OpCodes.Ldarg_0);
        //}

        private void GrantShieldReward(On.RoR2.GlobalEventManager.orig_OnCharacterDeath orig, RoR2.GlobalEventManager self, RoR2.DamageReport damageReport)
        {
            if (damageReport?.attackerBody)
            {
                int inventoryCount = GetCount(damageReport.attackerBody);
                if (inventoryCount > 0)
                {
                    var percentage = shieldPercentageRestoredPerKill + (maximumPercentageShieldRestoredPerKill - maximumPercentageShieldRestoredPerKill / (1 + additionalShieldPercentageRestoredPerKillDiminishing * (inventoryCount - 1)));
                    damageReport.attackerBody.healthComponent.RechargeShield(damageReport.attackerBody.healthComponent.fullShield * percentage);
                }
            }
            orig(self, damageReport);
        }
示例#12
0
        private void OnCharacterDeathCallback(DamageReport damageReport)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.BossGroup::OnCharacterDeathCallback(RoR2.DamageReport)' called on client");
                return;
            }
            DamageInfo    damageInfo = damageReport.damageInfo;
            GameObject    gameObject = damageReport.victim.gameObject;
            CharacterBody component  = gameObject.GetComponent <CharacterBody>();

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

            if (!master)
            {
                return;
            }
            DeathRewards component2 = gameObject.GetComponent <DeathRewards>();

            if (component2)
            {
                PickupIndex pickupIndex = (PickupIndex)component2.bossPickup;
                if (pickupIndex != PickupIndex.none && ItemDropManager.IncludeSpecialBossDrops)
                {
                    this.bossDrops.Add(pickupIndex);
                }
            }
            GameObject victimMasterGameObject = master.gameObject;
            int        num = this.membersList.FindIndex((CharacterMaster x) => x.gameObject == victimMasterGameObject);

            if (num >= 0)
            {
                this.RemoveMemberAt(num);
                if (!this.defeated && this.membersList.Count == 0)
                {
                    Run.instance.OnServerBossKilled(true);
                    if (component)
                    {
                        int participatingPlayerCount = Run.instance.participatingPlayerCount;
                        if (participatingPlayerCount != 0 && this.dropPosition)
                        {
                            //ItemIndex itemIndex = ItemDropManager.BossDropList[this.rng.RangeInt(0, ItemDropManager.BossDropList.Count)];
                            ItemIndex  itemIndex = ItemDropManager.GetSelection(ItemDropLocation.Boss, rng.nextNormalizedFloat).itemIndex;
                            int        num2      = participatingPlayerCount * (1 + (TeleporterInteraction.instance ? TeleporterInteraction.instance.shrineBonusStacks : 0));
                            float      angle     = 360f / (float)num2;
                            Vector3    vector    = Quaternion.AngleAxis((float)UnityEngine.Random.Range(0, 360), Vector3.up) * (Vector3.up * 40f + Vector3.forward * 5f);
                            Quaternion rotation  = Quaternion.AngleAxis(angle, Vector3.up);
                            int        i         = 0;
                            while (i < num2)
                            {
                                PickupIndex pickupIndex2 = new PickupIndex(itemIndex);
                                if (this.bossDrops.Count > 0 && this.rng.nextNormalizedFloat <= this.bossDropChance)
                                {
                                    pickupIndex2 = this.bossDrops[this.rng.RangeInt(0, this.bossDrops.Count)];
                                }
                                PickupDropletController.CreatePickupDroplet(pickupIndex2, this.dropPosition.position, vector);
                                i++;
                                vector = rotation * vector;
                            }
                        }
                    }
                    this.defeated = true;
                    Action <BossGroup> action = onBossGroupDefeatedServer;
                    if (action == null)
                    {
                        return;
                    }
                    action(this);
                    return;
                }
                else
                {
                    Run.instance.OnServerBossKilled(false);
                }
            }
        }
 private void CalculateBFBuffGain(On.RoR2.GlobalEventManager.orig_OnCharacterDeath orig, GlobalEventManager self, RoR2.DamageReport damageReport)
 {
     if (damageReport.attackerBody)
     {
         var inventoryCount = GetCount(damageReport.attackerBody);
         if (GetCount(damageReport.attackerBody) > 0)
         {
             damageReport.attackerBody.AddBuff(BFBuff);
         }
     }
     orig(self, damageReport);
 }
示例#14
0
        public void TakeDamage(DamageInfo damageInfo)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.HealthComponent::TakeDamage(RoR2.DamageInfo)' called on client");
                return;
            }
            if (!alive || godMode)
            {
                return;
            }
            CharacterBody characterBody = null;

            if (damageInfo.attacker)
            {
                characterBody = damageInfo.attacker.GetComponent <CharacterBody>();
            }
            BroadcastMessage("OnIncomingDamage", damageInfo, SendMessageOptions.DontRequireReceiver);
            var master = body.master;

            GetComponent <TeamComponent>();
            if (master && master.inventory)
            {
                var itemCount = master.inventory.GetItemCount((ItemIndex)1);
                if (itemCount > 0 && Util.CheckRoll((1f - 1f / (0.15f * itemCount + 1f)) * 100f, 0f, null))
                {
                    var effectData = new EffectData
                    {
                        origin   = damageInfo.position,
                        rotation = Util.QuaternionSafeLookRotation((damageInfo.force != Vector3.zero) ? damageInfo.force : Random.onUnitSphere)
                    };
                    EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/BearProc"), effectData, true);
                    damageInfo.rejected = true;
                }
            }
            if (body.HasBuff((BuffIndex)3))
            {
                damageInfo.rejected = true;
            }
            if (body.HasBuff((BuffIndex)23) && (!characterBody || !characterBody.HasBuff((BuffIndex)22)))
            {
                EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/DamageRejected"), new EffectData
                {
                    origin = damageInfo.position
                }, true);
                damageInfo.rejected = true;
            }
            if (damageInfo.rejected)
            {
                return;
            }
            var num = damageInfo.damage;

            if (characterBody)
            {
                var master2 = characterBody.master;
                if (master2 && master2.inventory)
                {
                    if (combinedHealth >= fullCombinedHealth * 0.9f)
                    {
                        var itemCount2 = master2.inventory.GetItemCount((ItemIndex)17);
                        if (itemCount2 > 0)
                        {
                            Util.PlaySound("Play_item_proc_crowbar", gameObject);
                            num *= 1.5f + 0.3f * (itemCount2 - 1);
                            EffectManager.instance.SimpleImpactEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/ImpactCrowbar"), damageInfo.position, -damageInfo.force, true);
                        }
                    }
                    if (body.isBoss)
                    {
                        var itemCount3 = master2.inventory.GetItemCount((ItemIndex)61);
                        if (itemCount3 > 0)
                        {
                            num *= 1.2f + 0.1f * (itemCount3 - 1);
                            damageInfo.damageColorIndex = (DamageColorIndex)5;
                            EffectManager.instance.SimpleImpactEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/ImpactBossDamageBonus"), damageInfo.position, -damageInfo.force, true);
                        }
                    }
                }
            }
            if (damageInfo.crit)
            {
                num *= 2f;
            }
            if ((damageInfo.damageType & DamageType.WeakPointHit) != 0)
            {
                num *= 1.5f;
                damageInfo.damageColorIndex = (DamageColorIndex)5;
            }
            if ((damageInfo.damageType & DamageType.BypassArmor) == 0)
            {
                var armor = body.armor;
                var num2  = armor >= 0f ? 1f - armor / (armor + 100f) : 2f - 100f / (100f - armor);
                num = Mathf.Max(1f, num * num2);
            }
            if ((damageInfo.damageType & DamageType.BarrierBlocked) != 0)
            {
                damageInfo.force *= 0.5f;
                var component = GetComponent <IBarrier>();
                component?.BlockedDamage(damageInfo, num);
                damageInfo.procCoefficient = 0f;
                num = 0f;
            }
            if (hasOneshotProtection)
            {
                num = Mathf.Min(num, fullCombinedHealth * 0.40f);                 // Make this more aggressive; 90% -> 40%
            }
            if ((damageInfo.damageType & DamageType.SlowOnHit) != 0)
            {
                body.AddTimedBuff(0, 2f);
            }
            if ((damageInfo.damageType & DamageType.ClayGoo) != 0 && (body.bodyFlags & CharacterBody.BodyFlags.ImmuneToGoo) == 0)
            {
                body.AddTimedBuff((BuffIndex)21, 2f);
            }
            if (master && master.inventory)
            {
                var itemCount4 = master.inventory.GetItemCount((ItemIndex)44);
                if (itemCount4 > 0)
                {
                    var num3 = num / fullCombinedHealth;
                    var num4 = (uint)Mathf.Max(master.money * num3 * itemCount4, damageInfo.damage * itemCount4);
                    master.money = (uint)Mathf.Max(0f, master.money - num4);
                    EffectManager.instance.SimpleImpactEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/CoinImpact"), damageInfo.position, Vector3.up, true);
                }
            }
            if ((damageInfo.damageType & DamageType.NonLethal) != 0)
            {
                num = Mathf.Max(Mathf.Min(num, health - 1f), 0f);
            }
            if (shield > 0f)
            {
                var num5 = Mathf.Min(num, shield);
                var num6 = num - num5;
                Networkshield = Mathf.Max(shield - num5, 0f);
                if (Mathf.Approximately(shield, 0f))
                {
                    var scale = 1f;
                    if (body)
                    {
                        scale = body.radius;
                    }
                    EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ShieldBreakEffect"), new EffectData
                    {
                        origin = transform.position,
                        scale  = scale
                    }, true);
                }
                if (num6 > 0f)
                {
                    Networkhealth = health - num6;
                }
            }
            else
            {
                Networkhealth = health - num;
            }
            TakeDamageForce(damageInfo, false);
            SendMessage("OnTakeDamage", damageInfo, SendMessageOptions.DontRequireReceiver);
            var damageReport = new DamageReport
            {
                victim     = this,
                damageInfo = damageInfo
            };

            damageReport.damageInfo.damage = num;
            if (num > 0f)
            {
                SendDamageDealt(damageReport);
            }
            UpdateLastHitTime(damageInfo.damage, damageInfo.position, (damageInfo.damageType & (DamageType)2048) > 0);
            if (damageInfo.attacker)
            {
                damageInfo.attacker.SendMessage("OnDamageDealt", damageReport, SendMessageOptions.DontRequireReceiver);
            }
            GlobalEventManager.ServerDamageDealt(damageReport);
            if (isInFrozenState && (body.bodyFlags & (CharacterBody.BodyFlags) 16) == 0 && combinedHealthFraction < 0.3f)
            {
                Networkhealth = -1f;
                EffectManager.instance.SpawnEffect(FrozenState.executeEffectPrefab, new EffectData
                {
                    origin = body.corePosition,
                    scale  = body ? body.radius : 1f
                }, true);
            }
            if (!alive)
            {
                BroadcastMessage("OnKilled", damageInfo, SendMessageOptions.DontRequireReceiver);
                if (damageInfo.attacker)
                {
                    damageInfo.attacker.SendMessage("OnKilledOther", damageReport, SendMessageOptions.DontRequireReceiver);
                }
                GlobalEventManager.instance.OnCharacterDeath(damageReport);
                return;
            }
            if (master && master.inventory)
            {
                var itemCount5 = master.inventory.GetItemCount((ItemIndex)25);
                if (itemCount5 > 0 && Util.CheckRoll(damageInfo.damage / fullCombinedHealth * 100f, master))
                {
                    body.AddTimedBuff((BuffIndex)7, 1.5f + itemCount5 * 1.5f);
                    body.AddTimedBuff((BuffIndex)8, 1.5f + itemCount5 * 1.5f);
                    EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ProcStealthkit"), new EffectData
                    {
                        origin   = transform.position,
                        rotation = Quaternion.identity
                    }, true);
                }
            }
        }
示例#15
0
 private void CalculateShellBuffApplications(On.RoR2.GlobalEventManager.orig_OnCharacterDeath orig, GlobalEventManager self, RoR2.DamageReport damageReport)
 {
     orig(self, damageReport);
     if (damageReport.attackerBody)
     {
         var inventoryCount       = GetCount(damageReport.attackerBody);
         var currentShellStackMax = (((inventoryCount - 1) * 50) + 50);
         var currentShellStack    = damageReport.attackerBody.inventory.GetItemCount(shellStack);
         if (inventoryCount > 0 && currentShellStack < currentShellStackMax)
         {
             damageReport.attackerBody.inventory.GiveItem(shellStack);
         }
     }
 }
        public void TakeDamage(DamageInfo damageInfo)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.HealthComponent::TakeDamage(RoR2.DamageInfo)' called on client");
                return;
            }
            if (!this.alive || this.godMode)
            {
                return;
            }
            CharacterBody characterBody = null;

            if (damageInfo.attacker)
            {
                characterBody = damageInfo.attacker.GetComponent <CharacterBody>();
            }
            base.BroadcastMessage("OnIncomingDamage", damageInfo, SendMessageOptions.DontRequireReceiver);
            CharacterMaster master = this.body.master;

            base.GetComponent <TeamComponent>();
            if (master && master.inventory)
            {
                int itemCount = master.inventory.GetItemCount(ItemIndex.Bear);
                if (itemCount > 0 && Util.CheckRoll((1f - 1f / (0.15f * (float)itemCount + 1f)) * 100f, 0f, null))
                {
                    EffectData effectData = new EffectData
                    {
                        origin   = damageInfo.position,
                        rotation = Util.QuaternionSafeLookRotation((damageInfo.force != Vector3.zero) ? damageInfo.force : UnityEngine.Random.onUnitSphere)
                    };
                    EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/BearProc"), effectData, true);
                    damageInfo.rejected = true;
                }
            }
            if (this.body.HasBuff(BuffIndex.Immune) && (!characterBody || !characterBody.HasBuff(BuffIndex.GoldEmpowered)))
            {
                EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/DamageRejected"), new EffectData
                {
                    origin = damageInfo.position
                }, true);
                damageInfo.rejected = true;
            }
            if (damageInfo.rejected)
            {
                return;
            }
            float num = damageInfo.damage;

            if (characterBody)
            {
                CharacterMaster master2 = characterBody.master;
                if (master2 && master2.inventory)
                {
                    if (this.combinedHealth >= this.fullCombinedHealth * 0.9f)
                    {
                        int itemCount2 = master2.inventory.GetItemCount(ItemIndex.Crowbar);
                        if (itemCount2 > 0)
                        {
                            Util.PlaySound("Play_item_proc_crowbar", base.gameObject);
                            num *= 1.5f + 0.3f * (float)(itemCount2 - 1);
                            EffectManager.instance.SimpleImpactEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/ImpactCrowbar"), damageInfo.position, -damageInfo.force, true);
                        }
                    }
                    if (this.body.isBoss)
                    {
                        int itemCount3 = master2.inventory.GetItemCount(ItemIndex.BossDamageBonus);
                        if (itemCount3 > 0)
                        {
                            num *= 1.2f + 0.1f * (float)(itemCount3 - 1);
                            damageInfo.damageColorIndex = DamageColorIndex.WeakPoint;
                            EffectManager.instance.SimpleImpactEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/ImpactBossDamageBonus"), damageInfo.position, -damageInfo.force, true);
                        }
                    }
                }
            }
            if (damageInfo.crit)
            {
                num *= 2f;
            }
            if ((damageInfo.damageType & DamageType.WeakPointHit) != DamageType.Generic)
            {
                num *= 1.5f;
                damageInfo.damageColorIndex = DamageColorIndex.WeakPoint;
            }
            if ((damageInfo.damageType & DamageType.BypassArmor) == DamageType.Generic)
            {
                float armor = this.body.armor;
                float num2  = (armor >= 0f) ? (1f - armor / (armor + 100f)) : (2f - 100f / (100f - armor));
                num = Mathf.Max(1f, num * num2);
            }
            if ((damageInfo.damageType & DamageType.BarrierBlocked) != DamageType.Generic)
            {
                damageInfo.force *= 0.5f;
                IBarrier component = base.GetComponent <IBarrier>();
                if (component != null)
                {
                    component.BlockedDamage(damageInfo, num);
                }
                damageInfo.procCoefficient = 0f;
                num = 0f;
            }
            if (this.hasOneshotProtection)
            {
                num = Mathf.Min(num, this.fullCombinedHealth * 0.9f);
            }
            if ((damageInfo.damageType & DamageType.SlowOnHit) != DamageType.Generic)
            {
                this.body.AddTimedBuff(BuffIndex.Slow50, 2f);
            }
            if ((damageInfo.damageType & DamageType.ClayGoo) != DamageType.Generic && (this.body.bodyFlags & CharacterBody.BodyFlags.ImmuneToGoo) == CharacterBody.BodyFlags.None)
            {
                this.body.AddTimedBuff(BuffIndex.ClayGoo, 2f);
            }
            if (master && master.inventory)
            {
                int itemCount4 = master.inventory.GetItemCount(ItemIndex.GoldOnHit);
                if (itemCount4 > 0)
                {
                    float num3 = num / this.fullCombinedHealth;
                    uint  num4 = (uint)Mathf.Max(master.money * num3 * (float)itemCount4, damageInfo.damage * (float)itemCount4);
                    master.money = (uint)Mathf.Max(0f, master.money - num4);
                    EffectManager.instance.SimpleImpactEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/CoinImpact"), damageInfo.position, Vector3.up, true);
                }
            }
            if ((damageInfo.damageType & DamageType.NonLethal) != DamageType.Generic)
            {
                num = Mathf.Max(Mathf.Min(num, this.health - 1f), 0f);
            }
            if (this.shield > 0f)
            {
                float num5 = Mathf.Min(num, this.shield);
                float num6 = num - num5;
                this.Networkshield = Mathf.Max(this.shield - num5, 0f);
                if (this.shield == 0f)
                {
                    float scale = 1f;
                    if (this.body)
                    {
                        scale = this.body.radius;
                    }
                    EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ShieldBreakEffect"), new EffectData
                    {
                        origin = base.transform.position,
                        scale  = scale
                    }, true);
                }
                if (num6 > 0f)
                {
                    this.Networkhealth = this.health - num6;
                }
            }
            else
            {
                this.Networkhealth = this.health - num;
            }
            this.TakeDamageForce(damageInfo, false);
            base.SendMessage("OnTakeDamage", damageInfo, SendMessageOptions.DontRequireReceiver);
            DamageReport damageReport = new DamageReport
            {
                victim     = this,
                damageInfo = damageInfo
            };

            damageReport.damageInfo.damage = num;
            if (num > 0f)
            {
                HealthComponent.SendDamageDealt(damageReport);
            }
            this.UpdateLastHitTime(damageInfo.damage, damageInfo.position, (damageInfo.damageType & DamageType.Silent) > DamageType.Generic);
            if (damageInfo.attacker)
            {
                damageInfo.attacker.SendMessage("OnDamageDealt", damageReport, SendMessageOptions.DontRequireReceiver);
            }
            GlobalEventManager.ServerDamageDealt(damageReport);
            if (this.isFrozen && this.combinedHealthFraction < 0.3f)
            {
                this.Networkhealth = 0f;
                EffectManager.instance.SpawnEffect(FrozenState.cullEffectPrefab, new EffectData
                {
                    origin = this.body.corePosition,
                    scale  = (this.body ? this.body.radius : 1f)
                }, true);
            }
            if (!this.alive)
            {
                base.BroadcastMessage("OnKilled", damageInfo, SendMessageOptions.DontRequireReceiver);
                if (damageInfo.attacker)
                {
                    damageInfo.attacker.SendMessage("OnKilledOther", damageReport, SendMessageOptions.DontRequireReceiver);
                }
                GlobalEventManager.instance.OnCharacterDeath(damageReport);
                return;
            }
            if (master && master.inventory)
            {
                int itemCount5 = master.inventory.GetItemCount(ItemIndex.Phasing);
                if (itemCount5 > 0 && Util.CheckRoll(damageInfo.damage / this.fullCombinedHealth * 100f, master))
                {
                    this.body.AddTimedBuff(BuffIndex.Cloak, 1.5f + (float)itemCount5 * 1.5f);
                    this.body.AddTimedBuff(BuffIndex.CloakSpeed, 1.5f + (float)itemCount5 * 1.5f);
                    EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ProcStealthkit"), new EffectData
                    {
                        origin   = base.transform.position,
                        rotation = Quaternion.identity
                    }, true);
                }
            }
        }
示例#17
0
 private void Class1_OnCharacterDeathGlobal(orig_OnCharacterDeathGlobal orig, RoR2.Achievements.BaseServerAchievement self, RoR2.DamageReport damageReport)
 {
     orig(self, damageReport);
     if (allowedBodyIndicies.Contains(damageReport.victimBodyIndex) && self.serverAchievementTracker.networkUser.master == damageReport.attackerMaster)
     {
         self.Grant();
     }
 }
 // Token: 0x06000DF3 RID: 3571 RVA: 0x0003E7FB File Offset: 0x0003C9FB
 public void OnTakeDamageServer(DamageReport damageReport)
 {
     this.AddChargeServer(damageReport.damageDealt);
 }