コード例 #1
0
ファイル: TwistedFate.cs プロジェクト: 4859aa/LeagueSharp-Dev
 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;
 }
コード例 #2
0
ファイル: Orianna.cs プロジェクト: k88173/LeagueSharp-Dev
 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);
 }
コード例 #3
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;
 }
コード例 #4
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>());
        }
コード例 #5
0
ファイル: Orianna.cs プロジェクト: k88173/LeagueSharp-Dev
        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);
        }
コード例 #6
0
ファイル: Jayce.cs プロジェクト: omerolmaz/LeagueSharp
        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);
        }
コード例 #7
0
ファイル: Orianna.cs プロジェクト: jayblah/Lizzaran
        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>());
        }
コード例 #8
0
ファイル: Jayce.cs プロジェクト: omerolmaz/LeagueSharp
        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());
            }
        }
コード例 #9
0
ファイル: Orianna.cs プロジェクト: hprobotic/LeagueSharp-Dev
 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);
 }
コード例 #10
0
ファイル: AOESpellManager.cs プロジェクト: leenam0910/LSharp
        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;
                }
            }
        }
コード例 #11
0
ファイル: AOESpellManager.cs プロジェクト: leenam0910/LSharp
        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;
                }
            }
        }
コード例 #12
0
ファイル: Jinx.cs プロジェクト: JelloBeans/LeagueSharp-Dev
        /// <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);
        }