Esempio 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).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.
        }
Esempio n. 2
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:

                    if (!Config.collision["MinionCollision"].Cast <CheckBox>().CurrentValue)
                    {
                        break;
                    }
                    foreach (var minion in
                             MinionManager.GetMinions(
                                 from.To3D(), 1200, MinionTypes.All,
                                 skillshot.Unit.Team == ObjectManager.Player.Team
                                    ? MinionTeam.NotAlly
                                    : MinionTeam.NotAllyForEnemy))
                    {
                        var pred = FastPrediction(
                            from, minion,
                            Math.Max(0, skillshot.SpellData.Delay - (Environment.TickCount - skillshot.StartTick)),
                            skillshot.SpellData.MissileSpeed);
                        var pos = pred.PredictedPos;
                        var w   = skillshot.SpellData.RawRadius + (!pred.IsMoving ? (minion.BoundingRadius - 15) : 0) -
                                  pos.Distance(from, skillshot.End, true);
                        if (w > 0)
                        {
                            collisions.Add(
                                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:
                    if (!Config.collision["HeroCollision"].Cast <CheckBox>().CurrentValue)
                    {
                        break;
                    }
                    foreach (var hero in
                             ObjectManager.Get <AIHeroClient>()
                             .Where(
                                 h =>
                                 (h.IsValidTarget(1200, false) && h.Team == ObjectManager.Player.Team && !h.IsMe ||
                                  Config.TestOnAllies && h.Team != ObjectManager.Player.Team)))
                    {
                        var pred = FastPrediction(
                            from, ObjectManager.Player,
                            Math.Max(0, skillshot.SpellData.Delay - (Environment.TickCount - skillshot.StartTick)),
                            skillshot.SpellData.MissileSpeed);
                        var pos = pred.PredictedPos;

                        var w = skillshot.SpellData.RawRadius + 30 - pos.Distance(from, skillshot.End, true);
                        if (w > 0)
                        {
                            collisions.Add(
                                new DetectedCollision
                            {
                                Position =
                                    pos.ProjectOn(skillshot.End, skillshot.Start).LinePoint +
                                    skillshot.Direction * 30,
                                Unit     = ObjectManager.Player,
                                Type     = CollisionObjectTypes.Minion,
                                Distance = pos.Distance(from),
                                Diff     = w,
                            });
                        }
                    }
                    break;

                case CollisionObjectTypes.YasuoWall:
                    if (!Config.collision["YasuoCollision"].Cast <CheckBox>().CurrentValue)
                    {
                        break;
                    }
                    if (
                        !ObjectManager.Get <AIHeroClient>()
                        .Any(
                            hero =>
                            ObjectManager.Player.IsValidTarget(float.MaxValue, false) &&
                            ObjectManager.Player.Team == ObjectManager.Player.Team && ObjectManager.Player.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 Geometry.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.End);
                        if (inter.Intersects)
                        {
                            intersections.Add(inter.Point);
                        }
                    }

                    if (intersections.Count > 0)
                    {
                        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 - WallCastT < 4000)
                        {
                            if (skillshot.SpellData.Type != SkillShotType.SkillshotMissileLine)
                            {
                                skillshot.ForceDisabled = true;
                            }
                            return(intersection);
                        }
                    }

                    break;
                }
            }

            Vector2 result;

            if (collisions.Count > 0)
            {
                result = collisions.OrderBy(c => c.Distance).ToList()[0].Position;
            }
            else
            {
                result = new Vector2();
            }

            return(result);
        }
Esempio n. 3
0
        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 &&
                Utils.TickCount - _lastCollisionCalc > 50 && Config.Menu.Item("EnableCollision").GetValue <bool>())
            {
                _lastCollisionCalc = Utils.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();
                }
            }

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

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

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

            if (SpellData.FollowCaster)
            {
                Circle.Center = Unit.ServerPosition.To2D();
                UpdatePolygon();
            }
        }
Esempio 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:

                        if (!Config.collision["MinionCollision"].Cast<CheckBox>().CurrentValue)
                        {
                            break;
                        }
                        foreach (var minion in
                            EntityManager.MinionsAndMonsters.Get(EntityManager.MinionsAndMonsters.EntityType.Both, skillshot.Unit.Team == ObjectManager.Player.Team
                                    ? EntityManager.UnitTeam.Enemy
                                    : EntityManager.UnitTeam.Ally,
                            from.To3D(), 1200))

                        {
                            var pred = FastPrediction(
                                from, minion,
                                Math.Max(0, skillshot.SpellData.Delay - (Utils.TickCount - skillshot.StartTick)),
                                skillshot.SpellData.MissileSpeed);
                            var pos = pred.PredictedPos;
                            var w = skillshot.SpellData.RawRadius + (!pred.IsMoving ? (minion.BoundingRadius - 15) : 0) -
                                    pos.Distance(from, skillshot.End, true);
                            if (w > 0)
                            {
                                collisions.Add(
                                    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:
                        if (!Config.collision["HeroCollision"].Cast<CheckBox>().CurrentValue)
                        {
                            break;
                        }
                        foreach (var hero in
                            ObjectManager.Get<AIHeroClient>()
                                .Where(
                                    h =>
                                        (h.IsValidTarget(1200) && h.Team == ObjectManager.Player.Team && !h.IsMe ||
                                         Config.TestOnAllies && h.Team != ObjectManager.Player.Team)))
                        {
                            var pred = FastPrediction(
                                from, hero,
                                Math.Max(0, skillshot.SpellData.Delay - (Utils.TickCount - skillshot.StartTick)),
                                skillshot.SpellData.MissileSpeed);
                            var pos = pred.PredictedPos;

                            var w = skillshot.SpellData.RawRadius + 30 - pos.Distance(from, skillshot.End, true);
                            if (w > 0)
                            {
                                collisions.Add(
                                    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 (!Config.collision["YasuoCollision"].Cast<CheckBox>().CurrentValue)
                        {
                            break;
                        }
                        if (
                            !ObjectManager.Get<AIHeroClient>()
                                .Any(
                                    hero =>
                                        hero.IsValidTarget(float.MaxValue) &&
                                        hero.Team == ObjectManager.Player.Team && hero.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 Geometry.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.End);
                            if (inter.Intersects)
                            {
                                intersections.Add(inter.Point);
                            }
                        }

                        if (intersections.Count > 0)
                        {
                            intersection = intersections.OrderBy(item => item.Distance(from)).ToList()[0];
                            var collisionT = Utils.TickCount +
                                             Math.Max(
                                                 0,
                                                 skillshot.SpellData.Delay -
                                                 (Utils.TickCount - 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;
                }
            }

            Vector2 result;
            if (collisions.Count > 0)
            {
                result = collisions.OrderBy(c => c.Distance).ToList()[0].Position;
            }
            else
            {
                result = new Vector2();
            }

            return result;
        }
Esempio n. 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;

            //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.
        }
Esempio n. 6
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();
                }
            }
        }
Esempio n. 7
0
        public void Game_OnGameUpdate()
        {
            // Even if it doesnt consume a lot of resources with 20 updatest second works.
            if (SpellData.CollisionObjects != null && SpellData.CollisionObjects.Count() > 0 &&
                Utils.TickCount - _lastCollisionCalc > 50 && Config.collision["EnableCollision"].GetValue <MenuBool>().Value)
            {
                _lastCollisionCalc = Utils.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();
            }

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

            if (SpellData.FollowCaster)
            {
                switch (SpellData.Type)
                {
                case SkillShotType.SkillshotCircle:
                    Circle.Center = Unit.Position.ToVector2();
                    UpdatePolygon();
                    break;

                case SkillShotType.SkillshotLine:
                    Start     = Unit.Position.ToVector2();
                    End       = Start + Direction * SpellData.Range;
                    Rectangle = new Geometry.Rectangle(Start, End, SpellData.Radius);
                    UpdatePolygon();
                    break;

                case SkillShotType.SkillshotCone:
                    Sector.Center = Unit.Position.ToVector2();
                    UpdatePolygon();
                    break;
                }
            }

            if (SpellData.SpellName == "AatroxQ3")
            {
                Circle.Center = Unit.Position.ToVector2() + Direction * 3 * Unit.BoundingRadius;
                UpdatePolygon();
            }

            if (SpellData.SpellName == "JinxR" && !_speedUp)
            {
                SpellData.MissileSpeed = 1700;
                if (Utils.TickCount - StartTick >= 450)
                {
                    _speedUp = true;
                    SpellData.MissileSpeed += 500;
                }
            }

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

                SpellData.MissileSpeed = (int)Unit.MoveSpeed;
                if (Unit.IsValidTarget(float.MaxValue, false))
                {
                    if (!Unit.HasBuff("SionR") && Utils.TickCount - _helperTick > 600)
                    {
                        StartTick = 0;
                    }
                    else
                    {
                        StartTick = Utils.TickCount - SpellData.Delay;
                        Start     = Unit.Position.ToVector2();
                        End       = Unit.Position.ToVector2() + 1000 * Unit.Direction.ToVector2().Perpendicular();
                        Direction = (End - Start).Normalized();
                        UpdatePolygon();
                    }
                }
                else
                {
                    StartTick = 0;
                }
            }

            if ((SpellData.SpellName == "XayahQMissile1" || SpellData.SpellName == "XayahQMissile2") && !_speedUp)
            {
                SpellData.MissileSpeed = 400;
                if (Utils.TickCount - StartTick >= SpellData.Delay + 60)
                {
                    _speedUp = true;
                    SpellData.MissileSpeed += 3500;
                }
            }
        }
Esempio n. 8
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:
                    if (!Config.collision["MinionCollision"].GetValue <MenuBool>().Value)
                    {
                        break;
                    }

                    var minionList =
                        GameObjects.Jungle
                        .Where(
                            m =>
                            m.IsValidTarget(1200, false, from.ToVector3()) &&
                            (!skillshot.SpellData.CollisionExceptMini || m.GetJungleType() != JungleType.Small)).ToList();

                    if (!skillshot.SpellData.CollisionExceptMini)
                    {
                        minionList.AddRange(
                            GameObjects.Minions
                            .Where(
                                m =>
                                m.IsValidTarget(1200, false, from.ToVector3())));
                    }

                    foreach (var minion in minionList)
                    {
                        var pred = FastPrediction(
                            from, minion,
                            Math.Max(0, skillshot.SpellData.Delay - (Utils.TickCount - skillshot.StartTick)),
                            skillshot.SpellData.MissileSpeed);
                        var pos = pred.PredictedPos;
                        var w   = skillshot.SpellData.RawRadius + (!pred.IsMoving ? (minion.BoundingRadius - 15) : 0) - pos.Distance(from, skillshot.End, true);

                        if (w > 0)
                        {
                            collisions.Add(
                                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:
                    if (!Config.collision["HeroCollision"].GetValue <MenuBool>().Value)
                    {
                        break;
                    }

                    var heroTeam = skillshot.Unit == null
                            ? ObjectManager.Player.Team
                            : (skillshot.Unit.Team == GameObjectTeam.Order
                                ? GameObjectTeam.Chaos
                                : GameObjectTeam.Order);

                    foreach (var hero in
                             GameObjects.Heroes
                             .Where(
                                 h =>
                                 h.IsValidTarget(1200, false) &&
                                 h.Team == heroTeam &&
                                 !h.IsMe))
                    {
                        var pred = FastPrediction(
                            from, hero,
                            Math.Max(0, skillshot.SpellData.Delay - (Utils.TickCount - skillshot.StartTick)),
                            skillshot.SpellData.MissileSpeed);
                        var pos = pred.PredictedPos;
                        var w   = skillshot.SpellData.RawRadius + 30 - pos.Distance(from, skillshot.End, true);

                        if (w > 0)
                        {
                            collisions.Add(
                                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 (!Config.collision["YasuoCollision"].GetValue <MenuBool>().Value)
                    {
                        break;
                    }

                    var wallTeam = skillshot.Unit == null
                            ? ObjectManager.Player.Team
                            : (skillshot.Unit.Team == GameObjectTeam.Order
                                ? GameObjectTeam.Chaos
                                : GameObjectTeam.Order);

                    if (!GameObjects.Heroes
                        .Any(
                            hero =>
                            hero.IsValidTarget(float.MaxValue, false) &&
                            hero.Team == wallTeam &&
                            hero.CharacterName == "Yasuo"))
                    {
                        break;
                    }

                    var intersections = new List <Tuple <Vector2, float> >();

                    foreach (var effectEmitter in GameObjects.ParticleEmitters)
                    {
                        if (effectEmitter.IsValid &&
                            Regex.IsMatch(effectEmitter.Name,
                                          wallTeam == ObjectManager.Player.Team
                                        ? @"Yasuo_.+_W_windwall\d"
                                        : @"Yasuo_.+_w_windwall_enemy_\d", RegexOptions.IgnoreCase))
                        {
                            var wall          = effectEmitter;
                            var lvlLen        = wallTeam == ObjectManager.Player.Team ? 1 : 2;
                            var level         = wall.Name.Substring(wall.Name.Length - lvlLen, lvlLen);
                            var wallWidth     = 250 + 50 * Convert.ToInt32(level);
                            var wallDirection = wall.Perpendicular.ToVector2();
                            var wallStart     = wall.Position.ToVector2() + wallWidth / 2 * wallDirection;
                            var wallEnd       = wallStart - wallWidth * wallDirection;
                            var wallPolygon   = new Geometry.Rectangle(wallStart, wallEnd, 75).ToPolygon();

                            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(new Tuple <Vector2, float>(inter.Point, wall.RestartTime));
                                }
                            }
                        }
                    }

                    if (intersections.Count > 0)
                    {
                        var sortedIntersections = intersections.OrderBy(item => item.Item1.Distance(from)).ToList();
                        foreach (var inter in sortedIntersections)
                        {
                            var collisionT = Utils.TickCount +
                                             Math.Max(
                                0,
                                skillshot.SpellData.Delay -
                                (Utils.TickCount - skillshot.StartTick)) + 100 +
                                             (1000 * inter.Item1.Distance(from)) / skillshot.SpellData.MissileSpeed;
                            if (collisionT - inter.Item2 < 4000)
                            {
                                if (skillshot.SpellData.Type != SkillShotType.SkillshotMissileLine)
                                {
                                    skillshot.ForceDisabled = true;
                                }
                                return(inter.Item1);
                            }
                        }
                    }

                    break;

                case CollisionObjectTypes.Wall:
                    break;
                }
            }

            var result = Vector2.Zero;

            if (collisions.Count > 0)
            {
                result = collisions.OrderBy(c => c.Distance).ToList()[0].Position;
            }

            return(result);
        }
Esempio n. 9
0
        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 &&
                Utils.TickCount - _lastCollisionCalc > 50 && Config.collision["EnableCollision"].Cast<CheckBox>().CurrentValue)
            {
                _lastCollisionCalc = Utils.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();
                }
            }

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

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

            if (SpellData.FollowCaster)
            {
                Circle.Center = Unit.ServerPosition.To2D();
                UpdatePolygon();
            }
        }