Example #1
0
 internal override void UpdatePolygon()
 {
     if (this.Rectangle == null)
     {
         this.Rectangle = new RectanglePoly(this.StartPosition, this.EndPosition, this.SData.Radius);
         this.UpdatePath();
     }
 }
Example #2
0
 private static bool IsThroughWall(Vector3 from, Vector3 to)
 {
     if (wallLeft == null || wallRight == null)
     {
         return(false);
     }
     wallPoly = new RectanglePoly(wallLeft.Position, wallRight.Position, 75);
     for (var i = 0; i < wallPoly.Points.Count; i++)
     {
         var inter = wallPoly.Points[i].LSIntersection(
             wallPoly.Points[i != wallPoly.Points.Count - 1 ? i + 1 : 0],
             from.ToVector2(),
             to.ToVector2());
         if (inter.Intersects)
         {
             return(true);
         }
     }
     return(false);
 }
Example #3
0
 internal override void UpdatePolygon()
 {
     Rectangle = new RectanglePoly(this.StartPosition, this.EndPosition, this.SData.Width);
     this.UpdatePath();
 }
Example #4
0
 private static bool IsThroughWall(Vector3 from, Vector3 to)
 {
     if (wallLeft == null || wallRight == null)
     {
         return false;
     }
     wallPoly = new RectanglePoly(wallLeft.Position, wallRight.Position, 75);
     for (var i = 0; i < wallPoly.Points.Count; i++)
     {
         var inter = wallPoly.Points[i].LSIntersection(
             wallPoly.Points[i != wallPoly.Points.Count - 1 ? i + 1 : 0],
             from.ToVector2(),
             to.ToVector2());
         if (inter.Intersects)
         {
             return true;
         }
     }
     return false;
 }
Example #5
0
        /// <summary>
        ///     Returns the list of the units that the skill-shot will hit before reaching the set positions.
        /// </summary>
        /// <param name="positions">
        ///     The positions.
        /// </param>
        /// <param name="input">
        ///     The input.
        /// </param>
        /// <returns>
        ///     A list of <c>Obj_AI_Base</c>s which the input collides with.
        /// </returns>
        public static List<Obj_AI_Base> GetCollision(List<Vector3> positions, PredictionInput input)
        {
            var result = new List<Obj_AI_Base>();

            foreach (var position in positions)
            {
                if (input.CollisionObjects.HasFlag(CollisionableObjects.Minions))
                {
                    result.AddRange(
                        GameObjects.EnemyMinions.Where(i => i.IsMinion() || i.IsPet())
                            .Concat(GameObjects.Jungle)
                            .Where(
                                minion =>
                                minion.LSIsValidTarget(
                                    Math.Min(input.Range + input.Radius + 100, 2000),
                                    true,
                                    input.RangeCheckFrom) && IsHitCollision(minion, input, position, 15)));
                }

                if (input.CollisionObjects.HasFlag(CollisionableObjects.Heroes))
                {
                    result.AddRange(
                        GameObjects.EnemyHeroes.Where(
                            hero =>
                            hero.LSIsValidTarget(
                                Math.Min(input.Range + input.Radius + 100, 2000),
                                true,
                                input.RangeCheckFrom) && IsHitCollision(hero, input, position, 50)));
                }

                if (input.CollisionObjects.HasFlag(CollisionableObjects.Walls))
                {
                    var step = position.Distance(input.From) / 20;
                    for (var i = 0; i < 20; i++)
                    {
                        if (input.From.ToVector2().Extend(position, step * i).IsWall())
                        {
                            result.Add(GameObjects.Player);
                        }
                    }
                }

                if (input.CollisionObjects.HasFlag(CollisionableObjects.YasuoWall))
                {
                    if (yasuoWallLeft == null || yasuoWallRight == null)
                    {
                        continue;
                    }

                    yasuoWallPoly = new RectanglePoly(yasuoWallLeft.Position, yasuoWallRight.Position, 75);

                    var intersections = new List<Vector2>();
                    for (var i = 0; i < yasuoWallPoly.Points.Count; i++)
                    {
                        var inter =
                            yasuoWallPoly.Points[i].LSIntersection(
                                yasuoWallPoly.Points[i != yasuoWallPoly.Points.Count - 1 ? i + 1 : 0],
                                input.From.ToVector2(),
                                position.ToVector2());

                        if (inter.Intersects)
                        {
                            intersections.Add(inter.Point);
                        }
                    }

                    if (intersections.Count > 0)
                    {
                        result.Add(GameObjects.Player);
                    }
                }
            }

            return result.Distinct().ToList();
        }
Example #6
0
        internal static Vector2 GetCollisionPoint(Skillshot skillshot)
        {
            var collisions = new List <DetectedCollision>();
            var from       = skillshot.GetMissilePosition(0);

            skillshot.ForceDisabled = false;
            if (skillshot.SpellData.CollisionObjects.HasFlag(CollisionableObjects.Minions))
            {
                var minions = new List <Obj_AI_Minion>();
                minions.AddRange(GameObjects.Jungle.Where(i => i.IsValidTarget(1200, true, from.ToVector3())));
                minions.AddRange(
                    GameObjects.Minions.Where(
                        i =>
                        i.IsValidTarget(1200, false, from.ToVector3()) &&
                        (skillshot.Unit.Team == Program.Player.Team
                                ? i.Team != Program.Player.Team
                                : i.Team == Program.Player.Team) && (i.IsMinion() || i.IsPet())));
                collisions.AddRange(
                    from minion in minions
                    let pred =
                        FastPrediction(
                            @from,
                            minion,
                            Math.Max(0, skillshot.SpellData.Delay - (Variables.TickCount - skillshot.StartTick)),
                            skillshot.SpellData.MissileSpeed)
                        let pos                 = pred.PredictedPos
                                          let w =
                            skillshot.SpellData.RawRadius + (!pred.IsMoving ? minion.BoundingRadius - 15 : 0)
                            - pos.Distance(@from, skillshot.End, true)
                            where w > 0
                            select
                            new DetectedCollision
                {
                    Position =
                        pos.ProjectOn(skillshot.End, skillshot.Start).LinePoint + skillshot.Direction * 30,
                    Distance = pos.Distance(@from)
                });
            }
            if (skillshot.SpellData.CollisionObjects.HasFlag(CollisionableObjects.Heroes))
            {
                collisions.AddRange(
                    from hero in GameObjects.AllyHeroes.Where(i => i.IsValidTarget(1200, false) && !i.IsMe)
                    let pred =
                        FastPrediction(
                            @from,
                            hero,
                            Math.Max(0, skillshot.SpellData.Delay - (Variables.TickCount - skillshot.StartTick)),
                            skillshot.SpellData.MissileSpeed)
                        let pos                 = pred.PredictedPos
                                          let w = skillshot.SpellData.RawRadius + 30 - pos.Distance(@from, skillshot.End, true)
                                                  where w > 0
                                                  select
                                                  new DetectedCollision
                {
                    Position =
                        pos.ProjectOn(skillshot.End, skillshot.Start).LinePoint + skillshot.Direction * 30,
                    Distance = pos.Distance(@from)
                });
            }
            if (skillshot.SpellData.CollisionObjects.HasFlag(CollisionableObjects.YasuoWall))
            {
                if (yasuoWallLeft != null && yasuoWallRight != null)
                {
                    yasuoWallPoly = new RectanglePoly(yasuoWallLeft.Position, yasuoWallRight.Position, 75);
                    var intersections = new List <Vector2>();
                    for (var i = 0; i < yasuoWallPoly.Points.Count; i++)
                    {
                        var inter =
                            yasuoWallPoly.Points[i].Intersection(
                                yasuoWallPoly.Points[i != yasuoWallPoly.Points.Count - 1 ? i + 1 : 0],
                                from,
                                skillshot.End);
                        if (inter.Intersects)
                        {
                            intersections.Add(inter.Point);
                        }
                    }
                    if (intersections.Count > 0)
                    {
                        var intersection = intersections.OrderBy(item => item.Distance(from)).ToList()[0];
                        var collisionT   = Variables.TickCount
                                           + Math.Max(
                            0,
                            skillshot.SpellData.Delay - (Variables.TickCount - skillshot.StartTick))
                                           + 100
                                           + 1000
                                           * (Math.Abs(skillshot.SpellData.MissileSpeed - int.MaxValue) > 0
                                                ? intersection.Distance(from) / skillshot.SpellData.MissileSpeed
                                                : 0);
                        if (collisionT - yasuoWallTime < 4000)
                        {
                            if (skillshot.SpellData.Type != SkillShotType.SkillshotMissileLine)
                            {
                                skillshot.ForceDisabled = true;
                            }
                            return(intersection);
                        }
                    }
                }
            }
            return(collisions.Count > 0 ? collisions.OrderBy(i => i.Distance).First().Position : Vector2.Zero);
        }
Example #7
0
        public static int AoE(this Spell spell, Vector3 vector3)
        {
            var rect = new RectanglePoly(Config.Player.ServerPosition, Config.Player.ServerPosition.Extend(vector3, spell.Range), spell.Width);

            return(GameObjects.AllyHeroes.Count(a => a.IsValidTarget() && rect.IsInside(spell.GetPrediction(a).CastPosition)));
        }
Example #8
0
        public static void DrawRect(this Spell spell, Vector3 vector3, System.Drawing.Color color)
        {
            var rect = new RectanglePoly(Config.Player.ServerPosition, Config.Player.ServerPosition.Extend(vector3, spell.Range), spell.Width);

            rect.Draw(color, 2);
        }