Exemple #1
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:
                    var minions = new List <Obj_AI_Minion>();
                    minions.AddRange(ObjectManager.Get <Obj_AI_Minion>().Where(x => x.Team == GameObjectTeam.Neutral).Where(i => i.LSIsValidTarget(1200, true, from.To3D())));
                    minions.AddRange(
                        ObjectManager.Get <Obj_AI_Minion>().Where(
                            i =>
                            i.LSIsValidTarget(1200, false, @from.To3D()) &&
                            (skillshot.Unit.Team == ObjectManager.Player.Team
                                        ? i.Team != ObjectManager.Player.Team
                                        : i.Team == ObjectManager.Player.Team) && MinionManager.IsMinion(i)));
                    collisions.AddRange(
                        from minion in minions
                        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.LSDistance(@from, skillshot.End, true)
                                where w > 0
                                select
                                new DetectedCollision
                    {
                        Position =
                            pos.LSProjectOn(skillshot.End, skillshot.Start).LinePoint
                            + skillshot.Direction * 30,
                        Unit = minion,
                        Type = CollisionObjectTypes.Minion, Distance = pos.LSDistance(@from), Diff = w
                    });
                    break;

                case CollisionObjectTypes.Champions:
                    collisions.AddRange(
                        from hero in HeroManager.Allies.Where(i => i.LSIsValidTarget(1200, false) && !i.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.LSDistance(@from, skillshot.End, true)
                                                      where w > 0
                                                      select
                                                      new DetectedCollision
                    {
                        Position =
                            pos.LSProjectOn(skillshot.End, skillshot.Start).LinePoint
                            + skillshot.Direction * 30,
                        Unit     = hero, Type = CollisionObjectTypes.Minion,
                        Distance = pos.LSDistance(@from), Diff = w
                    });
                    break;

                case CollisionObjectTypes.YasuoWall:
                    if (
                        !HeroManager.Allies.Any(
                            i => i.LSIsValidTarget(float.MaxValue, false) && i.ChampionName == "Yasuo"))
                    {
                        break;
                    }
                    GameObject wall = null;
                    foreach (var gameObject in
                             ObjectManager.Get <GameObject>().Where(
                                 i => i.IsValid && Regex.IsMatch(i.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() - wallCastedPos).LSNormalized().LSPerpendicular();
                    var wallStart     = wall.Position.LSTo2D() + wallWidth / 2f * 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   = Utils.GameTimeTickCount
                                           + Math.Max(
                            0,
                            skillshot.SpellData.Delay - (Utils.GameTimeTickCount - skillshot.StartTick))
                                           + 100
                                           + (1000 * intersection.LSDistance(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(i => i.Distance).ToList()[0].Position : Vector2.Zero);
        }
Exemple #2
0
        public void OnUpdate()
        {
            if (this.SpellData.CollisionObjects.Length > 0 && this.SpellData.CollisionObjects != null
                && Utils.GameTimeTickCount - this.lastCollisionCalc > 50)
            {
                this.lastCollisionCalc = Utils.GameTimeTickCount;
                this.collisionEnd = Collision.GetCollisionPoint(this);
            }

            if (this.SpellData.Type == SkillShotType.SkillshotMissileLine)
            {
                this.Rectangle = new Geometry.Rectangle(
                    this.GetMissilePosition(0),
                    this.CollisionEnd,
                    this.SpellData.Radius);
                this.UpdatePolygon();
            }
            if (this.SpellData.MissileFollowsUnit && this.Unit.IsVisible)
            {
                this.End = this.Unit.ServerPosition.To2D();
                this.Direction = (this.End - this.Start).Normalized();
                this.UpdatePolygon();
            }
            if (this.SpellData.SpellName == "SionR")
            {
                if (this.helperTick == 0)
                {
                    this.helperTick = this.StartTick;
                }
                this.SpellData.MissileSpeed = (int)this.Unit.MoveSpeed;
                if (this.Unit.IsValidTarget(float.MaxValue, false))
                {
                    if (!this.Unit.HasBuff("SionR") && Utils.GameTimeTickCount - this.helperTick > 600)
                    {
                        this.StartTick = 0;
                    }
                    else
                    {
                        this.StartTick = Utils.GameTimeTickCount - this.SpellData.Delay;
                        this.Start = this.Unit.ServerPosition.To2D();
                        this.End = this.Unit.ServerPosition.To2D()
                                   + 1000 * this.Unit.Direction.To2D().Perpendicular();
                        this.Direction = (this.End - this.Start).Normalized();
                        this.UpdatePolygon();
                    }
                }
                else
                {
                    this.StartTick = 0;
                }
            }
            if (this.SpellData.FollowCaster)
            {
                this.Circle.Center = this.Unit.ServerPosition.To2D();
                this.UpdatePolygon();
            }
        }
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.SpellData.CollisionObjects)
     {
         switch (cObject)
         {
             case CollisionObjectTypes.Minion:
                 var minions = new List<Obj_AI_Minion>();
                 minions.AddRange(ObjectManager.Get<Obj_AI_Minion>().Where(x=> x.Team == GameObjectTeam.Neutral).Where(i => i.IsValidTarget(1200, true, from.To3D())));
                 minions.AddRange(
                     ObjectManager.Get<Obj_AI_Minion>().Where(
                         i =>
                         i.IsValidTarget(1200, false, @from.To3D())
                         && (skillshot.Unit.Team == ObjectManager.Player.Team
                                 ? i.Team != ObjectManager.Player.Team
                                 : i.Team == ObjectManager.Player.Team) && MinionManager.IsMinion(i)));
                 collisions.AddRange(
                     from minion in minions
                     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.Champion:
                 collisions.AddRange(
                     from hero in HeroManager.Allies.Where(i => i.IsValidTarget(1200, false) && !i.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 (
                     !HeroManager.Allies.Any(
                         i => i.IsValidTarget(float.MaxValue, false) && i.ChampionName == "Yasuo"))
                 {
                     break;
                 }
                 GameObject wall = null;
                 foreach (var gameObject in
                     ObjectManager.Get<GameObject>().Where(
                         i => i.IsValid && Regex.IsMatch(i.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() - wallCastedPos).Normalized().Perpendicular();
                 var wallStart = wall.Position.To2D() + wallWidth / 2f * 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 = 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(i => i.Distance).ToList()[0].Position : Vector2.Zero;
 }
Exemple #4
0
 public Skillshot(
     DetectionType detectionType,
     SpellData spellData,
     int startT,
     Vector2 start,
     Vector2 end,
     Obj_AI_Base unit)
 {
     this.DetectionType = detectionType;
     this.SpellData = spellData;
     this.StartTick = startT;
     this.Start = start;
     this.End = end;
     this.Direction = (end - start).Normalized();
     this.Unit = unit;
     switch (spellData.Type)
     {
         case SkillShotType.SkillshotCircle:
             this.Circle = new Geometry.Circle(this.CollisionEnd, spellData.Radius);
             break;
         case SkillShotType.SkillshotLine:
             this.Rectangle = new Geometry.Rectangle(this.Start, this.CollisionEnd, spellData.Radius);
             break;
         case SkillShotType.SkillshotMissileLine:
             this.Rectangle = new Geometry.Rectangle(this.Start, this.CollisionEnd, spellData.Radius);
             break;
         case SkillShotType.SkillshotCone:
             this.Sector = new Geometry.Sector(
                 start,
                 this.CollisionEnd - start,
                 spellData.Radius * (float)Math.PI / 180,
                 spellData.Range);
             break;
         case SkillShotType.SkillshotRing:
             this.Ring = new Geometry.Ring(this.CollisionEnd, spellData.Radius, spellData.RingRadius);
             break;
         case SkillShotType.SkillshotArc:
             this.Arc = new Geometry.Arc(
                 start,
                 end,
                 Config.SkillShotsExtraRadius + (int)ObjectManager.Player.BoundingRadius);
             break;
     }
     this.UpdatePolygon();
 }