Beispiel #1
0
        /// <summary>
        ///     Calculates the magic damage the source would deal towards the target on a specific given amount, taking in
        ///     consideration all of the damage modifiers.
        /// </summary>
        /// <param name="source">
        ///     The source
        /// </param>
        /// <param name="target">
        ///     The target
        /// </param>
        /// <param name="amount">
        ///     The amount
        /// </param>
        /// <returns>
        ///     The amount of estimated damage dealt to target from source.
        /// </returns>
        private static double CalculateMagicDamage(this Obj_AI_Base source, Obj_AI_Base target, double amount)
        {
            if (amount <= 0)
            {
                return(0);
            }

            // Penetration can't reduce magic resist below 0.
            var magicResist = target.SpellBlock;

            double value;

            if (magicResist < 0)
            {
                value = 2 - (100 / (100 - magicResist));
            }
            else if ((magicResist * source.PercentMagicPenetrationMod) - source.FlatMagicPenetrationMod < 0)
            {
                value = 1;
            }
            else
            {
                value = 100 / (100 + (magicResist * source.PercentMagicPenetrationMod) - source.FlatMagicPenetrationMod);
            }

            return
                (Math.Max(
                     Math.Floor(
                         source.DamageReductionMod(
                             target,
                             source.PassivePercentMod(target, value, DamageType.Magical) * amount,
                             DamageType.Magical)),
                     0));
        }
Beispiel #2
0
        /// <summary>
        ///     Calculates the physical damage the source would deal towards the target on a specific given amount, taking in
        ///     consideration all of the damage modifiers.
        /// </summary>
        /// <param name="source">
        ///     The source
        /// </param>
        /// <param name="target">
        ///     The target
        /// </param>
        /// <param name="amount">
        ///     The amount of damage
        /// </param>
        /// <returns>
        ///     The amount of estimated damage dealt to target from source.
        /// </returns>
        private static double CalculatePhysicalDamage(this Obj_AI_Base source, Obj_AI_Base target, double amount)
        {
            double armorPenetrationPercent = source.PercentArmorPenetrationMod;
            double armorPenetrationFlat    = source.FlatArmorPenetrationMod;

            // Minions return wrong percent values.
            if (source is Obj_AI_Minion)
            {
                armorPenetrationFlat    = 0d;
                armorPenetrationPercent = 1d;
            }

            // Turrets passive.
            var turret = source as Obj_AI_Turret;

            if (turret != null)
            {
                armorPenetrationFlat = 0d;

                var tier = turret.GetTurretType();
                switch (tier)
                {
                case TurretType.TierOne:
                case TurretType.TierTwo:
                    armorPenetrationPercent = 0.7d;
                    break;

                case TurretType.TierThree:
                case TurretType.TierFour:
                    armorPenetrationPercent = 0.3d;
                    break;
                }
            }

            // Penetration can't reduce armor below 0.
            var armor = target.Armor;

            double value;

            if (armor < 0)
            {
                value = 2 - (100 / (100 - armor));
            }
            else if ((armor * armorPenetrationPercent) - armorPenetrationFlat < 0)
            {
                value = 1;
            }
            else
            {
                value = 100 / (100 + (armor * armorPenetrationPercent) - armorPenetrationFlat);
            }

            // Take into account the percent passives, flat passives and damage reduction.
            return(source.DamageReductionMod(
                       target,
                       source.PassivePercentMod(target, value) * amount,
                       DamageType.Physical) + source.PassiveFlatMod(target));
        }
Beispiel #3
0
        /// <summary>
        ///     Calculates the physical damage the source would deal towards the target on a specific given amount, taking in
        ///     consideration all of the damage modifiers.
        /// </summary>
        /// <param name="source">
        ///     The source
        /// </param>
        /// <param name="target">
        ///     The target
        /// </param>
        /// <param name="amount">
        ///     The amount of damage
        /// </param>
        /// <returns>
        ///     The amount of estimated damage dealt to target from source.
        /// </returns>
        private static double CalculatePhysicalDamage(this Obj_AI_Base source, Obj_AI_Base target, double amount)
        {
            if (amount <= 0)
            {
                return(0);
            }

            double armorPenetrationPercent  = source.PercentArmorPenetrationMod;
            double armorPenetrationFlat     = source.FlatArmorPenetrationMod;
            double bonusArmorPenetrationMod = source.PercentBonusArmorPenetrationMod;

            // Minions return wrong percent values.
            if (source is Obj_AI_Minion)
            {
                armorPenetrationFlat     = 0;
                armorPenetrationPercent  = 1;
                bonusArmorPenetrationMod = 1;
            }

            // Turrets passive.
            var turret = source as Obj_AI_Turret;

            if (turret != null)
            {
                armorPenetrationFlat     = 0;
                bonusArmorPenetrationMod = 1;

                switch (turret.GetTurretType())
                {
                case TurretType.TierOne:
                case TurretType.TierTwo:
                    armorPenetrationPercent = 0.7;
                    break;

                case TurretType.TierThree:
                case TurretType.TierFour:
                    armorPenetrationPercent = 0.25;
                    break;
                }
            }

            // Penetration can't reduce armor below 0.
            var armor      = target.Armor;
            var bonusArmor = armor - target.CharData.Armor;

            double value;

            if (armor < 0)
            {
                value = 2 - (100 / (100 - armor));
            }
            else if ((armor * armorPenetrationPercent) - (bonusArmor * (1 - bonusArmorPenetrationMod))
                     - armorPenetrationFlat < 0)
            {
                value = 1;
            }
            else
            {
                value = 100
                        / (100 + (armor * armorPenetrationPercent) - (bonusArmor * (1 - bonusArmorPenetrationMod))
                           - armorPenetrationFlat);
            }

            // Take into account the percent passives, flat passives and damage reduction.
            return
                (Math.Max(
                     Math.Floor(
                         source.DamageReductionMod(
                             target,
                             source.PassivePercentMod(target, value, DamageType.Physical) * amount,
                             DamageType.Physical)),
                     0));
        }