Esempio n. 1
0
 private static void OnCreate(GameObject sender, EventArgs args)
 {
    // Game.PrintChat(sender.Name);
     if (sender.Name.ToLower().Contains("veigar_base_e_cage"))
     {
         Cage = sender;
         if (Cage != null)
             newCircle = new Geometry.Polygon.Circle(Cage.Position, 450);
     }
     
 }
Esempio n. 2
0
        public static Vector3 GetDashPosition(Spell spell, Obj_AI_Hero target, float safetyDistance)
        {
            var distance = target.Distance(ObjectManager.Player);
            var dashPoints = new Geometry.Polygon.Circle(ObjectManager.Player.Position, spell.Range).Points;
            if (distance < safetyDistance)
            {
                dashPoints.AddRange(
                    new Geometry.Polygon.Circle(ObjectManager.Player.Position, safetyDistance - distance).Points);
            }
            dashPoints = dashPoints.Where(p => !p.IsWall()).OrderBy(p => p.Distance(Game.CursorPos)).ToList();
            foreach (var point in dashPoints)
            {
                var allies =
                    GameObjects.AllyHeroes.Where(
                        hero => !hero.IsDead && hero.Distance(point.To3D()) < ObjectManager.Player.AttackRange).ToList();
                var enemies =
                    GameObjects.EnemyHeroes.Where(
                        hero => hero.IsValidTarget(ObjectManager.Player.AttackRange, true, point.To3D())).ToList();
                var lowEnemies = enemies.Where(hero => hero.HealthPercent <= 15).ToList();

                if (!point.To3D().IsUnderTurret(false))
                {
                    if (enemies.Count == 1 &&
                        (!target.IsMelee ||
                         (target.HealthPercent <= ObjectManager.Player.HealthPercent - 25 ||
                          target.Position.Distance(point.To3D()) >= safetyDistance)) ||
                        allies.Count >
                        enemies.Count -
                        (ObjectManager.Player.HealthPercent >= (10 * lowEnemies.Count) ? lowEnemies.Count : 0))
                    {
                        return point.To3D();
                    }
                }
                else
                {
                    if (enemies.Count == 1 && lowEnemies.Any(t => t.NetworkId.Equals(target.NetworkId)))
                    {
                        return point.To3D();
                    }
                }
            }

            return Vector3.Zero;
        }
Esempio n. 3
0
        private static void OnCreate(GameObject sender, EventArgs args)
        {
           // if (args == EventArgs.Empty) return;
          //  Game.PrintChat(sender.Name);

            if (sender.Name.ToLower().Contains("gragas_base_q"))
            {
                if (sender.Name.ToLower().Contains("ally"))
                {
                    Barrel = sender;
                    if (Barrel != null)
                        CirclePoly = new Geometry.Polygon.Circle(Barrel.Position, 300);
                }

                if (!sender.Name.ToLower().Contains("end")) return;
                Barrel = null;
                CirclePoly = null;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Get the ultimate explosion hit count with best location
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        private Tuple<int, List<Obj_AI_Hero>, Vector3> GetUltimateExplosionHits(Obj_AI_Hero target)
        {
            var hits = new List<Obj_AI_Hero>();
            var castPosition = Vector3.Zero;

            try
            {
                var prediction = R.GetPrediction(target);
                if (prediction.Hitchance >= R.GetHitChance("combo"))
                {
                    castPosition = prediction.CastPosition;
                    hits.Add(target);

                    var explosion = new PredictionInput
                    {
                        Range = UltimateExplosion.Range,
                        Delay = Player.Position.Distance(castPosition) / R.Speed + 0.1f,
                        From = castPosition,
                        RangeCheckFrom = castPosition,
                        Radius = UltimateExplosion.Width,
                        Type = SkillshotType.SkillshotCircle,
                        Speed = UltimateExplosion.Speed
                    };

                    var explosionCircle = new Geometry.Polygon.Circle(castPosition, UltimateExplosion.Width);

                    foreach (var enemy in GameObjects.EnemyHeroes.Where(e => e.IsValidTarget() && e.NetworkId != target.NetworkId))
                    {
                        explosion.Unit = enemy;
                        var explosionPrediction = Prediction.GetPrediction(explosion);
                        if (!explosionPrediction.UnitPosition.Equals(Vector3.Zero))
                        {
                            var enemyPosition = new Geometry.Polygon.Circle(enemy.Position, enemy.BoundingRadius);
                            if (enemyPosition.Points.Any(p => explosionCircle.IsInside(p)))
                            {
                                hits.Add(enemy);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }

            return new Tuple<int, List<Obj_AI_Hero>, Vector3>(hits.Count, hits, castPosition);
        }
Esempio n. 5
0
        private Tuple<int, Vector3> BestQPosition(Obj_AI_Base target, List<Obj_AI_Base> targets, HitChance hitChance)
        {
            var castPos = Vector3.Zero;
            var totalHits = 0;
            try
            {
                var enemies = targets.Where(e => e.IsValidTarget(Q.Range * 1.5f)).ToList();
                var enemyPositions = new List<Tuple<Obj_AI_Base, Vector3>>();
                var circle = new Geometry.Polygon.Circle(Player.Position, Player.BoundingRadius, 30).Points;

                foreach (var h in enemies)
                {
                    var ePred = Q.GetPrediction(h);
                    if (ePred.Hitchance >= hitChance)
                    {
                        circle.Add(Player.Position.Extend(ePred.UnitPosition, Player.BoundingRadius).To2D());
                        enemyPositions.Add(new Tuple<Obj_AI_Base, Vector3>(h, ePred.UnitPosition));
                    }
                }
                var targetPos = target == null ? Vector3.Zero : target.Position;
                if (target == null)
                {
                    var possibilities =
                        ListExtensions.ProduceEnumeration(enemyPositions).Where(p => p.Count > 0).ToList();
                    var count = 0;
                    foreach (var possibility in possibilities)
                    {
                        var mec = MEC.GetMec(possibility.Select(p => p.Item2.To2D()).ToList());
                        if (mec.Radius < Q.Width && possibility.Count > count)
                        {
                            count = possibility.Count;
                            targetPos = mec.Center.To3D();
                        }
                    }
                }
                if (targetPos.Equals(Vector3.Zero))
                {
                    return new Tuple<int, Vector3>(totalHits, castPos);
                }
                circle = circle.OrderBy(c => c.Distance(targetPos)).ToList();
                if (!enemyPositions.Any())
                {
                    return new Tuple<int, Vector3>(totalHits, castPos);
                }

                foreach (var point in circle)
                {
                    var hits = 0;
                    var containsTarget = false;
                    var direction = Q.Range * (point.To3D() - ObjectManager.Player.Position).Normalized().To2D();
                    var rect1 = new Geometry.Polygon.Rectangle(
                        Player.Position, Player.Position.Extend(Player.Position + direction.To3D(), Q.Range), Q.Width);
                    var rect2 = new Geometry.Polygon.Rectangle(
                        Player.Position,
                        Player.Position.Extend(Player.Position + direction.Rotated(QAngle).To3D(), Q.Range), Q.Width);
                    var rect3 = new Geometry.Polygon.Rectangle(
                        Player.Position,
                        Player.Position.Extend(Player.Position + direction.Rotated(-QAngle).To3D(), Q.Range), Q.Width);
                    foreach (var enemy in enemyPositions)
                    {
                        var bounding = new Geometry.Polygon.Circle(enemy.Item2, enemy.Item1.BoundingRadius * 0.85f);
                        if (bounding.Points.Any(p => rect1.IsInside(p) || rect2.IsInside(p) || rect3.IsInside(p)))
                        {
                            hits++;
                            if (target != null && enemy.Item1.NetworkId.Equals(target.NetworkId))
                            {
                                containsTarget = true;
                            }
                        }
                    }
                    if ((containsTarget || target == null) && hits > totalHits)
                    {
                        totalHits = hits;
                        castPos = Player.Position.Extend(point.To3D(), Q.Range);
                        if (totalHits >= enemies.Count)
                        {
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
            return new Tuple<int, Vector3>(totalHits, castPos);
        }
Esempio n. 6
0
 private Vector3 BestRFollowLocation(Vector3 position)
 {
     try
     {
         var center = Vector2.Zero;
         float radius = -1;
         var count = 0;
         var moveDistance = -1f;
         var maxRelocation = IsSpellUpgraded(R) ? R.Width * 1.2f : R.Width * 0.8f;
         var targets = GameObjects.EnemyHeroes.Where(t => t.IsValidTarget(1500f)).ToList();
         var circle = new Geometry.Polygon.Circle(position, R.Width);
         if (targets.Any())
         {
             var minDistance = targets.Any(t => circle.IsInside(t)) ? targets.Min(t => t.BoundingRadius) * 2 : 0;
             var possibilities =
                 ListExtensions.ProduceEnumeration(targets.Select(t => t.Position.To2D()).ToList())
                     .Where(p => p.Count > 1)
                     .ToList();
             if (possibilities.Any())
             {
                 foreach (var possibility in possibilities)
                 {
                     var mec = MEC.GetMec(possibility);
                     var distance = position.Distance(mec.Center.To3D());
                     if (mec.Radius < R.Width && distance < maxRelocation && distance > minDistance)
                     {
                         if (possibility.Count > count ||
                             possibility.Count == count && (mec.Radius < radius || distance < moveDistance))
                         {
                             moveDistance = position.Distance(mec.Center.To3D());
                             center = mec.Center;
                             radius = mec.Radius;
                             count = possibility.Count;
                         }
                     }
                 }
                 if (!center.Equals(Vector2.Zero))
                 {
                     return center.To3D();
                 }
             }
             var dTarget = targets.OrderBy(t => t.Distance(position)).FirstOrDefault();
             if (dTarget != null && position.Distance(dTarget.Position) > minDistance)
             {
                 return dTarget.Position;
             }
         }
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return Vector3.Zero;
 }
Esempio n. 7
0
        private Tuple<int, Vector3> GetBestQLocation(Obj_AI_Hero target, HitChance hitChance)
        {
            try
            {
                if (target == null)
                {
                    return new Tuple<int, Vector3>(0, Vector3.Zero);
                }
                var hits = new List<Obj_AI_Hero>();
                var center = Vector3.Zero;
                var radius = float.MaxValue;
                var range = Q.Range + Q.Width + target.BoundingRadius * 0.85f;
                var positions = (from t in GameObjects.EnemyHeroes
                    where t.IsValidTarget(range, true, Q.RangeCheckFrom)
                    let prediction = Q.GetPrediction(t)
                    where prediction.Hitchance >= (hitChance - 1)
                    select new CPrediction.Position(t, prediction.UnitPosition)).ToList();
                if (positions.Any())
                {
                    var mainTarget = positions.FirstOrDefault(p => p.Hero.NetworkId == target.NetworkId);
                    var possibilities =
                        ListExtensions.ProduceEnumeration(
                            positions.Where(p => p.UnitPosition.Distance(mainTarget.UnitPosition) <= Q.Width * 0.85f)
                                .ToList())
                            .Where(p => p.Count > 0 && p.Any(t => t.Hero.NetworkId == mainTarget.Hero.NetworkId))
                            .ToList();
                    var rReady = R.IsReady();
                    var wReady = W.IsReady();
                    foreach (var possibility in possibilities)
                    {
                        var mec = MEC.GetMec(possibility.Select(p => p.UnitPosition.To2D()).ToList());
                        var distance = Q.From.Distance(mec.Center.To3D());
                        if (distance < range)
                        {
                            if (mec.Radius < R.Width * 0.85f && possibility.Count >= 3 && rReady ||
                                mec.Radius < W.Width * 0.9f && possibility.Count >= 2 && wReady ||
                                mec.Radius < Q.Width * 0.9f && possibility.Count >= 1)
                            {
                                var lHits = new List<Obj_AI_Hero>();
                                var circle =
                                    new Geometry.Polygon.Circle(
                                        Q.From.Extend(mec.Center.To3D(), Q.Range > distance ? distance : Q.Range),
                                        Q.Width);

                                lHits.AddRange(
                                    (from position in positions
                                        where
                                            new Geometry.Polygon.Circle(
                                                position.UnitPosition, (position.Hero.BoundingRadius * 0.85f)).Points
                                                .Any(p => circle.IsInside(p))
                                        select position.Hero));

                                if ((lHits.Count > hits.Count || lHits.Count == hits.Count && mec.Radius < radius ||
                                     lHits.Count == hits.Count &&
                                     Q.From.Distance(circle.Center.To3D()) < Q.From.Distance(center)) &&
                                    lHits.Any(p => p.NetworkId == target.NetworkId))
                                {
                                    center = circle.Center.To3D2();
                                    radius = mec.Radius;
                                    hits.Clear();
                                    hits.AddRange(lHits);
                                }
                            }
                        }
                    }
                    if (!center.Equals(Vector3.Zero))
                    {
                        return new Tuple<int, Vector3>(hits.Count, center);
                    }
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
            return new Tuple<int, Vector3>(0, Vector3.Zero);
        }
Esempio n. 8
0
 private static Paths WPPolygon(Obj_AI_Hero Hero)
 {
     List<Vector2Time> HeroPath = Hero.GetWaypointsWithTime();
     Vector2 myPath;
     Paths WPPaths = new Paths();
     for (var i = 0; i < HeroPath.Count() - 1; i++)
     {
         if (HeroPath.ElementAt<Vector2Time>(i + 1).Time <= 0.6f)
         {
             Geometry.Polygon.Rectangle WPRectangle = new Geometry.Polygon.Rectangle(HeroPath.ElementAt<Vector2Time>(i).Position, HeroPath.ElementAt<Vector2Time>(i + 1).Position, Hero.BoundingRadius);
             Geometry.Polygon.Circle Box = new Geometry.Polygon.Circle(HeroPath.ElementAt<Vector2Time>(i).Position, Hero.BoundingRadius);
             WPPaths.Add(Box.ToClipperPath());
             WPPaths.Add(WPRectangle.ToClipperPath());
         }
         else
         {
             myPath = PositionAfter(Hero, 0.6f, Hero.MoveSpeed);
             Geometry.Polygon.Rectangle WPRectangle = new Geometry.Polygon.Rectangle(HeroPath.ElementAt<Vector2Time>(i).Position, myPath, Hero.BoundingRadius);
             Geometry.Polygon.Circle Box = new Geometry.Polygon.Circle(myPath, Hero.BoundingRadius);
             WPPaths.Add(Box.ToClipperPath());
             WPPaths.Add(WPRectangle.ToClipperPath());
             break;
         }
     }
     Geometry.Polygon.Circle WPFirstBox = new Geometry.Polygon.Circle(HeroPath.First<Vector2Time>().Position, Hero.BoundingRadius);
     WPPaths.Add(WPFirstBox.ToClipperPath());
     return WPPaths;
 }
        private void ELogicFarm(List<Obj_AI_Base> targets, HitChance hitChance, int minHits)
        {
            try
            {
                var input = new PredictionInput
                {
                    Range = ELength,
                    Delay = E.Delay,
                    Radius = E.Width,
                    Speed = E.Speed,
                    Type = E.Type
                };
                var input2 = new PredictionInput
                {
                    Range = E.Range + ELength,
                    Delay = E.Delay,
                    Radius = E.Width,
                    Speed = E.Speed,
                    Type = E.Type
                };
                var startPos = Vector3.Zero;
                var endPos = Vector3.Zero;
                var hits = 0;
                targets = targets.Where(t => t.IsValidTarget((E.Range + ELength + E.Width) * 1.1f)).ToList();
                var targetCount = targets.Count;

                foreach (var target in targets)
                {
                    var lTarget = target;
                    if (target.ServerPosition.Distance(Player.ServerPosition) <= E.Range)
                    {
                        var cCastPos = target.ServerPosition;
                        foreach (var t in targets.Where(t => t.NetworkId != lTarget.NetworkId))
                        {
                            var count = 1;
                            input.Unit = t;
                            input.From = cCastPos;
                            input.RangeCheckFrom = cCastPos;
                            var pred = Prediction.GetPrediction(input);
                            var rect = new Geometry.Polygon.Rectangle(
                                cCastPos.To2D(), cCastPos.Extend(pred.CastPosition, ELength).To2D(), E.Width);
                            foreach (var c in targets.Where(c => c.NetworkId != lTarget.NetworkId))
                            {
                                input.Unit = c;
                                var cPredPos = c.Position;
                                if (
                                    new Geometry.Polygon.Circle(
                                        cPredPos, (c.IsMoving ? (c.BoundingRadius / 2f) : (c.BoundingRadius) * 0.9f))
                                        .Points.Any(p => rect.IsInside(p)))
                                {
                                    count++;
                                }
                            }
                            if (pred.Hitchance >= (hitChance - 1))
                            {
                                count++;
                                if (count > hits)
                                {
                                    hits = count;
                                    startPos = cCastPos;
                                    endPos = cCastPos.Extend(pred.CastPosition, ELength);
                                    if (hits == targetCount)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                        if (endPos.Equals(Vector3.Zero))
                        {
                            startPos = cCastPos;
                            if (IsSpellUpgraded(E))
                            {
                                if (target.Path.Length > 0)
                                {
                                    var newPos = target.Path[0];
                                    if (target.Path.Length > 1 && newPos.Distance(target.ServerPosition) <= 150)
                                    {
                                        newPos = newPos.Extend(target.Path[1], 50);
                                    }
                                    startPos = target.ServerPosition.Extend(newPos, -(lTarget.BoundingRadius * 0.85f));
                                }
                                else if (target.IsFacing(Player))
                                {
                                    startPos = target.ServerPosition.Extend(
                                        Player.ServerPosition, -(lTarget.BoundingRadius * 0.85f));
                                }
                                else
                                {
                                    startPos = cCastPos;
                                }
                            }
                            if (startPos.Distance(Player.ServerPosition) > E.Range)
                            {
                                startPos = Player.ServerPosition.Extend(startPos, E.Range);
                            }
                            if (target.Path.Length > 0)
                            {
                                endPos = startPos.Extend(target.Path[0], ELength);
                            }
                            else if (target.IsFacing(Player))
                            {
                                endPos = startPos.Extend(Player.ServerPosition, ELength);
                            }
                            else
                            {
                                endPos = Player.ServerPosition.Extend(
                                    startPos, startPos.Distance(Player.ServerPosition) + ELength);
                            }
                            hits = 1;
                        }
                    }
                    else
                    {
                        input2.Unit = lTarget;
                        var castPos = Prediction.GetPrediction(input2).CastPosition;
                        if (castPos.Equals(Vector3.Zero))
                        {
                            continue;
                        }
                        var circle =
                            new Geometry.Polygon.Circle(
                                Player.ServerPosition, Math.Min(E.Range, castPos.Distance(Player.ServerPosition)), 45)
                                .Points.Where(p => p.Distance(castPos) < ELength * 1.5f)
                                .Select(p => p.To3D())
                                .OrderBy(p => p.Distance(lTarget.ServerPosition));
                        foreach (var point in circle)
                        {
                            input2.From = point;
                            input2.RangeCheckFrom = point;
                            input2.Range = ELength;
                            var pred2 = Prediction.GetPrediction(input2);
                            if (pred2.Hitchance >= hitChance)
                            {
                                var count = 1;
                                var rect = new Geometry.Polygon.Rectangle(
                                    point, point.Extend(pred2.CastPosition, ELength), E.Width);
                                foreach (var c in targets.Where(t => t.NetworkId != lTarget.NetworkId))
                                {
                                    input2.Unit = c;
                                    var cPredPos = c.Position;
                                    if (
                                        new Geometry.Polygon.Circle(
                                            cPredPos, (c.IsMoving ? (c.BoundingRadius / 2f) : (c.BoundingRadius) * 0.9f))
                                            .Points.Any(p => rect.IsInside(p)))
                                    {
                                        count++;
                                    }
                                }
                                if (count > hits)
                                {
                                    hits = count;
                                    startPos = point;
                                    endPos = startPos.Extend(pred2.CastPosition, ELength);
                                    if (hits == targetCount)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (hits == targetCount)
                    {
                        break;
                    }
                }
                if (hits >= minHits && !startPos.Equals(Vector3.Zero) && !endPos.Equals(Vector3.Zero))
                {
                    if (startPos.Distance(Player.ServerPosition) > E.Range)
                    {
                        startPos = Player.ServerPosition.Extend(startPos, E.Range);
                    }
                    if (endPos.Distance(startPos) > ELength)
                    {
                        endPos = startPos.Extend(endPos, ELength);
                    }
                    E.Cast(startPos, endPos);
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
        }
Esempio n. 10
0
 public Skillshot(DetectionType detectionType,
     SpellData spellData,
     int startT,
     Vector2 start,
     Vector2 end,
     Obj_AI_Base unit)
 {
     DetectionType = detectionType;
     SpellData = spellData;
     StartTick = startT;
     Start = start;
     End = end;
     Direction = (end - start).Normalized();
     Unit = unit;
     switch (spellData.Type)
     {
         case SkillShotType.SkillshotCircle:
             Circle = new Geometry.Polygon.Circle(CollisionEnd, spellData.Radius, 22);
             break;
         case SkillShotType.SkillshotLine:
         case SkillShotType.SkillshotMissileLine:
             Rectangle = new Geometry.Polygon.Rectangle(Start, CollisionEnd, spellData.Radius);
             break;
         case SkillShotType.SkillshotCone:
             Sector = new Geometry.Polygon.Sector(
                 start, CollisionEnd - start, spellData.Radius * (float) Math.PI / 180, spellData.Range, 22);
             break;
         case SkillShotType.SkillshotRing:
             Ring = new Geometry.Polygon.Ring(CollisionEnd, spellData.Radius, spellData.RingRadius, 22);
             break;
     }
     UpdatePolygon();
 }
Esempio n. 11
0
 public Skillshot(
     DetectionType detectionType,
     SpellData spellData,
     int startT,
     Vector2 start,
     Vector2 end,
     Obj_AI_Base unit)
 {
     this.DetectionType = detectionType;
     this.SpellData = spellData;
     this.StartTick = startT;
     this.Start = start;
     this.End = end;
     this.Direction = (end - start).Normalized();
     this.Unit = unit;
     switch (spellData.Type)
     {
         case SkillShotType.SkillshotCircle:
             this.Circle = new Geometry.Polygon.Circle(this.CollisionEnd, spellData.Radius, 22);
             break;
         case SkillShotType.SkillshotLine:
         case SkillShotType.SkillshotMissileLine:
             this.Rectangle = new Geometry.Polygon.Rectangle(this.Start, this.CollisionEnd, spellData.Radius);
             break;
         case SkillShotType.SkillshotCone:
             this.Sector = new Geometry.Polygon.Sector(
                 start,
                 this.CollisionEnd - start,
                 spellData.Radius * (float)Math.PI / 180,
                 spellData.Range,
                 22);
             break;
         case SkillShotType.SkillshotRing:
             this.Ring = new Geometry.Polygon.Ring(this.CollisionEnd, spellData.Radius, spellData.RingRadius, 22);
             break;
         case SkillShotType.SkillshotArc:
             this.Arc = new Geometry.Polygon.Arc(
                 start,
                 end,
                 Configs.SkillShotsExtraRadius + (int)ObjectManager.Player.BoundingRadius,
                 22);
             break;
     }
     this.UpdatePolygon();
 }
Esempio n. 12
0
 private Tuple<int, List<Obj_AI_Hero>> GetHits(Spell spell)
 {
     try
     {
         var hits = new List<Obj_AI_Hero>();
         var positions = (from t in GameObjects.EnemyHeroes
             where t.IsValidTarget(spell.Width * 4, true, spell.RangeCheckFrom)
             let prediction = spell.GetPrediction(t)
             where prediction.Hitchance >= HitChance.High
             select new CPrediction.Position(t, prediction.UnitPosition)).ToList();
         if (positions.Any())
         {
             var circle = new Geometry.Polygon.Circle(Ball.Position, spell.Width);
             hits.AddRange(
                 from position in positions
                 where
                     !position.Hero.IsDashing() ||
                     (position.Hero.Distance(Ball.Position) >= 100f &&
                      position.Hero.Position.Distance(Ball.Position) >
                      position.Hero.GetDashInfo().EndPos.Distance(Ball.Position) - 50f)
                 where
                     new Geometry.Polygon.Circle(
                         position.UnitPosition,
                         (position.Hero.BoundingRadius * CPrediction.BoundingRadiusMultiplicator)).Points.Any(
                             p => circle.IsInside(p))
                 select position.Hero);
             return new Tuple<int, List<Obj_AI_Hero>>(hits.Count, hits);
         }
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return new Tuple<int, List<Obj_AI_Hero>>(0, null);
 }
Esempio n. 13
0
        private static void CastMec(Spell spell, int minHit)
        {
            if (!spell.IsReady() || ObjectManager.Player.HealthPercent <= 10)
                return;

            foreach (var target in HeroManager.Enemies.Where(x => x.IsValidTarget(spell.Range)))
            {
                var pred = spell.GetPrediction(target, true);

                var nearByEnemies = 1;

                if (spell.Type == SkillshotType.SkillshotLine && spell.Collision)
                {
                    var poly = new Geometry.Polygon.Circle(pred.UnitPosition, spell.Width);

                    nearByEnemies +=
                        HeroManager.Enemies.Where(x => x.NetworkId != target.NetworkId)
                            .Count(enemy => poly.IsInside(enemy.ServerPosition));

                }
                else
                {
                    nearByEnemies = pred.AoeTargetsHitCount;
                }

                if (nearByEnemies >= minHit)
                {
                    
                    spell.Cast(target);
                    return;
                }
            }
        }
Esempio n. 14
0
        private static void CastComboMec(Spell spell, int minHit)
        {
            if (!spell.IsReady() || !E.IsReady() || ObjectManager.Player.HealthPercent <= 10)
                return;

            const int gateDis = 200;

            foreach (var target in ObjectManager.Get<Obj_AI_Hero>().Where(x => x.IsValidTarget(spell.Range)))
            {
                var tarPred = spell.GetPrediction(target, true);
                
                Vector3 gateVector = ObjectManager.Player.Position + Vector3.Normalize(target.ServerPosition - ObjectManager.Player.Position)*gateDis;

                var nearByEnemies = 1;

                var poly = new Geometry.Polygon.Circle(tarPred.UnitPosition, spell.Width);

                nearByEnemies += HeroManager.Enemies.Where(x => x.NetworkId != target.NetworkId).Count(enemy => poly.IsInside(enemy.ServerPosition));

                if (ObjectManager.Player.Distance(tarPred.CastPosition) < spell.Range + 100 && nearByEnemies >= minHit)
                {
                    if (Jayce.HammerTime && R.IsReady() && Jayce.CanQcd == 0 && Jayce.CanEcd == 0)
                        R.Cast();
                    else if(Jayce.HammerTime)
                        return;

                    Console.WriteLine("Hit Combo: " + nearByEnemies);
                    E.Cast(gateVector);
                    spell.Cast(tarPred.CastPosition);
                    return;
                }
            }
        }
Esempio n. 15
0
        private Tuple<List<Obj_AI_Hero>, Vector3> GetMaxRHits(HitChance hitChance, Vector3 fromCheck = default(Vector3))
        {
            if (fromCheck.Equals(default(Vector3)))
            {
                fromCheck = ObjectManager.Player.Position;
            }

            var input = new PredictionInput
            {
                Collision = true,
                CollisionObjects = new[] { CollisionableObjects.YasuoWall },
                From = fromCheck,
                RangeCheckFrom = fromCheck,
                Type = R.Type,
                Radius = R.Width,
                Delay = R.Delay,
                Speed = R.Speed,
                Range = R.Range,
                Aoe = true
            };

            var castPosition = Vector3.Zero;
            var totalHits = new List<Obj_AI_Hero>();
            try
            {
                var positions = new List<CPrediction.Position>();
                foreach (var t in GameObjects.EnemyHeroes)
                {
                    if (t.IsValidTarget(R.Range * 1.5f, true, fromCheck))
                    {
                        input.Unit = t;
                        var prediction = Prediction.GetPrediction(input);
                        if (prediction.Hitchance >= hitChance)
                        {
                            positions.Add(new CPrediction.Position(t, prediction.UnitPosition));
                        }
                    }
                }
                var circle = new Geometry.Polygon.Circle(fromCheck, R.Range).Points;
                foreach (var point in circle)
                {
                    var hits = new List<Obj_AI_Hero>();
                    foreach (var position in positions)
                    {
                        R.UpdateSourcePosition(fromCheck, fromCheck);
                        if (R.WillHit(position.UnitPosition, point.To3D()))
                        {
                            hits.Add(position.Hero);
                        }
                        R.UpdateSourcePosition();
                    }
                    if (hits.Count > totalHits.Count)
                    {
                        castPosition = point.To3D();
                        totalHits = hits;
                    }
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
            return new Tuple<List<Obj_AI_Hero>, Vector3>(totalHits, castPosition);
        }
Esempio n. 16
0
        public static Result Circle(Spell spell, Obj_AI_Hero target, HitChance hitChance, bool boundingRadius = true)
        {
            try
            {
                if (spell == null || target == null)
                {
                    return new Result(Vector3.Zero, new List<Obj_AI_Hero>());
                }
                var hits = new List<Obj_AI_Hero>();
                var center = Vector3.Zero;
                var radius = float.MaxValue;
                var range = spell.Range + spell.Width +
                            (boundingRadius ? target.BoundingRadius * BoundingRadiusMultiplicator : 0);
                var positions = (from t in GameObjects.EnemyHeroes
                    where t.IsValidTarget(range, true, spell.RangeCheckFrom)
                    let prediction = spell.GetPrediction(t)
                    where prediction.Hitchance >= hitChance
                    select new Position(t, prediction.UnitPosition)).ToList();
                var spellWidth = spell.Width;
                //+ (boundingRadius ? positions.Select(p => p.Hero).Min(p => p.BoundingRadius) : 0);
                if (positions.Any())
                {
                    var mainTarget = positions.FirstOrDefault(p => p.Hero.NetworkId == target.NetworkId);
                    var possibilities =
                        ListExtensions.ProduceEnumeration(
                            positions.Where(
                                p => p.UnitPosition.Distance(mainTarget.UnitPosition) <= spell.Width * 0.85f).ToList())
                            .Where(p => p.Count > 0 && p.Any(t => t.Hero.NetworkId == mainTarget.Hero.NetworkId))
                            .ToList();
                    foreach (var possibility in possibilities)
                    {
                        var mec = MEC.GetMec(possibility.Select(p => p.UnitPosition.To2D()).ToList());
                        var distance = spell.From.Distance(mec.Center.To3D());
                        if (mec.Radius < spellWidth && distance < range)
                        {
                            var lHits = new List<Obj_AI_Hero>();
                            var circle =
                                new Geometry.Polygon.Circle(
                                    spell.From.Extend(
                                        mec.Center.To3D(), spell.Range > distance ? distance : spell.Range), spell.Width);

                            if (boundingRadius)
                            {
                                lHits.AddRange(
                                    (from position in positions
                                        where
                                            new Geometry.Polygon.Circle(
                                                position.UnitPosition,
                                                (position.Hero.BoundingRadius * BoundingRadiusMultiplicator)).Points.Any
                                                (p => circle.IsInside(p))
                                        select position.Hero));
                            }
                            else
                            {
                                lHits.AddRange(
                                    from position in positions
                                    where circle.IsInside(position.UnitPosition)
                                    select position.Hero);
                            }

                            if ((lHits.Count > hits.Count || lHits.Count == hits.Count && mec.Radius < radius ||
                                 lHits.Count == hits.Count &&
                                 spell.From.Distance(circle.Center.To3D()) < spell.From.Distance(center)) &&
                                lHits.Any(p => p.NetworkId == target.NetworkId))
                            {
                                center = circle.Center.To3D2();
                                radius = mec.Radius;
                                hits.Clear();
                                hits.AddRange(lHits);
                            }
                        }
                    }
                    if (!center.Equals(Vector3.Zero))
                    {
                        return new Result(center, hits);
                    }
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
            return new Result(Vector3.Zero, new List<Obj_AI_Hero>());
        }
Esempio n. 17
0
        void Obj_AI_Hero_OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args)
        {
            //Patented by XcxooxL
            if (!sender.IsEnemy || !sender.IsValidTarget() || !sender.IsVisible) return;

            if (args.Target != null && !args.Target.IsAlly) return;
                double damage = 0;
                //if it is an Auto Attack !
            if (args.SData.IsAutoAttack())
            {
                var Target = args.Target as Obj_AI_Hero;
                if (Target == null)
                    return; //must be a champion
                if (args.SData.Name.ToLower().Contains("crit"))
                {
                    damage += sender.GetAutoAttackDamage(Target) * 2;
                    //Console.WriteLine("Critical " + damage);
                    if (sender.InventoryItems.Any(item => item.Id.Equals(3031)))
                    {
                        Console.WriteLine("Infinity Edge");
                        damage += damage * 1.25;
                    }
                    //Infinity edge
                }
                else
                {
                    damage += sender.GetAutoAttackDamage(Target, true);
                }
                damage += 2; //to be on the safe side
                Add(Target, damage, sender.Distance(Target) / args.SData.MissileSpeed + 1 / sender.AttackDelay);
                Console.WriteLine(
                    "Target : " + Target.Name + "Damage : " + damage + " Time To Hit : " +
                    sender.Distance(Target) / args.SData.MissileSpeed * 1000);

            }
            else //if its a Spell
            {
                float delay = 0;
                var missileSpeed = args.SData.MissileSpeed;
                foreach (var spellInfo in
                    SpellDatabase.Spells.Where(spellInfo => spellInfo.spellName.Equals(args.SData.Name)))
                {
                    if (spellInfo.spellType.Equals(SpellType.Line))
                    {
                        _myPoly = new Geometry.Polygon.Rectangle(
                            args.Start, args.Start.Extend(args.End, spellInfo.range), spellInfo.radius);
                    }
                    else if (spellInfo.spellType.Equals(SpellType.Circular))
                    {

                        var pos = sender.Distance(args.End) > spellInfo.range
                            ? sender.Position.Extend(args.End, spellInfo.range)
                            : args.End;
                        _myPoly = new Geometry.Polygon.Circle(pos, spellInfo.radius);
                    }
                    missileSpeed = spellInfo.projectileSpeed;
                    delay += spellInfo.spellDelay;
                    break;
                }

                //Patented by xcxooxl ALL OF THIS IS MINE ! YOU WANT IT? CREDIT ME!

                if (sender is Obj_AI_Hero)
                {
                    var enemy = sender as Obj_AI_Hero;
                    foreach (var ally in TrackList)
                    {
                        var timeToHit = delay + ally.Distance(args.Start) / missileSpeed * 1000 +
                                        args.SData.ChannelDuration + args.SData.DelayTotalTimePercent * -1;
                        if (args.SData.TargettingType.Equals(SpellDataTargetType.Unit)) //Targeted
                        {
                            damage += enemy.GetDamageSpell(args.Target as Obj_AI_Base, args.Slot).CalculatedDamage;
                            Add(ally, damage, timeToHit);
                        }

                        Console.WriteLine(
                            "Spellname" + args.SData.Name + " Time to hit " + timeToHit + "MissileSpeed " + missileSpeed);

                        var futurePos = Prediction.GetPrediction(ally, timeToHit / 1000).UnitPosition;
                        futurePosCircle = new Geometry.Polygon.Circle(futurePos, 125);
                        if (_myPoly.IsInside(futurePos))
                        {
                            damage += enemy.GetDamageSpell(ally, args.Slot).CalculatedDamage;
                            Add(ally, damage, timeToHit);
                        }
                        Utility.DelayAction.Add(
                            (int) (timeToHit + 1200), () =>
                            {
                                futurePosCircle = null;
                                _myPoly = null;
                            }); //stop drawing polygons

                    }
                }
            }

            //Patented by XcxooxL
        }
Esempio n. 18
0
 private bool ELogicHero(Obj_AI_Hero mainTarget, HitChance hitChance)
 {
     try
     {
         if (mainTarget == null)
         {
             return false;
         }
         var input = new PredictionInput
         {
             Range = ELength,
             Delay = E.Delay,
             Radius = E.Width,
             Speed = E.Speed,
             Type = E.Type,
             UseBoundingRadius = true
         };
         var input2 = new PredictionInput
         {
             Range = E.Range + ELength,
             Delay = E.Delay,
             Radius = E.Width,
             Speed = E.Speed,
             Type = E.Type,
             UseBoundingRadius = true
         };
         var startPosition = Vector3.Zero;
         var endPosition = Vector3.Zero;
         var targets =
             GameObjects.EnemyHeroes.Where(t => t.IsValidTarget((E.Range + ELength + E.Width) * 1.25f)).ToList();
         if (mainTarget.ServerPosition.Distance(Player.ServerPosition) <= E.Range)
         {
             var castPosition = mainTarget.ServerPosition;
             var maxAdditionalHits = 0;
             foreach (var target in targets.Where(t => t.NetworkId != mainTarget.NetworkId))
             {
                 var lTarget = target;
                 var additionalHits = 0;
                 input.Unit = lTarget;
                 input.From = castPosition;
                 input.RangeCheckFrom = castPosition;
                 var pred = Prediction.GetPrediction(input);
                 if (pred.Hitchance >= HitChance.High)
                 {
                     additionalHits++;
                     var rect = new Geometry.Polygon.Rectangle(
                         castPosition, castPosition.Extend(pred.CastPosition, ELength), E.Width);
                     foreach (var target2 in
                         targets.Where(
                             t => t.NetworkId != mainTarget.NetworkId && t.NetworkId != lTarget.NetworkId))
                     {
                         input.Unit = target2;
                         var pred2 = Prediction.GetPrediction(input);
                         if (!pred2.UnitPosition.Equals(Vector3.Zero) &&
                             new Geometry.Polygon.Circle(pred2.UnitPosition, target2.BoundingRadius * 0.9f)
                                 .Points.Any(p => rect.IsInside(p)))
                         {
                             additionalHits++;
                         }
                     }
                 }
                 if (additionalHits > maxAdditionalHits)
                 {
                     maxAdditionalHits = additionalHits;
                     endPosition = pred.CastPosition;
                 }
             }
             startPosition = castPosition;
             if (endPosition.Equals(Vector3.Zero))
             {
                 if (startPosition.Distance(Player.ServerPosition) > E.Range)
                 {
                     startPosition = Player.ServerPosition.Extend(startPosition, E.Range);
                 }
                 if (mainTarget.Path.Length > 0)
                 {
                     var newPos = mainTarget.Path[0];
                     if (mainTarget.Path.Length > 1 &&
                         newPos.Distance(mainTarget.ServerPosition) <= mainTarget.BoundingRadius * 4f)
                     {
                         var nnPos = newPos.Extend(
                             mainTarget.Path[1],
                             Math.Min(mainTarget.BoundingRadius * 1.5f, newPos.Distance(mainTarget.Path[1])));
                         if (startPosition.To2D().AngleBetween(nnPos.To2D()) < 30)
                         {
                             newPos = nnPos;
                         }
                     }
                     endPosition = startPosition.Extend(newPos, ELength);
                 }
                 else if (mainTarget.IsFacing(Player))
                 {
                     endPosition = startPosition.Extend(Player.ServerPosition, ELength);
                 }
                 else
                 {
                     endPosition = Player.ServerPosition.Extend(
                         startPosition, startPosition.Distance(Player.ServerPosition) + ELength);
                 }
             }
         }
         else
         {
             var totalHits = 0;
             input2.Unit = mainTarget;
             var pred = Prediction.GetPrediction(input2);
             if (!pred.UnitPosition.Equals(Vector3.Zero) && !pred.CastPosition.Equals(Vector3.Zero))
             {
                 var ranges =
                     new[] { E.Range }.Concat(
                         targets.Where(
                             t =>
                                 t.ServerPosition.Distance(Player.ServerPosition) < E.Range &&
                                 t.ServerPosition.Distance(mainTarget.ServerPosition) < ELength * 1.25f)
                             .Select(t => t.ServerPosition.Distance(Player.ServerPosition)));
                 var maxDistance = (ELength + E.Width + mainTarget.BoundingRadius) * 1.1f;
                 foreach (var range in ranges)
                 {
                     var circle =
                         new Geometry.Polygon.Circle(Player.ServerPosition, Math.Min(E.Range, range), 50).Points
                             .Where(p => p.Distance(pred.UnitPosition) <= maxDistance)
                             .Select(p => p.To3D())
                             .OrderBy(p => p.Distance(pred.CastPosition));
                     foreach (var point in circle)
                     {
                         var hits = 0;
                         input.From = point;
                         input.RangeCheckFrom = point;
                         input.Unit = mainTarget;
                         var pred2 = Prediction.GetPrediction(input);
                         if (pred2.Hitchance >= hitChance)
                         {
                             hits++;
                             var rect = new Geometry.Polygon.Rectangle(
                                 point, point.Extend(pred2.CastPosition, ELength), E.Width);
                             foreach (var target in targets.Where(t => t.NetworkId != mainTarget.NetworkId))
                             {
                                 input.Unit = target;
                                 var pred3 = Prediction.GetPrediction(input);
                                 if (!pred3.UnitPosition.Equals(Vector3.Zero) &&
                                     new Geometry.Polygon.Circle(
                                         pred3.UnitPosition, target.BoundingRadius * 0.9f).Points.Any(
                                             p => rect.IsInside(p)))
                                 {
                                     hits++;
                                 }
                             }
                             if (hits > totalHits ||
                                 hits > 0 && hits == totalHits &&
                                 point.Distance(mainTarget.ServerPosition) <
                                 startPosition.Distance(mainTarget.ServerPosition))
                             {
                                 totalHits = hits;
                                 startPosition = point;
                                 endPosition = point.Extend(pred2.CastPosition, ELength);
                             }
                             if (totalHits == targets.Count)
                             {
                                 break;
                             }
                         }
                     }
                     if (totalHits == targets.Count)
                     {
                         break;
                     }
                 }
             }
         }
         if (!startPosition.Equals(Vector3.Zero) && !endPosition.Equals(Vector3.Zero))
         {
             if (startPosition.Distance(Player.ServerPosition) > E.Range)
             {
                 startPosition = Player.ServerPosition.Extend(startPosition, E.Range);
             }
             if (endPosition.Distance(startPosition) > ELength)
             {
                 endPosition = startPosition.Extend(endPosition, ELength);
             }
             E.Cast(startPosition, endPosition);
             return true;
         }
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return false;
 }
Esempio n. 19
0
        private static void Laneclearmelee()
        {
            if (GetValue("minmana") > Player.ManaPercent) return;
            if (!Ismelee()) return;
            var min =
                ObjectManager.Get<Obj_AI_Minion>()
                    .Where(x => x.Distance(Player) < 300 && !x.IsDead && x.IsEnemy).ToList();

            if (min.FirstOrDefault() == null)
            {
                minionscirclemelee = null;
                return;
            }

            foreach (var minions in min)
            {
                minionscirclemelee = new Geometry.Polygon.Circle(minions.Position, 300);
                if (E.IsReady() && GetBool("useelm", typeof(bool)))
                {
                    if (minions.Health < EMeleeDamage(minions))
                    {
                        Em.Cast(minions);
                    }
                }
            }

            var count = min.Where(x => minionscirclemelee.IsInside(x));
            var objAiMinions = count as IList<Obj_AI_Minion> ?? count.ToList();
            if (objAiMinions.Count() >= GetValue("minhitwq"))
            {
                if (W.IsReady() && GetBool("usewlm", typeof(bool)))
                W.Cast();

                if (Q.IsReady() && GetBool("useqlm", typeof(bool)))
                    Qm.Cast(objAiMinions.FirstOrDefault());
            }
        }
Esempio n. 20
0
        private static void InterceptionQ(Obj_AI_Hero Enemy)
        {
            Geometry.Polygon.Circle Qspellpoly = new Geometry.Polygon.Circle(PreCastPos(Enemy, 0.6f), 130f);

            Paths subjs = new Paths();
            foreach (var bla in WPPolygon(Enemy).ToPolygons())
            {
                subjs.Add(bla.ToClipperPath());
            }

            Paths clips = new Paths(1);
            clips.Add(Qspellpoly.ToClipperPath());

            Paths solution = new Paths();
            Clipper c = new Clipper();
            c.AddPaths(subjs, PolyType.ptSubject, true);
            c.AddPaths(clips, PolyType.ptClip, true);
            c.Execute(ClipType.ctIntersection, solution);

            foreach (var bli in solution.ToPolygons())
            {
                bli.Draw(System.Drawing.Color.Blue);
            }
        }
Esempio n. 21
0
        private static void Laneclearrange()
        {
            if (GetValue("minmana") > Player.ManaPercent) return;
            var min =
                ObjectManager.Get<Obj_AI_Minion>()
                    .Where(x => x.Distance(Player) < Q.Range -200 && !x.IsDead && x.IsEnemy && x.IsTargetable);

            var objAiMinions = min as IList<Obj_AI_Minion> ?? min.ToList();
            foreach (var minions in objAiMinions)
            {
                minionscircle = new Geometry.Polygon.Circle(minions.Position, 250);
            }

            var count =objAiMinions.Where(x => minionscircle.IsInside(x));

            if (count.Count() < GetValue("minhitwq")) return;
            if (!Ismelee() && Q.IsReady() && GetBool("useqlr", typeof(bool)))
                Q.Cast(minionscircle.Center);
        }
Esempio n. 22
0
 private Tuple<int, List<Obj_AI_Hero>> GetHits(Spell spell, float overrideWidth = -1f)
 {
     try
     {
         var width = overrideWidth > 0 ? overrideWidth : spell.Width;
         var hits = new List<Obj_AI_Hero>();
         var positions = (from t in GameObjects.EnemyHeroes
             where t.IsValidTarget(width * 4, true, spell.RangeCheckFrom)
             let prediction = spell.GetPrediction(t)
             where prediction.Hitchance >= HitChance.High
             where
                 Utils.IsImmobile(t) || Utils.IsSlowed(t) || t.Distance(Ball.Position) < spell.Width * 0.75 ||
                 t.Distance(Ball.Position) < spell.Width && t.IsFacing(Ball.Position, 120f)
             select new CPrediction.Position(t, prediction.UnitPosition)).ToList();
         if (positions.Any())
         {
             var circle = new Geometry.Polygon.Circle(Ball.Position, width);
             hits.AddRange(
                 from position in positions
                 where
                     !position.Hero.IsDashing() ||
                     (position.Hero.Distance(Ball.Position) >= 100f &&
                      position.Hero.Position.Distance(Ball.Position) >
                      position.Hero.GetDashInfo().EndPos.Distance(Ball.Position) - 50f)
                 where circle.IsInside(position.UnitPosition)
                 select position.Hero);
             return new Tuple<int, List<Obj_AI_Hero>>(hits.Count, hits);
         }
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return new Tuple<int, List<Obj_AI_Hero>>(0, null);
 }
Esempio n. 23
0
        private Tuple<int, List<Obj_AI_Hero>> GetHits(Spell spell,
            float overrideWidth = -1f,
            Vector3 fromCheck = default(Vector3))
        {
            try
            {
                if (fromCheck.Equals(default(Vector3)))
                {
                    fromCheck = Ball.Position;
                }

                var input = new PredictionInput
                {
                    Collision = true,
                    CollisionObjects = new[] { CollisionableObjects.YasuoWall },
                    From = fromCheck,
                    RangeCheckFrom = fromCheck,
                    Type = spell.Type,
                    Radius = spell.Width,
                    Delay = spell.Delay,
                    Speed = spell.Speed,
                    Range = spell.Range,
                    Aoe = true
                };

                var width = overrideWidth > 0 ? overrideWidth : spell.Width;
                var hits = new List<Obj_AI_Hero>();
                var positions = new List<CPrediction.Position>();
                foreach (var t in GameObjects.EnemyHeroes)
                {
                    if (t.IsValidTarget(width * 4, true, fromCheck))
                    {
                        input.Unit = t;
                        var prediction = Prediction.GetPrediction(input);
                        if (prediction.Hitchance >= HitChance.High)
                        {
                            if (Utils.IsImmobile(t) || Utils.IsSlowed(t) || t.Distance(fromCheck) < spell.Width * 0.75 ||
                                t.Distance(fromCheck) < spell.Width &&
                                (fromCheck.Distance(Ball.Position) > 100 || t.IsFacing(fromCheck, 120f)))
                            {
                                positions.Add(new CPrediction.Position(t, prediction.UnitPosition));
                            }
                        }
                    }
                }
                if (positions.Any())
                {
                    var circle = new Geometry.Polygon.Circle(fromCheck, width);
                    hits.AddRange(
                        from position in positions
                        where
                            !position.Hero.IsDashing() ||
                            (position.Hero.Distance(fromCheck) >= 100f &&
                             position.Hero.Position.Distance(fromCheck) >
                             position.Hero.GetDashInfo().EndPos.Distance(fromCheck) - 50f)
                        where circle.IsInside(position.UnitPosition)
                        select position.Hero);
                    return new Tuple<int, List<Obj_AI_Hero>>(hits.Count, hits);
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
            return new Tuple<int, List<Obj_AI_Hero>>(0, new List<Obj_AI_Hero>());
        }
Esempio n. 24
0
        private bool ELogic(Obj_AI_Hero mainTarget, List<Obj_AI_Base> targets, HitChance hitChance, int minHits)
        {
            try
            {
                var input = new PredictionInput
                {
                    Range = ELength,
                    Delay = E.Delay,
                    Radius = E.Width,
                    Speed = E.Speed,
                    Type = E.Type
                };
                var input2 = new PredictionInput
                {
                    Range = E.Range + ELength,
                    Delay = E.Delay,
                    Radius = E.Width,
                    Speed = E.Speed,
                    Type = E.Type
                };
                var startPos = Vector3.Zero;
                var endPos = Vector3.Zero;
                var hits = 0;
                targets = targets.Where(t => t.IsValidTarget(E.Range + ELength + E.Width * 1.1f)).ToList();
                var targetCount = targets.Count;

                foreach (var target in targets)
                {
                    bool containsTarget;
                    var lTarget = target;
                    if (target.Distance(Player.Position) <= E.Range)
                    {
                        containsTarget = mainTarget == null || lTarget.NetworkId == mainTarget.NetworkId;
                        var cCastPos = target.Position;
                        foreach (var t in targets.Where(t => t.NetworkId != lTarget.NetworkId))
                        {
                            var count = 1;
                            var cTarget = t;
                            input.Unit = t;
                            input.From = cCastPos;
                            input.RangeCheckFrom = cCastPos;
                            var pred = Prediction.GetPrediction(input);
                            if (pred.Hitchance >= (hitChance - 1))
                            {
                                count++;
                                if (!containsTarget)
                                {
                                    containsTarget = t.NetworkId == mainTarget.NetworkId;
                                }
                                var rect = new Geometry.Polygon.Rectangle(
                                    cCastPos.To2D(), cCastPos.Extend(pred.CastPosition, ELength).To2D(), E.Width);
                                foreach (var c in
                                    targets.Where(
                                        c => c.NetworkId != cTarget.NetworkId && c.NetworkId != lTarget.NetworkId))
                                {
                                    input.Unit = c;
                                    var cPredPos = c.Type == GameObjectType.obj_AI_Minion
                                        ? c.Position
                                        : Prediction.GetPrediction(input).UnitPosition;
                                    if (
                                        new Geometry.Polygon.Circle(
                                            cPredPos,
                                            (c.Type == GameObjectType.obj_AI_Minion && c.IsMoving
                                                ? (c.BoundingRadius / 2f)
                                                : (c.BoundingRadius) * 0.9f)).Points.Any(p => rect.IsInside(p)))
                                    {
                                        count++;
                                        if (!containsTarget && c.NetworkId == mainTarget.NetworkId)
                                        {
                                            containsTarget = true;
                                        }
                                    }
                                }
                                if (count > hits && containsTarget)
                                {
                                    hits = count;
                                    startPos = cCastPos;
                                    endPos = cCastPos.Extend(pred.CastPosition, ELength);
                                    if (hits == targetCount)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                        if (endPos.Equals(Vector3.Zero) && containsTarget)
                        {
                            startPos = target.IsFacing(Player) && IsSpellUpgraded(E)
                                ? Player.Position.Extend(cCastPos, Player.Distance(cCastPos) - (ELength / 10f))
                                : cCastPos;
                            endPos = Player.Position.Extend(cCastPos, ELength);
                            hits = 1;
                        }
                    }
                    else
                    {
                        input2.Unit = lTarget;
                        var castPos = Prediction.GetPrediction(input2).CastPosition;
                        var sCastPos = Player.Position.Extend(castPos, E.Range);

                        var extDist = ELength / 4f;
                        var circle =
                            new Geometry.Polygon.Circle(Player.Position, sCastPos.Distance(Player.Position), 45).Points
                                .Where(p => p.Distance(sCastPos) < extDist).OrderBy(p => p.Distance(lTarget));
                        foreach (var point in circle)
                        {
                            input2.From = point.To3D();
                            input2.RangeCheckFrom = point.To3D();
                            input2.Range = ELength;
                            var pred2 = Prediction.GetPrediction(input2);
                            if (pred2.Hitchance >= hitChance)
                            {
                                containsTarget = mainTarget == null || lTarget.NetworkId == mainTarget.NetworkId;
                                var count = 1;
                                var rect = new Geometry.Polygon.Rectangle(
                                    point, point.To3D().Extend(pred2.CastPosition, ELength).To2D(), E.Width);
                                foreach (var c in targets.Where(t => t.NetworkId != lTarget.NetworkId))
                                {
                                    input2.Unit = c;
                                    var cPredPos = c.Type == GameObjectType.obj_AI_Minion
                                        ? c.Position
                                        : Prediction.GetPrediction(input2).UnitPosition;
                                    if (
                                        new Geometry.Polygon.Circle(
                                            cPredPos,
                                            (c.Type == GameObjectType.obj_AI_Minion && c.IsMoving
                                                ? (c.BoundingRadius / 2f)
                                                : (c.BoundingRadius) * 0.9f)).Points.Any(p => rect.IsInside(p)))
                                    {
                                        count++;
                                        if (!containsTarget && c.NetworkId == mainTarget.NetworkId)
                                        {
                                            containsTarget = true;
                                        }
                                    }
                                }
                                if (count > hits && containsTarget ||
                                    count == hits && containsTarget && mainTarget != null &&
                                    point.Distance(mainTarget.Position) < startPos.Distance(mainTarget.Position))
                                {
                                    hits = count;
                                    startPos = point.To3D();
                                    endPos = startPos.Extend(pred2.CastPosition, ELength);
                                    if (hits == targetCount)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (hits == targetCount)
                    {
                        break;
                    }
                }
                if (hits >= minHits && !startPos.Equals(Vector3.Zero) && !endPos.Equals(Vector3.Zero))
                {
                    if (startPos.Distance(Player.Position) > E.Range)
                    {
                        startPos = Player.Position.Extend(startPos, E.Range);
                    }
                    if (startPos.Distance(endPos) > ELength)
                    {
                        endPos = startPos.Extend(endPos, ELength);
                    }
                    E.Cast(startPos, endPos);
                    return true;
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
            return false;
        }
Esempio n. 25
0
 private Vector3 GetRealPosition(Vector3 end)
 {
     if (end.IsWall())
     {
         for (var i = 0; i < 500; i = i + 2)
         {
             List<IntPoint> circlePath = new Geometry.Polygon.Circle(end, i, 10).ToClipperPath();
             foreach (var item in circlePath)
             {
                 Vector3 newPos = new Vector2(item.X, item.Y).To3D2();
                 if (!newPos.IsWall())
                 {
                     return newPos;
                 }
             }
         }
     }
     return end;
 }
Esempio n. 26
0
 private int GetWHits(Obj_AI_Base target, List<Obj_AI_Base> targets = null, CardColor color = CardColor.Gold)
 {
     try
     {
         if (targets != null && color == CardColor.Red)
         {
             targets = targets.Where(t => t.IsValidTarget((W.Range + W.Width) * 1.5f)).ToList();
             var pred = W.GetPrediction(target);
             if (pred.Hitchance >= HitChance.Medium)
             {
                 var circle = new Geometry.Polygon.Circle(pred.UnitPosition, target.BoundingRadius + WRedRadius);
                 return 1 + (from t in targets.Where(x => x.NetworkId != target.NetworkId)
                     let pred2 = W.GetPrediction(t)
                     where pred2.Hitchance >= HitChance.Medium
                     select new Geometry.Polygon.Circle(pred2.UnitPosition, t.BoundingRadius * 0.9f)).Count(
                         circle2 => circle2.Points.Any(p => circle.IsInside(p)));
             }
         }
         if (W.IsInRange(target))
         {
             return 1;
         }
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return 0;
 }
Esempio n. 27
0
        public static void Interceptiontest(Obj_AI_Hero Enemy, float delay, float Range, float varRange)
        {
            Geometry.Polygon.Circle Qspellpoly = new Geometry.Polygon.Circle(LastQCastpos, Q.Width);
            Qspellpoly.Draw(System.Drawing.Color.Khaki);

            Paths subjs = new Paths();
            foreach (var Waypoint in WPPolygon(Enemy, delay).ToPolygons())
            {
                subjs.Add(Waypoint.ToClipperPath());
            }

            Paths clips = new Paths(1);
            clips.Add(Qspellpoly.ToClipperPath());

            Paths solution = new Paths();
            Clipper c = new Clipper();
            c.AddPaths(subjs, PolyType.ptSubject, true);
            c.AddPaths(clips, PolyType.ptClip, true);
            c.Execute(ClipType.ctIntersection, solution);

            foreach (var bli in solution.ToPolygons())
            {
                bli.Draw(System.Drawing.Color.Blue);
            }
        }