Beispiel #1
0
        /// <summary>
        ///     Gets the source auto attack damage on the target.
        /// </summary>
        /// <param name="source">
        ///     The source
        /// </param>
        /// <param name="target">
        ///     The target
        /// </param>
        /// <returns>
        ///     The estimated auto attack damage.
        /// </returns>
        public static double GetAutoAttackDamage(this Obj_AI_Base source, Obj_AI_Base target)
        {
            double dmgPhysical = source.TotalAttackDamage, dmgMagical = 0, dmgPassive = 0;
            var    dmgReduce = 1d;

            var hero       = source as Obj_AI_Hero;
            var targetHero = target as Obj_AI_Hero;

            var isMixDmg = false;

            if (hero != null)
            {
                // Spoils Of War
                if (hero.IsMelee() && target is Obj_AI_Minion && target.Team != GameObjectTeam.Neutral &&
                    hero.GetBuffCount("TalentReaper") > 0)
                {
                    var eyeEquinox = Items.HasItem(2303, hero);
                    if (
                        GameObjects.Heroes.Any(
                            h => h.Team == hero.Team && !h.Compare(hero) && h.Distance(hero) < (eyeEquinox ? 850 : 1050)))
                    {
                        var spoilwarDmg = 195 + (5 * hero.Level);
                        if (Items.HasItem((int)ItemId.Targons_Brace, hero))
                        {
                            spoilwarDmg = 200 + (10 * hero.Level);
                        }
                        else if (Items.HasItem((int)ItemId.Face_of_the_Mountain, hero) || eyeEquinox)
                        {
                            spoilwarDmg = 320 + (20 * hero.Level);
                        }
                        if (target.Health <= spoilwarDmg)
                        {
                            return(float.MaxValue);
                        }
                    }
                }

                // Bonus Damage (Passive)
                var passiveInfo = hero.GetPassiveDamageInfo(target);
                dmgPassive += passiveInfo.Value;

                if (passiveInfo.Override)
                {
                    return(dmgPassive);
                }

                switch (hero.ChampionName)
                {
                case "Kalista":
                    dmgPhysical *= 0.9;
                    break;

                case "Kled":
                    if (targetHero != null && hero.Spellbook.GetSpell(SpellSlot.Q).Name == "KledRiderQ")
                    {
                        dmgPhysical *= 0.8;
                    }
                    break;

                case "Jhin":
                    dmgPhysical +=
                        Math.Round(
                            (new[] { 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 18, 20, 24, 28, 32, 36, 40 }[
                                 hero.Level - 1] +(Math.Round((hero.Crit * 100 / 10) * 4))
                             + (Math.Round(((hero.AttackSpeedMod - 1) * 100 / 10) * 2.5))) / 100 * dmgPhysical);
                    break;

                case "Corki":
                    dmgPhysical /= 2;
                    dmgMagical   = dmgPhysical;
                    isMixDmg     = true;
                    break;

                case "Quinn":
                    if (target.HasBuff("quinnw"))
                    {
                        dmgPhysical += 10 + (5 * hero.Level) + (0.14 + (0.02 * hero.Level)) * hero.TotalAttackDamage;
                    }
                    break;
                }

                // Serrated Dirk
                if (hero.HasBuff("Serrated"))
                {
                    if (!isMixDmg)
                    {
                        dmgPhysical += 15;
                    }
                    else
                    {
                        dmgPhysical += 7.5;
                        dmgMagical  += 7.5;
                    }
                }

                if (targetHero != null)
                {
                    // Dorans Shield
                    if (Items.HasItem((int)ItemId.Dorans_Shield, targetHero))
                    {
                        var subDmg = (dmgPhysical + dmgMagical) - 8;
                        dmgPhysical = !isMixDmg ? subDmg : (dmgMagical = subDmg / 2);
                    }

                    // Fervor Of Battle
                    if (hero.GetFerocity(Ferocity.FervorofBattle).IsValid())
                    {
                        var fervorBuffCount = hero.GetBuffCount("MasteryOnHitDamageStacker");
                        if (fervorBuffCount > 0)
                        {
                            dmgPassive += hero.CalculatePhysicalDamage(
                                target,
                                (0.13 + (0.77 * hero.Level)) * fervorBuffCount);
                        }
                    }
                }
                else if (target is Obj_AI_Minion)
                {
                    // Savagery
                    var savagery = hero.GetCunning(Cunning.Savagery);
                    if (savagery.IsValid())
                    {
                        dmgPhysical += savagery.Points;
                    }

                    // RiftHerald P
                    if (!hero.IsMelee() && target.Team == GameObjectTeam.Neutral && target.Name == "SRU_RiftHerald")
                    {
                        dmgReduce *= 0.65;
                    }
                }
            }

            // Ninja Tabi
            if (targetHero != null && !(source is Obj_AI_Turret) && Items.HasItem(3047, targetHero))
            {
                dmgReduce *= 0.88;
            }

            dmgPhysical = source.CalculatePhysicalDamage(target, dmgPhysical);
            dmgMagical  = source.CalculateMagicDamage(target, dmgMagical);

            // Fizz P
            if (targetHero != null && targetHero.ChampionName == "Fizz")
            {
                dmgPhysical -= 4 + (2 * Math.Floor((targetHero.Level - 1) / 3d));
            }

            // This formula is right, work out the math yourself if you don't believe me
            return
                (Math.Max(
                     Math.Floor((dmgPhysical + dmgMagical) * dmgReduce + source.PassiveFlatMod(target) + dmgPassive),
                     0));
        }
Beispiel #2
0
        /// <summary>
        ///     Gets the automatic attack damage.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        /// <returns>System.Double.</returns>
        public static double GetAutoAttackDamage(this Obj_AI_Base source, Obj_AI_Base target)
        {
            var dmgPhysical = (double)source.TotalAttackDamage;
            var dmgMagical  = 0d;
            //var dmgPassive = 0d;
            var dmgReduce = 1d;

            var hero       = source as Obj_AI_Hero;
            var targetHero = target as Obj_AI_Hero;

            if (hero != null)
            {
                // todo passives

                switch (hero.ChampionName)
                {
                case "Kalista":
                    dmgPhysical *= 0.9;
                    break;

                case "Jhin":
                    dmgPhysical += Math.Round(
                        (new[] { 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 18, 20, 24, 28, 32, 36, 40 }[hero.Level - 1]
                         +Math.Round(hero.Crit * 100 / 10 * 4)
                         + Math.Round((hero.AttackSpeedMod - 1) * 100 / 10 * 2.5)) / 100 * dmgPhysical);
                    break;

                case "Corki":
                    dmgPhysical /= 2;
                    dmgMagical   = dmgPhysical;
                    break;

                case "Quinn":
                    if (target.HasBuff("quinnw"))
                    {
                        dmgPhysical += 10 + 5 * hero.Level + (0.14 + 0.02 * hero.Level) * hero.TotalAttackDamage;
                    }
                    break;

                case "Galio":
                    if (hero.HasBuff("galiopassivebuff"))
                    {
                        dmgMagical += 8 + 4 * hero.Level + hero.TotalAttackDamage + 0.6 * hero.TotalAbilityDamage + 0.6 * hero.BonusSpellBlock;
                    }
                    break;

                // TODO getting the actual buffname
                case "Sejuani":
                    if (target.HasBuff("sejuanistun") && targetHero != null)
                    {
                        switch (target.Type)
                        {
                        case GameObjectType.AIHeroClient:
                            if (hero.Level < 7)
                            {
                                dmgMagical += 0.1 * targetHero.MaxHealth;
                            }
                            else if (hero.Level < 14)
                            {
                                dmgMagical += 0.15 * targetHero.MaxHealth;
                            }
                            else
                            {
                                dmgMagical += 0.2 * targetHero.MaxHealth;
                            }
                            break;

                        case GameObjectType.obj_AI_Minion:
                            dmgMagical += 400;
                            break;
                        }
                    }
                    break;
                }

                if (target is Obj_AI_Minion)
                {
                    // RiftHerald P
                    if (!hero.IsMelee && target.Team == GameObjectTeam.Neutral &&
                        Regex.IsMatch(target.Name, "SRU_RiftHerald"))
                    {
                        dmgReduce *= 0.65;
                    }

                    // Dorans Shield
                    if (hero.HasItem(ItemId.DoransShield))
                    {
                        dmgPhysical += 5;
                    }
                }
            }

            // Ninja Tabi
            if (targetHero != null && !(source is Obj_AI_Turret) && targetHero.HasItem(3047))
            {
                dmgReduce *= 0.9;
            }

            dmgPhysical = source.CalculatePhysicalDamage(target, dmgPhysical);
            dmgMagical  = source.CalculateMagicDamage(target, dmgMagical);

            // Fizz P
            if (targetHero != null && targetHero.ChampionName == "Fizz")
            {
                dmgPhysical -= 4 + 2 * Math.Floor((targetHero.Level - 1) / 3d);
            }

            return(Math.Max(Math.Floor((dmgPhysical + dmgMagical) * dmgReduce + source.GetPassiveFlatMod(target)), 0));
        }
Beispiel #3
0
        /// <summary>
        ///     Gets the automatic attack damage.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        /// <returns>System.Double.</returns>
        public static double GetAutoAttackDamage(this Obj_AI_Base source, Obj_AI_Base target)
        {
            var dmgPhysical = (double)source.TotalAttackDamage;
            var dmgMagical  = 0d;
            var dmgTrue     = 0d;

            var dmgReduce = 1d;

            var hero       = source as Obj_AI_Hero;
            var targetHero = target as Obj_AI_Hero;

            if (hero != null)
            {
                var passiveDamage = DamagePassives.ComputePassiveDamages(hero, target);
                dmgPhysical += passiveDamage.PhysicalDamage;
                dmgMagical  += passiveDamage.MagicalDamage;
                dmgTrue     += passiveDamage.TrueDamage;

                dmgPhysical *= passiveDamage.PhysicalDamagePercent;
                dmgMagical  *= passiveDamage.MagicalDamagePercent;
                dmgTrue     *= passiveDamage.TrueDamagePercent;

                if (target is Obj_AI_Minion)
                {
                    if (hero.HasItem(ItemId.DoransShield))
                    {
                        dmgPhysical += 5;
                    }

                    if (!hero.IsMelee &&
                        target.Team == GameObjectTeam.Neutral &&
                        Regex.IsMatch(target.Name, "SRU_RiftHerald"))
                    {
                        dmgReduce *= 0.65;
                    }
                }
            }

            if (targetHero != null)
            {
                if (!(source is Obj_AI_Turret) &&
                    targetHero.HasItem(ItemId.NinjaTabi))
                {
                    dmgReduce *= 0.9;
                }

                /*
                 * if (hero != null &&
                 *  hero.IsUsingMastery(hero.GetFerocityPage(MasteryId.Ferocity.FreshBlood)) &&
                 *  !hero.HasBuff("Mastery6121"))
                 * {
                 *  dmgPhysical += 10 + hero.Level;
                 * }
                 */

                switch (targetHero.ChampionName)
                {
                case "Fizz":
                    dmgPhysical -= 4 + 2 * Math.Floor((targetHero.Level - 1) / 3d);
                    break;
                }
            }

            var itemDamage = DamageItems.ComputeItemDamages(source, target);

            dmgPhysical += itemDamage.PhysicalDamage;
            dmgMagical  += itemDamage.MagicalDamage;

            dmgPhysical = source.CalculatePhysicalDamage(target, dmgPhysical);
            dmgMagical  = source.CalculateMagicDamage(target, dmgMagical);

            dmgPhysical += source.GetPassiveFlatMod(target);

            switch (targetHero?.ChampionName)
            {
            case "Amumu":
                if (targetHero.HasBuff("Tantrum"))
                {
                    dmgPhysical -= new[] { 2, 4, 6, 8, 10 }[targetHero.SpellBook.GetSpell(SpellSlot.E).Level - 1];
                }
                break;
            }

            return(Math.Max(Math.Floor(dmgPhysical + dmgMagical) * dmgReduce + dmgTrue, 0));
        }
Beispiel #4
0
        /// <summary>
        ///     Gets the source auto attack damage on the target.
        /// </summary>
        /// <param name="source">
        ///     The source
        /// </param>
        /// <param name="target">
        ///     The target
        /// </param>
        /// <param name="includePassive">
        ///     Indicates whether to include passive effects.
        /// </param>
        /// <returns>
        ///     The estimated auto attack damage.
        /// </returns>
        public static double GetAutoAttackDamage(
            this Obj_AI_Base source,
            Obj_AI_Base target,
            bool includePassive = false)
        {
            double result         = source.TotalAttackDamage;
            var    damageModifier = 1d;
            var    reduction      = 0d;
            var    passive        = 0d;

            if (includePassive)
            {
                var hero         = source as Obj_AI_Hero;
                var targetHero   = target as Obj_AI_Hero;
                var targetMinion = target as Obj_AI_Minion;

                if (hero != null)
                {
                    // Spoils of War
                    if (hero.IsMelee() && targetMinion != null && targetMinion.IsEnemy &&
                        targetMinion.Team != GameObjectTeam.Neutral && hero.GetBuffCount("talentreaperdisplay") > 0)
                    {
                        if (
                            GameObjects.AllyHeroes.Any(
                                h => h.NetworkId != source.NetworkId && h.Distance(targetMinion.Position) < 1100))
                        {
                            var value = 200; // Relic Shield - 3302

                            if (!Items.HasItem(3302, hero))
                            {
                                // 240 = Tragon's Brace (3097)
                                // 400 = Face of the Mountain (3401)
                                value = Items.HasItem(3097, hero) ? 240 : 400;
                            }

                            return(value + hero.TotalAttackDamage);
                        }
                    }

                    // BotRK
                    if (Items.HasItem(3153, hero))
                    {
                        var d = 0.08 * target.Health;
                        result += targetMinion != null?Math.Min(d, 60) : d;
                    }

                    // Arcane blade
                    if (hero.Masteries.Any(m => m.Page == MasteryPage.Offense && m.Id == 132 && m.Points == 1))
                    {
                        reduction -= CalculateMagicDamage(hero, target, 0.05 * hero.FlatMagicDamageMod);
                    }
                }

                if (targetHero != null)
                {
                    // Ninja tabi
                    if (Items.HasItem(3047, targetHero))
                    {
                        damageModifier *= 0.9d;
                    }

                    // Nimble Fighter
                    if (targetHero.ChampionName == "Fizz")
                    {
                        reduction += 4 + ((targetHero.Level - (1 / 3)) * 2);
                    }

                    // Block
                    // + Reduces incoming damage from champion basic attacks by 1 / 2
                    if (hero != null)
                    {
                        var mastery =
                            targetHero.Masteries.FirstOrDefault(m => m.Page == MasteryPage.Defense && m.Id == 68);
                        if (mastery != null && mastery.Points >= 1)
                        {
                            reduction += 1 * mastery.Points;
                        }
                    }
                }

                // Bonus Damage (Passive)
                if (hero != null)
                {
                    var passiveInfo = hero.GetPassiveDamageInfo(target);
                    if (passiveInfo.Override)
                    {
                        return(source.CalculatePhysicalDamage(target, -reduction * damageModifier) + passiveInfo.Value);
                    }

                    passive += passiveInfo.Value;
                }
            }

            // This formula is right, work out the math yourself if you don't believe me
            return(source.CalculatePhysicalDamage(target, (result - reduction) * damageModifier) + passive);
        }