Пример #1
0
 public static Result Line(Spell spell,
                           Obj_AI_Hero target,
                           HitChance hitChance,
                           bool boundingRadius = true,
                           bool maxRange       = true)
 {
     try
     {
         if (spell == null || target == null)
         {
             return(new Result(Vector3.Zero, new List <Obj_AI_Hero>()));
         }
         var range = (spell.IsChargedSpell && maxRange ? spell.ChargedMaxRange : spell.Range) +
                     spell.Width * 0.9f +
                     (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();
         if (positions.Any())
         {
             var hits = new List <Obj_AI_Hero>();
             var pred = spell.GetPrediction(target);
             if (pred.Hitchance >= hitChance)
             {
                 hits.Add(target);
                 var rect = new Geometry.Polygon.Rectangle(
                     spell.From, spell.From.Extend(pred.CastPosition, range), spell.Width);
                 if (boundingRadius)
                 {
                     hits.AddRange(
                         from point in positions.Where(p => p.Hero.NetworkId != target.NetworkId)
                         let circle =
                             new Geometry.Polygon.Circle(
                                 point.UnitPosition, point.Hero.BoundingRadius * BoundingRadiusMultiplicator)
                             where circle.Points.Any(p => rect.IsInside(p))
                             select point.Hero);
                 }
                 else
                 {
                     hits.AddRange(
                         from position in positions
                         where rect.IsInside(position.UnitPosition)
                         select position.Hero);
                 }
                 return(new Result(pred.CastPosition, hits));
             }
         }
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return(new Result(Vector3.Zero, new List <Obj_AI_Hero>()));
 }
 public static Obj_AI_Hero GetTargetNoCollision(Spell spell,
                                                bool ignoreShields = true,
                                                Vector3 from       = default(Vector3),
                                                IEnumerable <Obj_AI_Hero> ignoredChampions = null)
 {
     try
     {
         return
             (GetTargets(spell.Range, spell.DamageType, ignoreShields, from, ignoredChampions)
              .FirstOrDefault(t => spell.GetPrediction(t).Hitchance != HitChance.Collision));
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return(null);
 }
Пример #3
0
        private static void LineFarm(Spell spell, List <Obj_AI_Base> minions, int min, float overrideWidth = -1f)
        {
            if (!spell.IsReady() || minions.Count == 0)
            {
                return;
            }
            var spellWidth = overrideWidth > 0 ? overrideWidth : spell.Width;
            var totalHits  = 0;
            var castPos    = Vector3.Zero;

            var positions = (from minion in minions
                             let pred = spell.GetPrediction(minion)
                                        where pred.Hitchance >= HitChance.Medium
                                        select new Tuple <Obj_AI_Base, Vector3>(minion, pred.UnitPosition)).ToList();

            if (positions.Any())
            {
                foreach (var position in positions)
                {
                    var rect = new Geometry.Polygon.Rectangle(
                        ObjectManager.Player.Position, ObjectManager.Player.Position.Extend(position.Item2, spell.Range),
                        spellWidth);
                    var count =
                        positions.Select(
                            position2 =>
                            new Geometry.Polygon.Circle(position2.Item2, position2.Item1.BoundingRadius * 0.9f))
                        .Count(circle => circle.Points.Any(p => rect.IsInside(p)));
                    if (count > totalHits)
                    {
                        totalHits = count;
                        castPos   = position.Item2;
                    }
                    if (totalHits == minions.Count)
                    {
                        break;
                    }
                }
                if (!castPos.Equals(Vector3.Zero) && totalHits >= min)
                {
                    spell.Cast(castPos);
                }
            }
        }
Пример #4
0
        private static void CircleFarm(Spell spell, List <Obj_AI_Base> minions, int min, float overrideWidth = -1f)
        {
            if (!spell.IsReady() || minions.Count == 0)
            {
                return;
            }
            var spellWidth = (overrideWidth > 0 ? overrideWidth : spell.Width) + minions.Average(m => m.BoundingRadius);
            var points     = (from minion in minions
                              select spell.GetPrediction(minion)
                              into pred
                              where pred.Hitchance >= HitChance.Medium
                              select pred.UnitPosition.To2D()).ToList();

            if (points.Any())
            {
                var possibilities = ListExtensions.ProduceEnumeration(points).Where(p => p.Count >= min).ToList();
                if (possibilities.Any())
                {
                    var hits   = 0;
                    var radius = float.MaxValue;
                    var pos    = Vector3.Zero;
                    foreach (var possibility in possibilities)
                    {
                        var mec = MEC.GetMec(possibility);
                        if (mec.Radius < spellWidth)
                        {
                            if (possibility.Count > hits || possibility.Count == hits && radius > mec.Radius)
                            {
                                hits   = possibility.Count;
                                radius = mec.Radius;
                                pos    = mec.Center.To3D();
                            }
                        }
                    }
                    if (hits >= min && !pos.Equals(Vector3.Zero))
                    {
                        spell.Cast(pos);
                    }
                }
            }
        }
Пример #5
0
        public static void SkillShot(Obj_AI_Hero target,
                                     Spell spell,
                                     HitChance hitChance,
                                     bool boundingRadius = true,
                                     bool maxRange       = true)
        {
            if (!spell.IsReady() || target == null)
            {
                return;
            }

            if (spell.Type == SkillshotType.SkillshotLine)
            {
                var prediction = CPrediction.Line(spell, target, hitChance, boundingRadius, maxRange);
                if (prediction.TotalHits >= 1)
                {
                    spell.Cast(prediction.CastPosition);
                }
            }
            else if (spell.Type == SkillshotType.SkillshotCircle)
            {
                var prediction = CPrediction.Circle(spell, target, hitChance);
                if (prediction.TotalHits >= 1)
                {
                    spell.Cast(prediction.CastPosition);
                }
            }
            else
            {
                var prediction = spell.GetPrediction(target);
                if (prediction.Hitchance >= hitChance)
                {
                    spell.Cast(prediction.CastPosition);
                }
            }
        }
Пример #6
0
        public static void SkillShot(Obj_AI_Hero target,
            Spell spell,
            HitChance hitChance,
            bool boundingRadius = true,
            bool maxRange = true)
        {
            if (!spell.IsReady() || target == null)
            {
                return;
            }

            if (spell.Type == SkillshotType.SkillshotLine)
            {
                var prediction = CPrediction.Line(spell, target, hitChance, boundingRadius, maxRange);
                if (prediction.TotalHits >= 1)
                {
                    spell.Cast(prediction.CastPosition);
                }
            }
            else if (spell.Type == SkillshotType.SkillshotCircle)
            {
                var prediction = CPrediction.Circle(spell, target, hitChance);
                if (prediction.TotalHits >= 1)
                {
                    spell.Cast(prediction.CastPosition);
                }
            }
            else
            {
                var prediction = spell.GetPrediction(target);
                if (prediction.Hitchance >= hitChance)
                {
                    spell.Cast(prediction.CastPosition);
                }
            }
        }
Пример #7
0
        public static Result Circle(Spell spell,
                                    Obj_AI_Hero target,
                                    HitChance hitChance,
                                    bool boundingRadius = true,
                                    bool extended       = 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 + (extended ? spell.Width * 0.85f : 0) +
                             (boundingRadius ? target.BoundingRadius * BoundingRadiusMultiplicator : 0);
                var positions = (from t in GameObjects.EnemyHeroes
                                 where t.IsValidTarget(range * 1.5f, true, spell.RangeCheckFrom)
                                 let prediction = spell.GetPrediction(t)
                                                  where prediction.Hitchance >= hitChance
                                                  select new Position(t, prediction.UnitPosition)).ToList();
                var spellWidth = spell.Width;
                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>()));
        }
        public static Result Circle(Spell spell,
            Obj_AI_Hero target,
            HitChance hitChance,
            bool boundingRadius = true,
            bool extended = 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 + (extended ? spell.Width * 0.85f : 0) +
                            (boundingRadius ? target.BoundingRadius * BoundingRadiusMultiplicator : 0);
                var positions = (from t in GameObjects.EnemyHeroes
                    where t.IsValidTarget(range * 1.5f, true, spell.RangeCheckFrom)
                    let prediction = spell.GetPrediction(t)
                    where prediction.Hitchance >= hitChance
                    select new Position(t, prediction.UnitPosition)).ToList();
                var spellWidth = spell.Width;
                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>());
        }
 public static Result Line(Spell spell,
     Obj_AI_Hero target,
     HitChance hitChance,
     bool boundingRadius = true,
     bool maxRange = true)
 {
     try
     {
         if (spell == null || target == null)
         {
             return new Result(Vector3.Zero, new List<Obj_AI_Hero>());
         }
         var range = (spell.IsChargedSpell && maxRange ? spell.ChargedMaxRange : spell.Range) +
                     spell.Width * 0.9f +
                     (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();
         if (positions.Any())
         {
             var hits = new List<Obj_AI_Hero>();
             var pred = spell.GetPrediction(target);
             if (pred.Hitchance >= hitChance)
             {
                 hits.Add(target);
                 var rect = new Geometry.Polygon.Rectangle(
                     spell.From, spell.From.Extend(pred.CastPosition, range), spell.Width);
                 if (boundingRadius)
                 {
                     hits.AddRange(
                         from point in positions.Where(p => p.Hero.NetworkId != target.NetworkId)
                         let circle =
                             new Geometry.Polygon.Circle(
                                 point.UnitPosition, point.Hero.BoundingRadius * BoundingRadiusMultiplicator)
                         where circle.Points.Any(p => rect.IsInside(p))
                         select point.Hero);
                 }
                 else
                 {
                     hits.AddRange(
                         from position in positions
                         where rect.IsInside(position.UnitPosition)
                         select position.Hero);
                 }
                 return new Result(pred.CastPosition, hits);
             }
         }
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return new Result(Vector3.Zero, new List<Obj_AI_Hero>());
 }
Пример #10
0
        private static void LineFarm(Spell spell, List<Obj_AI_Base> minions, int min, float overrideWidth = -1f)
        {
            var spellWidth = overrideWidth > 0 ? overrideWidth : spell.Width;
            var totalHits = 0;
            var castPos = Vector3.Zero;

            var positions = (from minion in minions
                let pred = spell.GetPrediction(minion)
                where pred.Hitchance >= HitChance.Medium
                select new Tuple<Obj_AI_Base, Vector3>(minion, pred.UnitPosition)).ToList();

            if (positions.Any())
            {
                foreach (var position in positions)
                {
                    var rect = new Geometry.Polygon.Rectangle(
                        ObjectManager.Player.Position, ObjectManager.Player.Position.Extend(position.Item2, spell.Range),
                        spellWidth);
                    var count =
                        positions.Select(
                            position2 =>
                                new Geometry.Polygon.Circle(position2.Item2, position2.Item1.BoundingRadius * 0.9f))
                            .Count(circle => circle.Points.Any(p => rect.IsInside(p)));
                    if (count > totalHits)
                    {
                        totalHits = count;
                        castPos = position.Item2;
                    }
                    if (totalHits == minions.Count)
                    {
                        break;
                    }
                }
                if (!castPos.Equals(Vector3.Zero) && totalHits >= min)
                {
                    spell.Cast(castPos);
                }
            }
        }
Пример #11
0
 private static void CircleFarm(Spell spell, List<Obj_AI_Base> minions, int min, float overrideWidth = -1f)
 {
     var spellWidth = (overrideWidth > 0 ? overrideWidth : spell.Width) + minions.Average(m => m.BoundingRadius);
     var points = (from minion in minions
         select spell.GetPrediction(minion)
         into pred
         where pred.Hitchance >= HitChance.Medium
         select pred.UnitPosition.To2D()).ToList();
     if (points.Any())
     {
         var possibilities = ListExtensions.ProduceEnumeration(points).Where(p => p.Count >= min).ToList();
         if (possibilities.Any())
         {
             var hits = 0;
             var radius = float.MaxValue;
             var pos = Vector3.Zero;
             foreach (var possibility in possibilities)
             {
                 var mec = MEC.GetMec(possibility);
                 if (mec.Radius < spellWidth)
                 {
                     if (possibility.Count > hits || possibility.Count == hits && radius > mec.Radius)
                     {
                         hits = possibility.Count;
                         radius = mec.Radius;
                         pos = mec.Center.To3D();
                     }
                 }
             }
             if (hits >= min && !pos.Equals(Vector3.Zero))
             {
                 spell.Cast(pos);
             }
         }
     }
 }