Beispiel #1
0
        private static void QLogic(AIHeroClient target, bool useExtendQ = true)
        {
            if (!Q.IsReady() || target == null || target.IsDead || target.IsUnKillable())
            {
                return;
            }

            if (target.IsValidTarget(Q.Range))
            {
                Q.CastOnUnit(target, true);
            }
            else if (target.IsValidTarget(QExtend.Range) && useExtendQ)
            {
                var collisions = MinionManager.GetMinions(Me.Position, Q.Range, MinionTypes.All, MinionTeam.NotAlly);

                if (!collisions.Any())
                {
                    return;
                }

                foreach (var minion in collisions)
                {
                    var qPred    = QExtend.GetPrediction(target);
                    var qPloygon = new MyGeometry.Polygon.Rectangle(Me.Position,
                                                                    Me.Position.Extend(minion.Position, QExtend.Range), QExtend.Width);

                    if (qPloygon.IsInside(qPred.UnitPosition.To2D()))
                    {
                        Q.CastOnUnit(minion, true);
                        break;
                    }
                }
            }
        }
Beispiel #2
0
        private static bool GoThroughWall(Vector2 pos1, Vector2 pos2)
        {
            if (Wall == null)
            {
                return(false);
            }

            var wallWidth     = 300 + 50 * Convert.ToInt32(Wall.Name.Substring(Wall.Name.Length - 6, 1));
            var wallDirection = (Wall.Position.To2D() - wallCastedPos).Normalized().Perpendicular();
            var wallStart     = Wall.Position.To2D() + wallWidth / 2f * wallDirection;
            var wallEnd       = wallStart - wallWidth * wallDirection;
            var wallPolygon   = new MyGeometry.Polygon.Rectangle(wallStart, wallEnd, 75);
            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],
                        pos1,
                        pos2);

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

            return(intersections.Any());
        }
Beispiel #3
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 MyGeometry.Polygon.Circle(CollisionEnd, spellData.Radius, 22);
                break;

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

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

            case SkillShotType.SkillshotCone:
                Sector = new MyGeometry.Polygon.Sector(
                    start, CollisionEnd - start, spellData.Radius * (float)Math.PI / 180, spellData.Range, 22);
                break;

            case SkillShotType.SkillshotRing:
                Ring = new MyGeometry.Polygon.Ring(CollisionEnd, spellData.Radius, spellData.RingRadius, 22);
                break;

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

            UpdatePolygon();
        }
Beispiel #4
0
        public void OnUpdate()
        {
            if (SpellData.CollisionObjects.Length > 0 && SpellData.CollisionObjects != null &&
                Utils.GameTimeTickCount - _lastCollisionCalc > 50)
            {
                _lastCollisionCalc = Utils.GameTimeTickCount;
                _collisionEnd      = Collision.GetCollisionPoint(this);
            }

            if (SpellData.Type == SkillShotType.SkillshotMissileLine)
            {
                Rectangle = new MyGeometry.Polygon.Rectangle(GetMissilePosition(0), CollisionEnd, SpellData.Radius);
                UpdatePolygon();
            }

            if (SpellData.MissileFollowsUnit)
            {
                if (Unit.IsVisible)
                {
                    End       = Unit.ServerPosition.To2D();
                    Direction = (End - Start).Normalized();
                    UpdatePolygon();
                }
            }

            if (SpellData.SpellName == "TaricE")
            {
                Start     = Unit.ServerPosition.To2D();
                End       = Start + Direction * SpellData.Range;
                Rectangle = new MyGeometry.Polygon.Rectangle(Start, End, SpellData.Radius);
                UpdatePolygon();
            }

            if (SpellData.SpellName == "SionR")
            {
                if (_helperTick == 0)
                {
                    _helperTick = StartTick;
                }

                SpellData.MissileSpeed = (int)Unit.MoveSpeed;
                if (Unit.IsValidTarget())
                {
                    if (!Unit.HasBuff("SionR") && Utils.GameTimeTickCount - _helperTick > 600)
                    {
                        StartTick = 0;
                    }
                    else
                    {
                        StartTick = Utils.GameTimeTickCount - SpellData.Delay;
                        Start     = Unit.ServerPosition.To2D();
                        End       = Unit.ServerPosition.To2D() + 1000 * Unit.Orientation.To2D().Perpendicular();
                        Direction = (End - Start).Normalized();
                        UpdatePolygon();
                    }
                }
                else
                {
                    StartTick = 0;
                }
            }

            if (SpellData.FollowCaster)
            {
                Circle.Center = Unit.ServerPosition.To2D();
                UpdatePolygon();
            }
        }
Beispiel #5
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.SpellData.CollisionObjects)
            {
                switch (cObject)
                {
                case CollisionObjectTypes.Minion:
                    collisions.AddRange(
                        from minion in
                        GameObjects.EnemyMinions.Where(
                            x => x.IsValidTarget(1200, false, false, @from.To3D()) && x.MaxHealth > 5)
                        let pred =
                            FastPrediction(@from, minion,
                                           Math.Max(0, skillshot.SpellData.Delay - (Utils.GameTimeTickCount - 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,
                        Unit     = minion,
                        Type     = CollisionObjectTypes.Minion,
                        Distance = pos.Distance(@from),
                        Diff     = w,
                    });
                    break;

                case CollisionObjectTypes.Champions:
                    collisions.AddRange(
                        from hero in GameObjects.AllyHeroes.Where(x => x.IsValidTarget(1200) && !x.IsMe)
                        let pred =
                            FastPrediction(@from, hero,
                                           Math.Max(0, skillshot.SpellData.Delay - (Utils.GameTimeTickCount - 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,
                        Unit     = hero,
                        Type     = CollisionObjectTypes.Minion,
                        Distance = pos.Distance(@from),
                        Diff     = w,
                    });
                    break;

                case CollisionObjectTypes.YasuoWall:
                    if (GameObjects.AllyHeroes.All(x => x.ChampionName != "Yasuo"))
                    {
                        break;
                    }

                    GameObject wall = null;

                    foreach (var gameObject in ObjectManager.Get <GameObject>())
                    {
                        if (gameObject.IsValid &&
                            System.Text.RegularExpressions.Regex.IsMatch(
                                gameObject.Name, "_w_windwall.\\.troy",
                                System.Text.RegularExpressions.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.To2D() - YasuoWallCastedPos).Normalized().Perpendicular();
                    var wallStart     = wall.Position.To2D() + wallWidth / 2 * wallDirection;
                    var wallEnd       = wallStart - wallWidth * wallDirection;
                    var wallPolygon   = new MyGeometry.Polygon.Rectangle(wallStart, wallEnd, 75);
                    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.End);
                        if (inter.Intersects)
                        {
                            intersections.Add(inter.Point);
                        }
                    }

                    if (intersections.Count > 0)
                    {
                        intersection = intersections.OrderBy(item => item.Distance(from)).ToList()[0];

                        var collisionT = Utils.GameTimeTickCount +
                                         Math.Max(
                            0,
                            skillshot.SpellData.Delay -
                            (Utils.GameTimeTickCount - skillshot.StartTick)) + 100 +
                                         1000 * intersection.Distance(from) / skillshot.SpellData.MissileSpeed;

                        if (collisionT - WallCastT < 4000)
                        {
                            if (skillshot.SpellData.Type != SkillShotType.SkillshotMissileLine)
                            {
                                skillshot.ForceDisabled = true;
                            }

                            return(intersection);
                        }
                    }
                    break;
                }
            }

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