Example #1
0
        internal static void Obj_AI_Base_OnStealth(Obj_AI_Base sender, Obj_AI_BaseMissileClientDataEventArgs args)
        {
            #region Stealth

            var attacker = sender as Obj_AI_Hero;
            if (attacker == null || attacker.IsAlly || !attacker.IsValid)
            {
                return;
            }

            foreach (var hero in ZLib.GetUnits().Where(h => h.Instance.Distance(attacker) <= 1000))
            {
                foreach (var entry in ZLib.CachedSpells.Where(s => s.EventTypes.Contains(EventType.Stealth)))
                {
                    if (entry.SpellName.ToLower() == args.SpellData.Name.ToLower())
                    {
                        EmulateDamage(sender, hero, new Gamedata {
                            SpellName = "Stealth"
                        }, EventType.Stealth, "process.onstealth");
                        break;
                    }
                }
            }

            #endregion
        }
Example #2
0
        private static void OnBuffGain(Obj_AI_Base sender, Buff buff)
        {
            #region Buffs

            foreach (var ally in ZLib.GetUnits())
            {
                if (sender.NetworkId == ally.Instance.NetworkId)
                {
                    if (buff.Name == "rengarralertsound")
                    {
                        Projections.EmulateDamage(sender, ally, new Gamedata {
                            SpellName = "Stealth"
                        }, EventType.Stealth,
                                                  "handlers.onbuffadd");
                    }
                }
            }

            #endregion
        }
Example #3
0
 internal static void Render_OnRender()
 {
     if (ZLib.Menu["acdebug"].As <MenuBool>().Enabled)
     {
         foreach (var hero in ZLib.GetUnits())
         {
             Vector2 mpos;
             if (Render.WorldToScreen(hero.Instance.Position, out mpos))
             {
                 if (!hero.Instance.IsDead)
                 {
                     Render.Text(mpos.X - 40, mpos.Y - 15, Color.Wheat, "Ability Damage: " + hero.AbilityDamage);
                     Render.Text(mpos.X - 40, mpos.Y + 0, Color.Wheat, "Tower Damage: " + hero.TowerDamage);
                     Render.Text(mpos.X - 40, mpos.Y + 15, Color.Wheat, "Buff Damage: " + hero.BuffDamage);
                     Render.Text(mpos.X - 40, mpos.Y + 30, Color.Wheat, "Troy Damage: " + hero.TroyDamage);
                     Render.Text(mpos.X - 40, mpos.Y + 45, Color.Wheat, "Minion Damage: " + hero.MinionDamage);
                 }
             }
         }
     }
 }
Example #4
0
        private static void OnBuffProximity()
        {
            try
            {
                foreach (var unit in ZLib.GetUnits())
                {
                    if (unit.Instance == null || !unit.Instance.IsValidTarget(float.MaxValue, true))
                    {
                        continue;
                    }

                    var aura = ZLib.CachedAuras.Find(au => unit.Instance.HasBuff(au.Name));
                    if (aura == null)
                    {
                        continue;
                    }

                    var owner = GetBuffCaster(unit, aura.Name);
                    if (owner == null || unit.Instance.NetworkId == owner.NetworkId)
                    {
                        continue;
                    }

                    Gamedata data = null;

                    if (aura.Champion == null && aura.Slot == SpellSlot.Unknown)
                    {
                        data = new Gamedata {
                            SpellName = aura.Name
                        }
                    }
                    ;

                    if (aura.Champion != null && aura.Slot != SpellSlot.Unknown)
                    {
                        data = ZLib.CachedSpells
                               .Where(x => x.Slot == aura.Slot).FirstOrDefault(x => x.HeroNameMatch(aura.Champion));
                    }

                    if (aura.Reverse && aura.DoT)
                    {
                        if ((int)(Game.ClockTime * 1000) - aura.TickLimiter >= aura.Interval * 1000)
                        {
                            foreach (var ally in ZLib.GetUnits())
                            {
                                if (ally.Instance.Distance(unit.Instance) <= aura.Radius + 35)
                                {
                                    Projections.EmulateDamage(owner, ally, data, EventType.Buff, "aura.dot");
                                }
                            }

                            aura.TickLimiter = (int)(Game.ClockTime * 1000);
                        }
                    }

                    if (aura.Reverse && aura.Evade)
                    {
                        if ((int)(Game.ClockTime * 1000) - aura.TickLimiter >= 100)
                        {
                            foreach (var ally in ZLib.GetUnits())
                            {
                                if (ally.Instance.Distance(unit.Instance) <= aura.Radius + 35)
                                {
                                    Projections.EmulateDamage(owner, ally, data, EventType.Buff, "aura.evade");
                                }
                            }

                            aura.TickLimiter = (int)(Game.ClockTime * 1000);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (ZLib.Menu["logerror"].As <MenuBool>().Enabled)
                {
                    Console.WriteLine("== Error at: ZLib.OnBuffSurrounding");
                    Console.WriteLine(e);
                }
            }
        }
Example #5
0
        private static void OnBuffUpdate()
        {
            try
            {
                foreach (var hero in ZLib.GetUnits())
                {
                    if (hero.Instance == null || !hero.Instance.IsValidTarget(float.MaxValue, true))
                    {
                        continue;
                    }

                    var aura = ZLib.CachedAuras.Find(au => hero.Instance.HasBuff(au.Name));
                    if (aura == null)
                    {
                        continue;
                    }

                    var owner = GetBuffCaster(hero, aura.Name);
                    if (owner == null || owner.NetworkId == hero.Instance.NetworkId)
                    {
                        continue;
                    }

                    if (aura.Reverse)
                    {
                        continue;
                    }

                    var data = new Gamedata();

                    if (aura.Champion == null && aura.Slot == SpellSlot.Unknown)
                    {
                        data = new Gamedata {
                            SpellName = aura.Name
                        }
                    }
                    ;

                    if (aura.Champion != null && aura.Slot != SpellSlot.Unknown)
                    {
                        data = ZLib.CachedSpells.Where(x => x.Slot == aura.Slot)
                               .FirstOrDefault(x => x.HeroNameMatch(aura.Champion));
                    }

                    if (aura.Evade)
                    {
                        DelayAction.Queue(aura.EvadeTimer,
                                          () =>
                        {
                            // double check after delay incase we no longer have the buff
                            if (hero.Instance.HasBuff(aura.Name))
                            {
                                if ((int)(Game.ClockTime * 1000) - aura.TickLimiter >= 250)
                                {
                                    Projections.EmulateDamage(owner, hero, data, EventType.Buff, "aura.evade");
                                    aura.TickLimiter = (int)(Game.ClockTime * 1000);
                                }
                            }
                        });
                    }

                    if (aura.DoT)
                    {
                        if ((int)(Game.ClockTime * 1000) - aura.TickLimiter >= aura.Interval * 1000)
                        {
                            if (aura.Name == "velkozresearchstack" && !hero.Instance.HasBuffOfType(BuffType.Slow))
                            {
                                continue;
                            }

                            // ReSharper disable once PossibleNullReferenceException
                            Projections.EmulateDamage(owner, hero, data, EventType.Buff, "aura.dot");
                            aura.TickLimiter = (int)(Game.ClockTime * 1000);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (ZLib.Menu["logerror"].As <MenuBool>().Enabled)
                {
                    Console.WriteLine("== Error at: ZLib.OnBuffUpdate");
                    Console.WriteLine(e);
                }
            }
        }
Example #6
0
        internal static int AddDamage(HPInstance hpi, Unit hero, string notes)
        {
            Id++;
            var id = Id;

            var aiHero = ZLib.GetUnits().FirstOrDefault(x => x.Instance.NetworkId == hero.Instance.NetworkId);

            if (aiHero != null && !ZLib.DamageCollection.ContainsKey(id))
            {
                aiHero.Attacker = hpi.Attacker;

                if (aiHero.Instance.IsValid)
                {
                    switch (hpi.EventType)
                    {
                    case EventType.Spell:
                        aiHero.AbilityDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.Spell);
                        break;

                    case EventType.Buff:
                        aiHero.BuffDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.Buff);

                        if (notes == "aura.Evade")
                        {
                            aiHero.Events.Add(EventType.Ultimate);
                        }

                        break;

                    case EventType.Troy:
                        aiHero.TroyDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.Troy);

                        if (notes != "debug.Test")
                        {
                            aiHero.Events.AddRange(hpi.GameData.EventTypes);
                        }

                        break;

                    case EventType.Item:
                        aiHero.ItemDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.Spell);
                        break;

                    case EventType.TurretAttack:
                        aiHero.TowerDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.TurretAttack);
                        break;

                    case EventType.MinionAttack:
                        aiHero.MinionDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.MinionAttack);
                        break;

                    case EventType.AutoAttack:
                        aiHero.AbilityDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.AutoAttack);
                        break;

                    case EventType.Stealth:
                        aiHero.Events.Add(EventType.Stealth);
                        break;

                    case EventType.Initiator:
                        aiHero.AbilityDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.Initiator);
                        break;

                    case EventType.Danger:
                        aiHero.AbilityDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.Danger);
                        break;

                    case EventType.CrowdControl:
                        aiHero.AbilityDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.CrowdControl);
                        break;

                    case EventType.Ultimate:
                        aiHero.AbilityDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.Ultimate);
                        break;

                    case EventType.ForceExhaust:
                        aiHero.AbilityDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.ForceExhaust);
                        break;
                    }

                    if (hpi.EventType == EventType.Stealth)
                    {
                        hpi.PredictedDmg = 0;
                    }

                    var damageEventArgs = new PredictDamageEventArgs {
                        HpInstance = hpi
                    };
                    ZLib.TriggerOnPredictDamage(hero, damageEventArgs);

                    if (damageEventArgs.NoProcess)
                    {
                        Helpers.ResetIncomeDamage(aiHero);
                        ZLib.DamageCollection.Add(id, null);
                        return(id);
                    }

                    hpi.Id = id;
                    ZLib.DamageCollection.Add(id, hpi);
                }
            }

            return(id);
        }
Example #7
0
        internal static void Obj_AI_Base_OnUnitSpellCast(Obj_AI_Base sender, Obj_AI_BaseMissileClientDataEventArgs args)
        {
            var aiHero = sender as Obj_AI_Hero;

            if (aiHero != null && ZLib.Menu["dumpdata"].As <MenuBool>().Enabled)
            {
                var clientdata = new Gamedata
                {
                    SpellName    = args.SpellData.Name.ToLower(),
                    ChampionName = aiHero.UnitSkinName.ToLower(),
                    Slot         = args.SpellSlot,
                    Radius       = args.SpellData.LineWidth > 0
                        ? args.SpellData.LineWidth
                        : (args.SpellData.CastRadiusSecondary > 0
                            ? args.SpellData.CastRadiusSecondary
                            : args.SpellData.CastRadius),
                    CastRange    = args.SpellData.CastRange,
                    Delay        = 250f,
                    MissileSpeed = (int)args.SpellData.MissileSpeed
                };

                Helpers.ExportSpellData(clientdata, args.SpellData.TargettingType.ToString().ToLower());
            }

            if (Helpers.IsEpicMinion(sender) || Helpers.IsCrab(sender))
            {
                return;
            }

            try
            {
                #region Hero

                var attacker = sender as Obj_AI_Hero;
                if (attacker != null)
                {
                    foreach (var hero in ZLib.GetUnits())
                    {
                        #region auto attack

                        if (args.SpellData.Name.ToLower().Contains("attack") && args.Target != null)
                        {
                            if (args.Target.NetworkId == hero.Instance.NetworkId)
                            {
                                double dmg = 0;
                                dmg += (int)Math.Max(attacker.GetAutoAttackDamage(hero.Instance), 0);

                                if (attacker.HasBuffOfType(BuffType.CombatEnchancer))
                                {
                                    dmg += attacker.AmplifyAuto(hero.Instance);
                                }

                                if (args.SpellData.Name.ToLower().Contains("crit"))
                                {
                                    dmg = dmg * 2;
                                }

                                EmulateDamage(attacker, hero, new Gamedata {
                                    SpellName = args.SpellData.Name
                                }, EventType.AutoAttack,
                                              "enemy.autoattack", (float)dmg);
                            }
                        }

                        #endregion

                        var data = ZLib.CachedSpells.Find(x => x.SpellName.ToLower() == args.SpellData.Name.ToLower());
                        if (data == null)
                        {
                            continue;
                        }

                        #region self/selfaoe

                        if (data.CastType == CastType.Proximity)
                        {
                            if (data.Radius < 1f)
                            {
                                data.Radius = args.SpellData.CastRadiusSecondary > 0
                                    ? args.SpellData.CastRadiusSecondary
                                    : args.SpellData.CastRadius;
                            }

                            GameObject fromobj = null;

                            if (data.FromObject != null)
                            {
                                fromobj =
                                    ObjectManager.Get <GameObject>()
                                    .FirstOrDefault(
                                        x =>
                                        data.FromObject != null &&         // todo: actually get team
                                        data.FromObject.Any(y => x.Name.Contains(y)));
                            }

                            var correctpos = fromobj?.Position ?? attacker.ServerPosition;
                            if (hero.Instance.Distance(correctpos) <= data.CastRange + 125)
                            {
                                if (!data.SpellName.Equals("kalistaexpungewrapper") || hero.Instance.HasBuff("kalistaexpungemarker"))
                                {
                                    EmulateDamage(attacker, hero, data, EventType.Spell, "spell.proximity");
                                }
                            }
                        }

                        #endregion

                        #region skillshot line

                        if (data.CastType.ToString().Contains("Linear"))
                        {
                            GameObject fromobj = null;

                            if (data.FromObject != null)
                            {
                                fromobj =
                                    ObjectManager.Get <GameObject>()
                                    .FirstOrDefault(
                                        x =>
                                        data.FromObject != null &&         // todo: actually get team
                                        data.FromObject.Any(y => x.Name.Contains(y)));
                            }

                            if (args.SpellData.LineWidth > 0 && data.Radius < 1f)
                            {
                                data.Radius = args.SpellData.LineWidth;
                            }

                            var startpos = fromobj?.Position ?? attacker.ServerPosition;
                            if (hero.Instance.Distance(startpos) > data.CastRange + 35)
                            {
                                continue;
                            }

                            if ((data.SpellName == "azirq" || data.SpellName == "azire") && fromobj == null)
                            {
                                continue;
                            }

                            var distance = (int)
                                           (1000 * (startpos.Distance(hero.Instance.ServerPosition)
                                                    / data.MissileSpeed));

                            var endtime   = data.Delay + distance - Game.Ping / 2f;
                            var direction = (args.End.To2D() - startpos.To2D()).Normalized();
                            var endpos    = startpos.To2D() + direction * startpos.To2D().Distance(args.End.To2D());

                            if (startpos.To2D().Distance(endpos) > data.CastRange)
                            {
                                endpos = startpos.To2D() + direction * data.CastRange;
                            }

                            if (startpos.To2D().Distance(endpos) < data.CastRange && data.FixedRange)
                            {
                                endpos = startpos.To2D() + direction * data.CastRange;
                            }

                            if (data.IsPerpindicular)
                            {
                                startpos = (endpos - direction.Perpendicular() * data.CastRange).To3D();
                                endpos   = endpos + direction.Perpendicular() * data.CastRange;
                            }

                            var proj      = hero.Instance.ServerPosition.To2D().ProjectOn(startpos.To2D(), endpos);
                            var projdist  = hero.Instance.ServerPosition.To2D().Distance(proj.SegmentPoint);
                            var evadetime = (int)(1000 * (data.Radius - projdist + hero.Instance.BoundingRadius)
                                                  / hero.Instance.MoveSpeed);

                            if (proj.IsOnSegment && projdist <= data.Radius + hero.Instance.BoundingRadius + 35)
                            {
                                if (data.CastRange > 9000 || data.Global)
                                {
                                    if (hero.Instance.NetworkId == Player.NetworkId)
                                    {
                                        if (evadetime < endtime)
                                        {
                                            continue;
                                        }
                                    }
                                }

                                if (data.CastType == CastType.LinearAoE || data.CastType == CastType.MissileLinearAoE)
                                {
                                    if (hero.Instance.Distance(endpos) <= hero.Instance.BoundingRadius + 235)
                                    {
                                        EmulateDamage(attacker, hero, data, EventType.Spell, "spell.linear.explosion");
                                    }
                                }

                                EmulateDamage(attacker, hero, data, EventType.Spell, "spell.linear", 0f, (int)endtime);
                            }
                        }

                        #endregion

                        #region skillshot circle/cone

                        if (data.CastType == CastType.Circlular || data.CastType == CastType.Sector)
                        {
                            GameObject fromobj = null;

                            if (data.FromObject != null)
                            {
                                fromobj =
                                    ObjectManager.Get <GameObject>()
                                    .FirstOrDefault(
                                        x =>
                                        data.FromObject != null &&         // todo: actually get team
                                        data.FromObject.Any(y => x.Name.Contains(y)));
                            }

                            if (data.Radius < 1f)
                            {
                                data.Radius = args.SpellData.CastRadiusSecondary > 0
                                    ? args.SpellData.CastRadiusSecondary
                                    : args.SpellData.CastRadius;
                            }

                            var startpos = fromobj?.Position ?? attacker.ServerPosition;
                            if (hero.Instance.Distance(startpos) > data.CastRange + 35)
                            {
                                continue;
                            }

                            if ((data.SpellName == "azirq" || data.SpellName == "azire") && fromobj == null)
                            {
                                continue;
                            }

                            var distance = (int)(1000 *
                                                 (startpos.Distance(hero.Instance.ServerPosition)
                                                  / data.MissileSpeed));

                            var endtime   = data.Delay + distance - Game.Ping / 2f;
                            var direction = (args.End.To2D() - startpos.To2D()).Normalized();
                            var endpos    = startpos.To2D() + direction * startpos.To2D().Distance(args.End.To2D());

                            if (startpos.To2D().Distance(endpos) > data.CastRange)
                            {
                                endpos = startpos.To2D() + direction * data.CastRange;
                            }

                            var evadetime = (int)(1000 *
                                                  (data.Radius - hero.Instance.Distance(startpos) + hero.Instance.BoundingRadius)
                                                  / hero.Instance.MoveSpeed);

                            if (hero.Instance.Distance(endpos) <= data.Radius + hero.Instance.BoundingRadius + 35)
                            {
                                if (evadetime > endtime)
                                {
                                    EmulateDamage(attacker, hero, data, EventType.Spell, "spell.circular", 0f, (int)endtime);
                                }
                            }
                        }

                        #endregion

                        #region unit type

                        if (data.CastType == CastType.Targeted)
                        {
                            if (args.Target == null)
                            {
                                continue;
                            }

                            if (hero.Instance.NetworkId == args.Target.NetworkId)
                            {
                                if (hero.Instance.Distance(attacker.ServerPosition) <= data.CastRange + 100)
                                {
                                    var distance =
                                        (int)(1000 * (attacker.Distance(hero.Instance.ServerPosition)
                                                      / data.MissileSpeed));

                                    var endtime = data.Delay + distance - Game.Ping / 2f;
                                    EmulateDamage(attacker, hero, data, EventType.Spell, "spell.targeted", 0f, (int)endtime);
                                }
                            }
                        }

                        #endregion
                    }
                }

                #endregion
            }
            catch (Exception e)
            {
                if (ZLib.Menu["logerror"].As <MenuBool>().Enabled)
                {
                    Console.WriteLine("== Error at: ZLib.Projections.Hero");
                    Console.WriteLine(e);
                }
            }

            try
            {
                #region Turret

                var turret = sender as Obj_AI_Turret;
                if (turret != null && !turret.IsDead && args.Target != null)
                {
                    foreach (var hero in ZLib.GetUnits())
                    {
                        if (args.Target.NetworkId == hero.Instance.NetworkId)
                        {
                            if (turret.Distance(hero.Instance.ServerPosition) <= 900 &&
                                Player.Distance(hero.Instance.ServerPosition) <= 1000)
                            {
                                EmulateDamage(turret, hero, new Gamedata {
                                    SpellName = args.SpellData.Name
                                },
                                              EventType.TurretAttack, "enemy.turret");
                            }
                        }
                    }
                }

                #endregion
            }
            catch (Exception e)
            {
                if (ZLib.Menu["logerror"].As <MenuBool>().Enabled)
                {
                    Console.WriteLine("== Error at: ZLib.Projections.Turret");
                    Console.WriteLine(e);
                }
            }

            try
            {
                #region Minion

                var minion = sender as Obj_AI_Minion;
                if (minion != null && !minion.IsDead && args.Target != null)
                {
                    foreach (var hero in ZLib.GetUnits())
                    {
                        if (hero.Instance.NetworkId == args.Target.NetworkId)
                        {
                            if (hero.Instance.Distance(minion.ServerPosition) <= 750 &&
                                Player.Distance(hero.Instance.ServerPosition) <= 1000)
                            {
                                EmulateDamage(minion, hero, new Gamedata {
                                    SpellName = args.SpellData.Name
                                },
                                              EventType.MinionAttack, "enemy.minion");
                            }
                        }
                    }
                }

                #endregion
            }
            catch (Exception e)
            {
                if (ZLib.Menu["logerror"].As <MenuBool>().Enabled)
                {
                    Console.WriteLine("== Error at: ZLib.Projections.Minion");
                    Console.WriteLine(e);
                }
            }

            try
            {
                #region Gangplank Barrel

                var attacker = sender as Obj_AI_Hero;
                if (attacker != null && attacker.ChampionName.Equals("Gangplank"))
                {
                    var data = ZLib.CachedSpells.Find(x => x.SpellName.ToLower() == "gangplanke");
                    if (data != null)
                    {
                        foreach (var hero in ZLib.GetUnits())
                        {
                            var gplist = new List <Obj_AI_Minion>();

                            gplist.AddRange(ObjectManager.Get <Obj_AI_Minion>()
                                            .Where(
                                                x =>
                                                x.UnitSkinName.ToLower() == "gangplankbarrel" &&
                                                x.Position.Distance(x.Position) <= 375 && x.IsFloatingHealthBarActive)
                                            .OrderBy(y => y.Position.Distance(hero.Instance.ServerPosition)));

                            foreach (var obj in gplist)
                            {
                                if (hero.Instance.Distance(obj.Position) <= 375 && args.Target.Name == "Barrel")
                                {
                                    var dmg = (float)Math.Abs(attacker.GetAutoAttackDamage(hero.Instance) * 1.2 + 150);

                                    if (args.SpellData.Name.ToLower().Contains("crit"))
                                    {
                                        dmg = dmg * 2;
                                    }

                                    EmulateDamage(attacker, hero, data, EventType.Spell, "enemy.gankplankbarrel", dmg);
                                }
                            }
                        }
                    }
                }


                #endregion
            }
            catch (Exception e)
            {
                if (ZLib.Menu["logerror"].As <MenuBool>().Enabled)
                {
                    Console.WriteLine("== Error at: ZLib.Projections.GangplankBarrel");
                    Console.WriteLine(e);
                }
            }

            try
            {
                #region Items

                var attacker = sender as Obj_AI_Hero;
                if (attacker != null && attacker.IsValid)
                {
                    if (args.SpellData.TargettingType == 1 && args.Target != null)
                    {
                        foreach (var hero in ZLib.GetUnits())
                        {
                            if (args.Target.NetworkId != hero.Instance.NetworkId)
                            {
                                continue;
                            }

                            // todo: item damage

                            if (args.SpellData.Name.ToLower() == "bilgewatercutlass")
                            {
                                var dmg = (float)0;
                                EmulateDamage(attacker, hero, new Gamedata {
                                    SpellName = args.SpellData.Name
                                }, EventType.Item,
                                              "enemy.itemcast", dmg);
                            }

                            if (args.SpellData.Name.ToLower() == "itemswordoffeastandfamine")
                            {
                                var dmg = (float)0;
                                EmulateDamage(attacker, hero, new Gamedata {
                                    SpellName = args.SpellData.Name
                                }, EventType.Item,
                                              "enemy.itemcast", dmg);
                            }

                            if (args.SpellData.Name.ToLower() == "hextechgunblade")
                            {
                                var dmg = (float)0;
                                EmulateDamage(attacker, hero, new Gamedata {
                                    SpellName = args.SpellData.Name
                                }, EventType.Item,
                                              "enemy.itemcast", dmg);
                            }
                        }
                    }

                    // todo:
                    if (args.SpellData.TargettingType == 0)
                    {
                        foreach (var hero in ZLib.GetUnits())
                        {
                            if (args.SpellData.Name.ToLower() == "itemtiamatcleave")
                            {
                                if (attacker.Distance(hero.Instance.ServerPosition) <= 375)
                                {
                                    var dmg = (float)0;
                                    EmulateDamage(attacker, hero, new Gamedata {
                                        SpellName = args.SpellData.Name
                                    }, EventType.Item,
                                                  "enemy.itemcast", dmg);
                                }
                            }
                        }
                    }
                }


                #endregion
            }
            catch (Exception e)
            {
                if (ZLib.Menu["logerror"].As <MenuBool>().Enabled)
                {
                    Console.WriteLine("== Error at: ZLib.Projections.Items");
                    Console.WriteLine(e);
                }
            }

            try
            {
                #region LucianQ

                if (args.SpellData.Name.ToLower() == "lucianq")
                {
                    var data = ZLib.CachedSpells.Find(x => x.SpellName.ToLower() == "lucianq");
                    if (data != null)
                    {
                        foreach (var hero in ZLib.GetUnits())
                        {
                            var delay = ((350 - Game.Ping) / 1000f);

                            var herodir     = (hero.Instance.ServerPosition - hero.Instance.Position).Normalized();
                            var expectedpos = args.Target.Position + herodir * hero.Instance.MoveSpeed * (delay);

                            if (args.Start.Distance(expectedpos) < 1100)
                            {
                                expectedpos = args.Target.Position +
                                              (args.Target.Position - sender.ServerPosition).Normalized() * 800;
                            }

                            var proj     = hero.Instance.ServerPosition.To2D().ProjectOn(args.Start.To2D(), expectedpos.To2D());
                            var projdist = hero.Instance.ServerPosition.To2D().Distance(proj.SegmentPoint);

                            if (100 + hero.Instance.BoundingRadius > projdist)
                            {
                                EmulateDamage(sender, hero, data, EventType.Spell, "enemy.lucianq");
                            }
                        }
                    }
                }

                #endregion
            }

            catch (Exception e)
            {
                if (ZLib.Menu["logerror"].As <MenuBool>().Enabled)
                {
                    Console.WriteLine("== Error at: ZLib.Projections.LucianQ");
                    Console.WriteLine(e);
                }
            }
        }
Example #8
0
        internal static void MissileClient_OnSpellMissileCreate(GameObject sender)
        {
            try
            {
                #region FoW / Missile

                if (sender.Type != GameObjectType.MissileClient)
                {
                    return;
                }

                var missile = (MissileClient)sender;
                if (missile.SpellCaster is Obj_AI_Hero && missile.SpellCaster?.Team != Player.Team)
                {
                    var startPos = missile.StartPosition.To2D();
                    var endPos   = missile.EndPosition.To2D();

                    var data = Gamedata.GetByMissileName(missile.SpellData.Name.ToLower());
                    if (data == null)
                    {
                        return;
                    }

                    if (data.Radius < 1f)
                    {
                        data.Radius = missile.SpellData.LineWidth;
                    }

                    var direction = (endPos - startPos).Normalized();
                    if (startPos.Distance(endPos) > data.CastRange)
                    {
                        endPos = startPos + direction * data.CastRange;
                    }

                    if (startPos.Distance(endPos) < data.CastRange && data.FixedRange)
                    {
                        endPos = startPos + direction * data.CastRange;
                    }

                    foreach (var hero in ZLib.GetUnits())
                    {
                        var distance = (1000 * (startPos.Distance(hero.Instance.ServerPosition) / data.MissileSpeed));
                        var endtime  = -100 + Game.Ping / 2 + distance;

                        // setup projection
                        var proj     = hero.Instance.ServerPosition.To2D().ProjectOn(startPos, endPos);
                        var projdist = hero.Instance.ServerPosition.To2D().Distance(proj.SegmentPoint);

                        // get the evade time
                        var evadetime = (int)(1000 *
                                              (data.Radius - projdist + hero.Instance.BoundingRadius)
                                              / hero.Instance.MoveSpeed);

                        // check if hero on segment
                        if (proj.IsOnSegment && projdist <= data.Radius + hero.Instance.BoundingRadius + 35)
                        {
                            if (data.CastRange > 10000)
                            {
                                // ignore if can evade
                                if (hero.Instance.NetworkId == Player.NetworkId)
                                {
                                    if (evadetime < endtime)
                                    {
                                        // check next player
                                        continue;
                                    }
                                }
                            }

                            EmulateDamage(missile.SpellCaster, hero, data, EventType.Spell, "missile.oncreate", 0f, (int)endtime);
                        }
                    }
                }

                #endregion
            }
            catch (Exception e)
            {
                if (ZLib.Menu["logerror"].As <MenuBool>().Enabled)
                {
                    Console.WriteLine("== Error at: ZLib.Projections.Missile");
                    Console.WriteLine(e);
                }
            }
        }
Example #9
0
        internal static void RemoveDamage(int id, string notes)
        {
            var entry = ZLib.DamageCollection.FirstOrDefault(x => x.Key == id);

            if (entry.Value == null)
            {
                ZLib.DamageCollection.Remove(id);
                return;
            }

            if (ZLib.DamageCollection.ContainsKey(entry.Key))
            {
                var hpi = entry.Value;

                var aiHero = ZLib.GetUnits().FirstOrDefault(x => x.Instance.NetworkId == hpi.Target.NetworkId);
                if (aiHero != null)
                {
                    switch (hpi.EventType)
                    {
                    case EventType.Spell:
                        aiHero.AbilityDamage -= hpi.PredictedDmg;
                        aiHero.Events.Remove(EventType.Spell);
                        break;

                    case EventType.Buff:
                        aiHero.BuffDamage -= hpi.PredictedDmg;
                        aiHero.Events.Remove(EventType.Buff);

                        if (notes == "aura.Evade")
                        {
                            aiHero.Events.Remove(EventType.Ultimate);
                        }

                        break;

                    case EventType.Troy:
                        aiHero.TroyDamage -= hpi.PredictedDmg;
                        aiHero.Events.Remove(EventType.Troy);
                        aiHero.Events.RemoveAll(x => hpi.GameData.EventTypes.Contains(x));
                        break;

                    case EventType.Item:
                        aiHero.ItemDamage -= hpi.PredictedDmg;
                        aiHero.Events.Remove(EventType.Item);
                        break;

                    case EventType.TurretAttack:
                        aiHero.TowerDamage -= hpi.PredictedDmg;
                        aiHero.Events.Remove(EventType.TurretAttack);
                        break;

                    case EventType.MinionAttack:
                        aiHero.MinionDamage -= hpi.PredictedDmg;
                        aiHero.Events.Remove(EventType.MinionAttack);
                        break;

                    case EventType.AutoAttack:
                        aiHero.AbilityDamage -= hpi.PredictedDmg;
                        aiHero.Events.Remove(EventType.AutoAttack);
                        break;

                    case EventType.Stealth:
                        aiHero.Events.Remove(EventType.Stealth);
                        break;

                    case EventType.Initiator:
                        aiHero.AbilityDamage -= hpi.PredictedDmg;
                        aiHero.Events.Remove(EventType.Initiator);
                        break;

                    case EventType.Danger:
                        aiHero.AbilityDamage -= hpi.PredictedDmg;
                        aiHero.Events.Remove(EventType.Danger);
                        break;

                    case EventType.CrowdControl:
                        aiHero.AbilityDamage -= hpi.PredictedDmg;
                        aiHero.Events.Remove(EventType.CrowdControl);
                        break;

                    case EventType.Ultimate:
                        aiHero.AbilityDamage -= hpi.PredictedDmg;
                        aiHero.Events.Remove(EventType.Ultimate);
                        break;

                    case EventType.ForceExhaust:
                        aiHero.AbilityDamage -= hpi.PredictedDmg;
                        aiHero.Events.Remove(EventType.ForceExhaust);
                        break;
                    }

                    aiHero.Attacker = null;
                    ZLib.DamageCollection.Remove(id);
                }

                else
                {
                    // if this block is reached the hero is dead
                    var deadHero = ZLib.GetUnits().FirstOrDefault(x => x.Instance.NetworkId == hpi.Target.NetworkId);
                    if (deadHero != null)
                    {
                        Helpers.ResetIncomeDamage(deadHero);
                    }
                }
            }
        }
Example #10
0
        internal static void OnUpdate()
        {
            try
            {
                foreach (var unit in ZLib.GetUnits())
                {
                    var troy = Gametroy.Troys.Find(x => x.Included);
                    if (troy == null)
                    {
                        continue;
                    }

                    if (!troy.Obj.IsVisible || !troy.Obj.IsValid)
                    {
                        continue;
                    }

                    foreach (var entry in ZLib.TroyList.Where(x => x.Name.ToLower() == troy.Name.ToLower()))
                    {
                        var owner = ZLib.GetUnits().FirstOrDefault(x => x.HeroNameMatch(entry.ChampionName));
                        if (owner == null || owner.Instance == null)
                        {
                            continue;
                        }

                        if (owner.Instance.NetworkId == unit.Instance.NetworkId)
                        {
                            continue;
                        }

                        Gamedata data = null;

                        if (entry.ChampionName == null && entry.Slot == SpellSlot.Unknown)
                        {
                            data = new Gamedata {
                                SpellName = troy.Obj.Name
                            }
                        }
                        ;

                        if (entry.ChampionName != null && entry.Slot != SpellSlot.Unknown)
                        {
                            data = ZLib.CachedSpells.Where(x => x.Slot == entry.Slot)
                                   .FirstOrDefault(x => x.HeroNameMatch(entry.ChampionName));

                            if (data != null)
                            {
                                data.EventTypes = entry.EventTypes;
                            }
                        }

                        if (unit.Instance.Distance(troy.Obj.Position) <= entry.Radius + unit.Instance.BoundingRadius)
                        {
                            // check delay (e.g fizz bait)
                            if ((int)(Game.ClockTime * 1000) - troy.Start >= entry.DelayFromStart)
                            {
                                // limit the damage using an interval
                                if ((int)(Game.ClockTime * 1000) - troy.Limiter >= entry.Interval * 1000)
                                {
                                    Projections.EmulateDamage(owner.Instance, unit, data, EventType.Troy, "troy.onupdate");
                                    troy.Limiter = (int)(Game.ClockTime * 1000);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (ZLib.Menu["logerror"].As <MenuBool>().Enabled)
                {
                    Console.WriteLine("== Error at: ZLib.Gametroys.OnUpdate");
                    Console.WriteLine(e);
                }
            }
        }
Example #11
0
 /// <summary>
 ///     Returns if the matched hero is valid and in the current game.
 /// </summary>
 /// <param name="heroname">The heroname.</param>
 /// <returns>
 ///     <c>true</c> if hero is in game, <c>false</c> otherwise.
 /// </returns>
 internal static bool IsHeroInGame(string heroname)
 {
     return(ZLib.GetUnits().ToList().Exists(x => x.Instance is Obj_AI_Hero &&
                                            ((Obj_AI_Hero)x.Instance).ChampionName.ToLower() == heroname.ToLower()));
 }