Exemplo n.º 1
0
        public virtual void InflictDamages(Damages damages)
        {
            if (!ObjectAvailable)
            {
                return;
            }

            damages.Apply();

            if (!Stats.IsLifeStealImmune && damages.ApplyAutoAttack && damages.Type == DamageType.DAMAGE_TYPE_PHYSICAL)
            {
                damages.Source.Stats.Health.Heal(damages.Delta * damages.Source.Stats.LifeSteal.TotalSafe);
            }

            if (Shields.Magical > 0 && damages.Type == DamageType.DAMAGE_TYPE_MAGICAL)
            {
                float value = Shields.UseMagicalShield(damages.Delta);
                Stats.Health.Current -= value;
                float shieldLoss = -(damages.Delta - value);
                OnShieldModified(true, false, shieldLoss);
            }
            else if (Shields.Physical > 0 && damages.Type == DamageType.DAMAGE_TYPE_PHYSICAL)
            {
                float value = Shields.UsePhysicalShield(damages.Delta);
                Stats.Health.Current -= value;
                float shieldLoss = -(damages.Delta - value);
                OnShieldModified(false, true, shieldLoss);
            }
            else if (Shields.MagicalAndPhysical > 0)
            {
                float value = Shields.UseMagicalAndPhysicalShield(damages.Delta);
                Stats.Health.Current -= value;
                float shieldLoss = -(damages.Delta - value);
                OnShieldModified(true, true, shieldLoss);
            }
            else
            {
                Stats.Health.Current -= damages.Delta;
                Game.Send(new DamageDoneMessage(damages.Result, damages.Type, damages.Delta, NetId, damages.Source.NetId));
            }



            UpdateStats();
            damages.Source.UpdateStats();

            EventsBinder.OnDamagesInflicted(damages);

            if (Stats.Health.Current <= 0)
            {
                OnDead(damages.Source);
            }
        }