public static int HitNumber(this Spell.Skillshot.BestPosition self, Spell.Skillshot spell)
 {
     if(spell.Type == EloBuddy.SDK.Enumerations.SkillShotType.Cone)
     {
         Geometry.Polygon.Sector cone = new Geometry.Polygon.Sector(Program.JarvanIV.Position, Program.JarvanIV.Position - self.CastPosition, spell.ConeAngleDegrees, spell.Range);
         return EntityManager.Heroes.Enemies.Where(a => a.MeetsCriteria() && cone.IsInside(a)).Count();
     }
     return 0;
 }
Example #2
0
        public static void CastExtendedQ()
        {
            var target = TargetSelector.GetTarget(Q.Range, DamageType.Magical);
            if (target == null || target.IsZombie) return;
               /* var t = TargetSelector.SelectedTarget != null &&
                    TargetSelector.SelectedTarget.Distance(ObjectManager.Player) < Q1.Range
                ? TargetSelector.SelectedTarget
                : TargetSelector.GetTarget(Q1.Range, DamageType.Physical);

            if (!t.IsValidTarget(Q1.Range) ||
                t.IsZombie ||
                Orbwalker.IsAutoAttacking ||
                t.HasBuffOfType(BuffType.Invulnerability))
                return;
            {
                var q1Pred = Q1.GetPrediction(t);
                var q1Col = q1Pred.CollisionObjects;
                if (!q1Col.Any()) return;
                {
                    var qMinion = q1Col.Last();
                    if (!qMinion.IsValidTarget(Q.Range)) return;
                    {
                        if (qMinion.Distance(q1Pred.CastPosition) < 380 &&
                            qMinion.Distance(t.Position) < 380)
                        {
                            Q.Cast(qMinion);
                        }
                    }
                }
            }*/
              if (Q.IsReady() && target.IsValidTarget(Q1.Range))
            {
                var minionQ =
                    EntityManager.MinionsAndMonsters.GetLaneMinions().OrderByDescending(m => m.Health)
                        .FirstOrDefault(m => m.IsValidTarget(Q.Range) && m.Health <= Q.GetRealDamage(m));
                if (minionQ != null)
                {
                    const float rad = (float)Math.PI / 180f;

                    var cone = new Geometry.Polygon.Sector(target.ServerPosition, target.ServerPosition.Extend(Player, -400).To3D(), 60f * rad, 250f);

                    if (cone.IsInside(target))
                    {
                        Q.Cast(minionQ);
                    }
                }
            }
        }
Example #3
0
        private static void GameObject_OnCreate(GameObject sender, EventArgs args)
        {
            var missile = sender as MissileClient;
            if (missile == null) return;

            var missileInfo =
                SpellDatabase.GetSpellInfoList(missile.SpellCaster).FirstOrDefault(s => s.RealSlot == missile.Slot);
            if (missileInfo == null) return;

            switch (missileInfo.Type)
            {
                case SpellType.Self:
                    break;
                case SpellType.Circle:
                    var polCircle = new Geometry.Polygon.Circle(missile.Position, missileInfo.Radius);
                    Missiles.Add(missile, polCircle);
                    break;
                case SpellType.Line:
                    var polLine = new Geometry.Polygon.Rectangle(missile.StartPosition,
                        missile.StartPosition.Extend(missile.EndPosition, missileInfo.Range).To3D(), 5);
                    Missiles.Add(missile, polLine);
                    break;
                case SpellType.Cone:
                    var polCone = new Geometry.Polygon.Sector(missile.StartPosition, missile.EndPosition, missileInfo.Radius, missileInfo.Range, 80);
                    Missiles.Add(missile, polCone);
                    break;
                case SpellType.Ring:
                    break;
                case SpellType.Arc:
                    break;
                case SpellType.MissileLine:
                    var polMissileLine = new Geometry.Polygon.Rectangle(missile.StartPosition,
                        missile.StartPosition.Extend(missile.EndPosition, missileInfo.Range).To3D(), 5);
                    Missiles.Add(missile, polMissileLine);
                    break;
                case SpellType.MissileAoe:
                    var polMissileAoe = new Geometry.Polygon.Rectangle(missile.StartPosition,
                        missile.StartPosition.Extend(missile.EndPosition, missileInfo.Range).To3D(), 5);
                    Missiles.Add(missile, polMissileAoe);
                    break;
            }

            var polygons = new List<Geometry.Polygon>();
            polygons.AddRange(Missiles.Values);

            Joined = polygons.JoinPolygons();
        }
        public static Vector3 GetBestConeAndLinearCastPosition(this Spell.Skillshot cone, Spell.Skillshot linearSpell, List<Obj_AI_Base> enemies, Vector3 sourcePosition, out int bestHitNumber)
        {
            int radius = (int)cone.Range;

            enemies = enemies.Where(a => a.MeetsCriteria() && a.IsInRange(sourcePosition, radius)).ToList();

            bestHitNumber = 0;
            Vector3 castPosition = Vector3.Zero;

            //if there is nothing that meets the criteria
            if (enemies.Count() == 0)
                return castPosition;

            List<Tuple<Geometry.Polygon.Sector, Vector3>> conePositions = new List<Tuple<Geometry.Polygon.Sector, Vector3>>();

            Vector3 extendingPosition = sourcePosition + new Vector3(0, radius, 0);

            //checks every 15 degrees
            for(int i = 0; i < 24; i++)
            {
                Vector3 endPosition = extendingPosition.To2D().RotateAroundPoint(sourcePosition.To2D(), (float)((i * 15) * Math.PI / 180)).To3D((int)sourcePosition.Z);
                Geometry.Polygon.Sector sector = new Geometry.Polygon.Sector(sourcePosition,
                     endPosition, (float)(cone.ConeAngleDegrees * Math.PI / 180), radius);
                
                conePositions.Add(Tuple.Create(sector, endPosition));
            }

            //order list by most hit by Q1 and Q2
            conePositions = conePositions.OrderByDescending(a => a.Item1.EnemiesHitInSectorAndRectangle(new Geometry.Polygon.Rectangle(sourcePosition, a.Item2, linearSpell.Width), enemies)).ToList();
            //only leave the ones with the highest amount
            conePositions = conePositions.Where(a => a.Item1.EnemiesHitInSectorAndRectangle(new Geometry.Polygon.Rectangle(sourcePosition, a.Item2, linearSpell.Width), enemies) == conePositions[0].Item1.EnemiesHitInSectorAndRectangle(new Geometry.Polygon.Rectangle(sourcePosition, a.Item2, linearSpell.Width), enemies)).ToList();
            //from the ones with the most Sector/Line enemies hit, find the one with the most in the rectangle
            conePositions = conePositions.OrderByDescending(a => new Geometry.Polygon.Rectangle(sourcePosition, a.Item2, linearSpell.Width).EnemiesHitInRectangle(enemies)).ToList();
            //only take the ones with the most enemies
            conePositions = conePositions.Where(a => new Geometry.Polygon.Rectangle(sourcePosition, a.Item2, linearSpell.Width).EnemiesHitInRectangle(enemies) == new Geometry.Polygon.Rectangle(sourcePosition, conePositions[0].Item2, linearSpell.Width).EnemiesHitInRectangle(enemies)).ToList();
            //from the ones with the most sector/line enemies hit AND the most line enemies hit, find the ones with the most sector area
            conePositions = conePositions.OrderByDescending(a => a.Item1.EnemiesHitInSector(enemies)).ToList();

            Tuple<Geometry.Polygon.Sector, Vector3> bestCone = conePositions.First();
            bestHitNumber = bestCone.Item1.EnemiesHitInSectorAndRectangle(new Geometry.Polygon.Rectangle(sourcePosition, bestCone.Item2, linearSpell.Width), enemies);
            
            return sourcePosition.Extend(bestCone.Item2, radius - 1).To3D((int)sourcePosition.Z);
        }
Example #5
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;
            MissilePosition = start;
            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:
                Rectangle = new Geometry.Polygon.Rectangle(Start, CollisionEnd, spellData.Radius);
                break;

            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;

            case SkillShotType.SkillshotArc:
                Arc = new Geometry.Polygon.Arc(start, end,
                                               EvadeManager.SkillShotsExtraRadius + (int)ObjectManager.Player.BoundingRadius, 22);
                break;
            }

            UpdatePolygon();
        }
Example #6
0
        public static Vector3 BestConeCastPosition(this Spell.Skillshot cone, List <Obj_AI_Base> enemies, out int bestHitNumber)
        {
            int radius = (int)cone.Range;

            enemies = enemies.Where(a => a.IsValidTarget() && a.PredictedPositionInTime(cone.CastDelay).IsInRange(Player.Instance.Position, radius)).ToList();

            bestHitNumber = 0;
            Vector3 castPosition = Vector3.Zero;

            //if there is nothing that meets the criteria
            if (enemies.Count() == 0)
            {
                return(castPosition);
            }

            List <Tuple <Geometry.Polygon.Sector, Vector3> > conePositions = new List <Tuple <Geometry.Polygon.Sector, Vector3> >();

            Vector3 extendingPosition = Player.Instance.Position + new Vector3(0, radius, 0);

            //checks every 15 degrees
            for (int i = 0; i < 24; i++)
            {
                Vector3 endPosition = extendingPosition.To2D().RotateAroundPoint(Player.Instance.Position.To2D(),
                                                                                 (float)((i * 15) * Math.PI / 180)).To3D((int)Player.Instance.Position.Z);
                Geometry.Polygon.Sector sector = new Geometry.Polygon.Sector(Player.Instance.Position,
                                                                             endPosition, (float)(cone.ConeAngleDegrees * Math.PI / 180), radius);

                conePositions.Add(Tuple.Create(sector, endPosition));
            }

            //from the ones with the most sector/line enemies hit AND the most line enemies hit, find the ones with the most sector area
            conePositions = conePositions.Where(a => a.Item1.GetEnemiesHitInSector(enemies, cone.CastDelay).Count > 0)
                            .OrderByDescending(a => a.Item1.EnemiesHitInSector(enemies, cone.CastDelay))
                            .ThenBy(a => a.Item1.GetEnemiesHitInSector(enemies, cone.CastDelay)[0].Distance(a.Item1.Points[a.Item1.Points.Count / 2]))
                            .ToList();

            Tuple <Geometry.Polygon.Sector, Vector3> bestCone = conePositions.First();

            bestHitNumber = bestCone.Item1.EnemiesHitInSector(enemies, cone.CastDelay);

            return(Player.Instance.Position.Extend(bestCone.Item2, radius - 1).To3D((int)Player.Instance.Position.Z));
        }
Example #7
0
        private void DravenOnDraw(EventArgs args)
        {
            if (Utilities.Enabled("draw.catch.modes"))
            {
                switch (Initializer.Config.Item("catch.logic", true).GetValue <StringList>().SelectedIndex)
                {
                case 0:     //Sector
                    var sectorpoly = new Geometry.Polygon.Sector(
                        ObjectManager.Player.Position.To2D(),
                        Game.CursorPos.To2D(),
                        100 * (float)Math.PI / 180,
                        Utilities.Slider("catch.radius"));
                    sectorpoly.Draw(Color.Gold);
                    break;

                case 1:     // Circle
                    var circlepoly = new Geometry.Polygon.Circle(ObjectManager.Player.Position.Extend(Game.CursorPos, Utilities.Slider("catch.radius")),
                                                                 Utilities.Slider("catch.radius"));
                    circlepoly.Draw(Color.Gold);
                    break;
                }
            }

            if (Utilities.Enabled("draw.axe.positions"))
            {
                foreach (var axe in AxeSpots)
                {
                    if (CatchableAxes(axe))
                    {
                        Render.Circle.DrawCircle(axe.Object.Position, 100, Color.GreenYellow);
                        Drawing.DrawText(Drawing.WorldToScreen(axe.Object.Position).X - 40, Drawing.WorldToScreen(axe.Object.Position).Y,
                                         Color.Gold, (((float)(axe.EndTick - Environment.TickCount))) + " ms");
                    }
                }
            }
        }
Example #8
0
        private Geometry.Polygon GetFilledPolygon(bool predictPosition = false)
        {
            var basePos = predictPosition ? SpellManager.Q.GetPrediction(Target).UnitPosition : Target.ServerPosition;
            var pos     = basePos + GetPassiveOffset();
            var points  = new List <Vector2>();

            for (var i = 100; i < PolygonRadius; i += 10)
            {
                if (i > PolygonRadius)
                {
                    break;
                }

                var calcRads = PolygonAngle; //PolygonRadius - i < 50 ? PolygonAngle - 20 : PolygonAngle;
                var sector   = new Geometry.Polygon.Sector(basePos, pos, Geometry.DegreeToRadian(calcRads), i, 30);
                sector.UpdatePolygon();
                points.AddRange(sector.Points);
            }

            points.RemoveAll(p => p.Distance(basePos) < 100);
            return(new Geometry.Polygon {
                Points = points.Distinct().ToList()
            });
        }
Example #9
0
        public static void CastE(List<Obj_AI_Base> enemies)
        {
            if (!Program.E.IsReady() || hasDoneActionThisTick || !Vi.IsAutoCanceling(enemies, true))
                return;

            int bestCount = 0;
            Obj_AI_Base bestEnemy = null;
            foreach (Obj_AI_Base enemy in EntityManager.Enemies.Where(a => a.MeetsCriteria() && a.IsInRange(Vi, Program.E.Range)).ToList())
            {
                Geometry.Polygon.Sector cone = new Geometry.Polygon.Sector(Vi.Position, enemy.Position, (float)(45 * Math.PI / 180), 600);

                List<Obj_AI_Base> enemiesHitByE = enemies.Where(a => cone.IsInside(a) && a != enemy).ToList();
                if(!enemiesHitByE.Contains(enemy))
                    enemiesHitByE.Add(enemy);
                if(bestCount < enemiesHitByE.Count())
                {
                    bestCount = enemiesHitByE.Count();
                    bestEnemy = enemy;
                }
            }   
            if (bestEnemy != null && bestCount > 0 && bestEnemy.IsInRange(Vi, Vi.GetAutoAttackRange()))
            {
                Orbwalker.ResetAutoAttack();
                hasDoneActionThisTick = Program.E.Cast();
                Orbwalker.ForcedTarget = bestEnemy;
            }
        }
Example #10
0
        private void QLogic()
        {
            try
            {
                var target = TargetSelector.GetTarget(Q.Range);
                if (target != null)
                {
                    Q.CastOnUnit(target);
                }
                else if (Menu.Item(Menu.Name + ".miscellaneous.extended-q").GetValue <bool>())
                {
                    target = TargetSelector.GetTarget(Q1);
                    if (target != null)
                    {
                        var heroPositions = (from t in GameObjects.EnemyHeroes
                                             where t.IsValidTarget(Q1.Range)
                                             let prediction = Q.GetPrediction(t)
                                                              select new CPrediction.Position(t, prediction.UnitPosition)).Where(
                            t => t.UnitPosition.Distance(Player.Position) < Q1.Range).ToList();
                        if (heroPositions.Any())
                        {
                            var minions = MinionManager.GetMinions(
                                Q1.Range, MinionTypes.All, MinionTeam.NotAlly, MinionOrderTypes.None);

                            if (minions.Any(m => m.IsMoving) && !heroPositions.Any(h => HasPassiveDebuff(h.Hero)))
                            {
                                return;
                            }

                            var outerMinions   = minions.Where(m => m.Distance(Player) > Q.Range).ToList();
                            var innerPositions = minions.Where(m => m.Distance(Player) < Q.Range).ToList();
                            foreach (var minion in innerPositions)
                            {
                                var lMinion  = minion;
                                var coneBuff = new Geometry.Polygon.Sector(
                                    minion.Position,
                                    Player.Position.Extend(minion.Position, Player.Distance(minion) + Q.Range * 0.5f),
                                    (float)(40 * Math.PI / 180), Q1.Range - Q.Range);
                                var coneNormal = new Geometry.Polygon.Sector(
                                    minion.Position,
                                    Player.Position.Extend(minion.Position, Player.Distance(minion) + Q.Range * 0.5f),
                                    (float)(60 * Math.PI / 180), Q1.Range - Q.Range);
                                foreach (var enemy in
                                         heroPositions.Where(
                                             m => m.UnitPosition.Distance(lMinion.Position) < Q1.Range - Q.Range))
                                {
                                    if (coneBuff.IsInside(enemy.Hero) && HasPassiveDebuff(enemy.Hero))
                                    {
                                        Q.CastOnUnit(minion);
                                        return;
                                    }
                                    if (coneNormal.IsInside(enemy.UnitPosition))
                                    {
                                        var insideCone =
                                            outerMinions.Where(m => coneNormal.IsInside(m.Position)).ToList();
                                        if (!insideCone.Any() ||
                                            enemy.UnitPosition.Distance(minion.Position) <
                                            insideCone.Select(
                                                m => m.Position.Distance(minion.Position) - m.BoundingRadius)
                                            .DefaultIfEmpty(float.MaxValue)
                                            .Min())
                                        {
                                            Q.CastOnUnit(minion);
                                            return;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
        }
Example #11
0
 public static List <Obj_AI_Base> GetEnemiesHitInSector(this Geometry.Polygon.Sector sector, List <Obj_AI_Base> enemies, int delay)
 {
     return(enemies.Where(a => a.IsValidTarget() && sector.IsInside(a.PredictedPositionInTime(delay))).ToList());
 }
Example #12
0
        //--------------------------------------GetBestWPos----------------------------------------

        Vector3 GetBestWPos(bool minions = false, AIHeroClient Target = null)
        {
            if (minions)
            {
                var CS = new List<Geometry.Polygon.Sector>();

                var Minion = EntityManager.MinionsAndMonsters.EnemyMinions.Where(it => it.IsValidTarget(W.Range)).OrderByDescending(it => it.Distance(Player)).FirstOrDefault();

                if (Minion == null) return default(Vector3);

                var Vectors = new List<Vector3>() { new Vector3(Minion.ServerPosition.X + 550, Minion.ServerPosition.Y, Minion.ServerPosition.Z), new Vector3(Minion.ServerPosition.X - 550, Minion.ServerPosition.Y, Minion.ServerPosition.Z), new Vector3(Minion.ServerPosition.X, Minion.ServerPosition.Y + 550, Minion.ServerPosition.Z), new Vector3(Minion.ServerPosition.X, Minion.ServerPosition.Y - 550, Minion.ServerPosition.Z), new Vector3(Minion.ServerPosition.X + 230, Minion.ServerPosition.Y, Minion.ServerPosition.Z), new Vector3(Minion.ServerPosition.X - 230, Minion.ServerPosition.Y, Minion.ServerPosition.Z), new Vector3(Minion.ServerPosition.X, Minion.ServerPosition.Y + 230, Minion.ServerPosition.Z), new Vector3(Minion.ServerPosition.X, Minion.ServerPosition.Y - 230, Minion.ServerPosition.Z), Minion.ServerPosition };

                var CS1 = new Geometry.Polygon.Sector(Player.Position, Vectors[0], ANGLE, 585);
                var CS2 = new Geometry.Polygon.Sector(Player.Position, Vectors[1], ANGLE, 585);
                var CS3 = new Geometry.Polygon.Sector(Player.Position, Vectors[2], ANGLE, 585);
                var CS4 = new Geometry.Polygon.Sector(Player.Position, Vectors[3], ANGLE, 585);
                var CS5 = new Geometry.Polygon.Sector(Player.Position, Vectors[4], ANGLE, 585);
                var CS6 = new Geometry.Polygon.Sector(Player.Position, Vectors[5], ANGLE, 585);
                var CS7 = new Geometry.Polygon.Sector(Player.Position, Vectors[6], ANGLE, 585);
                var CS8 = new Geometry.Polygon.Sector(Player.Position, Vectors[7], ANGLE, 585);
                var CS9 = new Geometry.Polygon.Sector(Player.Position, Vectors[8], ANGLE, 585);

                CS.Add(CS1);
                CS.Add(CS2);
                CS.Add(CS3);
                CS.Add(CS4);
                CS.Add(CS5);
                CS.Add(CS6);
                CS.Add(CS7);
                CS.Add(CS8);
                CS.Add(CS9);

                var CSHits = new List<byte>() { 0, 0, 0, 0, 0, 0, 0, 0, 0 };

                for (byte j = 0; j < 9; j++)
                {
                    foreach (Obj_AI_Base minion in EntityManager.MinionsAndMonsters.EnemyMinions.Where(it => it.IsValidTarget(W.Range)))
                    {
                        if (CS.ElementAt(j).IsInside(minion)) CSHits[j]++;
                    }
                }

                int i = CSHits.Select((value, index) => new { Value = value, Index = index }).Aggregate((a, b) => (a.Value > b.Value) ? a : b).Index;

                if (CSHits[i] < laneclear.Value("w.minminions")) return default(Vector3);

                return Vectors[i];
            }
            else if (Target != null && Target.IsValidTarget())
            {
                var CS = new List<Geometry.Polygon.Sector>();
                var Vectors = new List<Vector3>() { new Vector3(Target.ServerPosition.X + 550, Target.ServerPosition.Y, Target.ServerPosition.Z), new Vector3(Target.ServerPosition.X - 550, Target.ServerPosition.Y, Target.ServerPosition.Z), new Vector3(Target.ServerPosition.X, Target.ServerPosition.Y + 550, Target.ServerPosition.Z), new Vector3(Target.ServerPosition.X, Target.ServerPosition.Y - 550, Target.ServerPosition.Z), new Vector3(Target.ServerPosition.X + 230, Target.ServerPosition.Y, Target.ServerPosition.Z), new Vector3(Target.ServerPosition.X - 230, Target.ServerPosition.Y, Target.ServerPosition.Z), new Vector3(Target.ServerPosition.X, Target.ServerPosition.Y + 230, Target.ServerPosition.Z), new Vector3(Target.ServerPosition.X, Target.ServerPosition.Y - 230, Target.ServerPosition.Z), Target.ServerPosition };

                var CS1 = new Geometry.Polygon.Sector(Player.Position, Vectors[0], ANGLE, 585);
                var CS2 = new Geometry.Polygon.Sector(Player.Position, Vectors[1], ANGLE, 585);
                var CS3 = new Geometry.Polygon.Sector(Player.Position, Vectors[2], ANGLE, 585);
                var CS4 = new Geometry.Polygon.Sector(Player.Position, Vectors[3], ANGLE, 585);
                var CS5 = new Geometry.Polygon.Sector(Player.Position, Vectors[4], ANGLE, 585);
                var CS6 = new Geometry.Polygon.Sector(Player.Position, Vectors[5], ANGLE, 585);
                var CS7 = new Geometry.Polygon.Sector(Player.Position, Vectors[6], ANGLE, 585);
                var CS8 = new Geometry.Polygon.Sector(Player.Position, Vectors[7], ANGLE, 585);
                var CS9 = new Geometry.Polygon.Sector(Player.Position, Vectors[8], ANGLE, 585);

                CS.Add(CS1);
                CS.Add(CS2);
                CS.Add(CS3);
                CS.Add(CS4);
                CS.Add(CS5);
                CS.Add(CS6);
                CS.Add(CS7);
                CS.Add(CS8);
                CS.Add(CS9);

                var CSHits = new List<byte>() { 0, 0, 0, 0, 0, 0, 0, 0, 0 };

                for (byte j = 0; j < 9; j++)
                {
                    foreach (AIHeroClient hero in EntityManager.Heroes.Enemies.Where(enemy => !enemy.IsDead && enemy.IsValidTarget(W.Range)))
                    {
                        if (CS.ElementAt(j).IsInside(hero)) CSHits[j]++;
                        if (hero == Target) CSHits[j] += 10;
                    }
                }

                byte i = (byte)CSHits.Select((value, index) => new { Value = value, Index = index }).Aggregate((a, b) => (a.Value > b.Value) ? a : b).Index;

                if (CSHits[i] <= 0) return default(Vector3);

                return Vectors[i];
            }

            return default(Vector3);
        }
        //credits to whoever made it
        public static int GetBestWLocationUnits(GameObjectType type, out Vector3 pos)
        {
            var sectorList = new List<Geometry.Polygon.Sector>();
            pos = Vector3.Zero;

            List<Obj_AI_Minion> minionList = EntityManager.MinionsAndMonsters.EnemyMinions.Where(it => !it.IsDead && it.IsValidTarget(Program.W.Range)).OrderByDescending(it => it.Distance(Annie)).ToList();
            List<AIHeroClient> championList = EntityManager.Heroes.Enemies.Where(it => !it.IsDead && it.IsValidTarget(Program.W.Range)).OrderByDescending(it => it.Distance(Annie)).ToList();

            Obj_AI_Base enemy = (type == GameObjectType.AIHeroClient) ?
                (Obj_AI_Base)championList.FirstOrDefault() : (Obj_AI_Base)minionList.FirstOrDefault();

            if (enemy == null)
                return 0;

            var Vectors = new List<Vector3>()
            {
                new Vector3(enemy.ServerPosition.X + 550, enemy.ServerPosition.Y, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X - 550, enemy.ServerPosition.Y, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X, enemy.ServerPosition.Y + 550, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X, enemy.ServerPosition.Y - 550, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X + 230, enemy.ServerPosition.Y, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X - 230, enemy.ServerPosition.Y, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X, enemy.ServerPosition.Y + 230, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X, enemy.ServerPosition.Y - 230, enemy.ServerPosition.Z),
                enemy.ServerPosition
            };

            float ANGLE = (float)(5 * Math.PI / 18);

            var sector1 = new Geometry.Polygon.Sector(Annie.Position, Vectors[0], ANGLE, 585);
            var sector2 = new Geometry.Polygon.Sector(Annie.Position, Vectors[1], ANGLE, 585);
            var sector3 = new Geometry.Polygon.Sector(Annie.Position, Vectors[2], ANGLE, 585);
            var sector4 = new Geometry.Polygon.Sector(Annie.Position, Vectors[3], ANGLE, 585);
            var sector5 = new Geometry.Polygon.Sector(Annie.Position, Vectors[4], ANGLE, 585);
            var sector6 = new Geometry.Polygon.Sector(Annie.Position, Vectors[5], ANGLE, 585);
            var sector7 = new Geometry.Polygon.Sector(Annie.Position, Vectors[6], ANGLE, 585);
            var sector8 = new Geometry.Polygon.Sector(Annie.Position, Vectors[7], ANGLE, 585);
            var sector9 = new Geometry.Polygon.Sector(Annie.Position, Vectors[8], ANGLE, 585);

            sectorList.Add(sector1);
            sectorList.Add(sector2);
            sectorList.Add(sector3);
            sectorList.Add(sector4);
            sectorList.Add(sector5);
            sectorList.Add(sector6);
            sectorList.Add(sector7);
            sectorList.Add(sector8);
            sectorList.Add(sector9);

            var CSHits = new List<int>() { 0, 0, 0, 0, 0, 0, 0, 0, 0 };

            for (int count = 0; count < 9; count++)
                if (type == GameObjectType.AIHeroClient)
                {
                    foreach (Obj_AI_Base champion in championList)
                        if (sectorList.ElementAt(count).IsInside(champion))
                            CSHits[count]++;
                }
                else
                {
                    foreach (Obj_AI_Base minion in minionList)
                        if (sectorList.ElementAt(count).IsInside(minion))
                            CSHits[count]++;
                }

            int i = CSHits.Select((value, index) => new { Value = value, Index = index }).Aggregate((a, b) => (a.Value > b.Value) ? a : b).Index;

            pos = Vectors[i];
            return CSHits[i];
        }
Example #14
0
 public static int EnemiesHitInSector(this Geometry.Polygon.Sector sector, List <Obj_AI_Base> enemies)
 {
     return(enemies.Where(a => a.MeetsCriteria() && sector.IsInside(a)).Count());
 }
Example #15
0
        public Jhin()
        {
            foreach (var enemy in EntityManager.Heroes.Enemies)
            {
                TextsDictionary.Add(enemy.NetworkId, new Text(enemy.ChampionName + " is R Killable", new Font("Arial", 30F, FontStyle.Bold)));
            }
            Q = new SpellBase(SpellSlot.Q, SpellType.Targeted, 550)
            {
                Width = 450,
                Speed = 1800,
                CastDelay = 250,
            };
            W = new SpellBase(SpellSlot.W, SpellType.Linear, 3000)
            {
                Width = 40,
                CastDelay = 750,
            };
            E = new SpellBase(SpellSlot.E, SpellType.Circular, 750)
            {
                Width = 135,
                CastDelay = 500,
            };
            R = new SpellBase(SpellSlot.R, SpellType.Linear, 3500)
            {
                Width = 80,
                CastDelay = 200,
                Speed = 5000,
                AllowedCollisionCount = -1,
            };
            Evader.OnEvader += delegate
            {
                if (EvaderMenu.CheckBox("BlockW"))
                {
                    LastBlockTick = Core.GameTickCount;
                }
            };

            Spellbook.OnCastSpell += delegate (Spellbook sender, SpellbookCastSpellEventArgs args)
            {
                if (sender.Owner.IsMe)
                {
                    if (args.Slot == SpellSlot.W)
                    {
                        args.Process = Core.GameTickCount - LastBlockTick > 750;
                    }
                }
            };
            Obj_AI_Base.OnProcessSpellCast += delegate (Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args)
            {
                if (sender.IsMe)
                {
                    switch (args.Slot)
                    {
                        case SpellSlot.W:
                            W.LastCastTime = Core.GameTickCount;
                            W.LastEndPosition = args.End;
                            break;
                        case SpellSlot.R:
                            if (args.SData.Name == "JhinR")
                            {
                                IsCastingR = true;
                                LastRCone = new Geometry.Polygon.Sector(sender.Position, args.End, (float)(45 * 2f * Math.PI / 180f), R.Range);
                                Stacks = 4;
                            }
                            else if (args.SData.Name == "JhinRShot")
                            {
                                R.LastCastTime = Core.GameTickCount;
                                Stacks--;
                            }
                            break;
                    }
                }
            };
            Gapcloser.OnGapcloser += delegate (AIHeroClient sender, Gapcloser.GapcloserEventArgs args)
            {
                if (sender.IsValidTarget() && sender.IsEnemy)
                {
                    if (MyHero.Distance(args.Start, true) > MyHero.Distance(args.End))
                    {
                        if (AutomaticMenu.CheckBox("E.Gapcloser") && MyHero.IsInRange(args.End, E.Range))
                        {
                            E.Cast(args.End);
                        }
                        if (MyHero.Distance(args.End, true) < (sender.GetAutoAttackRange(MyHero) * 1.5f).Pow())
                        {
                            WShouldWaitTick = Core.GameTickCount;
                        }
                    }
                }
            };

            MenuManager.AddSubMenu("Keys");
            {
                KeysMenu.AddValue("TapKey", new KeyBind("R Tap Key", false, KeyBind.BindTypes.HoldActive, 'T')).OnValueChange +=
                    delegate (ValueBase<bool> sender, ValueBase<bool>.ValueChangeArgs args)
                    {
                        if (args.NewValue && R.IsLearned && (R.IsReady || IsCastingR) && R.EnemyHeroes.Count > 0)
                        {
                            TapKeyPressed = true;
                        }
                    };
            }

            W.AddConfigurableHitChancePercent();
            R.AddConfigurableHitChancePercent();

            MenuManager.AddSubMenu("Combo");
            {
                ComboMenu.AddValue("Q", new CheckBox("Use Q"));
                ComboMenu.AddValue("W", new CheckBox("Use W"));
                ComboMenu.AddValue("E", new CheckBox("Use E"));
                ComboMenu.AddValue("Items", new CheckBox("Use offensive items"));
            }
            MenuManager.AddSubMenu("Ultimate");
            {
                UltimateMenu.AddStringList("Mode", "R AIM Mode", new[] { "Disabled", "Using TapKey", "Automatic" }, 2);
                UltimateMenu.AddValue("OnlyKillable", new CheckBox("Only attack if it's killable", false));
                UltimateMenu.AddValue("Delay", new Slider("Delay between R's (in ms)", 0, 0, 1500));
                UltimateMenu.AddValue("NearMouse", new GroupLabel("Near Mouse Settings"));
                UltimateMenu.AddValue("NearMouse.Enabled", new CheckBox("Only select target near mouse", false));
                UltimateMenu.AddValue("NearMouse.Radius", new Slider("Near mouse radius", 500, 100, 1500));
                UltimateMenu.AddValue("NearMouse.Draw", new CheckBox("Draw near mouse radius"));
            }
            MenuManager.AddSubMenu("Harass");
            {
                HarassMenu.AddValue("Q", new CheckBox("Use Q"));
                HarassMenu.AddValue("W", new CheckBox("Use W", false));
                HarassMenu.AddValue("E", new CheckBox("Use E", false));
                HarassMenu.AddValue("ManaPercent", new Slider("Minimum Mana Percent", 20));
            }

            MenuManager.AddSubMenu("Clear");
            {
                ClearMenu.AddValue("LaneClear", new GroupLabel("LaneClear"));
                {
                    ClearMenu.AddValue("LaneClear.Q", new Slider("Use Q if hit is greater than {0}", 3, 0, 10));
                    ClearMenu.AddValue("LaneClear.W", new Slider("Use W if hit is greater than {0}", 5, 0, 10));
                    ClearMenu.AddValue("LaneClear.E", new Slider("Use E if hit is greater than {0}", 4, 0, 10));
                    ClearMenu.AddValue("LaneClear.ManaPercent", new Slider("Minimum Mana Percent", 50));
                }
                ClearMenu.AddValue("LastHit", new GroupLabel("LastHit"));
                {
                    ClearMenu.AddStringList("LastHit.Q", "Use Q", new[] { "Never", "Smartly", "Always" }, 1);
                    ClearMenu.AddValue("LastHit.ManaPercent", new Slider("Minimum Mana Percent", 50));
                }
                ClearMenu.AddValue("JungleClear", new GroupLabel("JungleClear"));
                {
                    ClearMenu.AddValue("JungleClear.Q", new CheckBox("Use Q"));
                    ClearMenu.AddValue("JungleClear.W", new CheckBox("Use W"));
                    ClearMenu.AddValue("JungleClear.E", new CheckBox("Use W"));
                    ClearMenu.AddValue("JungleClear.ManaPercent", new Slider("Minimum Mana Percent", 20));
                }
            }

            MenuManager.AddKillStealMenu();
            {
                KillStealMenu.AddValue("Q", new CheckBox("Use Q"));
                KillStealMenu.AddValue("W", new CheckBox("Use W"));
                KillStealMenu.AddValue("E", new CheckBox("Use E"));
                KillStealMenu.AddValue("R", new CheckBox("Use R", false));
            }

            MenuManager.AddSubMenu("Automatic");
            {
                AutomaticMenu.AddValue("E.Gapcloser", new CheckBox("Use E on hero gapclosing / dashing"));
                AutomaticMenu.AddValue("Immobile", new CheckBox("Use E on hero immobile"));
                AutomaticMenu.AddValue("Buffed", new CheckBox("Use W on hero with buff"));
            }
            MenuManager.AddSubMenu("Evader");
            {
                EvaderMenu.AddValue("BlockW", new CheckBox("Block W to Evade"));
            }
            Evader.Initialize();
            Evader.AddCrowdControlSpells();
            Evader.AddDangerousSpells();
            MenuManager.AddDrawingsMenu();
            {
                Q.AddDrawings();
                W.AddDrawings();
                E.AddDrawings(false);
                R.AddDrawings();
                DrawingsMenu.Add("R.Killable", new CheckBox("Draw text if target is r killable"));
            }
        }
Example #16
0
        protected static IEnumerable <AIHeroClient> GetRSplashHits(Vector3 positionToCheckFrom)
        {
            var conePolygon = new Geometry.Polygon.Sector(positionToCheckFrom, (positionToCheckFrom - Player.Instance.Position).Normalized(), (float)(Math.PI / 180 * 70), RCone.Range);

            return(EntityManager.Heroes.Enemies.Where(x => !x.IsDead && !x.HasUndyingBuffA() && new Geometry.Polygon.Circle(x.Position, x.BoundingRadius).Points.Any(p => conePolygon.IsInside(p))));
        }
Example #17
0
        private void QLogic(AIHeroClient target, bool UseQ1 = false)// SFX Challenger MissFortune QLogic (im so lazy, kappa)
        {
            if (target != null)
            {
                if (target.IsValidTarget(Q.Range))
                {
                    Q.CastOnUnit(target);
                }
                else if (UseQ1 && target.IsValidTarget(QExtend.Range) && target.DistanceToPlayer() > Q.Range)
                {
                    var heroPositions = (from t in HeroManager.Enemies
                                         where t.IsValidTarget(QExtend.Range)
                                         let prediction = Q.GetPrediction(t)
                                                          select new CPrediction.Position(t, prediction.UnitPosition)).Where(
                        t => t.UnitPosition.Distance(Me.Position) < QExtend.Range).ToList();

                    if (heroPositions.Any())
                    {
                        var minions = MinionManager.GetMinions(QExtend.Range, MinionTypes.All, MinionTeam.NotAlly);

                        if (minions.Any(m => m.IsMoving) &&
                            !heroPositions.Any(h => h.Hero.HasBuff("missfortunepassive")))
                        {
                            return;
                        }

                        var outerMinions   = minions.Where(m => m.Distance(Me) > Q.Range).ToList();
                        var innerPositions = minions.Where(m => m.Distance(Me) < Q.Range).ToList();

                        foreach (var minion in innerPositions)
                        {
                            var lMinion  = minion;
                            var coneBuff = new Geometry.Polygon.Sector(
                                minion.Position,
                                Me.Position.Extend(minion.Position, Me.Distance(minion) + Q.Range * 0.5f),
                                (float)(40 * Math.PI / 180), QExtend.Range - Q.Range);
                            var coneNormal = new Geometry.Polygon.Sector(
                                minion.Position,
                                Me.Position.Extend(minion.Position, Me.Distance(minion) + Q.Range * 0.5f),
                                (float)(60 * Math.PI / 180), QExtend.Range - Q.Range);

                            foreach (var enemy in
                                     heroPositions.Where(
                                         m => m.UnitPosition.Distance(lMinion.Position) < QExtend.Range - Q.Range))
                            {
                                if (coneBuff.IsInside(enemy.Hero) && enemy.Hero.HasBuff("missfortunepassive"))
                                {
                                    Q.CastOnUnit(minion);
                                    return;
                                }
                                if (coneNormal.IsInside(enemy.UnitPosition))
                                {
                                    var insideCone =
                                        outerMinions.Where(m => coneNormal.IsInside(m.Position)).ToList();

                                    if (!insideCone.Any() ||
                                        enemy.UnitPosition.Distance(minion.Position) <
                                        insideCone.Select(
                                            m => m.Position.Distance(minion.Position) - m.BoundingRadius)
                                        .DefaultIfEmpty(float.MaxValue)
                                        .Min())
                                    {
                                        Q.CastOnUnit(minion);
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #18
0
        private static void GameObject_OnCreate(GameObject sender, EventArgs args)
        {
            var missile = sender as MissileClient;

            if (missile == null)
            {
                return;
            }

            var missileInfo =
                SpellDatabase.GetSpellInfoList(missile.SpellCaster).FirstOrDefault(s => s.RealSlot == missile.Slot);

            if (missileInfo == null)
            {
                return;
            }

            switch (missileInfo.Type)
            {
            case SpellType.Self:
                break;

            case SpellType.Circle:
                var polCircle = new Geometry.Polygon.Circle(missile.Position, missileInfo.Radius);
                Missiles.Add(missile, polCircle);
                break;

            case SpellType.Line:
                var polLine = new Geometry.Polygon.Rectangle(missile.StartPosition,
                                                             missile.StartPosition.Extend(missile.EndPosition, missileInfo.Range).To3D(), 5);
                Missiles.Add(missile, polLine);
                break;

            case SpellType.Cone:
                var polCone = new Geometry.Polygon.Sector(missile.StartPosition, missile.EndPosition, missileInfo.Radius, missileInfo.Range, 80);
                Missiles.Add(missile, polCone);
                break;

            case SpellType.Ring:
                break;

            case SpellType.Arc:
                break;

            case SpellType.MissileLine:
                var polMissileLine = new Geometry.Polygon.Rectangle(missile.StartPosition,
                                                                    missile.StartPosition.Extend(missile.EndPosition, missileInfo.Range).To3D(), 5);
                Missiles.Add(missile, polMissileLine);
                break;

            case SpellType.MissileAoe:
                var polMissileAoe = new Geometry.Polygon.Rectangle(missile.StartPosition,
                                                                   missile.StartPosition.Extend(missile.EndPosition, missileInfo.Range).To3D(), 5);
                Missiles.Add(missile, polMissileAoe);
                break;
            }

            var polygons = new List <Geometry.Polygon>();

            polygons.AddRange(Missiles.Values);

            Joined = polygons.JoinPolygons();
        }
Example #19
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;
            MissilePosition = start;
            Direction       = (end - start).Normalized();

            Unit = unit;
            if (ObjectManager.GetLocalPlayer().ChampionName == "Janna" ||
                ObjectManager.GetLocalPlayer().ChampionName == "Rakan" || ObjectManager.GetLocalPlayer().ChampionName == "Ivern" ||
                ObjectManager.GetLocalPlayer().ChampionName == "Lulu" ||
                ObjectManager.GetLocalPlayer().ChampionName == "Karma")
            {
                bestAllies = GameObjects.AllyHeroes
                             .Where(t =>
                                    t.Distance(ObjectManager.GetLocalPlayer()) < Support_AIO.Bases.Champion.E.Range)
                             .OrderBy(x => x.Health);
            }
            if (ObjectManager.GetLocalPlayer().ChampionName == "Lux" ||
                ObjectManager.GetLocalPlayer().ChampionName == "Sona" ||
                ObjectManager.GetLocalPlayer().ChampionName == "Taric")

            {
                bestAllies = GameObjects.AllyHeroes
                             .Where(t =>
                                    t.Distance(ObjectManager.GetLocalPlayer()) < Support_AIO.Bases.Champion.W.Range)
                             .OrderBy(x => x.Health);
            }
            foreach (var ally in bestAllies)
            {
                switch (spellData.Type)
                {
                case SkillShotType.SkillshotCircle:
                    Circle = new Geometry.Polygon.Circle(CollisionEnd, spellData.Radius, 22);
                    break;

                case SkillShotType.SkillshotLine:
                    Rectangle = new Geometry.Polygon.Rectangle(Start, CollisionEnd, spellData.Radius);
                    break;

                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;

                case SkillShotType.SkillshotArc:
                    Arc = new Geometry.Polygon.Arc(start, end,
                                                   EvadeManager.SkillShotsExtraRadius + (int)ally.BoundingRadius, 22);
                    break;
                }
            }
            UpdatePolygon();
        }
        public Geometry.Polygon PredictedPolygon(float afterTime, float extraWidth = 0)
        {
            var extraAngle = Math.Max(1, Math.Max(1, extraWidth) / 4);

            extraWidth += this.Width;

            Geometry.Polygon polygon = null;
            switch (this.Data.type)
            {
            case Type.LineMissile:
                polygon = new Geometry.Polygon.Rectangle(this.CalculatedPosition(afterTime), this.CollideEndPosition, extraWidth);
                break;

            case Type.CircleMissile:
                polygon = new Geometry.Polygon.Circle(this.Data.IsMoving ? this.CalculatedPosition(afterTime) : this.CollideEndPosition, extraWidth);
                break;

            case Type.Cone:
                polygon = new Geometry.Polygon.Sector(this.CurrentPosition, this.CollideEndPosition, (float)((this.Angle + extraAngle) * Math.PI / 180), this.Range);
                break;

            case Type.Arc:
                polygon = new CustomGeometry.Arc(this.Start, this.CollideEndPosition, (int)extraWidth).ToSDKPolygon();
                break;

            case Type.Ring:
                polygon = new CustomGeometry.Ring(this.CollideEndPosition, extraWidth, this.RingRadius).ToSDKPolygon();
                break;
            }

            if (polygon != null && (this.ExplodeEnd || this.CollideExplode))
            {
                var newpolygon   = polygon;
                var pos          = this.CurrentPosition;
                var collidepoint = this.CollideExplode ? this.CorrectCollidePoint.GetValueOrDefault() : this.CollideEndPosition;
                switch (this.Data.Explodetype)
                {
                case Type.CircleMissile:
                    this.ExplodePolygon = new Geometry.Polygon.Circle(collidepoint, this.ExplodeWidth);
                    break;

                case Type.LineMissile:
                    var st = collidepoint - (collidepoint - pos).Normalized().Perpendicular() * (this.ExplodeWidth);
                    var en = collidepoint + (collidepoint - pos).Normalized().Perpendicular() * (this.ExplodeWidth);
                    this.ExplodePolygon = new Geometry.Polygon.Rectangle(st, en, this.ExplodeWidth / 2);
                    break;

                case Type.Cone:
                    var st2 = collidepoint - Direction * (this.ExplodeWidth * 0.25f);
                    var en2 = collidepoint + Direction * (this.ExplodeWidth * 3);
                    this.ExplodePolygon = new Geometry.Polygon.Sector(st2, en2, (float)(this.Angle * Math.PI / 180), this.ExplodeWidth);
                    break;
                }

                var poly    = Geometry.ClipPolygons(new[] { newpolygon, this.ExplodePolygon });
                var vectors = new List <IntPoint>();
                foreach (var p in poly)
                {
                    vectors.AddRange(p.ToPolygon().ToClipperPath());
                }

                polygon = vectors.ToPolygon();
            }

            return(polygon);
        }
        //credits to whoever made it
        public static int GetBestWLocationUnits(GameObjectType type, out Vector3 pos)
        {
            var sectorList = new List <Geometry.Polygon.Sector>();

            pos = Vector3.Zero;

            List <Obj_AI_Minion> minionList   = EntityManager.MinionsAndMonsters.EnemyMinions.Where(it => !it.IsDead && it.IsValidTarget(Program.W.Range)).OrderByDescending(it => it.Distance(Annie)).ToList();
            List <AIHeroClient>  championList = EntityManager.Heroes.Enemies.Where(it => !it.IsDead && it.IsValidTarget(Program.W.Range)).OrderByDescending(it => it.Distance(Annie)).ToList();

            Obj_AI_Base enemy = (type == GameObjectType.AIHeroClient) ?
                                (Obj_AI_Base)championList.FirstOrDefault() : (Obj_AI_Base)minionList.FirstOrDefault();

            if (enemy == null)
            {
                return(0);
            }

            var Vectors = new List <Vector3>()
            {
                new Vector3(enemy.ServerPosition.X + 550, enemy.ServerPosition.Y, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X - 550, enemy.ServerPosition.Y, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X, enemy.ServerPosition.Y + 550, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X, enemy.ServerPosition.Y - 550, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X + 230, enemy.ServerPosition.Y, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X - 230, enemy.ServerPosition.Y, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X, enemy.ServerPosition.Y + 230, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X, enemy.ServerPosition.Y - 230, enemy.ServerPosition.Z),
                enemy.ServerPosition
            };

            float ANGLE = (float)(5 * Math.PI / 18);

            var sector1 = new Geometry.Polygon.Sector(Annie.Position, Vectors[0], ANGLE, 585);
            var sector2 = new Geometry.Polygon.Sector(Annie.Position, Vectors[1], ANGLE, 585);
            var sector3 = new Geometry.Polygon.Sector(Annie.Position, Vectors[2], ANGLE, 585);
            var sector4 = new Geometry.Polygon.Sector(Annie.Position, Vectors[3], ANGLE, 585);
            var sector5 = new Geometry.Polygon.Sector(Annie.Position, Vectors[4], ANGLE, 585);
            var sector6 = new Geometry.Polygon.Sector(Annie.Position, Vectors[5], ANGLE, 585);
            var sector7 = new Geometry.Polygon.Sector(Annie.Position, Vectors[6], ANGLE, 585);
            var sector8 = new Geometry.Polygon.Sector(Annie.Position, Vectors[7], ANGLE, 585);
            var sector9 = new Geometry.Polygon.Sector(Annie.Position, Vectors[8], ANGLE, 585);

            sectorList.Add(sector1);
            sectorList.Add(sector2);
            sectorList.Add(sector3);
            sectorList.Add(sector4);
            sectorList.Add(sector5);
            sectorList.Add(sector6);
            sectorList.Add(sector7);
            sectorList.Add(sector8);
            sectorList.Add(sector9);

            var CSHits = new List <int>()
            {
                0, 0, 0, 0, 0, 0, 0, 0, 0
            };

            for (int count = 0; count < 9; count++)
            {
                if (type == GameObjectType.AIHeroClient)
                {
                    foreach (Obj_AI_Base champion in championList)
                    {
                        if (sectorList.ElementAt(count).IsInside(champion))
                        {
                            CSHits[count]++;
                        }
                    }
                }
                else
                {
                    foreach (Obj_AI_Base minion in minionList)
                    {
                        if (sectorList.ElementAt(count).IsInside(minion))
                        {
                            CSHits[count]++;
                        }
                    }
                }
            }

            int i = CSHits.Select((value, index) => new { Value = value, Index = index }).Aggregate((a, b) => (a.Value > b.Value) ? a : b).Index;

            pos = Vectors[i];
            return(CSHits[i]);
        }
Example #22
0
        private bool Q2Logic()
        {
            /*
             * --Not Trusted-- http://leagueoflegends.wikia.com/wiki/Miss_Fortune
             * The second shot follows a priority order on targets within 500 units of the primary target:
             * Enemy champions in a 40° cone marked by Love Tap.
             * Minions and neutral monsters within a 40° cone.
             * Enemy champions within a 40° cone.
             * Enemy or neutral units within a 110° cone.
             * Enemy or neutral units within a 150-range 160° cone.
             * Double Up's range is not listed as spell range, but instead matches her basic attack range.
             * Double Up can bounce to units in brush or fog of war if they are in range of the target the spell is initially cast on.
             * Double Up must kill the first target for the second hit to deal enhanced damage. If the first target dies before the first hit lands, the second target receives the normal second target bonus damage.
             */
            if (_q.IsReadyPerfectly())
            {
                var q2Range         = _q.Range + 450;
                var longRangeTarget = TargetSelector.GetTarget(q2Range, _q.DamageType);

                if (longRangeTarget != null)
                {
                    Obj_AI_Base bestTarget = null;

                    var targets = new List <Obj_AI_Base>();
                    targets.AddRange(
                        MinionManager.GetMinions(_q.Range, MinionTypes.All, MinionTeam.NotAlly)
                        .Where(x => x.IsValidTarget()));
                    targets.AddRange(HeroManager.Enemies.Where(x => x.IsValidTarget(_q.Range)));
                    targets.OrderBy(x => x.Health);

                    foreach (
                        var target in
                        MenuProvider.Champion.Misc.GetBoolValue("Harass Q2 Only if Kills Unit")
                                ? targets.Where(
                            x => x.IsKillableAndValidTarget(_q.GetDamage(x), _q.DamageType, _q.Range))
                                : targets)
                    {
                        var direction            = target.ServerPosition.Extend(ObjectManager.Player.ServerPosition, -500);
                        var radian               = (float)Math.PI / 180f;
                        var targetServerPosition = target.ServerPosition;
                        var time = ObjectManager.Player.ServerPosition.Distance(target.ServerPosition) / _q.Speed +
                                   _q.Delay;
                        var predic = Prediction.GetPrediction(longRangeTarget, time);

                        var cone40 = new Geometry.Polygon.Sector(targetServerPosition, direction, 40f * radian, 450f);

                        if (cone40.IsInside(longRangeTarget.ServerPosition))
                        {
                            if (cone40.IsInside(predic.UnitPosition))
                            {
                                if (longRangeTarget.NetworkId == _loveTapTargetNetworkId)
                                {
                                    bestTarget = target;
                                    break;
                                }
                                if (
                                    !MinionManager.GetMinions(q2Range)
                                    .Where(
                                        x =>
                                        x.IsValidTarget() && x.NetworkId != target.NetworkId &&
                                        cone40.IsInside(x))
                                    .Any(
                                        x =>
                                        target.ServerPosition.Distance(longRangeTarget.ServerPosition) >=
                                        target.ServerPosition.Distance(x.ServerPosition)))
                                {
                                    bestTarget = target;
                                    break;
                                }
                            }
                        }
                    }

                    if (bestTarget != null)
                    {
                        return(_q.CastOnUnit(bestTarget));
                    }
                    return(false);
                }
                return(false);
            }
            return(false);
        }
Example #23
0
        private void UpdatePolygons()
        {
            Polygons = new List <Geometry.Polygon>();

            foreach (var myMissile in Missiles)
            {
                var missile = myMissile.Missile;
                var info    = myMissile.SpellInfo;

                // ReSharper disable once SwitchStatementMissingSomeCases
                switch (info.Type)
                {
                case SpellType.Self:
                    return;

                case SpellType.Circle:
                    var polygonCircle = new Geometry.Polygon.Circle(missile.Position,
                                                                    myMissile.SpellInfo.Radius, 80);
                    myMissile.Polygon = polygonCircle;

                    Polygons.Add(polygonCircle);
                    return;

                case SpellType.Line:
                    var polygonLine = new Geometry.Polygon.Line(missile.StartPosition, missile.EndPosition, 5f);
                    myMissile.Polygon = polygonLine;

                    Polygons.Add(polygonLine);
                    return;

                case SpellType.Cone:
                    var polygonCone = new Geometry.Polygon.Sector(missile.StartPosition, missile.EndPosition, info.Radius, info.Range, 80);
                    myMissile.Polygon = polygonCone;

                    Polygons.Add(polygonCone);
                    return;

                case SpellType.Ring:
                    return;

                case SpellType.Arc:
                    return;

                case SpellType.MissileLine:
                    var polygonMissileLine = new Geometry.Polygon.Line(missile.StartPosition, missile.EndPosition, 5f);
                    myMissile.Polygon = polygonMissileLine;

                    Polygons.Add(polygonMissileLine);
                    return;

                case SpellType.MissileAoe:
                    var polygonMissileAOE = new Geometry.Polygon.Line(missile.StartPosition, missile.EndPosition, 5f);
                    myMissile.Polygon = polygonMissileAOE;

                    Polygons.Add(polygonMissileAOE);
                    return;
                }
            }

            Polygons = Polygons.JoinPolygons();
        }
Example #24
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();
 }
Example #25
0
        public Jhin()
        {
            foreach (var enemy in EntityManager.Heroes.Enemies)
            {
                TextsInScreen.Add(enemy.NetworkId, new Text(enemy.ChampionName + " 可击杀", new Font("Arial", 30F, FontStyle.Bold))
                {
                    Color = Color.Red
                });
                TextsInHeroPosition.Add(enemy.NetworkId, new Text("R 可击杀", new Font("Arial", 23F, FontStyle.Bold))
                {
                    Color = Color.Red
                });
                LastPredictedPositionText.Add(enemy.NetworkId, new Text(enemy.ChampionName + " 最后预知位置", new Font("Arial", 23F, FontStyle.Bold))
                {
                    Color = Color.Red
                });
            }
            Q = new SpellBase(SpellSlot.Q, SpellType.Targeted, 600)
            {
                Width     = 450,
                Speed     = 1800,
                CastDelay = 250,
            };
            W = new SpellBase(SpellSlot.W, SpellType.Linear, 2500)
            {
                Width                 = 40,
                CastDelay             = 750,
                AllowedCollisionCount = -1,
            };
            E = new SpellBase(SpellSlot.E, SpellType.Circular, 750)
            {
                Width     = 135,
                CastDelay = 250,
                Speed     = 1600,
            };
            R = new SpellBase(SpellSlot.R, SpellType.Linear, 3500)
            {
                Width                 = 80,
                CastDelay             = 200,
                Speed                 = 5000,
                AllowedCollisionCount = -1,
            };
            Evader.OnEvader += delegate
            {
                if (EvaderMenu.CheckBox("BlockW"))
                {
                    LastBlockTick = Core.GameTickCount;
                }
            };

            Spellbook.OnCastSpell += delegate(Spellbook sender, SpellbookCastSpellEventArgs args)
            {
                if (sender.Owner.IsMe)
                {
                    if (args.Slot == SpellSlot.W)
                    {
                        args.Process = Core.GameTickCount - LastBlockTick > 750;
                    }
                }
            };
            Obj_AI_Base.OnProcessSpellCast += delegate(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args)
            {
                if (sender.IsMe)
                {
                    switch (args.Slot)
                    {
                    case SpellSlot.W:
                        W.LastCastTime    = Core.GameTickCount;
                        W.LastEndPosition = args.End;
                        break;

                    case SpellSlot.R:
                        if (args.SData.Name == "JhinR")
                        {
                            IsCastingR = true;
                            LastRCone  = new Geometry.Polygon.Sector(sender.Position, args.End, (float)(60f * Math.PI / 180f), R.Range);
                            Stacks     = 4;
                        }
                        else if (args.SData.Name == "JhinRShot")
                        {
                            R.LastCastTime = Core.GameTickCount;
                            TapKeyPressed  = false;
                            Stacks--;
                        }
                        break;
                    }
                }
            };
            Gapcloser.OnGapcloser += delegate(AIHeroClient sender, Gapcloser.GapcloserEventArgs args)
            {
                if (sender.IsValidTarget() && sender.IsEnemy)
                {
                    if (MyHero.Distance(args.Start, true) > MyHero.Distance(args.End))
                    {
                        if (AutomaticMenu.CheckBox("E.Gapcloser") && MyHero.IsInRange(args.End, E.Range))
                        {
                            E.Cast(args.End);
                        }
                        if (MyHero.Distance(args.End, true) < (sender.GetAutoAttackRange(MyHero) * 1.5f).Pow())
                        {
                            WShouldWaitTick = Core.GameTickCount;
                        }
                    }
                }
            };

            MenuManager.AddSubMenu("Keys");
            {
                KeysMenu.AddValue("TapKey", new KeyBind("R 半自动发射", false, KeyBind.BindTypes.HoldActive, 32)).OnValueChange +=
                    delegate(ValueBase <bool> sender, ValueBase <bool> .ValueChangeArgs args)
                {
                    if (args.NewValue && R.IsLearned && IsCastingR)
                    {
                        TapKeyPressed = true;
                    }
                };
                ToggleManager.RegisterToggle(
                    KeysMenu.AddValue("AutoW",
                                      new KeyBind("自动W开关", true, KeyBind.BindTypes.PressToggle, 'K')),
                    delegate
                {
                    foreach (var enemy in UnitManager.ValidEnemyHeroes.Where(TargetHaveEBuff))
                    {
                        if (MyHero.ManaPercent >= MiscMenu.Slider("W.ManaPercent"))
                        {
                            if (MiscMenu.CheckBox("自动W." + enemy.ChampionName))
                            {
                                CastW(enemy);
                            }
                        }
                    }
                });
            }

            W.AddConfigurableHitChancePercent();
            R.AddConfigurableHitChancePercent();

            MenuManager.AddSubMenu("Combo");
            {
                ComboMenu.AddValue("Q", new CheckBox("Use Q"));
                ComboMenu.AddValue("E", new CheckBox("Use E"));
                ComboMenu.AddValue("Items", new CheckBox("Use offensive items"));
                ComboMenu.AddStringList("W", "Use W", new[] { "Never", "Only buffed enemies", "Always" }, 2);
            }
            MenuManager.AddSubMenu("Ultimate");
            {
                UltimateMenu.AddStringList("Mode", "R 瞄准模式", new[] { "不使用", "使用扳机键", "自动" }, 2);
                UltimateMenu.AddValue("OnlyKillable", new CheckBox("只攻击可击杀目标"));
                UltimateMenu.AddValue("Delay", new Slider("R之间的延迟(毫秒)", 0, 0, 1500));
                UltimateMenu.AddValue("NearMouse", new GroupLabel("鼠标附近设置"));
                UltimateMenu.AddValue("NearMouse.Enabled", new CheckBox("只选择鼠标附近目标", false));
                UltimateMenu.AddValue("NearMouse.Radius", new Slider("靠近鼠标半径", 500, 100, 1500));
                UltimateMenu.AddValue("NearMouse.Draw", new CheckBox("显示鼠标半径"));
            }
            MenuManager.AddSubMenu("Harass");
            {
                HarassMenu.AddValue("Q", new CheckBox("Use Q"));
                HarassMenu.AddValue("W", new CheckBox("Use W", false));
                HarassMenu.AddValue("E", new CheckBox("Use E", false));
                HarassMenu.AddValue("ManaPercent", new Slider("Minimum Mana Percent", 20));
            }

            MenuManager.AddSubMenu("Clear");
            {
                ClearMenu.AddValue("LaneClear", new GroupLabel("LaneClear"));
                {
                    ClearMenu.AddValue("LaneClear.Q", new Slider("Use Q if hit is greater than {0}", 3, 0, 10));
                    ClearMenu.AddValue("LaneClear.W", new Slider("Use W if hit is greater than {0}", 5, 0, 10));
                    ClearMenu.AddValue("LaneClear.E", new Slider("Use E if hit is greater than {0}", 4, 0, 10));
                    ClearMenu.AddValue("LaneClear.ManaPercent", new Slider("Minimum Mana Percent", 50));
                }
                ClearMenu.AddValue("LastHit", new GroupLabel("LastHit"));
                {
                    ClearMenu.AddStringList("LastHit.Q", "Use Q", new[] { "Never", "Smartly", "Always" }, 1);
                    ClearMenu.AddValue("LastHit.ManaPercent", new Slider("Minimum Mana Percent", 50));
                }
                ClearMenu.AddValue("JungleClear", new GroupLabel("JungleClear"));
                {
                    ClearMenu.AddValue("JungleClear.Q", new CheckBox("Use Q"));
                    ClearMenu.AddValue("JungleClear.W", new CheckBox("Use W"));
                    ClearMenu.AddValue("JungleClear.E", new CheckBox("Use E"));
                    ClearMenu.AddValue("JungleClear.ManaPercent", new Slider("Minimum Mana Percent", 20));
                }
            }

            MenuManager.AddKillStealMenu();
            {
                KillStealMenu.AddValue("Q", new CheckBox("Use Q"));
                KillStealMenu.AddValue("W", new CheckBox("Use W"));
                KillStealMenu.AddValue("E", new CheckBox("Use E"));
                KillStealMenu.AddValue("R", new CheckBox("Use R"));
            }

            MenuManager.AddSubMenu("Automatic");
            {
                AutomaticMenu.AddValue("E.Gapcloser", new CheckBox("Use E on hero gapclosing / dashing"));
                AutomaticMenu.AddValue("Immobile", new CheckBox("对无法移动目标使用E"));
            }
            MenuManager.AddSubMenu("Evader");
            {
                EvaderMenu.AddValue("BlockW", new CheckBox("保留W进行躲避"));
            }
            Evader.Initialize();
            Evader.AddCrowdControlSpells();
            Evader.AddDangerousSpells();
            MenuManager.AddSubMenu("Misc");
            {
                MiscMenu.AddValue("W.ManaPercent", new Slider("最低蓝量百分比使用自动W", 10));
                MiscMenu.AddValue("Champions", new GroupLabel("自动使用W英雄"));
                foreach (var enemy in EntityManager.Heroes.Enemies)
                {
                    MiscMenu.AddValue("自动W." + enemy.ChampionName, new CheckBox(enemy.ChampionName));
                }
            }
            MenuManager.AddDrawingsMenu();
            {
                Q.AddDrawings(false);
                W.AddDrawings();
                E.AddDrawings(false);
                R.AddDrawings();
                DrawingsMenu.AddValue("Toggles", new CheckBox("Draw toggles status"));
                DrawingsMenu.AddValue("R.Killable", new CheckBox("显示可被R击杀的目标"));
                DrawingsMenu.AddValue("R.LastPredictedPosition", new CheckBox("显示预判敌人最后出现位置"));
            }
        }
Example #26
0
        private static void UpdatePolygons()
        {
            foreach (var missile in Missiles)
            {
                var missileInfo =
                    SpellDatabase.GetSpellInfoList(missile.Key.SpellCaster)
                        .FirstOrDefault(s => s.RealSlot == missile.Key.Slot);
                if (missileInfo == null) return;

                switch (missileInfo.Type)
                {
                    case SpellType.Self:
                        break;
                    case SpellType.Circle:
                        var polCircle = new Geometry.Polygon.Circle(missile.Key.Position, missileInfo.Radius);
                        Missiles[missile.Key] = polCircle;
                        break;
                    case SpellType.Line:
                        var polLine = new Geometry.Polygon.Rectangle(missile.Key.StartPosition,
                            missile.Key.StartPosition.Extend(missile.Key.EndPosition, missileInfo.Range).To3D(), 5);
                        Missiles[missile.Key] = polLine;
                        break;
                    case SpellType.Cone:
                        var polCone = new Geometry.Polygon.Sector(missile.Key.StartPosition, missile.Key.EndPosition, missileInfo.Radius, missileInfo.Range, 80);
                        Missiles[missile.Key] = polCone;
                        break;
                    case SpellType.Ring:
                        break;
                    case SpellType.Arc:
                        break;
                    case SpellType.MissileLine:
                        var polMissileLine = new Geometry.Polygon.Rectangle(missile.Key.StartPosition,
                            missile.Key.StartPosition.Extend(missile.Key.EndPosition, missileInfo.Range).To3D(), 5);
                        Missiles[missile.Key] = polMissileLine;
                        break;
                    case SpellType.MissileAoe:
                        var polMissileAoe = new Geometry.Polygon.Rectangle(missile.Key.StartPosition,
                            missile.Key.StartPosition.Extend(missile.Key.EndPosition, missileInfo.Range).To3D(), 5);
                        Missiles[missile.Key] = polMissileAoe;
                        break;
                }
            }

            var polygons = new List<Geometry.Polygon>();
            polygons.AddRange(Missiles.Values);

            Joined = polygons.JoinPolygons();
        }
        private static void GameObject_OnCreate(GameObject sender, EventArgs args)
        {
            var missile = sender as MissileClient;
            var caster  = missile?.SpellCaster as AIHeroClient;

            if (caster == null || missile == null || !caster.IsMe || !missile.IsValid)
            {
                return;
            }

            if (Database.SkillShotSpells.SkillShotsSpellsList.Any(s => caster != null && (s.hero == caster.Hero && s.MissileName.ToLower() == missile.SData.Name.ToLower())))
            {
                var spell = Database.SkillShotSpells.SkillShotsSpellsList.FirstOrDefault(s => caster != null && (s.hero == caster.Hero && s.MissileName.ToLower() == missile.SData.Name.ToLower()));

                if (DetectedSpells.All(s => !spell.MissileName.Equals(s.spell.MissileName, StringComparison.CurrentCultureIgnoreCase) && caster.NetworkId != s.Caster.NetworkId))
                {
                    var endpos = missile.StartPosition.Extend(missile.EndPosition, spell.Range).To3D();

                    if (spell.type == Database.SkillShotSpells.Type.LineMissile || spell.type == Database.SkillShotSpells.Type.CircleMissile)
                    {
                        var rect    = new Geometry.Polygon.Rectangle(missile.StartPosition, endpos, spell.Width);
                        var collide =
                            ObjectManager.Get <Obj_AI_Base>()
                            .OrderBy(m => m.Distance(sender))
                            .FirstOrDefault(
                                s =>
                                s.Team != sender.Team &&
                                (((s.IsMinion || s.IsMonster || s is Obj_AI_Minion) && !s.IsWard() && spell.Collisions.Contains(Database.SkillShotSpells.Collision.Minions)) ||
                                 s is AIHeroClient && spell.Collisions.Contains(Database.SkillShotSpells.Collision.Heros)) && rect.IsInside(s) && s.IsValidTarget());

                        if (collide != null)
                        {
                            endpos = collide.ServerPosition;
                        }
                    }

                    if (spell.type == Database.SkillShotSpells.Type.Cone)
                    {
                        var sector  = new Geometry.Polygon.Sector(missile.StartPosition, endpos, spell.Angle, spell.Range);
                        var collide =
                            ObjectManager.Get <Obj_AI_Base>()
                            .OrderBy(m => m.Distance(sender))
                            .FirstOrDefault(
                                s =>
                                s.Team != sender.Team &&
                                (((s.IsMinion || s.IsMonster || s is Obj_AI_Minion) && !s.IsWard() && spell.Collisions.Contains(Database.SkillShotSpells.Collision.Minions)) ||
                                 s is AIHeroClient && spell.Collisions.Contains(Database.SkillShotSpells.Collision.Heros)) && sector.IsInside(s) && s.IsValidTarget());

                        if (collide != null)
                        {
                            endpos = collide.ServerPosition;
                        }
                    }
                    //Chat.Print("OnCreate " + missile.SData.Name);
                    DetectedSpells.Add(
                        new ActiveSpells
                    {
                        spell      = spell, Start = missile.StartPosition, End = missile.EndPosition, Width = spell.Width,
                        EndTime    = (endpos.Distance(missile.StartPosition) / spell.Speed) + (spell.CastDelay / 1000) + Game.Time, Missile = missile, Caster = caster,
                        ArriveTime = (missile.StartPosition.Distance(Player.Instance) / spell.Speed) - (spell.CastDelay / 1000)
                    });
                }
            }
        }
Example #28
0
 public static List <Obj_AI_Base> GetEnemiesHitInSectorAndRectangle(this Geometry.Polygon.Sector sector, Geometry.Polygon.Rectangle rect, List <Obj_AI_Base> enemies, int delay)
 {
     return(enemies.Where(a => a.MeetsCriteria() && rect.IsInside(a.Position(delay))).ToList());
 }
Example #29
0
        public static List <Vector3> GetShapePositions(string shape, Vector3 originalPosition)
        {
            int            dist   = MenuHandler.PingMenu.GetSliderValue("Distance");
            List <Vector3> points = new List <Vector3>();

            switch (shape)
            {
            case "Square":
            case "Cross":
                if (shape == "Cross")
                {
                    points.Add(originalPosition);
                }

                points.Add(originalPosition + new Vector3(dist, dist, 0));
                points.Add(originalPosition + new Vector3(-dist, dist, 0));
                points.Add(originalPosition + new Vector3(dist, -dist, 0));
                points.Add(originalPosition + new Vector3(-dist, -dist, 0));
                break;

            case "Diamond":
            case "Plus Sign":
                if (shape == "Plus Sign")
                {
                    points.Add(originalPosition);
                }

                points.Add(originalPosition + new Vector3(dist, 0, 0));
                points.Add(originalPosition + new Vector3(0, dist, 0));
                points.Add(originalPosition + new Vector3(0, -dist, 0));
                points.Add(originalPosition + new Vector3(-dist, 0, 0));
                break;

            case "Vertical Line":
                points.Add(originalPosition);
                points.Add(originalPosition + new Vector3(0, dist, 0));
                points.Add(originalPosition + new Vector3(0, dist * 2, 0));
                points.Add(originalPosition + new Vector3(0, -dist, 0));
                points.Add(originalPosition + new Vector3(0, -dist * 2, 0));
                break;

            case "Horizontal Line":
                points.Add(originalPosition);
                points.Add(originalPosition + new Vector3(dist, 0, 0));
                points.Add(originalPosition + new Vector3(dist * 2, 0, 0));
                points.Add(originalPosition + new Vector3(-dist, 0, 0));
                points.Add(originalPosition + new Vector3(-dist * 2, 0, 0));
                break;

            case "Triangle":
            case "Pentagon":
                int    numPoints = ((shape == "Triangle") ? 3 : 5);
                double constant  = Math.PI / 2 - Math.PI / numPoints;
                for (var i = 0; i < numPoints; i++)
                {
                    Vector3 v = new Vector3(
                        (float)(originalPosition.X + dist * Math.Cos(i * 2 * Math.PI / numPoints + constant)),
                        (float)(originalPosition.Y + dist * Math.Sin(i * 2 * Math.PI / numPoints + constant)), 0);
                    points.Add(v);
                }
                break;

            case "Arrow to Player":
            case "Arrow away from Player":
                points.Add(originalPosition);
                points.Add(originalPosition.Extend(Player.Instance, (shape.Contains("away")?-dist:dist)).To3D());
                Vector2 ExtendedPosition = originalPosition.Extend(Player.Instance, (shape.Contains("away") ? -dist : dist) * 2);
                points.Add(ExtendedPosition.To3D());
                Geometry.Polygon.Sector sec = new Geometry.Polygon.Sector(originalPosition, ExtendedPosition.To3D(), MathUtil.DegreesToRadians(45), dist * 1.5f);
                points.Add(sec.Points[1].To3D());
                points.Add(sec.Points.Last().To3D());
                break;

            case "Single":
            default:
                points.Add(originalPosition);
                break;
            }

            return(points);
        }
Example #30
0
        // TODO PRIORITY: MEDIUM - LOW
        /// <summary>
        ///     Removes every PathBase that intersects with a skillshot
        /// </summary>
        public void RemovePathesThroughSkillshots(List <Skillshot> skillshots)
        {
            if (GlobalVariables.Debug)
            {
                Console.WriteLine($"GridGenerator.Cs > RemovePathesThroughSkillshots() > {skillshots.Count}");
            }

            if (this.Grid?.Connections == null || !this.Grid.Connections.Any() || this.Grid.Points == null)
            {
                return;
            }

            var skillshotDict = new Dictionary <Skillshot, Geometry.Polygon>();

            if (skillshots.Any())
            {
                foreach (var skillshot in skillshots)
                {
                    var polygon = new Geometry.Polygon();

                    switch (skillshot.SData.SpellType)
                    {
                    case LeagueSharp.Data.Enumerations.SpellType.SkillshotLine:
                        polygon = new Geometry.Polygon.Rectangle(
                            skillshot.StartPosition,
                            skillshot.EndPosition,
                            skillshot.SData.Radius);
                        break;

                    case LeagueSharp.Data.Enumerations.SpellType.SkillshotCircle:
                        polygon = new Geometry.Polygon.Circle(skillshot.EndPosition, skillshot.SData.Radius);
                        break;

                    case LeagueSharp.Data.Enumerations.SpellType.SkillshotArc:
                        polygon = new Geometry.Polygon.Sector(
                            skillshot.StartPosition,
                            skillshot.Direction,
                            skillshot.SData.Angle,
                            skillshot.SData.Radius);
                        break;
                    }

                    skillshotDict.Add(skillshot, polygon);
                }
            }

            if (skillshotDict.Any())
            {
                foreach (var skillshot in skillshotDict)
                {
                    //foreach (var point in Grid.Points.ToList())
                    //{
                    //    if (skillshot.Value.IsInside(point.Position))
                    //    {
                    //        Grid?.Points?.Remove(point);
                    //    }
                    //}

                    foreach (var connection in
                             this.Grid.Connections.Where(x => x is YasuoDashConnection))
                    {
                        var clipperpath       = skillshot.Value.ToClipperPath();
                        var connectionpolygon = new Geometry.Polygon.Line(
                            connection.Start.Position,
                            connection.End.Position);
                        var connectionclipperpath = connectionpolygon.ToClipperPath();

                        if (clipperpath.Intersect(connectionclipperpath).Any())
                        {
                            Console.WriteLine(@"Removing YasuoConnection");
                            this.Grid?.Connections?.Remove(connection);
                        }
                    }
                }
            }

            this.RemoveDisconnectedConnections();
        }
Example #31
0
        public Skillshot(DetectionType detectionType, SpellData spellData, int startT, Vector2 start, Vector2 end, AIBaseClient unit)
        {
            DetectionType   = detectionType;
            SpellData       = spellData;
            StartTick       = startT;
            Start           = start;
            End             = end;
            MissilePosition = start;
            Direction       = (Vector2)(end - start).ToVector3().Normalized();

            Unit = unit;
            //if (ObjectManager.Player.CharacterName == "Janna" ||
            //    ObjectManager.Player.CharacterName == "Rakan" || ObjectManager.Player.CharacterName == "Ivern" ||
            //    ObjectManager.Player.CharacterName == "Lulu" ||
            //    ObjectManager.Player.CharacterName == "Karma")
            //{
            //    bestAllies = GameObjects.AllyHeroes
            //        .Where(t =>
            //            t.Distance(ObjectManager.Player) < Helper.Spells[Helper.E].Range)
            //        .OrderBy(x => x.Health);
            //}
            //if (ObjectManager.Player.CharacterName == "Lux" ||
            //    ObjectManager.Player.CharacterName == "Sona" ||
            //    ObjectManager.Player.CharacterName == "Taric")

            //{
            //    bestAllies = GameObjects.AllyHeroes
            //        .Where(t =>
            //            t.Distance(ObjectManager.Player) < Helper.Spells[Helper.W].Range)
            //        .OrderBy(x => x.Health);
            //}
            foreach (var ally in bestAllies)
            {
                switch (spellData.Type)
                {
                case SkillShotType.SkillshotCircle:
                    Circle = new Geometry.Polygon.Circle(CollisionEnd, spellData.Radius, 22);
                    break;

                case SkillShotType.SkillshotLine:
                    Rectangle = new Geometry.Polygon.Rectangle(Start, CollisionEnd, spellData.Radius);
                    break;

                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;

                case SkillShotType.SkillshotArc:
                    Arc = new Geometry.Polygon.Arc(start, end,
                                                   EvadeManager.SkillShotsExtraRadius + (int)ally.BoundingRadius, 22);
                    break;
                }
            }
            UpdatePolygon();
        }
Example #32
0
        /* Pasta from WuAnnie */ /* TODO: MAYBE REWORK LATER */
        public static int GetBestLocationW(out Vector3 pos)
        {
            List <Geometry.Polygon.Sector> sectorList = new List <Geometry.Polygon.Sector>();

            pos = Vector3.Zero;

            List <Obj_AI_Minion> minionList = SpellsManager.W.GetLaneMinions().OrderByDescending(m => m.Distance(Globals.MyHero)).ToList();

            Obj_AI_Base enemy = minionList.FirstOrDefault();

            if (enemy == null)
            {
                return(0);
            }

            List <Vector3> _Vectors = new List <Vector3>
            {
                new Vector3(enemy.ServerPosition.X + 550, enemy.ServerPosition.Y, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X - 550, enemy.ServerPosition.Y, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X, enemy.ServerPosition.Y + 550, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X, enemy.ServerPosition.Y - 550, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X + 230, enemy.ServerPosition.Y, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X - 230, enemy.ServerPosition.Y, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X, enemy.ServerPosition.Y + 230, enemy.ServerPosition.Z),
                new Vector3(enemy.ServerPosition.X, enemy.ServerPosition.Y - 230, enemy.ServerPosition.Z),
                enemy.ServerPosition
            };

            float _Angle = (float)(5 * Math.PI / 18);

            Geometry.Polygon.Sector _Sector1 = new Geometry.Polygon.Sector(Globals.MyHero.Position, _Vectors[0], _Angle, 585);
            Geometry.Polygon.Sector _Sector2 = new Geometry.Polygon.Sector(Globals.MyHero.Position, _Vectors[1], _Angle, 585);
            Geometry.Polygon.Sector _Sector3 = new Geometry.Polygon.Sector(Globals.MyHero.Position, _Vectors[2], _Angle, 585);
            Geometry.Polygon.Sector _Sector4 = new Geometry.Polygon.Sector(Globals.MyHero.Position, _Vectors[3], _Angle, 585);
            Geometry.Polygon.Sector _Sector5 = new Geometry.Polygon.Sector(Globals.MyHero.Position, _Vectors[4], _Angle, 585);
            Geometry.Polygon.Sector _Sector6 = new Geometry.Polygon.Sector(Globals.MyHero.Position, _Vectors[5], _Angle, 585);
            Geometry.Polygon.Sector _Sector7 = new Geometry.Polygon.Sector(Globals.MyHero.Position, _Vectors[6], _Angle, 585);
            Geometry.Polygon.Sector _Sector8 = new Geometry.Polygon.Sector(Globals.MyHero.Position, _Vectors[7], _Angle, 585);
            Geometry.Polygon.Sector _Sector9 = new Geometry.Polygon.Sector(Globals.MyHero.Position, _Vectors[8], _Angle, 585);

            sectorList.Add(_Sector1);
            sectorList.Add(_Sector2);
            sectorList.Add(_Sector3);
            sectorList.Add(_Sector4);
            sectorList.Add(_Sector5);
            sectorList.Add(_Sector6);
            sectorList.Add(_Sector7);
            sectorList.Add(_Sector8);
            sectorList.Add(_Sector9);

            List <int> countHits = new List <int> {
                0, 0, 0, 0, 0, 0, 0, 0, 0
            };

            for (int count = 0; count < 9; count++)
            {
                foreach (Obj_AI_Base minion in minionList)
                {
                    if (sectorList.ElementAt(count).IsInside(minion))
                    {
                        countHits[count]++;
                    }
                }
            }

            int _Value = countHits.Select((value, index) => new { Value = value, Index = index }).Aggregate((a, b) => a.Value > b.Value ? a : b).Index;

            pos = _Vectors[_Value];
            return(countHits[_Value]);
        }
Example #33
0
 private static bool InsideCone()
 {
     var target = TargetSelector.GetTarget(_e.Range, DamageType.Mixed);
     if (target == null) return false;
     var cone = new Geometry.Polygon.Sector(Player.Instance.Position,
         OKTRGeometry.Rotatoes(Player.Instance.Position.To2D(), target.Position.To2D(), 90).To3D(),
         Geometry.DegreeToRadian(180),
         Player.Instance.AttackRange + Player.Instance.BoundingRadius*2);
     return cone.IsInside(Game.CursorPos.To2D());
 }
Example #34
0
 private static bool InsideCone()
 {
     if (_target == null) return false;
     var cone = new Geometry.Polygon.Sector(Player.Instance.Position,
                     OKTRGeometry.Deviation(Player.Instance.Position.To2D(), _target.Position.To2D(), 90).To3D(), Geometry.DegreeToRadian(180),
                     (Player.Instance.AttackRange + Player.Instance.BoundingRadius * 2));
     return cone.IsInside(Game.CursorPos.To2D());
 }
Example #35
0
        public Jhin()
        {
            foreach (var enemy in EntityManager.Heroes.Enemies)
            {
                TextsInScreen.Add(enemy.NetworkId, new Text(enemy.ChampionName + " is R killable", new Font("Arial", 30F, FontStyle.Bold))
                {
                    Color = Color.Red
                });
                TextsInHeroPosition.Add(enemy.NetworkId, new Text("R killable", new Font("Arial", 23F, FontStyle.Bold))
                {
                    Color = Color.Red
                });
                LastPredictedPositionText.Add(enemy.NetworkId, new Text(enemy.ChampionName + " last predicted position", new Font("Arial", 23F, FontStyle.Bold))
                {
                    Color = Color.Red
                });
            }
            Q = new SpellBase(SpellSlot.Q, SpellType.Targeted, 600)
            {
                Width     = 450,
                Speed     = 1800,
                CastDelay = 250,
            };
            W = new SpellBase(SpellSlot.W, SpellType.Linear, 2500)
            {
                Width                 = 40,
                CastDelay             = 750,
                Speed                 = 5000,
                AllowedCollisionCount = -1,
            };
            E = new SpellBase(SpellSlot.E, SpellType.Circular, 750)
            {
                Width     = 135,
                CastDelay = 250,
                Speed     = 1600,
            };
            R = new SpellBase(SpellSlot.R, SpellType.Linear, 3500)
            {
                Width                 = 65,
                CastDelay             = 250,
                Speed                 = 5000,
                AllowedCollisionCount = -1,
            };
            Evader.OnEvader += delegate
            {
                if (EvaderMenu.CheckBox("BlockW"))
                {
                    LastBlockTick = Core.GameTickCount;
                }
            };

            Spellbook.OnCastSpell += delegate(Spellbook sender, SpellbookCastSpellEventArgs args)
            {
                if (sender.Owner.IsMe)
                {
                    if (args.Slot == SpellSlot.W)
                    {
                        args.Process = Core.GameTickCount - LastBlockTick > 750;
                    }
                }
            };
            Obj_AI_Base.OnProcessSpellCast += delegate(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args)
            {
                if (sender.IsMe)
                {
                    switch (args.Slot)
                    {
                    case SpellSlot.W:
                        W.LastCastTime    = Core.GameTickCount;
                        W.LastEndPosition = args.End;
                        break;

                    case SpellSlot.R:
                        if (args.SData.Name == "JhinR")
                        {
                            IsCastingR = true;
                            LastRCone  = new Geometry.Polygon.Sector(sender.Position, args.End, (float)(45 * 2f * Math.PI / 175f), R.Range);
                            Stacks     = 4;
                        }
                        else if (args.SData.Name == "JhinRShot")
                        {
                            R.LastCastTime = Core.GameTickCount;
                            TapKeyPressed  = false;
                            Stacks--;
                        }
                        break;
                    }
                }
            };
            Gapcloser.OnGapcloser += delegate(AIHeroClient sender, Gapcloser.GapcloserEventArgs args)
            {
                if (sender.IsValidTarget(E.Range) && sender.IsEnemy)
                {
                    if (MyHero.Distance(args.Start, true) > MyHero.Distance(args.End))
                    {
                        if (AutomaticMenu.CheckBox("E.Gapcloser") && MyHero.IsInRange(args.End, E.Range) && E.IsReady)
                        {
                            E.Cast(args.End);
                        }
                        if (MyHero.Distance(args.End, true) < (sender.GetAutoAttackRange(MyHero) * 1.5f).Pow())
                        {
                            WShouldWaitTick = Core.GameTickCount;
                        }
                    }
                }
            };

            MenuManager.AddSubMenu("Keys");
            {
                KeysMenu.AddValue("TapKey", new KeyBind("R Tap Key", false, KeyBind.BindTypes.HoldActive, 'T')).OnValueChange +=
                    delegate(ValueBase <bool> sender, ValueBase <bool> .ValueChangeArgs args)
                {
                    if (args.NewValue && R.IsLearned && (R.IsReady || IsCastingR) && R.EnemyHeroes.Count > 0)
                    {
                        TapKeyPressed = true;
                    }
                };
                KeysMenu.AddValue("UltKey", new KeyBind("R Key in game", false, KeyBind.BindTypes.HoldActive, 'R')).OnValueChange +=
                    delegate(ValueBase <bool> sender, ValueBase <bool> .ValueChangeArgs args)
                {
                    if (args.NewValue && R.IsLearned && (R.IsReady || IsCastingR))
                    {
                        Player.IssueOrder(GameObjectOrder.Stop, Player.Instance.ServerPosition);
                    }
                };
                ToggleManager.RegisterToggle(
                    KeysMenu.AddValue("AutoW",
                                      new KeyBind("AutoW Toggle", false, KeyBind.BindTypes.PressToggle, 'K')),
                    delegate
                {
                    foreach (var enemy in UnitManager.ValidEnemyHeroes.Where(TargetHaveEBuff))
                    {
                        if (MiscMenu.CheckBox("AutoW." + enemy.ChampionName))
                        {
                            CastW(enemy);
                        }
                    }
                });
            }

            W.AddConfigurableHitChancePercent();
            R.AddConfigurableHitChancePercent();

            MenuManager.AddSubMenu("Combo");
            {
                ComboMenu.AddValue("Q", new CheckBox("Use Q"));
                ComboMenu.AddValue("W", new CheckBox("Use W", false));
                ComboMenu.AddValue("E", new CheckBox("Use E", false));
                ComboMenu.AddValue("Items", new CheckBox("Use offensive items"));
            }
            MenuManager.AddSubMenu("Ultimate");
            {
                UltimateMenu.AddStringList("Mode", "R AIM Mode", new[] { "Disabled", "Using TapKey", "Automatic" }, 3);
                UltimateMenu.AddValue("OnlyKillable", new CheckBox("Only attack if it's killable", false));
                UltimateMenu.AddValue("Delay", new Slider("Delay between R's (in ms)", 0, 0, 1500));
                UltimateMenu.AddValue("NearMouse", new GroupLabel("Near Mouse Settings"));
                UltimateMenu.AddValue("NearMouse.Enabled", new CheckBox("Only select target near mouse", false));
                UltimateMenu.AddValue("NearMouse.Radius", new Slider("Near mouse radius", 500, 100, 1500));
                UltimateMenu.AddValue("NearMouse.Draw", new CheckBox("Draw near mouse radius"));
            }
            MenuManager.AddSubMenu("Harass");
            {
                HarassMenu.AddValue("Q", new CheckBox("Use Q"));
                HarassMenu.AddValue("W", new CheckBox("Use W", false));
                HarassMenu.AddValue("E", new CheckBox("Use E", false));
                HarassMenu.AddValue("ManaPercent", new Slider("Minimum Mana Percent", 20));
            }

            MenuManager.AddSubMenu("Clear");
            {
                ClearMenu.AddValue("LaneClear", new GroupLabel("LaneClear"));
                {
                    ClearMenu.AddValue("LaneClear.Q", new Slider("Use Q if hit is greater than {0}", 5, 0, 10));
                    ClearMenu.AddValue("LaneClear.W", new Slider("Use W if hit is greater than {0}", 6, 0, 10));
                    ClearMenu.AddValue("LaneClear.E", new Slider("Use E if hit is greater than {0}", 5, 0, 10));
                    ClearMenu.AddValue("LaneClear.ManaPercent", new Slider("Minimum Mana Percent", 50));
                }
                ClearMenu.AddValue("LastHit", new GroupLabel("LastHit"));
                {
                    ClearMenu.AddStringList("LastHit.Q", "Use Q", new[] { "Never", "Smartly", "Always" }, 1);
                    ClearMenu.AddValue("LastHit.ManaPercent", new Slider("Minimum Mana Percent", 50));
                }
                ClearMenu.AddValue("JungleClear", new GroupLabel("JungleClear"));
                {
                    ClearMenu.AddValue("JungleClear.Q", new CheckBox("Use Q"));
                    ClearMenu.AddValue("JungleClear.W", new CheckBox("Use W", false));
                    ClearMenu.AddValue("JungleClear.E", new CheckBox("Use E", false));
                    ClearMenu.AddValue("JungleClear.ManaPercent", new Slider("Minimum Mana Percent", 20));
                }
            }

            MenuManager.AddKillStealMenu();
            {
                KillStealMenu.AddValue("Q", new CheckBox("Use Q"));
                KillStealMenu.AddValue("Qmin", new CheckBox("Use Q On Minions"));
                KillStealMenu.AddValue("W", new CheckBox("Use W"));
                KillStealMenu.AddValue("E", new CheckBox("Use E", false));
                KillStealMenu.AddValue("R", new CheckBox("Use R"));
            }

            MenuManager.AddSubMenu("Automatic");
            {
                AutomaticMenu.AddValue("E.Gapcloser", new CheckBox("Use E on hero gapclosing / dashing"));
                AutomaticMenu.AddValue("Immobile", new CheckBox("Use E on hero immobile"));
                AutomaticMenu.AddValue("Buffed", new CheckBox("Use W on hero with buff"));
            }
            MenuManager.AddSubMenu("Evader");
            {
                EvaderMenu.AddValue("BlockW", new CheckBox("Block W to Evade"));
            }
            Evader.Initialize();
            Evader.AddCrowdControlSpells();
            Evader.AddDangerousSpells();
            MenuManager.AddSubMenu("Misc");
            {
                MiscMenu.AddValue("Champions", new GroupLabel("Allowed champions to use Auto W"));
                foreach (var enemy in EntityManager.Heroes.Enemies)
                {
                    MiscMenu.AddValue("AutoW." + enemy.ChampionName, new CheckBox(enemy.ChampionName));
                }
            }
            MenuManager.AddDrawingsMenu();
            {
                Q.AddDrawings(false);
                W.AddDrawings();
                E.AddDrawings(false);
                R.AddDrawings();
                DrawingsMenu.AddValue("Toggles", new CheckBox("Draw toggles status"));
                DrawingsMenu.AddValue("R.Killable", new CheckBox("Draw text if target is r killable"));
                DrawingsMenu.AddValue("R.LastPredictedPosition", new CheckBox("Draw last predicted position"));
            }
        }
Example #36
0
        private static void CastQ1()
        {
            var target = TargetSelector.GetTarget(Q.Range, TargetSelector.DamageType.Physical);

            if (target != null)
            {
                Q.CastOnUnit(target);
            }
            else if (1 == 1)
            {
                target = TargetSelector.GetTarget(Q1.Range, TargetSelector.DamageType.Physical);
                if (target != null)
                {
                    var heroPositions = (from t in HeroManager.Enemies
                                         where t.IsValidTarget(Q1.Range)
                                         let prediction = Q.GetPrediction(t)
                                                          select new CPrediction.Position(t, prediction.UnitPosition)).Where(
                        t => t.UnitPosition.Distance(Player.Position) < Q1.Range).ToList();
                    if (heroPositions.Any())
                    {
                        var minions = MinionManager.GetMinions(
                            Q1.Range, MinionTypes.All, MinionTeam.NotAlly, MinionOrderTypes.None);

                        if (minions.Any(m => m.IsMoving) && !heroPositions.Any(h => HasPassiveDebuff(h.Hero)))
                        {
                            return;
                        }

                        var outerMinions   = minions.Where(m => m.Distance(Player) > Q.Range).ToList();
                        var innerPositions = minions.Where(m => m.Distance(Player) < Q.Range).ToList();
                        foreach (var minion in innerPositions)
                        {
                            var lMinion  = minion;
                            var coneBuff = new Geometry.Polygon.Sector(minion.Position,
                                                                       Player.Position.Extend(minion.Position, Player.Distance(minion) + Q.Range * 0.5f),
                                                                       (float)(40 * Math.PI / 180), Q1.Range - Q.Range);

                            var coneNormal = new Geometry.Polygon.Sector(minion.Position,
                                                                         Player.Position.Extend(minion.Position, Player.Distance(minion) + Q.Range * 0.5f),
                                                                         (float)(60 * Math.PI / 180), Q1.Range - Q.Range);

                            foreach (
                                var enemy in
                                heroPositions.Where(
                                    m => m.UnitPosition.Distance(lMinion.Position) < Q1.Range - Q.Range))
                            {
                                if (coneBuff.IsInside(enemy.Hero) && HasPassiveDebuff(enemy.Hero))
                                {
                                    Q.CastOnUnit(minion);
                                    return;
                                }

                                if (coneNormal.IsInside(enemy.UnitPosition))
                                {
                                    var insideCone =
                                        outerMinions.Where(m => coneNormal.IsInside(m.Position)).ToList();
                                    if (!insideCone.Any() ||
                                        enemy.UnitPosition.Distance(minion.Position) <
                                        insideCone.Select(
                                            m => m.Position.Distance(minion.Position) - m.BoundingRadius)
                                        .DefaultIfEmpty(float.MaxValue)
                                        .Min())
                                    {
                                        Q.CastOnUnit(minion);
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #37
0
        //--------------------------------------GetBestWPos----------------------------------------

        Vector3 GetBestWPos(bool minions = false, AIHeroClient Target = null)
        {
            if (minions)
            {
                var CS = new List <Geometry.Polygon.Sector>();

                var Minion = EntityManager.MinionsAndMonsters.EnemyMinions.Where(it => it.IsValidTarget(W.Range)).OrderByDescending(it => it.Distance(Player)).FirstOrDefault();

                if (Minion == null)
                {
                    return(default(Vector3));
                }

                var Vectors = new List <Vector3>()
                {
                    new Vector3(Minion.ServerPosition.X + 550, Minion.ServerPosition.Y, Minion.ServerPosition.Z), new Vector3(Minion.ServerPosition.X - 550, Minion.ServerPosition.Y, Minion.ServerPosition.Z), new Vector3(Minion.ServerPosition.X, Minion.ServerPosition.Y + 550, Minion.ServerPosition.Z), new Vector3(Minion.ServerPosition.X, Minion.ServerPosition.Y - 550, Minion.ServerPosition.Z), new Vector3(Minion.ServerPosition.X + 230, Minion.ServerPosition.Y, Minion.ServerPosition.Z), new Vector3(Minion.ServerPosition.X - 230, Minion.ServerPosition.Y, Minion.ServerPosition.Z), new Vector3(Minion.ServerPosition.X, Minion.ServerPosition.Y + 230, Minion.ServerPosition.Z), new Vector3(Minion.ServerPosition.X, Minion.ServerPosition.Y - 230, Minion.ServerPosition.Z), Minion.ServerPosition
                };

                var CS1 = new Geometry.Polygon.Sector(Player.Position, Vectors[0], ANGLE, 585);
                var CS2 = new Geometry.Polygon.Sector(Player.Position, Vectors[1], ANGLE, 585);
                var CS3 = new Geometry.Polygon.Sector(Player.Position, Vectors[2], ANGLE, 585);
                var CS4 = new Geometry.Polygon.Sector(Player.Position, Vectors[3], ANGLE, 585);
                var CS5 = new Geometry.Polygon.Sector(Player.Position, Vectors[4], ANGLE, 585);
                var CS6 = new Geometry.Polygon.Sector(Player.Position, Vectors[5], ANGLE, 585);
                var CS7 = new Geometry.Polygon.Sector(Player.Position, Vectors[6], ANGLE, 585);
                var CS8 = new Geometry.Polygon.Sector(Player.Position, Vectors[7], ANGLE, 585);
                var CS9 = new Geometry.Polygon.Sector(Player.Position, Vectors[8], ANGLE, 585);

                CS.Add(CS1);
                CS.Add(CS2);
                CS.Add(CS3);
                CS.Add(CS4);
                CS.Add(CS5);
                CS.Add(CS6);
                CS.Add(CS7);
                CS.Add(CS8);
                CS.Add(CS9);

                var CSHits = new List <byte>()
                {
                    0, 0, 0, 0, 0, 0, 0, 0, 0
                };

                for (byte j = 0; j < 9; j++)
                {
                    foreach (Obj_AI_Base minion in EntityManager.MinionsAndMonsters.EnemyMinions.Where(it => it.IsValidTarget(W.Range)))
                    {
                        if (CS.ElementAt(j).IsInside(minion))
                        {
                            CSHits[j]++;
                        }
                    }
                }

                int i = CSHits.Select((value, index) => new { Value = value, Index = index }).Aggregate((a, b) => (a.Value > b.Value) ? a : b).Index;

                if (CSHits[i] < Features.First(it => it.NameFeature == "Lane Clear").SliderValue("laneclear.w.minminions"))
                {
                    return(default(Vector3));
                }

                return(Vectors[i]);
            }
            else if (Target != null && Target.IsValidTarget())
            {
                var CS      = new List <Geometry.Polygon.Sector>();
                var Vectors = new List <Vector3>()
                {
                    new Vector3(Target.ServerPosition.X + 550, Target.ServerPosition.Y, Target.ServerPosition.Z), new Vector3(Target.ServerPosition.X - 550, Target.ServerPosition.Y, Target.ServerPosition.Z), new Vector3(Target.ServerPosition.X, Target.ServerPosition.Y + 550, Target.ServerPosition.Z), new Vector3(Target.ServerPosition.X, Target.ServerPosition.Y - 550, Target.ServerPosition.Z), new Vector3(Target.ServerPosition.X + 230, Target.ServerPosition.Y, Target.ServerPosition.Z), new Vector3(Target.ServerPosition.X - 230, Target.ServerPosition.Y, Target.ServerPosition.Z), new Vector3(Target.ServerPosition.X, Target.ServerPosition.Y + 230, Target.ServerPosition.Z), new Vector3(Target.ServerPosition.X, Target.ServerPosition.Y - 230, Target.ServerPosition.Z), Target.ServerPosition
                };

                var CS1 = new Geometry.Polygon.Sector(Player.Position, Vectors[0], ANGLE, 585);
                var CS2 = new Geometry.Polygon.Sector(Player.Position, Vectors[1], ANGLE, 585);
                var CS3 = new Geometry.Polygon.Sector(Player.Position, Vectors[2], ANGLE, 585);
                var CS4 = new Geometry.Polygon.Sector(Player.Position, Vectors[3], ANGLE, 585);
                var CS5 = new Geometry.Polygon.Sector(Player.Position, Vectors[4], ANGLE, 585);
                var CS6 = new Geometry.Polygon.Sector(Player.Position, Vectors[5], ANGLE, 585);
                var CS7 = new Geometry.Polygon.Sector(Player.Position, Vectors[6], ANGLE, 585);
                var CS8 = new Geometry.Polygon.Sector(Player.Position, Vectors[7], ANGLE, 585);
                var CS9 = new Geometry.Polygon.Sector(Player.Position, Vectors[8], ANGLE, 585);

                CS.Add(CS1);
                CS.Add(CS2);
                CS.Add(CS3);
                CS.Add(CS4);
                CS.Add(CS5);
                CS.Add(CS6);
                CS.Add(CS7);
                CS.Add(CS8);
                CS.Add(CS9);

                var CSHits = new List <byte>()
                {
                    0, 0, 0, 0, 0, 0, 0, 0, 0
                };

                for (byte j = 0; j < 9; j++)
                {
                    foreach (AIHeroClient hero in EntityManager.Heroes.Enemies.Where(enemy => !enemy.IsDead && enemy.IsValidTarget(W.Range)))
                    {
                        if (CS.ElementAt(j).IsInside(hero))
                        {
                            CSHits[j]++;
                        }
                        if (hero == Target)
                        {
                            CSHits[j] += 10;
                        }
                    }
                }

                byte i = (byte)CSHits.Select((value, index) => new { Value = value, Index = index }).Aggregate((a, b) => (a.Value > b.Value) ? a : b).Index;

                if (CSHits[i] <= 0)
                {
                    return(default(Vector3));
                }

                return(Vectors[i]);
            }

            return(default(Vector3));
        }
        public static bool EToMouse(bool goUnderEnemyTower, bool stackQ, bool EQ, List<Obj_AI_Base> EQTargets = null)
        {
            if (Program.E.IsReady() && !YasuoCalcs.IsDashing())
            {
                Geometry.Polygon.Sector sector = new Geometry.Polygon.Sector(Yasuo.Position, Game.CursorPos, (float)(30 * Math.PI / 180), Program.E.Range);

                List<Obj_AI_Base> dashableEnemies = EntityManager.Enemies.Where(a => !a.IsDead && a.MeetsCriteria() && YasuoCalcs.ERequirements(a, goUnderEnemyTower) && a.IsInRange(Yasuo.Position, Program.E.Range) && sector.IsInside(a)).OrderBy(a => YasuoCalcs.GetDashingEnd(a).Distance(Game.CursorPos)).ToList();
                List<Obj_AI_Base> dashableEnemiesWithTargets = dashableEnemies.Where(a => YasuoCalcs.GetDashingEnd(a).CountEnemyHeroesInRangeWithPrediction((int)Program.EQ.Range, 250) >= 1)
                    .OrderBy(a => YasuoCalcs.GetDashingEnd(a).CountEnemyHeroesInRangeWithPrediction((int)Program.EQ.Range, 250)).ToList();

                if (YasuoCalcs.WillQBeReady() && stackQ && !Yasuo.HasBuff("yasuoq3w") && dashableEnemies.Count != 0)
                    return CastEQ(dashableEnemies, false, goUnderEnemyTower);
                else if (YasuoCalcs.WillQBeReady() && EQ && dashableEnemiesWithTargets.Count != 0)
                    return CastEQ(dashableEnemies, false, goUnderEnemyTower, EQTargets);
                else
                    return CastE(dashableEnemies.FirstOrDefault());
            }
            return false;
        }