Esempio n. 1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="SpellDamage" /> class.
        /// </summary>
        /// <param name="sdata">
        ///     The spell damage data.
        /// </param>
        internal SpellDamage(SpellDamageData sdata)
        {
            this.SData = sdata;
            this.GetDamageFunc = (@base, aiBase) =>
                {
                    if (@base.Spellbook.GetSpell(sdata.Slot).Level == 0)
                    {
                        return 0d;
                    }

                    var spellLevel = @base.Spellbook.GetSpell(sdata.Slot).Level - 1;
                    var damage = 0d;
                    var abilityPowerDamageAmount = 0d;
                    var attackDamageAmount = 0d;

                    if (sdata.Base != null && sdata.Base.Length > 0)
                    {
                        if (sdata.Flags.HasFlag(DamageFlags.SpecialDistance)
                            && @base.Distance(aiBase) > sdata.DistanceOffset)
                        {
                            damage += sdata.BaseDistance[Math.Min(spellLevel, sdata.BaseDistance.Length - 1)];
                        }
                        else
                        {
                            if (sdata.BaseMinion != null && sdata.BaseMinion.Length > 0 && aiBase is Obj_AI_Minion)
                            {
                                damage += sdata.BaseMinion[Math.Min(spellLevel, sdata.BaseMinion.Length - 1)];
                            }
                            else
                            {
                                SpellSlot spellSlot;
                                int intValue;
                                if (sdata.Flags.HasFlag(DamageFlags.SpecialPassiveAlternative)
                                    && ((sdata.AlternativePassive.Length == 1
                                         && @base.HasBuff(sdata.AlternativePassive[0]))
                                        || (sdata.AlternativePassive.Length == 2
                                            && Enum.TryParse(sdata.AlternativePassive[0], out spellSlot)
                                            && int.TryParse(sdata.AlternativePassive[1], out intValue)
                                            && @base.Spellbook.GetSpell(spellSlot).ToggleState == intValue))
                                    && sdata.BaseAlternative != null && sdata.BaseAlternative.Length > 0)
                                {
                                    damage +=
                                        sdata.BaseAlternative[Math.Min(spellLevel, sdata.BaseAlternative.Length - 1)];
                                }
                                else
                                {
                                    damage += sdata.Base[Math.Min(spellLevel, sdata.Base.Length - 1)];
                                }
                            }
                        }
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.AbilityPower))
                    {
                        var value = @base.TotalMagicalDamage * sdata.AbilityPower
                                    + @base.TotalMagicalDamage * sdata.AbilityPowerMinion;
                        damage += value;
                        abilityPowerDamageAmount += value;
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.AttackDamage))
                    {
                        var value = @base.TotalAttackDamage * sdata.AttackDamage;
                        damage += value;
                        attackDamageAmount += value;
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.BonusAttackDamage))
                    {
                        var value = (sdata.Flags.HasFlag(DamageFlags.SpecialDistance)
                                     && @base.Distance(aiBase) > sdata.DistanceOffset)
                                        ? @base.FlatPhysicalDamageMod * sdata.DistanceBonusAttackDamage
                                        : @base.FlatPhysicalDamageMod * sdata.BonusAttackDamage;
                        damage += value;
                        attackDamageAmount += value;
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.EnemyMaxHealth) && sdata.EnemyMaxHealthBase != null
                        && sdata.EnemyMaxHealthBase.Length > 0)
                    {
                        damage += aiBase.MaxHealth
                                  * sdata.EnemyMaxHealthBase[Math.Min(spellLevel, sdata.EnemyMaxHealthBase.Length - 1)];
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.AbilityPowerEnemyMaxHealth))
                    {
                        damage += @base.TotalMagicalDamage * sdata.AbilityPowerEnemyMaxHealth;
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.BaseAttackDamagePercent)
                        && sdata.BaseAttackDamagePercent != null && sdata.BaseAttackDamagePercent.Length > 0)
                    {
                        damage += @base.TotalAttackDamage
                                  * sdata.BaseAttackDamagePercent[
                                      Math.Min(spellLevel, sdata.BaseAttackDamagePercent.Length - 1)];
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.BaseAbilityPowerPercent)
                        && sdata.BaseAbilityPowerPercent != null && sdata.BaseAbilityPowerPercent.Length > 0)
                    {
                        damage += @base.TotalAttackDamage
                                  * sdata.BaseAbilityPowerPercent[
                                      Math.Min(spellLevel, sdata.BaseAbilityPowerPercent.Length - 1)];
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.BaseBonusAttackDamagePercent)
                        && sdata.BaseAttackDamagePercent != null && sdata.BaseAttackDamagePercent.Length > 0)
                    {
                        damage += @base.TotalAttackDamage
                                  * sdata.BaseBonusAttackDamagePercent[
                                      Math.Min(spellLevel, sdata.BaseBonusAttackDamagePercent.Length - 1)];
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.BaseChampionLevel) && sdata.BaseChampionLevel != null
                        && sdata.BaseChampionLevel.Length > 0)
                    {
                        damage += sdata.BaseChampionLevel[Math.Min(@base.Level, sdata.BaseChampionLevel.Length - 1)];
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.MaxHealth))
                    {
                        damage += @base.MaxHealth * sdata.MaxHealth;
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.TargetHealth))
                    {
                        SpellSlot spellSlot;
                        int intValue;
                        var flag = !sdata.Flags.HasFlag(DamageFlags.SpecialPassiveAlternative)
                                   || !((sdata.AlternativePassive.Length == 1
                                         && @base.HasBuff(sdata.AlternativePassive[0]))
                                        || (sdata.AlternativePassive.Length == 2
                                            && Enum.TryParse(sdata.AlternativePassive[0], out spellSlot)
                                            && int.TryParse(sdata.AlternativePassive[1], out intValue)
                                            && @base.Spellbook.GetSpell(spellSlot).ToggleState == intValue));

                        var baseTargetHealth = flag ? sdata.BaseTargetHealth : sdata.BaseAlternativeTargetHealth;
                        var targetHealthBaseAbilityPowerScale = flag
                                                                    ? sdata.TargetHealthBaseAbilityPowerScale
                                                                    : sdata.AlternativeTargetHealthBaseAbilityPowerScale;
                        var targetHealthBaseMinimumDamage = flag
                                                                ? sdata.TargetHealthBaseMinimumDamage
                                                                : sdata.AlternativeTargetHealthBaseMinimumDamage;
                        var minionHealthBaseMaximumDamage = flag
                                                                ? sdata.MinionHealthBaseMaximumDamage
                                                                : sdata.AlternativeMinionHealthBaseMaximumDamage;

                        var flagDamage = 0f;

                        if (baseTargetHealth != null && baseTargetHealth.Length > 0)
                        {
                            flagDamage += aiBase.Health
                                          * baseTargetHealth[Math.Min(spellLevel, baseTargetHealth.Length - 1)];
                        }

                        if (targetHealthBaseAbilityPowerScale != null && targetHealthBaseAbilityPowerScale.Length > 0)
                        {
                            float value;
                            switch (targetHealthBaseAbilityPowerScale.Length)
                            {
                                case 1:
                                    value = aiBase.Health * targetHealthBaseAbilityPowerScale[0];
                                    flagDamage += value;
                                    abilityPowerDamageAmount += value;
                                    break;
                                case 2:
                                    if (@base.TotalMagicalDamage / targetHealthBaseAbilityPowerScale[1] >= 1f)
                                    {
                                        value = aiBase.Health
                                                * ((@base.TotalMagicalDamage / targetHealthBaseAbilityPowerScale[1])
                                                   * targetHealthBaseAbilityPowerScale[0]);
                                        flagDamage += value;
                                        abilityPowerDamageAmount += value;
                                    }

                                    break;
                            }
                        }

                        if (targetHealthBaseMinimumDamage != null && targetHealthBaseMinimumDamage.Length > 0)
                        {
                            flagDamage =
                                Math.Max(
                                    targetHealthBaseMinimumDamage[
                                        Math.Min(spellLevel, targetHealthBaseMinimumDamage.Length - 1)], 
                                    flagDamage);
                        }

                        if (minionHealthBaseMaximumDamage != null && minionHealthBaseMaximumDamage.Length > 0
                            && aiBase is Obj_AI_Minion)
                        {
                            flagDamage =
                                Math.Min(
                                    minionHealthBaseMaximumDamage[
                                        Math.Min(spellLevel, minionHealthBaseMaximumDamage.Length - 1)], 
                                    flagDamage);
                        }

                        damage += flagDamage;

                        flagDamage = 0f;
                        var baseTargetMissingHealth = flag
                                                          ? sdata.BaseTargetMissingHealth
                                                          : sdata.BaseAlternativeTargetMissingHealth;
                        var targetMissingHealthBaseAbilityPowerScale = flag
                                                                           ? sdata
                                                                                 .TargetMissingHealthBaseAbilityPowerScale
                                                                           : sdata
                                                                                 .AlternativeTargetMissingHealthBaseAbilityPowerScale;
                        var targetMissingHealthBaseMinimumDamage = flag
                                                                       ? sdata.TargetMissingHealthBaseMinimumDamage
                                                                       : sdata
                                                                             .AlternativeTargetMissingHealthBaseMinimumDamage;
                        var minionMissingHealthBaseMaximumDamage = flag
                                                                       ? sdata.MinionMissingHealthBaseMaximumDamage
                                                                       : sdata
                                                                             .AlternativeMinionMissingHealthBaseMaximumDamage;
                        var missingHealth = aiBase.MaxHealth - aiBase.Health;

                        if (baseTargetMissingHealth != null && baseTargetMissingHealth.Length > 0)
                        {
                            flagDamage += missingHealth
                                          * baseTargetMissingHealth[
                                              Math.Min(spellLevel, baseTargetMissingHealth.Length - 1)];
                        }

                        if (targetMissingHealthBaseAbilityPowerScale != null
                            && targetMissingHealthBaseAbilityPowerScale.Length > 0)
                        {
                            float value;
                            switch (targetMissingHealthBaseAbilityPowerScale.Length)
                            {
                                case 1:
                                    value = missingHealth * targetMissingHealthBaseAbilityPowerScale[0];
                                    flagDamage += value;
                                    abilityPowerDamageAmount += value;
                                    break;
                                case 2:
                                    if (@base.TotalMagicalDamage / targetMissingHealthBaseAbilityPowerScale[1] >= 1f)
                                    {
                                        value = missingHealth
                                                * ((@base.TotalMagicalDamage
                                                    / targetMissingHealthBaseAbilityPowerScale[1])
                                                   * targetMissingHealthBaseAbilityPowerScale[0]);
                                        flagDamage += value;
                                        abilityPowerDamageAmount += value;
                                    }

                                    break;
                            }
                        }

                        if (targetMissingHealthBaseMinimumDamage != null
                            && targetMissingHealthBaseMinimumDamage.Length > 0)
                        {
                            flagDamage =
                                Math.Max(
                                    targetMissingHealthBaseMinimumDamage[
                                        Math.Min(spellLevel, targetMissingHealthBaseMinimumDamage.Length - 1)], 
                                    flagDamage);
                        }

                        if (minionMissingHealthBaseMaximumDamage != null
                            && minionMissingHealthBaseMaximumDamage.Length > 0 && aiBase is Obj_AI_Minion)
                        {
                            flagDamage =
                                Math.Min(
                                    minionMissingHealthBaseMaximumDamage[
                                        Math.Min(spellLevel, minionMissingHealthBaseMaximumDamage.Length - 1)], 
                                    flagDamage);
                        }

                        damage += flagDamage;
                    }

                    damage = Math.Round(damage);
                    attackDamageAmount = Math.Round(attackDamageAmount);
                    abilityPowerDamageAmount = Math.Round(abilityPowerDamageAmount);

                    return sdata.Type == DamageType.Mixed
                               ? @base.CalculateMixedDamage(aiBase, attackDamageAmount, abilityPowerDamageAmount)
                               : @base.CalculateDamage(aiBase, sdata.Type, damage);
                };
        }
Esempio n. 2
0
        internal SpellDamage(SpellDamageData sdata)
        {
            this.SData = sdata;
            this.GetDamageFunc = (@base, aiBase) =>
                {
                    if (@base.Spellbook.GetSpell(sdata.Slot).Level == 0)
                    {
                        return 0d;
                    }

                    var spellLevel = sdata.Flags.HasFlag(DamageFlags.LevelScale)
                                         ? @base.Spellbook.GetSpell(sdata.LevelScale).Level - 1
                                         : @base.Spellbook.GetSpell(sdata.Slot).Level - 1;

                    var damage = 0d;
                    var abilityPowerDamageAmount = 0d;
                    var attackDamageAmount = 0d;

                    SpellSlot spellSlot;
                    int intValue;
                    var alternativePassive = sdata.Flags.HasFlag(DamageFlags.SpecialPassiveAlternative)
                                             && ((sdata.AlternativePassive.Length == 1
                                                  && @base.HasBuff(sdata.AlternativePassive[0]))
                                                 || (sdata.AlternativePassive.Length == 2
                                                     && Enum.TryParse(sdata.AlternativePassive[0], out spellSlot)
                                                     && int.TryParse(sdata.AlternativePassive[1], out intValue)
                                                     && @base.Spellbook.GetSpell(spellSlot).ToggleState == intValue));

                    if (sdata.Base != null && sdata.Base.Length > 0)
                    {
                        if (sdata.Flags.HasFlag(DamageFlags.SpecialDistance)
                            && @base.Distance(aiBase) > sdata.DistanceOffset)
                        {
                            damage += sdata.BaseDistance[Math.Min(spellLevel, sdata.BaseDistance.Length - 1)];
                        }
                        else
                        {
                            if (sdata.BaseMinion != null && sdata.BaseMinion.Length > 0 && aiBase is Obj_AI_Minion)
                            {
                                damage += sdata.BaseMinion[Math.Min(spellLevel, sdata.BaseMinion.Length - 1)];
                            }
                            else
                            {
                                if (alternativePassive)
                                {
                                    damage +=
                                        sdata.BaseAlternative[Math.Min(spellLevel, sdata.BaseAlternative.Length - 1)];
                                }
                                else
                                {
                                    damage += sdata.Base[Math.Min(spellLevel, sdata.Base.Length - 1)];
                                }
                            }
                        }
                    }

                    if (sdata.TargetBase != null && sdata.TargetBase.Length > 0 && aiBase is Obj_AI_Hero)
                    {
                        damage += sdata.TargetBase[Math.Min(spellLevel, sdata.TargetBase.Length - 1)];
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.AbilityPower))
                    {
                        var value = @base.TotalMagicalDamage
                                    * (aiBase is Obj_AI_Minion && sdata.AbilityPowerMinion > float.Epsilon
                                           ? sdata.AbilityPowerMinion
                                           : sdata.AbilityPower);

                        if (alternativePassive)
                        {
                            value = @base.TotalMagicalDamage * sdata.AlternativeAbilityPower;
                        }

                        damage += value;
                        abilityPowerDamageAmount += value;
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.AttackDamage))
                    {
                        var value = @base.TotalAttackDamage
                                    * (aiBase is Obj_AI_Minion && sdata.AttackDamageMinion > float.Epsilon
                                           ? sdata.AttackDamageMinion
                                           : sdata.AttackDamage);

                        if (alternativePassive)
                        {
                            value = @base.TotalAttackDamage * sdata.AlternativeAttackDamage;
                        }

                        damage += value;
                        attackDamageAmount += value;
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.BonusAttackDamage))
                    {
                        var value = (sdata.Flags.HasFlag(DamageFlags.SpecialDistance)
                                     && @base.Distance(aiBase) > sdata.DistanceOffset)
                                        ? @base.FlatPhysicalDamageMod * sdata.DistanceBonusAttackDamage
                                        : @base.FlatPhysicalDamageMod * sdata.BonusAttackDamage;

                        if (alternativePassive)
                        {
                            value = @base.FlatPhysicalDamageMod * sdata.AlternativeBonusAttackDamage;
                        }

                        damage += value;
                        attackDamageAmount += value;
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.EnemyMaxHealth) && sdata.EnemyMaxHealthBase != null
                        && sdata.EnemyMaxHealthBase.Length > 0)
                    {
                        damage += aiBase.MaxHealth
                                  * sdata.EnemyMaxHealthBase[Math.Min(spellLevel, sdata.EnemyMaxHealthBase.Length - 1)];
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.AbilityPowerEnemyMaxHealth))
                    {
                        damage += @base.TotalMagicalDamage * sdata.AbilityPowerEnemyMaxHealth;
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.BaseAttackDamagePercent)
                        && ((sdata.BaseAttackDamagePercent != null && sdata.BaseAttackDamagePercent.Length > 0)
                            || (sdata.BaseMinionAttackDamagePercent != null
                                && sdata.BaseMinionAttackDamagePercent.Length > 0)))
                    {
                        var value = @base.TotalAttackDamage
                                    * (aiBase is Obj_AI_Minion && sdata.BaseMinionAttackDamagePercent != null
                                       && sdata.BaseMinionAttackDamagePercent.Length > 0
                                           ? sdata.BaseMinionAttackDamagePercent[
                                               Math.Min(spellLevel, sdata.BaseMinionAttackDamagePercent.Length - 1)]
                                           : sdata.BaseAttackDamagePercent[
                                               Math.Min(spellLevel, sdata.BaseAttackDamagePercent.Length - 1)]);
                        damage += value;
                        attackDamageAmount += value;
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.BaseAbilityPowerPercent)
                        && sdata.BaseAbilityPowerPercent != null && sdata.BaseAbilityPowerPercent.Length > 0)
                    {
                        var value = @base.TotalMagicalDamage
                                    * sdata.BaseAbilityPowerPercent[
                                        Math.Min(spellLevel, sdata.BaseAbilityPowerPercent.Length - 1)];
                        damage += value;
                        abilityPowerDamageAmount += value;
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.BaseBonusAttackDamagePercent)
                        && sdata.BaseBonusAttackDamagePercent != null && sdata.BaseBonusAttackDamagePercent.Length > 0)
                    {
                        var value = @base.TotalAttackDamage
                                    * sdata.BaseBonusAttackDamagePercent[
                                        Math.Min(spellLevel, sdata.BaseBonusAttackDamagePercent.Length - 1)];
                        damage += value;
                        attackDamageAmount += value;
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.BaseChampionLevel) && sdata.BaseChampionLevel != null
                        && sdata.BaseChampionLevel.Length > 0)
                    {
                        damage += sdata.BaseChampionLevel[Math.Min(@base.Level, sdata.BaseChampionLevel.Length - 1)];
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.MaxHealth))
                    {
                        damage += @base.MaxHealth * sdata.MaxHealth;
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.TargetHealth))
                    {
                        var baseTargetHealth = alternativePassive
                                                   ? sdata.BaseTargetHealth
                                                   : sdata.BaseAlternativeTargetHealth;
                        var targetHealthBaseAbilityPowerScale = alternativePassive
                                                                    ? sdata.TargetHealthBaseAbilityPowerScale
                                                                    : sdata.AlternativeTargetHealthBaseAbilityPowerScale;
                        var targetHealthBaseMinimumDamage = alternativePassive
                                                                ? sdata.TargetHealthBaseMinimumDamage
                                                                : sdata.AlternativeTargetHealthBaseMinimumDamage;
                        var minionHealthBaseMaximumDamage = alternativePassive
                                                                ? sdata.MinionHealthBaseMaximumDamage
                                                                : sdata.AlternativeMinionHealthBaseMaximumDamage;

                        var flagDamage = 0f;

                        if (baseTargetHealth != null && baseTargetHealth.Length > 0)
                        {
                            flagDamage += aiBase.Health
                                          * baseTargetHealth[Math.Min(spellLevel, baseTargetHealth.Length - 1)];
                        }

                        if (targetHealthBaseAbilityPowerScale != null && targetHealthBaseAbilityPowerScale.Length > 0)
                        {
                            float value;
                            switch (targetHealthBaseAbilityPowerScale.Length)
                            {
                                case 1:
                                    value = aiBase.Health * targetHealthBaseAbilityPowerScale[0];
                                    flagDamage += value;
                                    abilityPowerDamageAmount += value;
                                    break;
                                case 2:
                                    if (@base.TotalMagicalDamage / targetHealthBaseAbilityPowerScale[1] >= 1f)
                                    {
                                        value = aiBase.Health
                                                * ((@base.TotalMagicalDamage / targetHealthBaseAbilityPowerScale[1])
                                                   * targetHealthBaseAbilityPowerScale[0]);
                                        flagDamage += value;
                                        abilityPowerDamageAmount += value;
                                    }

                                    break;
                            }
                        }

                        if (targetHealthBaseMinimumDamage != null && targetHealthBaseMinimumDamage.Length > 0)
                        {
                            flagDamage =
                                Math.Max(
                                    targetHealthBaseMinimumDamage[
                                        Math.Min(spellLevel, targetHealthBaseMinimumDamage.Length - 1)], 
                                    flagDamage);
                        }

                        if (minionHealthBaseMaximumDamage != null && minionHealthBaseMaximumDamage.Length > 0
                            && aiBase is Obj_AI_Minion)
                        {
                            flagDamage =
                                Math.Min(
                                    minionHealthBaseMaximumDamage[
                                        Math.Min(spellLevel, minionHealthBaseMaximumDamage.Length - 1)], 
                                    flagDamage);
                        }

                        damage += flagDamage;

                        flagDamage = 0f;
                        var baseTargetMissingHealth = alternativePassive
                                                          ? sdata.BaseTargetMissingHealth
                                                          : sdata.BaseAlternativeTargetMissingHealth;
                        var targetMissingHealthBaseAbilityPowerScale = alternativePassive
                                                                           ? sdata
                                                                                 .TargetMissingHealthBaseAbilityPowerScale
                                                                           : sdata
                                                                                 .AlternativeTargetMissingHealthBaseAbilityPowerScale;
                        var targetMissingHealthBaseMinimumDamage = alternativePassive
                                                                       ? sdata.TargetMissingHealthBaseMinimumDamage
                                                                       : sdata
                                                                             .AlternativeTargetMissingHealthBaseMinimumDamage;
                        var minionMissingHealthBaseMaximumDamage = alternativePassive
                                                                       ? sdata.MinionMissingHealthBaseMaximumDamage
                                                                       : sdata
                                                                             .AlternativeMinionMissingHealthBaseMaximumDamage;
                        var missingHealth = aiBase.MaxHealth - aiBase.Health;

                        if (baseTargetMissingHealth != null && baseTargetMissingHealth.Length > 0)
                        {
                            flagDamage += missingHealth
                                          * baseTargetMissingHealth[
                                              Math.Min(spellLevel, baseTargetMissingHealth.Length - 1)];
                        }

                        if (targetMissingHealthBaseAbilityPowerScale != null
                            && targetMissingHealthBaseAbilityPowerScale.Length > 0)
                        {
                            float value;
                            switch (targetMissingHealthBaseAbilityPowerScale.Length)
                            {
                                case 1:
                                    value = missingHealth * targetMissingHealthBaseAbilityPowerScale[0];
                                    flagDamage += value;
                                    abilityPowerDamageAmount += value;
                                    break;
                                case 2:
                                    if (@base.TotalMagicalDamage / targetMissingHealthBaseAbilityPowerScale[1] >= 1f)
                                    {
                                        value = missingHealth
                                                * ((@base.TotalMagicalDamage
                                                    / targetMissingHealthBaseAbilityPowerScale[1])
                                                   * targetMissingHealthBaseAbilityPowerScale[0]);
                                        flagDamage += value;
                                        abilityPowerDamageAmount += value;
                                    }

                                    break;
                            }
                        }

                        if (targetMissingHealthBaseMinimumDamage != null
                            && targetMissingHealthBaseMinimumDamage.Length > 0)
                        {
                            flagDamage =
                                Math.Max(
                                    targetMissingHealthBaseMinimumDamage[
                                        Math.Min(spellLevel, targetMissingHealthBaseMinimumDamage.Length - 1)], 
                                    flagDamage);
                        }

                        if (minionMissingHealthBaseMaximumDamage != null
                            && minionMissingHealthBaseMaximumDamage.Length > 0 && aiBase is Obj_AI_Minion)
                        {
                            flagDamage =
                                Math.Min(
                                    minionMissingHealthBaseMaximumDamage[
                                        Math.Min(spellLevel, minionMissingHealthBaseMaximumDamage.Length - 1)], 
                                    flagDamage);
                        }

                        damage += flagDamage;
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.SpecialTargetPassive))
                    {
                        if (sdata.TargetPassiveIdentifier != null && sdata.TargetPassiveIdentifier.Length > 0)
                        {
                            var passiveName = sdata.TargetPassiveIdentifier[0];
                            int rawTempValue;
                            var passiveCountPrefix = sdata.TargetPassiveIdentifier.Length > 1
                                                     && int.TryParse(sdata.TargetPassiveIdentifier[1], out rawTempValue)
                                                         ? rawTempValue
                                                         : 0;

                            var enemyPassiveCount = aiBase.GetBuffCount(passiveName) - passiveCountPrefix;
                            if (enemyPassiveCount > 0)
                            {
                                if (sdata.BaseTargetPassive != null && sdata.BaseTargetPassive.Length > 0)
                                {
                                    damage += enemyPassiveCount
                                              * sdata.BaseTargetPassive[
                                                  Math.Min(spellLevel, sdata.BaseTargetPassive.Length - 1)];
                                }

                                if (sdata.BaseTargetPassiveAttackDamage != null
                                    && sdata.BaseTargetPassiveAttackDamage.Length > 0)
                                {
                                    damage += enemyPassiveCount
                                              * sdata.BaseTargetPassiveAttackDamage[
                                                  Math.Min(spellLevel, sdata.BaseTargetPassiveAttackDamage.Length - 1)]
                                              * @base.TotalAttackDamage;
                                }
                            }
                        }
                    }

                    var trueDamage = 0d;
                    if (alternativePassive)
                    {
                        trueDamage += damage * sdata.AlternativeTrueDamage;
                    }

                    var forceIgnoreArmor = -sdata.TargetArmorIgnore;

                    return (sdata.Type == DamageType.Mixed
                                ? @base.CalculateMixedDamage(aiBase, attackDamageAmount, abilityPowerDamageAmount)
                                : @base.CalculateDamage(aiBase, sdata.Type, damage, forceIgnoreArmor)) + trueDamage;
                };
        }
Esempio n. 3
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="SpellDamage" /> class.
        /// </summary>
        /// <param name="sdata">
        ///     The spell damage data.
        /// </param>
        internal SpellDamage(SpellDamageData sdata)
        {
            this.SData = sdata;
            this.GetDamageFunc = (@base, aiBase) =>
                {
                    var spellLevel = @base.Spellbook.GetSpell(sdata.Slot).Level - 1;
                    var damage = 0d;

                    if (spellLevel >= 0 && sdata.Base.Length > 0)
                    {
                        damage += sdata.Base[Math.Min(spellLevel, sdata.Base.Length - 1)];
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.AbilityPower))
                    {
                        damage += @base.TotalMagicalDamage * sdata.AbilityPower;
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.AttackDamage))
                    {
                        damage += @base.TotalAttackDamage * sdata.AttackDamage;
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.BonusAttackDamage))
                    {
                        damage += @base.FlatPhysicalDamageMod * sdata.BonusAttackDamage;
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.EnemyMaxHealth))
                    {
                        damage += aiBase.MaxHealth
                                  * sdata.EnemyMaxHealthBase[Math.Min(spellLevel, sdata.EnemyMaxHealthBase.Length - 1)];
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.AbilityPowerEnemyMaxHealth))
                    {
                        damage += @base.TotalMagicalDamage * sdata.AbilityPowerEnemyMaxHealth;
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.BaseAttackDamagePercent))
                    {
                        damage += @base.TotalAttackDamage
                                  * sdata.BaseAttackDamagePercent[
                                      Math.Min(spellLevel, sdata.BaseAttackDamagePercent.Length - 1)];
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.BaseChampionLevel))
                    {
                        damage += sdata.BaseChampionLevel[Math.Min(@base.Level, sdata.BaseChampionLevel.Length - 1)];
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.MaxHealth))
                    {
                        damage += sdata.MaxHealth * @base.MaxHealth;
                    }

                    return @base.CalculateDamage(aiBase, sdata.Type, damage);
                };
        }
Esempio n. 4
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="SpellDamage" /> class.
        /// </summary>
        /// <param name="sdata">
        ///     The spell damage data.
        /// </param>
        internal SpellDamage(SpellDamageData sdata)
        {
            this.SData = sdata;
            this.GetDamageFunc = (@base, aiBase) =>
                {
                    var spellLevel = @base.Spellbook.GetSpell(sdata.Slot).Level - 1;
                    var damage = 0d;

                    if (spellLevel >= 0)
                    {
                        damage += sdata.Base[Math.Min(spellLevel, sdata.Base.Length)];
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.AbilityPower))
                    {
                        damage += @base.TotalMagicalDamage * sdata.AbilityPower;
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.AttackDamage))
                    {
                        damage += @base.TotalAttackDamage * sdata.AttackDamage;
                    }

                    if (sdata.Flags.HasFlag(DamageFlags.BonusAttackDamage))
                    {
                        damage += @base.FlatPhysicalDamageMod * sdata.BonusAttackDamage;
                    }

                    return @base.CalculateDamage(aiBase, sdata.Type, damage);
                };
        }