Ejemplo n.º 1
0
        /// <summary>
        ///     Amplifies the basic attack.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        /// <returns>System.Double.</returns>
        internal static double AmplifyAuto(this Obj_AI_Base source, Obj_AI_Base target)
        {
            double dmg = 0;

            var aiHero = source as Obj_AI_Hero;

            if (aiHero != null)
            {
                if (source.HasBuff("sheen"))
                {
                    dmg +=
                        source.CalculateDamage(target, DamageType.Physical,
                                               1.0 * source.FlatPhysicalDamageMod + source.BaseAttackDamage);
                }

                if (source.HasBuff("lichbane"))
                {
                    dmg +=
                        source.CalculateDamage(target, DamageType.Magical,
                                               (0.75 * source.FlatPhysicalDamageMod + source.BaseAttackDamage) +
                                               (0.50 * source.FlatMagicDamageMod));
                }

                if (source.HasBuff("itemdisknighstalkerdamageproc"))
                {
                    dmg += source.CalculateDamage(target, DamageType.Physical, 50 + (15 * source.Level));
                }

                if (source.HasBuff("itemstatikshankcharge") && source.GetBuff("itemstatikshankcharge").Count == 100)
                {
                    return((int)source.CalculateDamage(target, DamageType.Physical,
                                                       new[] { 62, 120, 200, 200 }[Math.Min(18, source.Level) / 6]));
                }

                foreach (var data in ZLib.CachedSpells.Where(x => x.ChampionName.ToLower() == aiHero.ChampionName.ToLower()))
                {
                    if (aiHero.HasBuff(data.SpellName.ToLower()))
                    {
                        if (data.BasicAttackAmplifier)
                        {
                            dmg += aiHero.GetSpellDamage(target, data.Slot);
                        }
                    }
                    else if (aiHero.Buffs.Any(x => x.IsActive && x.IsValid && x.Name.ToLower().Contains(data.SpellName.ToLower())))
                    {
                        if (data.BasicAttackAmplifier)
                        {
                            dmg += aiHero.GetSpellDamage(target, data.Slot);
                        }
                    }
                }

                return(dmg);
            }

            return(dmg);
        }
Ejemplo n.º 2
0
        internal static void EmulateDamage(Obj_AI_Base sender, Unit hero, Gamedata data, EventType dmgType, string notes = null,
                                           float dmgEntry = 0f, int expiry = 500)
        {
            var hpred = new HPInstance();

            hpred.EventType = dmgType;
            hpred.Target    = hero.Instance;
            hpred.GameData  = data;
            hpred.Name      = string.Empty;

            if (sender != null)
            {
                hpred.Attacker = sender;
            }

            if (!string.IsNullOrEmpty(data?.SpellName))
            {
                hpred.Name = data.SpellName;
            }

            if (dmgEntry < 1f && sender != null)
            {
                switch (dmgType)
                {
                case EventType.AutoAttack:
                    hpred.PredictedDmg = (float)Math.Max(sender.GetAutoAttackDamage(hero.Instance), 0);
                    break;

                case EventType.MinionAttack:
                case EventType.TurretAttack:
                    hpred.PredictedDmg =
                        (float)
                        Math.Max(sender.CalculateDamage(hero.Instance, DamageType.Physical,
                                                        sender.BaseAttackDamage + sender.FlatPhysicalDamageMod), 0);
                    break;

                default:
                    var aiHero = sender as Obj_AI_Hero;
                    if (aiHero != null)
                    {
                        if (!string.IsNullOrEmpty(data?.SpellName))
                        {
                            hpred.PredictedDmg = (float)Math.Max(aiHero.GetSpellDamage(hero.Instance, data.Slot), 0);
                        }
                    }

                    break;
                }
            }

            else
            {
                var idmg = dmgEntry;
                hpred.PredictedDmg = (float)Math.Round(idmg);
            }

            if (hpred.PredictedDmg > 0)
            {
                var idmg = hpred.PredictedDmg * ZLib.Menu["weightdmg"].As <MenuSlider>().Value / 100;
                hpred.PredictedDmg = (float)Math.Round(idmg);
            }

            else
            {
                var idmg = (hero.Instance.Health / hero.Instance.MaxHealth) * 5;
                hpred.PredictedDmg = (float)Math.Round(idmg);
            }

            if (dmgType != EventType.Buff && dmgType != EventType.Troy)
            {
                // check duplicates (missiles and process spell)
                if (ZLib.DamageCollection.Select(entry => entry.Value).Any(o => data != null && o.Name == data.SpellName))
                {
                    return;
                }
            }

            var dmg             = AddDamage(hpred, hero, notes);
            var extendedEndtime = ZLib.Menu["lagtolerance"].As <MenuSlider>().Value * 10;

            DelayAction.Queue(expiry + extendedEndtime, () => RemoveDamage(dmg, notes));
        }