Ejemplo n.º 1
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).LSNormalized();

            Unit = unit;

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

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

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

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

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

            UpdatePolygon(); //Create the polygon.
        }
Ejemplo n.º 2
0
        //public bool Evade()
        //{
        //    if (ForceDisabled)
        //    {
        //        return false;
        //    }
        //    if (Environment.TickCount - _cachedValueTick < 100)
        //    {
        //        return _cachedValue;
        //    }
        //    if (!ConfigValue<bool>("IsDangerous") && Config.Menu.Item("OnlyDangerous").ConfigValue<KeyBind>().Active)
        //    {
        //        _cachedValue = false;
        //        _cachedValueTick = Environment.TickCount;
        //        return _cachedValue;
        //    }
        //    _cachedValue = ConfigValue<bool>("Enabled");
        //    _cachedValueTick = Environment.TickCount;
        //    return _cachedValue;
        //}
        public void Game_OnGameUpdate()
        {
            //Even if it doesnt consume a lot of resources with 20 updatest second works k
            if (SpellData.CollisionObjects.Count() > 0 && SpellData.CollisionObjects != null &&
                Environment.TickCount - _lastCollisionCalc > 50)
            {
                _lastCollisionCalc = Environment.TickCount;
                _collisionEnd = Collision.GetCollisionPoint(this);
            }

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

            //Spells that update to the unit position.
            if (SpellData.MissileFollowsUnit)
            {
                if (Unit.IsVisible)
                {
                    End = Unit.ServerPosition.To2D();
                    Direction = (End - Start).Normalized();
                    UpdatePolygon();
                }
            }
        }
Ejemplo n.º 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;

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

            UpdatePolygon(); //Create the polygon.
        }
Ejemplo n.º 4
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
                        MinionManager.GetMinions(
                            @from.To3D(), 1200, MinionTypes.All,
                            skillshot.Unit.Team == ObjectManager.Player.Team
                                        ? MinionTeam.NotAlly
                                        : MinionTeam.NotAllyForEnemy)
                        let pred =
                            FastPrediction(
                                @from, minion,
                                Math.Max(
                                    0, skillshot.SpellData.Delay - (Environment.TickCount - skillshot.StartTick)),
                                skillshot.SpellData.MissileSpeed)
                            let pos                 = pred.PredictedPosVector2
                                              let w =
                                skillshot.SpellData.RawRadius + (!pred.IsMoving ? (minion.BoundingRadius - 15) : 0) -
                                pos.Distance(@from, skillshot.End, true)
                                where w > 0
                                select
                                new DetectedCollision
                    {
                        PositionVector2 =
                            pos.ProjectOn(skillshot.End, skillshot.Start).LinePoint +
                            skillshot.Direction * 30,
                        UnitAiBase = minion,
                        Type       = CollisionObjectTypes.Minion,
                        Distance   = pos.Distance(@from),
                        Difference = w
                    });

                    break;

                case CollisionObjectTypes.Champion:
                    collisions.AddRange(
                        from hero in
                        ObjectManager.Get <AIHeroClient>()
                        .Where(
                            h =>
                            (h.IsValidTarget(1200, false) && h.Team == ObjectManager.Player.Team &&
                             !h.IsMe || h.Team != ObjectManager.Player.Team))
                        let pred =
                            FastPrediction(
                                @from, hero,
                                Math.Max(
                                    0, skillshot.SpellData.Delay - (Environment.TickCount - skillshot.StartTick)),
                                skillshot.SpellData.MissileSpeed)
                            let pos                 = pred.PredictedPosVector2
                                              let w = skillshot.SpellData.RawRadius + 30 - pos.Distance(@from, skillshot.End, true)
                                                      where w > 0
                                                      select
                                                      new DetectedCollision
                    {
                        PositionVector2 =
                            pos.ProjectOn(skillshot.End, skillshot.Start).LinePoint +
                            skillshot.Direction * 30,
                        UnitAiBase = hero,
                        Type       = CollisionObjectTypes.Minion,
                        Distance   = pos.Distance(@from),
                        Difference = w
                    });
                    break;

                case CollisionObjectTypes.YasuoWall:
                    if (
                        !ObjectManager.Get <AIHeroClient>()
                        .Any(
                            hero =>
                            hero.IsValidTarget(float.MaxValue, false) &&
                            hero.Team == ObjectManager.Player.Team && hero.ChampionName == "Yasuo"))
                    {
                        break;
                    }
                    GameObject wall = null;
                    foreach (
                        var gameObject in
                        ObjectManager.Get <GameObject>()
                        .Where(
                            gameObject =>
                            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.To2D() - _yasuoWallVector2).Normalized().Perpendicular();
                    var fraction      = wallWidth / 0x2; // 0x2 = 2
                    var wallStart     = wall.Position.To2D() + fraction * wallDirection;
                    var wallEnd       = wallStart - wallWidth * wallDirection;
                    var wallPolygon   = new Geometry.Rectangle(wallStart, wallEnd, 75).ToPolygon();
                    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)
                    {
                        var intersection = intersections.OrderBy(item => item.Distance(from)).ToList()[0];
                        var collisionT   = Environment.TickCount +
                                           Math.Max(
                            0,
                            skillshot.SpellData.Delay -
                            (Environment.TickCount - skillshot.StartTick)) + 100 +
                                           (1000 * intersection.Distance(from)) / skillshot.SpellData.MissileSpeed;
                        if (collisionT - _wallCastTick < 4000)
                        {
                            if (skillshot.SpellData.Type != SkillShotType.SkillshotMissileLine)
                            {
                                skillshot.ForceDisabled = true;
                            }
                            return(intersection);
                        }
                    }

                    break;
                }
            }

            return(collisions.Count > 0
                ? collisions.OrderBy(c => c.Distance).ToList()[0].PositionVector2
                : new Vector2());
        }
Ejemplo n.º 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
                                MinionManager.GetMinions(
                                    @from.To3D(), 1200, MinionTypes.All,
                                    skillshot.Unit.Team == ObjectManager.Player.Team
                                        ? MinionTeam.NotAlly
                                        : MinionTeam.NotAllyForEnemy)
                            let pred =
                                FastPrediction(
                                    @from, minion,
                                    Math.Max(
                                        0, skillshot.SpellData.Delay - (Environment.TickCount - skillshot.StartTick)),
                                    skillshot.SpellData.MissileSpeed)
                            let pos = pred.PredictedPosVector2
                            let w =
                                skillshot.SpellData.RawRadius + (!pred.IsMoving ? (minion.BoundingRadius - 15) : 0) -
                                pos.LSDistance(@from, skillshot.End, true)
                            where w > 0
                            select
                                new DetectedCollision
                                {
                                    PositionVector2 =
                                        pos.LSProjectOn(skillshot.End, skillshot.Start).LinePoint +
                                        skillshot.Direction * 30,
                                    UnitAiBase = minion,
                                    Type = CollisionObjectTypes.Minion,
                                    Distance = pos.LSDistance(@from),
                                    Difference = w
                                });

                        break;

                    case CollisionObjectTypes.Champion:
                        collisions.AddRange(
                            from hero in
                                ObjectManager.Get<AIHeroClient>()
                                    .Where(
                                        h =>
                                            (h.LSIsValidTarget(1200, false) && h.Team == ObjectManager.Player.Team &&
                                             !h.IsMe || h.Team != ObjectManager.Player.Team))
                            let pred =
                                FastPrediction(
                                    @from, hero,
                                    Math.Max(
                                        0, skillshot.SpellData.Delay - (Environment.TickCount - skillshot.StartTick)),
                                    skillshot.SpellData.MissileSpeed)
                            let pos = pred.PredictedPosVector2
                            let w = skillshot.SpellData.RawRadius + 30 - pos.LSDistance(@from, skillshot.End, true)
                            where w > 0
                            select
                                new DetectedCollision
                                {
                                    PositionVector2 =
                                        pos.LSProjectOn(skillshot.End, skillshot.Start).LinePoint +
                                        skillshot.Direction * 30,
                                    UnitAiBase = hero,
                                    Type = CollisionObjectTypes.Minion,
                                    Distance = pos.LSDistance(@from),
                                    Difference = w
                                });
                        break;

                    case CollisionObjectTypes.YasuoWall:
                        if (
                            !ObjectManager.Get<AIHeroClient>()
                                .Any(
                                    hero =>
                                        hero.LSIsValidTarget(float.MaxValue, false) &&
                                        hero.Team == ObjectManager.Player.Team && hero.ChampionName == "Yasuo"))
                        {
                            break;
                        }
                        GameObject wall = null;
                        foreach (
                            var gameObject in
                                ObjectManager.Get<GameObject>()
                                    .Where(
                                        gameObject =>
                                            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() - _yasuoWallVector2).LSNormalized().LSPerpendicular();
                        var fraction = wallWidth / 0x2; // 0x2 = 2
                        var wallStart = wall.Position.LSTo2D() + fraction * wallDirection;
                        var wallEnd = wallStart - wallWidth * wallDirection;
                        var wallPolygon = new Geometry.Rectangle(wallStart, wallEnd, 75).ToPolygon();
                        var intersections = new List<Vector2>();

                        for (var i = 0; i < wallPolygon.Points.Count; i++)
                        {
                            var inter =
                                wallPolygon.Points[i].LSIntersection(
                                    wallPolygon.Points[i != wallPolygon.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.LSDistance(from)).ToList()[0];
                            var collisionT = Environment.TickCount +
                                             Math.Max(
                                                 0,
                                                 skillshot.SpellData.Delay -
                                                 (Environment.TickCount - skillshot.StartTick)) + 100 +
                                             (1000 * intersection.LSDistance(from)) / skillshot.SpellData.MissileSpeed;
                            if (collisionT - _wallCastTick < 4000)
                            {
                                if (skillshot.SpellData.Type != SkillShotType.SkillshotMissileLine)
                                {
                                    skillshot.ForceDisabled = true;
                                }
                                return intersection;
                            }
                        }

                        break;
                }
            }

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