Exemple #1
0
        public void Game_OnGameUpdate()
        {
            //Even if it doesnt consume a lot of resources with 20 updatest second works k
            if (SkillshotData.CollisionObjects.Count() > 0 && SkillshotData.CollisionObjects != null &&
                System.Environment.TickCount - _lastCollisionCalc > 50)
            {
                _lastCollisionCalc = System.Environment.TickCount;
                _collisionEnd      = Collision.GetCollisionPoint(this);
            }

            //Update the missile position each time the game updates.
            if (SkillshotData.Type == SkillShotType.SkillshotMissileLine)
            {
                Rectangle = new SkillshotGeometry.Rectangle(GetMissilePosition(0), CollisionEnd, SkillshotData.Radius);
                UpdatePolygon();
            }

            //Spells that update to the Caster position.
            if (SkillshotData.MissileFollowsUnit)
            {
                if (Caster.IsVisible)
                {
                    EndPosition = Caster.ServerPosition.To2D();
                    Direction   = (EndPosition - StartPosition).Normalized();
                    UpdatePolygon();
                }
            }
        }
Exemple #2
0
        public Skillshot(DetectionType detectionType,
                         SkillshotData skillshotData,
                         int startT,
                         Vector2 startPosition,
                         Vector2 endPosition,
                         Obj_AI_Base caster)
        {
            DetectionType   = detectionType;
            SkillshotData   = skillshotData;
            StartTick       = startT;
            StartPosition   = startPosition;
            EndPosition     = endPosition;
            MissilePosition = startPosition;
            Direction       = (endPosition - startPosition).Normalized();
            Caster          = caster;

            //Create the spatial object for each type of skillshot.
            switch (skillshotData.Type)
            {
            case SkillShotType.SkillshotCircle:
                Circle = new SkillshotGeometry.Circle(CollisionEnd, skillshotData.Radius);
                break;

            case SkillShotType.SkillshotLine:
                Rectangle = new SkillshotGeometry.Rectangle(StartPosition, CollisionEnd, skillshotData.Radius);
                break;

            case SkillShotType.SkillshotMissileLine:
                Rectangle = new SkillshotGeometry.Rectangle(StartPosition, CollisionEnd, skillshotData.Radius);
                break;

            case SkillShotType.SkillshotCone:
                Sector = new SkillshotGeometry.Sector(
                    startPosition, CollisionEnd - startPosition, skillshotData.Radius * (float)Math.PI / 180,
                    skillshotData.Range);
                break;

            case SkillShotType.SkillshotRing:
                Ring = new SkillshotGeometry.Ring(CollisionEnd, skillshotData.Radius, skillshotData.RingRadius);
                break;
            }

            UpdatePolygon(); // Create the polygon
        }
Exemple #3
0
        public static Vector2 GetCollisionPoint(Skillshot skillshot)
        {
            var collisions = new List <DetectedCollision>();
            var from       = skillshot.GetMissilePosition(0);

            skillshot.ForceDisabled = false;
            foreach (var cObject in skillshot.SkillshotData.CollisionObjects)
            {
                switch (cObject)
                {
                case CollisionObjectTypes.Minion:

                    collisions.AddRange(from minion in MinionManager.GetMinions(@from.To3D(), 1200, MinionTypes.All, skillshot.Caster.Team == ObjectManager.Player.Team ? MinionTeam.NotAlly : MinionTeam.NotAllyForEnemy)
                                        let pred                                             = FastPrediction(@from, minion, Math.Max(0, skillshot.SkillshotData.Delay - (System.Environment.TickCount - skillshot.StartTick)), skillshot.SkillshotData.MissileSpeed)
                                                                     let pos                 = pred.PredictedPos
                                                                                       let w = skillshot.SkillshotData.RawRadius + (!pred.IsMoving ? minion.BoundingRadius - 15 : 0) - pos.LSDistance(@from, skillshot.EndPosition, true)
                                                                                               where w > 0
                                                                                               select new DetectedCollision
                    {
                        Position = pos.ProjectOn(skillshot.EndPosition, skillshot.StartPosition).LinePoint + skillshot.Direction * 30, Unit = minion, Type = CollisionObjectTypes.Minion, Distance = pos.LSDistance(@from), Diff = w
                    });

                    break;

                case CollisionObjectTypes.Champions:
                    collisions.AddRange(from hero in ObjectManager.Get <AIHeroClient>().Where(h => h.LSIsValidTarget(1200) && h.Team == ObjectManager.Player.Team && !h.IsMe || h.Team != ObjectManager.Player.Team)
                                        let pred                                             = FastPrediction(@from, hero, Math.Max(0, skillshot.SkillshotData.Delay - (System.Environment.TickCount - skillshot.StartTick)), skillshot.SkillshotData.MissileSpeed)
                                                                     let pos                 = pred.PredictedPos
                                                                                       let w = skillshot.SkillshotData.RawRadius + 30 - pos.LSDistance(@from, skillshot.EndPosition, true)
                                                                                               where w > 0
                                                                                               select new DetectedCollision
                    {
                        Position = pos.ProjectOn(skillshot.EndPosition, skillshot.StartPosition).LinePoint + skillshot.Direction * 30, Unit = hero, Type = CollisionObjectTypes.Minion, Distance = pos.LSDistance(@from), Diff = w
                    });
                    break;

                case CollisionObjectTypes.YasuoWall:
                    if (
                        !ObjectManager.Get <AIHeroClient>()
                        .Any(
                            hero =>
                            hero.LSIsValidTarget(float.MaxValue) &&
                            hero.Team == ObjectManager.Player.Team && hero.ChampionName == "Yasuo"))
                    {
                        break;
                    }
                    GameObject wall = null;
                    foreach (var gameObject in ObjectManager.Get <GameObject>())
                    {
                        if (gameObject.IsValid &&
                            Regex.IsMatch(gameObject.Name, "_w_windwall.\\.troy", RegexOptions.IgnoreCase))
                        {
                            wall = gameObject;
                        }
                    }
                    if (wall == null)
                    {
                        break;
                    }
                    var level     = wall.Name.Substring(wall.Name.Length - 6, 1);
                    var wallWidth = 300 + 50 * Convert.ToInt32(level);


                    var wallDirection = (wall.Position.LSTo2D() - _yasuoWallCastedPos).Normalized().Perpendicular();
                    var wallStart     = wall.Position.LSTo2D() + wallWidth / 2 * wallDirection;
                    var wallEnd       = wallStart - wallWidth * wallDirection;
                    var wallPolygon   = new SkillshotGeometry.Rectangle(wallStart, wallEnd, 75).ToPolygon();
                    var intersection  = new Vector2();
                    var intersections = new List <Vector2>();

                    for (var i = 0; i < wallPolygon.Points.Count; i++)
                    {
                        var inter =
                            wallPolygon.Points[i].Intersection(
                                wallPolygon.Points[i != wallPolygon.Points.Count - 1 ? i + 1 : 0], from,
                                skillshot.EndPosition);
                        if (inter.Intersects)
                        {
                            intersections.Add(inter.Point);
                        }
                    }

                    if (intersections.Count > 0)
                    {
                        intersection = intersections.OrderBy(item => item.LSDistance(from)).ToList()[0];
                        var collisionT = System.Environment.TickCount +
                                         Math.Max(
                            0,
                            skillshot.SkillshotData.Delay -
                            (System.Environment.TickCount - skillshot.StartTick)) + 100 +
                                         1000 * intersection.LSDistance(@from) / skillshot.SkillshotData.MissileSpeed;
                        if (collisionT - _wallCastT < 4000)
                        {
                            if (skillshot.SkillshotData.Type != SkillShotType.SkillshotMissileLine)
                            {
                                skillshot.ForceDisabled = true;
                            }
                            return(intersection);
                        }
                    }

                    break;
                }
            }

            Vector2 result;

            result = collisions.Count > 0 ? collisions.OrderBy(c => c.Distance).ToList()[0].Position : new Vector2();

            return(result);
        }
Exemple #4
0
        public Skillshot(DetectionType detectionType,
            SkillshotData skillshotData,
            int startT,
            Vector2 startPosition,
            Vector2 endPosition,
            Obj_AI_Base caster)
        {
            DetectionType = detectionType;
            SkillshotData = skillshotData;
            StartTick = startT;
            StartPosition = startPosition;
            EndPosition = endPosition;
            MissilePosition = startPosition;
            Direction = (endPosition - startPosition).Normalized();
            Caster = caster;

            //Create the spatial object for each type of skillshot.
            switch (skillshotData.Type)
            {
                case SkillShotType.SkillshotCircle:
                    Circle = new SkillshotGeometry.Circle(CollisionEnd, skillshotData.Radius);
                    break;
                case SkillShotType.SkillshotLine:
                    Rectangle = new SkillshotGeometry.Rectangle(StartPosition, CollisionEnd, skillshotData.Radius);
                    break;
                case SkillShotType.SkillshotMissileLine:
                    Rectangle = new SkillshotGeometry.Rectangle(StartPosition, CollisionEnd, skillshotData.Radius);
                    break;
                case SkillShotType.SkillshotCone:
                    Sector = new SkillshotGeometry.Sector(
                        startPosition, CollisionEnd - startPosition, skillshotData.Radius*(float) Math.PI/180,
                        skillshotData.Range);
                    break;
                case SkillShotType.SkillshotRing:
                    Ring = new SkillshotGeometry.Ring(CollisionEnd, skillshotData.Radius, skillshotData.RingRadius);
                    break;
            }

            UpdatePolygon(); // Create the polygon
        }
Exemple #5
0
        public void Game_OnGameUpdate()
        {
            //Even if it doesnt consume a lot of resources with 20 updatest second works k
            if (SkillshotData.CollisionObjects.Count() > 0 && SkillshotData.CollisionObjects != null &&
                System.Environment.TickCount - _lastCollisionCalc > 50)
            {
                _lastCollisionCalc = System.Environment.TickCount;
                _collisionEnd = Collision.GetCollisionPoint(this);
            }

            //Update the missile position each time the game updates.
            if (SkillshotData.Type == SkillShotType.SkillshotMissileLine)
            {
                Rectangle = new SkillshotGeometry.Rectangle(GetMissilePosition(0), CollisionEnd, SkillshotData.Radius);
                UpdatePolygon();
            }

            //Spells that update to the Caster position.
            if (SkillshotData.MissileFollowsUnit)
            {
                if (Caster.IsVisible)
                {
                    EndPosition = Caster.ServerPosition.To2D();
                    Direction = (EndPosition - StartPosition).Normalized();
                    UpdatePolygon();
                }
            }
        }
Exemple #6
0
        public static Vector2 GetCollisionPoint(Skillshot skillshot)
        {
            var collisions = new List<DetectedCollision>();
            var from = skillshot.GetMissilePosition(0);
            skillshot.ForceDisabled = false;
            foreach (var cObject in skillshot.SkillshotData.CollisionObjects)
            {
                switch (cObject)
                {
                    case CollisionObjectTypes.Minion:

                        collisions.AddRange(from minion in MinionManager.GetMinions(@from.To3D(), 1200, MinionTypes.All, skillshot.Caster.Team == ObjectManager.Player.Team ? MinionTeam.NotAlly : MinionTeam.NotAllyForEnemy)
                            let pred = FastPrediction(@from, minion, Math.Max(0, skillshot.SkillshotData.Delay - (System.Environment.TickCount - skillshot.StartTick)), skillshot.SkillshotData.MissileSpeed)
                            let pos = pred.PredictedPos
                            let w = skillshot.SkillshotData.RawRadius + (!pred.IsMoving ? minion.BoundingRadius - 15 : 0) - pos.LSDistance(@from, skillshot.EndPosition, true)
                            where w > 0
                            select new DetectedCollision
                            {
                                Position = pos.ProjectOn(skillshot.EndPosition, skillshot.StartPosition).LinePoint + skillshot.Direction*30, Unit = minion, Type = CollisionObjectTypes.Minion, Distance = pos.LSDistance(@from), Diff = w
                            });

                        break;

                    case CollisionObjectTypes.Champions:
                        collisions.AddRange(from hero in ObjectManager.Get<AIHeroClient>().Where(h => h.LSIsValidTarget(1200) && h.Team == ObjectManager.Player.Team && !h.IsMe || h.Team != ObjectManager.Player.Team)
                            let pred = FastPrediction(@from, hero, Math.Max(0, skillshot.SkillshotData.Delay - (System.Environment.TickCount - skillshot.StartTick)), skillshot.SkillshotData.MissileSpeed)
                            let pos = pred.PredictedPos
                            let w = skillshot.SkillshotData.RawRadius + 30 - pos.LSDistance(@from, skillshot.EndPosition, true)
                            where w > 0
                            select new DetectedCollision
                            {
                                Position = pos.ProjectOn(skillshot.EndPosition, skillshot.StartPosition).LinePoint + skillshot.Direction*30, Unit = hero, Type = CollisionObjectTypes.Minion, Distance = pos.LSDistance(@from), Diff = w
                            });
                        break;

                    case CollisionObjectTypes.YasuoWall:
                        if (
                            !ObjectManager.Get<AIHeroClient>()
                                .Any(
                                    hero =>
                                        hero.LSIsValidTarget(float.MaxValue) &&
                                        hero.Team == ObjectManager.Player.Team && hero.ChampionName == "Yasuo"))
                        {
                            break;
                        }
                        GameObject wall = null;
                        foreach (var gameObject in ObjectManager.Get<GameObject>())
                        {
                            if (gameObject.IsValid &&
                                Regex.IsMatch(gameObject.Name, "_w_windwall.\\.troy", RegexOptions.IgnoreCase))
                            {
                                wall = gameObject;
                            }
                        }
                        if (wall == null)
                        {
                            break;
                        }
                        var level = wall.Name.Substring(wall.Name.Length - 6, 1);
                        var wallWidth = 300 + 50*Convert.ToInt32(level);

                        var wallDirection = (wall.Position.LSTo2D() - _yasuoWallCastedPos).Normalized().Perpendicular();
                        var wallStart = wall.Position.LSTo2D() + wallWidth/2*wallDirection;
                        var wallEnd = wallStart - wallWidth*wallDirection;
                        var wallPolygon = new SkillshotGeometry.Rectangle(wallStart, wallEnd, 75).ToPolygon();
                        var intersection = new Vector2();
                        var intersections = new List<Vector2>();

                        for (var i = 0; i < wallPolygon.Points.Count; i++)
                        {
                            var inter =
                                wallPolygon.Points[i].Intersection(
                                    wallPolygon.Points[i != wallPolygon.Points.Count - 1 ? i + 1 : 0], from,
                                    skillshot.EndPosition);
                            if (inter.Intersects)
                            {
                                intersections.Add(inter.Point);
                            }
                        }

                        if (intersections.Count > 0)
                        {
                            intersection = intersections.OrderBy(item => item.LSDistance(from)).ToList()[0];
                            var collisionT = System.Environment.TickCount +
                                             Math.Max(
                                                 0,
                                                 skillshot.SkillshotData.Delay -
                                                 (System.Environment.TickCount - skillshot.StartTick)) + 100 +
                                             1000*intersection.LSDistance(@from)/skillshot.SkillshotData.MissileSpeed;
                            if (collisionT - _wallCastT < 4000)
                            {
                                if (skillshot.SkillshotData.Type != SkillShotType.SkillshotMissileLine)
                                {
                                    skillshot.ForceDisabled = true;
                                }
                                return intersection;
                            }
                        }

                        break;
                }
            }

            Vector2 result;
            result = collisions.Count > 0 ? collisions.OrderBy(c => c.Distance).ToList()[0].Position : new Vector2();

            return result;
        }