Exemplo n.º 1
0
 private static void OnDeleteMissile(Skillshot skillshot, MissileClient missile)
 {
     if (skillshot.SpellData.SpellName != "VelkozQ"
         || DetectedSkillshots.Count(i => i.SpellData.SpellName == "VelkozQSplit") != 0)
     {
         return;
     }
     var spellData = SpellDatabase.GetByName("VelkozQSplit");
     for (var i = -1; i <= 1; i = i + 2)
     {
         DetectedSkillshots.Add(
             new Skillshot(
                 DetectionType.ProcessSpell,
                 spellData,
                 Variables.TickCount,
                 missile.Position.ToVector2(),
                 missile.Position.ToVector2() + i * skillshot.Direction.Perpendicular() * spellData.Range,
                 skillshot.Unit));
     }
 }
Exemplo n.º 2
0
 private static void OnDetectSkillshot(Skillshot skillshot)
 {
     var alreadyAdded =
         DetectedSkillshots.Any(
             i =>
             i.SpellData.SpellName == skillshot.SpellData.SpellName && i.Unit.Compare(skillshot.Unit)
             && skillshot.Direction.AngleBetween(i.Direction) < 5
             && (skillshot.Start.Distance(i.Start) < 100 || skillshot.SpellData.FromObjects.Length == 0));
     if (skillshot.Unit.IsAlly)
     {
         return;
     }
     if (skillshot.Start.Distance(PlayerPosition)
         > (skillshot.SpellData.Range + skillshot.SpellData.Radius + 1000) * 1.5)
     {
         return;
     }
     if (alreadyAdded && !skillshot.SpellData.DontCheckForDuplicates)
     {
         return;
     }
     if (skillshot.DetectionType == DetectionType.ProcessSpell)
     {
         if (skillshot.SpellData.MultipleNumber != -1)
         {
             var originalDirection = skillshot.Direction;
             for (var i = -(skillshot.SpellData.MultipleNumber - 1) / 2;
                  i <= (skillshot.SpellData.MultipleNumber - 1) / 2;
                  i++)
             {
                 DetectedSkillshots.Add(
                     new Skillshot(
                         skillshot.DetectionType,
                         skillshot.SpellData,
                         skillshot.StartTick,
                         skillshot.Start,
                         skillshot.Start
                         + skillshot.SpellData.Range
                         * originalDirection.Rotated(skillshot.SpellData.MultipleAngle * i),
                         skillshot.Unit));
             }
             return;
         }
         if (skillshot.SpellData.SpellName == "UFSlash")
         {
             skillshot.SpellData.MissileSpeed = 1600 + (int)skillshot.Unit.MoveSpeed;
         }
         if (skillshot.SpellData.SpellName == "SionR")
         {
             skillshot.SpellData.MissileSpeed = (int)skillshot.Unit.MoveSpeed;
         }
         if (skillshot.SpellData.Invert)
         {
             DetectedSkillshots.Add(
                 new Skillshot(
                     skillshot.DetectionType,
                     skillshot.SpellData,
                     skillshot.StartTick,
                     skillshot.Start,
                     skillshot.Start
                     + -(skillshot.End - skillshot.Start).Normalized() * skillshot.Start.Distance(skillshot.End),
                     skillshot.Unit));
             return;
         }
         if (skillshot.SpellData.Centered)
         {
             DetectedSkillshots.Add(
                 new Skillshot(
                     skillshot.DetectionType,
                     skillshot.SpellData,
                     skillshot.StartTick,
                     skillshot.Start - skillshot.Direction * skillshot.SpellData.Range,
                     skillshot.Start + skillshot.Direction * skillshot.SpellData.Range,
                     skillshot.Unit));
             return;
         }
         if (skillshot.SpellData.SpellName == "SyndraE" || skillshot.SpellData.SpellName == "syndrae5")
         {
             const int Angle = 60;
             var edge1 =
                 (skillshot.End - skillshot.Unit.ServerPosition.ToVector2()).Rotated(
                     -Angle / 2f * (float)Math.PI / 180);
             var edge2 = edge1.Rotated(Angle * (float)Math.PI / 180);
             foreach (var skillshotToAdd in
                 from orb in
                     GameObjects.EnemyMinions.Where(i => i.Name == "Seed" && i.Distance(skillshot.Unit) < 800)
                 let v = (orb.ServerPosition - skillshot.Unit.ServerPosition).ToVector2()
                 where edge1.CrossProduct(v) > 0 && v.CrossProduct(edge2) > 0
                 select
                     new Skillshot(
                     skillshot.DetectionType,
                     skillshot.SpellData,
                     skillshot.StartTick,
                     orb.ServerPosition.ToVector2(),
                     skillshot.Unit.ServerPosition.Extend(
                         orb.ServerPosition,
                         skillshot.Unit.Distance(orb) > 200 ? 1300 : 1000).ToVector2(),
                     skillshot.Unit))
             {
                 DetectedSkillshots.Add(skillshotToAdd);
             }
             return;
         }
         if (skillshot.SpellData.SpellName == "AlZaharCalloftheVoid")
         {
             DetectedSkillshots.Add(
                 new Skillshot(
                     skillshot.DetectionType,
                     skillshot.SpellData,
                     skillshot.StartTick,
                     skillshot.End - skillshot.Direction.Perpendicular() * 400,
                     skillshot.End + skillshot.Direction.Perpendicular() * 400,
                     skillshot.Unit));
             return;
         }
         if (skillshot.SpellData.SpellName == "DianaArc")
         {
             DetectedSkillshots.Add(
                 new Skillshot(
                     skillshot.DetectionType,
                     SpellDatabase.GetByName("DianaArcArc"),
                     skillshot.StartTick,
                     skillshot.Start,
                     skillshot.End,
                     skillshot.Unit));
         }
         if (skillshot.SpellData.SpellName == "ZiggsQ")
         {
             var d1 = skillshot.Start.Distance(skillshot.End);
             var d2 = d1 * 0.4f;
             var d3 = d2 * 0.69f;
             var bounce1SpellData = SpellDatabase.GetByName("ZiggsQBounce1");
             var bounce2SpellData = SpellDatabase.GetByName("ZiggsQBounce2");
             var bounce1Pos = skillshot.End + skillshot.Direction * d2;
             var bounce2Pos = bounce1Pos + skillshot.Direction * d3;
             bounce1SpellData.Delay =
                 (int)(skillshot.SpellData.Delay + d1 * 1000f / skillshot.SpellData.MissileSpeed + 500);
             bounce2SpellData.Delay =
                 (int)(bounce1SpellData.Delay + d2 * 1000f / bounce1SpellData.MissileSpeed + 500);
             DetectedSkillshots.Add(
                 new Skillshot(
                     skillshot.DetectionType,
                     bounce1SpellData,
                     skillshot.StartTick,
                     skillshot.End,
                     bounce1Pos,
                     skillshot.Unit));
             DetectedSkillshots.Add(
                 new Skillshot(
                     skillshot.DetectionType,
                     bounce2SpellData,
                     skillshot.StartTick,
                     bounce1Pos,
                     bounce2Pos,
                     skillshot.Unit));
         }
         if (skillshot.SpellData.SpellName == "ZiggsR")
         {
             skillshot.SpellData.Delay =
                 (int)(1500 + 1500 * skillshot.End.Distance(skillshot.Start) / skillshot.SpellData.Range);
         }
         if (skillshot.SpellData.SpellName == "JarvanIVDragonStrike")
         {
             var endPos = new Vector2();
             foreach (var s in
                 DetectedSkillshots.Where(i => i.SpellData.Slot == SpellSlot.E))
             {
                 if (!s.Unit.Compare(skillshot.Unit))
                 {
                     continue;
                 }
                 var extendedE = new Skillshot(
                     skillshot.DetectionType,
                     skillshot.SpellData,
                     skillshot.StartTick,
                     skillshot.Start,
                     skillshot.End + skillshot.Direction * 100,
                     skillshot.Unit);
                 if (!extendedE.IsSafePoint(s.End))
                 {
                     endPos = s.End;
                 }
                 break;
             }
             foreach (var m in
                 GameObjects.Minions.Where(i => i.CharData.BaseSkinName == "jarvanivstandard"))
             {
                 if (m.Team != skillshot.Unit.Team)
                 {
                     continue;
                 }
                 var extendedE = new Skillshot(
                     skillshot.DetectionType,
                     skillshot.SpellData,
                     skillshot.StartTick,
                     skillshot.Start,
                     skillshot.End + skillshot.Direction * 100,
                     skillshot.Unit);
                 if (!extendedE.IsSafePoint(m.Position.ToVector2()))
                 {
                     endPos = m.Position.ToVector2();
                 }
                 break;
             }
             if (endPos.IsValid())
             {
                 skillshot = new Skillshot(
                     DetectionType.ProcessSpell,
                     SpellDatabase.GetByName("JarvanIVEQ"),
                     Variables.TickCount,
                     skillshot.Start,
                     endPos + 200 * (endPos - skillshot.Start).Normalized(),
                     skillshot.Unit);
             }
         }
     }
     if (skillshot.SpellData.SpellName == "OriannasQ")
     {
         DetectedSkillshots.Add(
             new Skillshot(
                 skillshot.DetectionType,
                 SpellDatabase.GetByName("OriannaQend"),
                 skillshot.StartTick,
                 skillshot.Start,
                 skillshot.End,
                 skillshot.Unit));
     }
     if ((skillshot.SpellData.DisableFowDetection
          || Program.MainMenu["Evade"][skillshot.SpellData.ChampionName.ToLowerInvariant()][
              skillshot.SpellData.SpellName]["DisableFoW"].GetValue<MenuBool>().Value)
         && skillshot.DetectionType == DetectionType.RecvPacket)
     {
         return;
     }
     DetectedSkillshots.Add(skillshot);
 }
Exemplo n.º 3
0
        private static void OnDetectSkillshot(Skillshot skillshot)
        {
            var alreadyAdded = false;
            foreach (var item in DetectedSkillshots)
            {
                if (item.SpellData.SpellName == skillshot.SpellData.SpellName
                    && item.Unit.NetworkId == skillshot.Unit.NetworkId
                    && skillshot.Direction.AngleBetween(item.Direction) < 5
                    && (skillshot.Start.Distance(item.Start) < 100 || skillshot.SpellData.FromObjects.Length == 0))
                {
                    alreadyAdded = true;
                }
            }
            if (skillshot.Unit.Team == ObjectManager.Player.Team)
            {
                return;
            }
            if (skillshot.Start.Distance(PlayerPosition)
                > (skillshot.SpellData.Range + skillshot.SpellData.Radius + 1000) * 1.5)
            {
                return;
            }
            if (alreadyAdded && !skillshot.SpellData.DontCheckForDuplicates)
            {
                return;
            }
            if (skillshot.DetectionType == DetectionType.ProcessSpell)
            {
                if (skillshot.SpellData.MultipleNumber != -1)
                {
                    var originalDirection = skillshot.Direction;
                    for (var i = -(skillshot.SpellData.MultipleNumber - 1) / 2;
                         i <= (skillshot.SpellData.MultipleNumber - 1) / 2;
                         i++)
                    {
                        var end = skillshot.Start
                                  + skillshot.SpellData.Range
                                  * originalDirection.Rotated(skillshot.SpellData.MultipleAngle * i);
                        var skillshotToAdd = new Skillshot(
                            skillshot.DetectionType,
                            skillshot.SpellData,
                            skillshot.StartTick,
                            skillshot.Start,
                            end,
                            skillshot.Unit);
                        DetectedSkillshots.Add(skillshotToAdd);
                    }
                    return;
                }
                if (skillshot.SpellData.SpellName == "UFSlash")
                {
                    skillshot.SpellData.MissileSpeed = 1600 + (int)skillshot.Unit.MoveSpeed;
                }
                if (skillshot.SpellData.SpellName == "SionR")
                {
                    skillshot.SpellData.MissileSpeed = (int)skillshot.Unit.MoveSpeed;
                }
                if (skillshot.SpellData.Invert)
                {
                    var newDirection = -(skillshot.End - skillshot.Start).Normalized();
                    var end = skillshot.Start + newDirection * skillshot.Start.Distance(skillshot.End);
                    var skillshotToAdd = new Skillshot(
                        skillshot.DetectionType,
                        skillshot.SpellData,
                        skillshot.StartTick,
                        skillshot.Start,
                        end,
                        skillshot.Unit);
                    DetectedSkillshots.Add(skillshotToAdd);
                    return;
                }
                if (skillshot.SpellData.Centered)
                {
                    var start = skillshot.Start - skillshot.Direction * skillshot.SpellData.Range;
                    var end = skillshot.Start + skillshot.Direction * skillshot.SpellData.Range;
                    var skillshotToAdd = new Skillshot(
                        skillshot.DetectionType,
                        skillshot.SpellData,
                        skillshot.StartTick,
                        start,
                        end,
                        skillshot.Unit);
                    DetectedSkillshots.Add(skillshotToAdd);
                    return;
                }
                if (skillshot.SpellData.SpellName == "SyndraE" || skillshot.SpellData.SpellName == "syndrae5")
                {
                    const int Angle = 60;
                    var edge1 =
                        (skillshot.End - skillshot.Unit.ServerPosition.ToVector2()).Rotated(
                            -Angle / 2f * (float)Math.PI / 180);
                    var edge2 = edge1.Rotated(Angle * (float)Math.PI / 180);
                    foreach (var skillshotToAdd in
                        from minion in
                            GameObjects.EnemyMinions.Where(i => i.Name == "Seed" && i.Distance(skillshot.Unit) < 800)
                        let v = minion.ServerPosition.ToVector2() - skillshot.Unit.ServerPosition.ToVector2()
                        where edge1.CrossProduct(v) > 0 && v.CrossProduct(edge2) > 0
                        let start = minion.ServerPosition.ToVector2()
                        let end =
                            skillshot.Unit.ServerPosition.ToVector2()
                            .Extend(
                                minion.ServerPosition.ToVector2(),
                                skillshot.Unit.Distance(minion) > 200 ? 1300 : 1000)
                        select
                            new Skillshot(
                            skillshot.DetectionType,
                            skillshot.SpellData,
                            skillshot.StartTick,
                            start,
                            end,
                            skillshot.Unit))
                    {
                        DetectedSkillshots.Add(skillshotToAdd);
                    }
                    return;
                }
                if (skillshot.SpellData.SpellName == "AlZaharCalloftheVoid")
                {
                    var start = skillshot.End - skillshot.Direction.Perpendicular() * 400;
                    var end = skillshot.End + skillshot.Direction.Perpendicular() * 400;
                    var skillshotToAdd = new Skillshot(
                        skillshot.DetectionType,
                        skillshot.SpellData,
                        skillshot.StartTick,
                        start,
                        end,
                        skillshot.Unit);
                    DetectedSkillshots.Add(skillshotToAdd);
                    return;
                }
                if (skillshot.SpellData.SpellName == "DianaArc")
                {
                    var skillshotToAdd = new Skillshot(
                        skillshot.DetectionType,
                        SpellDatabase.GetByName("DianaArcArc"),
                        skillshot.StartTick,
                        skillshot.Start,
                        skillshot.End,
                        skillshot.Unit);

                    DetectedSkillshots.Add(skillshotToAdd);
                }
                if (skillshot.SpellData.SpellName == "ZiggsQ")
                {
                    var d1 = skillshot.Start.Distance(skillshot.End);
                    var d2 = d1 * 0.4f;
                    var d3 = d2 * 0.69f;
                    var bounce1SpellData = SpellDatabase.GetByName("ZiggsQBounce1");
                    var bounce2SpellData = SpellDatabase.GetByName("ZiggsQBounce2");
                    var bounce1Pos = skillshot.End + skillshot.Direction * d2;
                    var bounce2Pos = bounce1Pos + skillshot.Direction * d3;
                    bounce1SpellData.Delay =
                        (int)(skillshot.SpellData.Delay + d1 * 1000f / skillshot.SpellData.MissileSpeed + 500);
                    bounce2SpellData.Delay =
                        (int)(bounce1SpellData.Delay + d2 * 1000f / bounce1SpellData.MissileSpeed + 500);
                    var bounce1 = new Skillshot(
                        skillshot.DetectionType,
                        bounce1SpellData,
                        skillshot.StartTick,
                        skillshot.End,
                        bounce1Pos,
                        skillshot.Unit);
                    var bounce2 = new Skillshot(
                        skillshot.DetectionType,
                        bounce2SpellData,
                        skillshot.StartTick,
                        bounce1Pos,
                        bounce2Pos,
                        skillshot.Unit);
                    DetectedSkillshots.Add(bounce1);
                    DetectedSkillshots.Add(bounce2);
                }
                if (skillshot.SpellData.SpellName == "ZiggsR")
                {
                    skillshot.SpellData.Delay =
                        (int)(1500 + 1500 * skillshot.End.Distance(skillshot.Start) / skillshot.SpellData.Range);
                }
                if (skillshot.SpellData.SpellName == "JarvanIVDragonStrike")
                {
                    var endPos = Vector2.Zero;
                    foreach (var s in DetectedSkillshots)
                    {
                        if (s.Unit.NetworkId == skillshot.Unit.NetworkId && s.SpellData.Slot == SpellSlot.E)
                        {
                            var extendedE = new Skillshot(
                                skillshot.DetectionType,
                                skillshot.SpellData,
                                skillshot.StartTick,
                                skillshot.Start,
                                skillshot.End + skillshot.Direction * 100,
                                skillshot.Unit);
                            if (!extendedE.IsSafe(s.End))
                            {
                                endPos = s.End;
                            }
                            break;
                        }
                    }
                    foreach (var m in ObjectManager.Get<Obj_AI_Minion>())
                    {
                        if (m.CharData.BaseSkinName == "jarvanivstandard" && m.Team == skillshot.Unit.Team)
                        {
                            var extendedE = new Skillshot(
                                skillshot.DetectionType,
                                skillshot.SpellData,
                                skillshot.StartTick,
                                skillshot.Start,
                                skillshot.End + skillshot.Direction * 100,
                                skillshot.Unit);
                            if (!extendedE.IsSafe(m.Position.ToVector2()))
                            {
                                endPos = m.Position.ToVector2();
                            }
                            break;
                        }
                    }
                    if (endPos.IsValid())
                    {
                        skillshot = new Skillshot(
                            DetectionType.ProcessSpell,
                            SpellDatabase.GetByName("JarvanIVEQ"),
                            Variables.TickCount,
                            skillshot.Start,
                            endPos,
                            skillshot.Unit);
                        skillshot.End = endPos + 200 * (endPos - skillshot.Start).Normalized();
                        skillshot.Direction = (skillshot.End - skillshot.Start).Normalized();
                    }
                }
            }
            if (skillshot.SpellData.SpellName == "OriannasQ")
            {
                var skillshotToAdd = new Skillshot(
                    skillshot.DetectionType,
                    SpellDatabase.GetByName("OriannaQend"),
                    skillshot.StartTick,
                    skillshot.Start,
                    skillshot.End,
                    skillshot.Unit);
                DetectedSkillshots.Add(skillshotToAdd);
            }
            if (skillshot.SpellData.DisableFowDetection && skillshot.DetectionType == DetectionType.RecvPacket)
            {
                return;
            }
            DetectedSkillshots.Add(skillshot);
        }
Exemplo n.º 4
0
 public static void Init()
 {
     Config.CreateMenu(Program.MainMenu);
     Collision.Init();
     Game.OnUpdate += args =>
         {
             DetectedSkillshots.RemoveAll(i => !i.IsActive);
             foreach (var skillshot in DetectedSkillshots)
             {
                 skillshot.OnUpdate();
             }
             if (!Program.MainMenu["Evade"]["Enabled"].GetValue<MenuKeyBind>().Active)
             {
                 return;
             }
             if (ObjectManager.Player.IsDead)
             {
                 return;
             }
             if (InterruptableSpell.IsCastingInterruptableSpell(ObjectManager.Player, true))
             {
                 return;
             }
             if (ObjectManager.Player.HasBuffOfType(BuffType.SpellShield)
                 || ObjectManager.Player.HasBuffOfType(BuffType.SpellImmunity))
             {
                 return;
             }
             Evading?.Invoke();
             var currentPath = ObjectManager.Player.GetWaypoints();
             var safePoint = IsSafePoint(PlayerPosition);
             var safePath = IsSafePath(currentPath, 100);
             if (!safePath.IsSafe && !safePoint.IsSafe)
             {
                 TryEvading?.Invoke(safePoint.SkillshotList, Game.CursorPos.ToVector2());
             }
         };
     SkillshotDetector.OnDetectSkillshot += OnDetectSkillshot;
     SkillshotDetector.OnDeleteSkillshot += (skillshot, missile) =>
         {
             if (skillshot.SpellData.SpellName == "VelkozQ")
             {
                 var spellData = SpellDatabase.GetByName("VelkozQSplit");
                 var direction = skillshot.Direction.Perpendicular();
                 if (DetectedSkillshots.Count(i => i.SpellData.SpellName == "VelkozQSplit") == 0)
                 {
                     for (var i = -1; i <= 1; i = i + 2)
                     {
                         var skillshotToAdd = new Skillshot(
                             DetectionType.ProcessSpell,
                             spellData,
                             Variables.TickCount,
                             missile.Position.ToVector2(),
                             missile.Position.ToVector2() + i * direction * spellData.Range,
                             skillshot.Unit);
                         DetectedSkillshots.Add(skillshotToAdd);
                     }
                 }
             }
         };
     Drawing.OnDraw += args =>
         {
             if (Program.MainMenu["Evade"]["Draw"]["Status"])
             {
                 var active = Program.MainMenu["Evade"]["Enabled"].GetValue<MenuKeyBind>().Active;
                 var text =
                     $"Evade Skillshot: {(active ? (Program.MainMenu["Evade"]["OnlyDangerous"].GetValue<MenuKeyBind>().Active ? "Dangerous" : "On") : "Off")}";
                 var pos = Drawing.WorldToScreen(ObjectManager.Player.Position);
                 Drawing.DrawText(
                     pos.X - (float)Drawing.GetTextExtent(text).Width / 2,
                     pos.Y + 40,
                     active
                         ? (Program.MainMenu["Evade"]["OnlyDangerous"].GetValue<MenuKeyBind>().Active
                                ? Color.Yellow
                                : Color.White)
                         : Color.Gray,
                     text);
             }
             if (Program.MainMenu["Evade"]["Draw"]["Skillshot"])
             {
                 foreach (var skillshot in DetectedSkillshots)
                 {
                     skillshot.Draw(
                         skillshot.Enable && Program.MainMenu["Evade"]["Enabled"].GetValue<MenuKeyBind>().Active
                             ? Color.White
                             : Color.Red,
                         Color.LimeGreen);
                 }
             }
         };
 }
Exemplo n.º 5
0
        internal static Vector2 GetCollisionPoint(this 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.Minions.Where(
                            i =>
                            i.IsValidTarget(1200, false, @from.ToVector3()) && skillshot.Unit.IsAlly
                                        ? i.IsEnemy
                                        : i.IsAlly)
                        let pred =
                            FastPrediction(
                                @from,
                                minion,
                                Math.Max(0, skillshot.SpellData.Delay - (Variables.TickCount - 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 = cObject,
                        Distance = pos.Distance(@from), Diff = w
                    });
                    break;

                case CollisionObjectTypes.Champion:
                    collisions.AddRange(
                        from hero in GameObjects.AllyHeroes.Where(i => i.IsValidTarget(1200, false) && !i.IsMe)
                        let pred =
                            FastPrediction(
                                @from,
                                hero,
                                Math.Max(0, skillshot.SpellData.Delay - (Variables.TickCount - 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 = cObject,
                        Distance = pos.Distance(@from), Diff = w
                    });
                    break;

                case CollisionObjectTypes.YasuoWall:
                    if (
                        !GameObjects.AllyHeroes.Any(
                            i => i.IsValidTarget(float.MaxValue, false) && i.ChampionName == "Yasuo"))
                    {
                        break;
                    }
                    var wall =
                        GameObjects.AllGameObjects.FirstOrDefault(
                            i => i.IsValid && Regex.IsMatch(i.Name, "_w_windwall.\\.troy", RegexOptions.IgnoreCase));
                    if (wall == null)
                    {
                        break;
                    }
                    var wallWidth     = 300 + 50 * Convert.ToInt32(wall.Name.Substring(wall.Name.Length - 6, 1));
                    var wallDirection = (wall.Position - yasuoWallCastedPos).Normalized().Perpendicular();
                    var wallStart     = wall.Position + wallWidth / 2f * wallDirection;
                    var wallEnd       = wallStart - wallWidth * wallDirection;
                    var wallPolygon   = new 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],
                                from,
                                skillshot.End);
                        if (inter.Intersects)
                        {
                            intersections.Add(inter.Point);
                        }
                    }
                    if (intersections.Count > 0)
                    {
                        var intersection = intersections.OrderBy(i => i.Distance(@from)).ToList()[0];
                        if (Variables.TickCount
                            + Math.Max(0, skillshot.SpellData.Delay - (Variables.TickCount - skillshot.StartTick))
                            + 100 + (1000 * intersection.Distance(@from)) / skillshot.SpellData.MissileSpeed
                            - yasuoWallCastT < 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 : new Vector2());
        }
Exemplo n.º 6
0
        public static Vector2 GetCollisionPoint(Skillshot skillshot)
        {
            var collisions = new List <DetectedCollision>();
            var from       = skillshot.GetMissilePosition(0);

            skillshot.ForceDisabled = false;
            if (skillshot.SpellData.CollisionObjects.HasFlag(CollisionableObjects.Minions))
            {
                var minions = new List <Obj_AI_Minion>();
                minions.AddRange(GameObjects.Jungle.Where(i => i.LSIsValidTarget(1200, true, from.ToVector3())));
                minions.AddRange(
                    GameObjects.Minions.Where(
                        i =>
                        i.LSIsValidTarget(1200, false, @from.ToVector3()) &&
                        (skillshot.Unit.Team == Program.Player.Team
                                ? i.Team != Program.Player.Team
                                : i.Team == Program.Player.Team) && (i.IsMinion() || i.IsPet())));
                collisions.AddRange(
                    from minion in minions
                    let pred =
                        FastPrediction(
                            @from,
                            minion,
                            Math.Max(0, skillshot.SpellData.Delay - (Variables.TickCount - 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.LSProjectOn(skillshot.End, skillshot.Start).LinePoint + skillshot.Direction * 30,
                    Unit = minion, Type = CollisionableObjects.Minions, Distance = pos.Distance(@from),
                    Diff = w
                });
            }
            if (skillshot.SpellData.CollisionObjects.HasFlag(CollisionableObjects.Heroes))
            {
                collisions.AddRange(
                    from hero in GameObjects.AllyHeroes.Where(i => i.LSIsValidTarget(1200, false) && !i.IsMe)
                    let pred =
                        FastPrediction(
                            @from,
                            hero,
                            Math.Max(0, skillshot.SpellData.Delay - (Variables.TickCount - 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.LSProjectOn(skillshot.End, skillshot.Start).LinePoint + skillshot.Direction * 30,
                    Unit = hero, Type = CollisionableObjects.Heroes, Distance = pos.Distance(@from),
                    Diff = w
                });
            }
            if (skillshot.SpellData.CollisionObjects.HasFlag(CollisionableObjects.YasuoWall) &&
                GameObjects.AllyHeroes.Any(i => i.ChampionName == "Yasuo"))
            {
                var wall =
                    GameObjects.AllGameObjects.FirstOrDefault(
                        i => i.IsValid && Regex.IsMatch(i.Name, "_w_windwall.\\.troy", RegexOptions.IgnoreCase));
                if (wall != null)
                {
                    var level         = wall.Name.Substring(wall.Name.Length - 6, 1);
                    var wallWidth     = 300 + 50 * Convert.ToInt32(level);
                    var wallPos       = wall.Position.ToVector2();
                    var wallDirection = (wallPos - wallCastedPos).LSNormalized().Perpendicular();
                    var wallStart     = wallPos + 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   = Variables.TickCount
                                           + Math.Max(
                            0,
                            skillshot.SpellData.Delay - (Variables.TickCount - skillshot.StartTick))
                                           + 100
                                           + 1000
                                           * (Math.Abs(skillshot.SpellData.MissileSpeed - int.MaxValue) > 0
                                                ? intersection.Distance(@from) / skillshot.SpellData.MissileSpeed
                                                : 0);
                        if (collisionT - wallCastT < 4000)
                        {
                            if (skillshot.SpellData.Type != SkillShotType.SkillshotMissileLine)
                            {
                                skillshot.ForceDisabled = true;
                            }
                            return(intersection);
                        }
                    }
                }
            }
            return(collisions.Count > 0 ? collisions.OrderBy(i => i.Distance).First().Position : new Vector2());
        }
Exemplo n.º 7
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.Minions.Where(
                             i =>
                             i.IsValidTarget(1200, false, @from.ToVector3()) && skillshot.Unit.IsAlly
                                 ? i.IsEnemy
                                 : i.IsAlly)
                     let pred =
                         FastPrediction(
                             @from,
                             minion,
                             Math.Max(0, skillshot.SpellData.Delay - (Variables.TickCount - 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 = cObject,
                                 Distance = pos.Distance(@from), Diff = w
                             });
                 break;
             case CollisionObjectTypes.Champions:
                 collisions.AddRange(
                     from hero in GameObjects.AllyHeroes.Where(i => i.IsValidTarget(1200, false) && !i.IsMe)
                     let pred =
                         FastPrediction(
                             @from,
                             hero,
                             Math.Max(0, skillshot.SpellData.Delay - (Variables.TickCount - 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 = cObject,
                                 Distance = pos.Distance(@from), Diff = w
                             });
                 break;
             case CollisionObjectTypes.YasuoWall:
                 if (
                     !GameObjects.AllyHeroes.Any(
                         i => i.IsValidTarget(float.MaxValue, false) && i.ChampionName == "Yasuo"))
                 {
                     break;
                 }
                 var wall =
                     GameObjects.AllGameObjects.FirstOrDefault(
                         i => i.IsValid && Regex.IsMatch(i.Name, "_w_windwall.\\.troy", RegexOptions.IgnoreCase));
                 if (wall == null)
                 {
                     break;
                 }
                 var wallWidth = 300 + 50 * Convert.ToInt32(wall.Name.Substring(wall.Name.Length - 6, 1));
                 var wallDirection = (wall.Position - yasuoWallCastedPos).Normalized().Perpendicular();
                 var wallStart = wall.Position + wallWidth / 2f * wallDirection;
                 var wallEnd = wallStart - wallWidth * wallDirection;
                 var wallPolygon = new 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],
                             from,
                             skillshot.End);
                     if (inter.Intersects)
                     {
                         intersections.Add(inter.Point);
                     }
                 }
                 if (intersections.Count > 0)
                 {
                     var intersection = intersections.OrderBy(i => i.Distance(@from)).ToList()[0];
                     if (Variables.TickCount
                         + Math.Max(0, skillshot.SpellData.Delay - (Variables.TickCount - skillshot.StartTick))
                         + 100 + (1000 * intersection.Distance(@from)) / skillshot.SpellData.MissileSpeed
                         - yasuoWallCastT < 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 : new Vector2();
 }
Exemplo n.º 8
0
        private static void OnDetectSkillshot(Skillshot skillshot)
        {
            if (skillshot.Unit.Team == Program.Player.Team)
            {
                return;
            }
            var alreadyAdded =
                DetectedSkillshots.Where(
                    i => i.SpellData.SpellName == skillshot.SpellData.SpellName && i.Unit.Compare(skillshot.Unit))
                .Any(
                    i =>
                    i.Direction.AngleBetween(skillshot.Direction) < 5 &&
                    (i.Start.Distance(skillshot.Start) < 100 || skillshot.SpellData.FromObjects.Length == 0));

            if (skillshot.Start.Distance(PlayerPosition)
                > (skillshot.SpellData.Range + skillshot.SpellData.Radius + 1000) * 1.5)
            {
                return;
            }
            if (alreadyAdded && !skillshot.SpellData.DontCheckForDuplicates)
            {
                return;
            }
            if (skillshot.DetectionType == DetectionType.ProcessSpell)
            {
                if (skillshot.SpellData.MultipleNumber != -1)
                {
                    var originalDirection = skillshot.Direction;
                    for (var i = -(skillshot.SpellData.MultipleNumber - 1) / 2;
                         i <= (skillshot.SpellData.MultipleNumber - 1) / 2;
                         i++)
                    {
                        var end = skillshot.Start
                                  + skillshot.SpellData.Range
                                  * originalDirection.LSRotated(skillshot.SpellData.MultipleAngle * i);
                        DetectedSkillshots.Add(
                            new Skillshot(
                                skillshot.DetectionType,
                                skillshot.SpellData,
                                skillshot.StartTick,
                                skillshot.Start,
                                end,
                                skillshot.Unit));
                    }
                    return;
                }
                if (skillshot.SpellData.SpellName == "UFSlash")
                {
                    skillshot.SpellData.MissileSpeed = 1600 + (int)skillshot.Unit.MoveSpeed;
                }
                if (skillshot.SpellData.SpellName == "SionR")
                {
                    skillshot.SpellData.MissileSpeed = (int)skillshot.Unit.MoveSpeed;
                }
                if (skillshot.SpellData.Invert)
                {
                    var newDirection = -(skillshot.End - skillshot.Start).LSNormalized();
                    var end          = skillshot.Start + newDirection * skillshot.Start.Distance(skillshot.End);
                    DetectedSkillshots.Add(
                        new Skillshot(
                            skillshot.DetectionType,
                            skillshot.SpellData,
                            skillshot.StartTick,
                            skillshot.Start,
                            end,
                            skillshot.Unit));
                    return;
                }
                if (skillshot.SpellData.Centered)
                {
                    var start = skillshot.Start - skillshot.Direction * skillshot.SpellData.Range;
                    var end   = skillshot.Start + skillshot.Direction * skillshot.SpellData.Range;
                    DetectedSkillshots.Add(
                        new Skillshot(
                            skillshot.DetectionType,
                            skillshot.SpellData,
                            skillshot.StartTick,
                            start,
                            end,
                            skillshot.Unit));
                    return;
                }
                if (skillshot.SpellData.SpellName == "TaricE")
                {
                    var source = skillshot.Unit as AIHeroClient;
                    if (source != null && source.ChampionName == "Taric")
                    {
                        var target =
                            GameObjects.Heroes.FirstOrDefault(
                                h => h.Team == source.Team && h.HasBuff("taricwleashactive"));
                        if (target != null)
                        {
                            var start     = target.ServerPosition.ToVector2();
                            var direction = (skillshot.OriginalEnd - start).LSNormalized();
                            var end       = start + direction * skillshot.SpellData.Range;
                            DetectedSkillshots.Add(
                                new Skillshot(
                                    skillshot.DetectionType,
                                    skillshot.SpellData,
                                    skillshot.StartTick,
                                    start,
                                    end,
                                    target)
                            {
                                OriginalEnd = skillshot.OriginalEnd
                            });
                        }
                    }
                }
                if (skillshot.SpellData.SpellName == "SyndraE" || skillshot.SpellData.SpellName == "syndrae5")
                {
                    const int Angle = 60;
                    var       edge1 =
                        (skillshot.End - skillshot.Unit.ServerPosition.ToVector2()).LSRotated(
                            -Angle / 2f * (float)Math.PI / 180);
                    var edge2      = edge1.LSRotated(Angle * (float)Math.PI / 180);
                    var positions  = new List <Vector2>();
                    var explodingQ = DetectedSkillshots.FirstOrDefault(s => s.SpellData.SpellName == "SyndraQ");
                    if (explodingQ != null)
                    {
                        positions.Add(explodingQ.End);
                    }
                    positions.AddRange(
                        GameObjects.EnemyMinions.Where(i => !i.IsDead && i.Name == "Seed")
                        .Select(minion => minion.ServerPosition.ToVector2()));
                    foreach (var pos in positions.Where(i => skillshot.Unit.Distance(i) < 800))
                    {
                        var v = pos - skillshot.Unit.ServerPosition.ToVector2();
                        if (edge1.CrossProduct(v) > 0 && v.CrossProduct(edge2) > 0)
                        {
                            var start = pos;
                            var end   = skillshot.Unit.ServerPosition.ToVector2()
                                        .Extend(pos, skillshot.Unit.Distance(pos) > 200 ? 1300 : 1000);
                            DetectedSkillshots.Add(
                                new Skillshot(
                                    skillshot.DetectionType,
                                    skillshot.SpellData,
                                    skillshot.StartTick + (int)(150 + skillshot.Unit.Distance(pos) / 2.5),
                                    start,
                                    end,
                                    skillshot.Unit));
                        }
                    }
                    return;
                }
                if (skillshot.SpellData.SpellName == "AlZaharCalloftheVoid")
                {
                    var start = skillshot.End - skillshot.Direction.Perpendicular() * 400;
                    var end   = skillshot.End + skillshot.Direction.Perpendicular() * 400;
                    DetectedSkillshots.Add(
                        new Skillshot(
                            skillshot.DetectionType,
                            skillshot.SpellData,
                            skillshot.StartTick,
                            start,
                            end,
                            skillshot.Unit));
                    return;
                }
                if (skillshot.SpellData.SpellName == "DianaArc")
                {
                    DetectedSkillshots.Add(
                        new Skillshot(
                            skillshot.DetectionType,
                            SpellDatabase.GetByName("DianaArcArc"),
                            skillshot.StartTick,
                            skillshot.Start,
                            skillshot.End,
                            skillshot.Unit));
                }
                if (skillshot.SpellData.SpellName == "ZiggsQ")
                {
                    var d1 = skillshot.Start.Distance(skillshot.End);
                    var d2 = d1 * 0.4f;
                    var d3 = d2 * 0.69f;
                    var bounce1SpellData = SpellDatabase.GetByName("ZiggsQBounce1");
                    var bounce2SpellData = SpellDatabase.GetByName("ZiggsQBounce2");
                    var bounce1Pos       = skillshot.End + skillshot.Direction * d2;
                    var bounce2Pos       = bounce1Pos + skillshot.Direction * d3;
                    bounce1SpellData.Delay =
                        (int)(skillshot.SpellData.Delay + d1 * 1000f / skillshot.SpellData.MissileSpeed + 500);
                    bounce2SpellData.Delay =
                        (int)(bounce1SpellData.Delay + d2 * 1000f / bounce1SpellData.MissileSpeed + 500);
                    DetectedSkillshots.Add(
                        new Skillshot(
                            skillshot.DetectionType,
                            bounce1SpellData,
                            skillshot.StartTick,
                            skillshot.End,
                            bounce1Pos,
                            skillshot.Unit));
                    DetectedSkillshots.Add(
                        new Skillshot(
                            skillshot.DetectionType,
                            bounce2SpellData,
                            skillshot.StartTick,
                            bounce1Pos,
                            bounce2Pos,
                            skillshot.Unit));
                }
                if (skillshot.SpellData.SpellName == "ZiggsR")
                {
                    skillshot.SpellData.Delay =
                        (int)(1500 + 1500 * skillshot.End.Distance(skillshot.Start) / skillshot.SpellData.Range);
                }
                if (skillshot.SpellData.SpellName == "JarvanIVDragonStrike")
                {
                    var endPos = new Vector2();
                    foreach (var s in
                             DetectedSkillshots.Where(i => i.SpellData.Slot == SpellSlot.E))
                    {
                        if (!s.Unit.Compare(skillshot.Unit))
                        {
                            continue;
                        }
                        var extendedE = new Skillshot(
                            skillshot.DetectionType,
                            skillshot.SpellData,
                            skillshot.StartTick,
                            skillshot.Start,
                            skillshot.End + skillshot.Direction * 100,
                            skillshot.Unit);
                        if (!extendedE.IsSafe(s.End))
                        {
                            endPos = s.End;
                        }
                        break;
                    }
                    foreach (var m in
                             ObjectManager.Get <Obj_AI_Minion>().Where(i => i.CharData.BaseSkinName == "jarvanivstandard"))
                    {
                        if (m.Team != skillshot.Unit.Team)
                        {
                            continue;
                        }
                        var extendedE = new Skillshot(
                            skillshot.DetectionType,
                            skillshot.SpellData,
                            skillshot.StartTick,
                            skillshot.Start,
                            skillshot.End + skillshot.Direction * 100,
                            skillshot.Unit);
                        if (!extendedE.IsSafe(m.Position.ToVector2()))
                        {
                            endPos = m.Position.ToVector2();
                        }
                        break;
                    }
                    if (endPos.IsValid())
                    {
                        skillshot = new Skillshot(
                            DetectionType.ProcessSpell,
                            SpellDatabase.GetByName("JarvanIVEQ"),
                            Variables.TickCount,
                            skillshot.Start,
                            endPos,
                            skillshot.Unit);
                        skillshot.End       = endPos + 200 * (endPos - skillshot.Start).LSNormalized();
                        skillshot.Direction = (skillshot.End - skillshot.Start).LSNormalized();
                    }
                }
            }
            if (skillshot.SpellData.SpellName == "OriannasQ")
            {
                DetectedSkillshots.Add(
                    new Skillshot(
                        skillshot.DetectionType,
                        SpellDatabase.GetByName("OriannaQend"),
                        skillshot.StartTick,
                        skillshot.Start,
                        skillshot.End,
                        skillshot.Unit,
                        skillshot.DetectionType == DetectionType.RecvPacket && skillshot.Missile != null
                            ? skillshot.Missile
                            : null));
            }
            if (skillshot.SpellData.DisableFowDetection && skillshot.DetectionType == DetectionType.RecvPacket)
            {
                return;
            }
            DetectedSkillshots.Add(skillshot);
        }
Exemplo n.º 9
0
        internal static Vector2 GetCollisionPoint(Skillshot skillshot)
        {
            var collisions = new List <DetectedCollision>();
            var from       = skillshot.GetMissilePosition(0);

            skillshot.ForceDisabled = false;
            if (skillshot.SpellData.CollisionObjects.HasFlag(CollisionableObjects.Minions))
            {
                var minions = new List <Obj_AI_Minion>();
                minions.AddRange(GameObjects.Jungle.Where(i => i.IsValidTarget(1200, true, from.ToVector3())));
                minions.AddRange(
                    GameObjects.Minions.Where(
                        i =>
                        i.IsValidTarget(1200, false, from.ToVector3()) &&
                        (skillshot.Unit.Team == Program.Player.Team
                                ? i.Team != Program.Player.Team
                                : i.Team == Program.Player.Team) && (i.IsMinion() || i.IsPet())));
                collisions.AddRange(
                    from minion in minions
                    let pred =
                        FastPrediction(
                            @from,
                            minion,
                            Math.Max(0, skillshot.SpellData.Delay - (Variables.TickCount - 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,
                    Distance = pos.Distance(@from)
                });
            }
            if (skillshot.SpellData.CollisionObjects.HasFlag(CollisionableObjects.Heroes))
            {
                collisions.AddRange(
                    from hero in GameObjects.AllyHeroes.Where(i => i.IsValidTarget(1200, false) && !i.IsMe)
                    let pred =
                        FastPrediction(
                            @from,
                            hero,
                            Math.Max(0, skillshot.SpellData.Delay - (Variables.TickCount - 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,
                    Distance = pos.Distance(@from)
                });
            }
            if (skillshot.SpellData.CollisionObjects.HasFlag(CollisionableObjects.YasuoWall))
            {
                if (yasuoWallLeft != null && yasuoWallRight != null)
                {
                    yasuoWallPoly = new RectanglePoly(yasuoWallLeft.Position, yasuoWallRight.Position, 75);
                    var intersections = new List <Vector2>();
                    for (var i = 0; i < yasuoWallPoly.Points.Count; i++)
                    {
                        var inter =
                            yasuoWallPoly.Points[i].Intersection(
                                yasuoWallPoly.Points[i != yasuoWallPoly.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   = Variables.TickCount
                                           + Math.Max(
                            0,
                            skillshot.SpellData.Delay - (Variables.TickCount - skillshot.StartTick))
                                           + 100
                                           + 1000
                                           * (Math.Abs(skillshot.SpellData.MissileSpeed - int.MaxValue) > 0
                                                ? intersection.Distance(from) / skillshot.SpellData.MissileSpeed
                                                : 0);
                        if (collisionT - yasuoWallTime < 4000)
                        {
                            if (skillshot.SpellData.Type != SkillShotType.SkillshotMissileLine)
                            {
                                skillshot.ForceDisabled = true;
                            }
                            return(intersection);
                        }
                    }
                }
            }
            return(collisions.Count > 0 ? collisions.OrderBy(i => i.Distance).First().Position : new Vector2());
        }
Exemplo n.º 10
0
 public static void Init()
 {
     Config.CreateMenu(Program.MainMenu);
     Collision.Init();
     Game.OnUpdate += args =>
     {
         DetectedSkillshots.RemoveAll(i => !i.IsActive);
         foreach (var skillshot in DetectedSkillshots)
         {
             skillshot.OnUpdate();
         }
         if (!Program.MainMenu["Evade"]["Enabled"].GetValue <MenuKeyBind>().Active)
         {
             return;
         }
         if (ObjectManager.Player.IsDead)
         {
             return;
         }
         if (InterruptableSpell.IsCastingInterruptableSpell(ObjectManager.Player, true))
         {
             return;
         }
         if (ObjectManager.Player.HasBuffOfType(BuffType.SpellShield) ||
             ObjectManager.Player.HasBuffOfType(BuffType.SpellImmunity))
         {
             return;
         }
         Evading?.Invoke();
         var currentPath = ObjectManager.Player.GetWaypoints();
         var safePoint   = IsSafePoint(PlayerPosition);
         var safePath    = IsSafePath(currentPath, 100);
         if (!safePath.IsSafe && !safePoint.IsSafe)
         {
             TryEvading?.Invoke(safePoint.SkillshotList, Game.CursorPos.ToVector2());
         }
     };
     SkillshotDetector.OnDetectSkillshot += OnDetectSkillshot;
     SkillshotDetector.OnDeleteSkillshot += (skillshot, missile) =>
     {
         if (skillshot.SpellData.SpellName == "VelkozQ")
         {
             var spellData = SpellDatabase.GetByName("VelkozQSplit");
             var direction = skillshot.Direction.Perpendicular();
             if (DetectedSkillshots.Count(i => i.SpellData.SpellName == "VelkozQSplit") == 0)
             {
                 for (var i = -1; i <= 1; i = i + 2)
                 {
                     var skillshotToAdd = new Skillshot(
                         DetectionType.ProcessSpell,
                         spellData,
                         Variables.TickCount,
                         missile.Position.ToVector2(),
                         missile.Position.ToVector2() + i * direction * spellData.Range,
                         skillshot.Unit);
                     DetectedSkillshots.Add(skillshotToAdd);
                 }
             }
         }
     };
     Drawing.OnDraw += args =>
     {
         if (Program.MainMenu["Evade"]["Draw"]["Status"])
         {
             var active = Program.MainMenu["Evade"]["Enabled"].GetValue <MenuKeyBind>().Active;
             var text   =
                 $"Evade Skillshot: {(active ? (Program.MainMenu["Evade"]["OnlyDangerous"].GetValue<MenuKeyBind>().Active ? "Dangerous" : "On") : "Off")}";
             var pos = Drawing.WorldToScreen(ObjectManager.Player.Position);
             Drawing.DrawText(
                 pos.X - (float)Drawing.GetTextExtent(text).Width / 2,
                 pos.Y + 40,
                 active
                         ? (Program.MainMenu["Evade"]["OnlyDangerous"].GetValue <MenuKeyBind>().Active
                                ? Color.Yellow
                                : Color.White)
                         : Color.Gray,
                 text);
         }
         if (Program.MainMenu["Evade"]["Draw"]["Skillshot"])
         {
             foreach (var skillshot in DetectedSkillshots)
             {
                 skillshot.Draw(
                     skillshot.Enable && Program.MainMenu["Evade"]["Enabled"].GetValue <MenuKeyBind>().Active
                             ? Color.White
                             : Color.Red,
                     Color.LimeGreen);
             }
         }
     };
 }
Exemplo n.º 11
0
        private static void OnDetectSkillshot(Skillshot skillshot)
        {
            var alreadyAdded = false;

            foreach (var item in DetectedSkillshots)
            {
                if (item.SpellData.SpellName == skillshot.SpellData.SpellName &&
                    item.Unit.NetworkId == skillshot.Unit.NetworkId &&
                    skillshot.Direction.AngleBetween(item.Direction) < 5 &&
                    (skillshot.Start.Distance(item.Start) < 100 || skillshot.SpellData.FromObjects.Length == 0))
                {
                    alreadyAdded = true;
                }
            }
            if (skillshot.Unit.Team == ObjectManager.Player.Team)
            {
                return;
            }
            if (skillshot.Start.Distance(PlayerPosition)
                > (skillshot.SpellData.Range + skillshot.SpellData.Radius + 1000) * 1.5)
            {
                return;
            }
            if (alreadyAdded && !skillshot.SpellData.DontCheckForDuplicates)
            {
                return;
            }
            if (skillshot.DetectionType == DetectionType.ProcessSpell)
            {
                if (skillshot.SpellData.MultipleNumber != -1)
                {
                    var originalDirection = skillshot.Direction;
                    for (var i = -(skillshot.SpellData.MultipleNumber - 1) / 2;
                         i <= (skillshot.SpellData.MultipleNumber - 1) / 2;
                         i++)
                    {
                        var end = skillshot.Start
                                  + skillshot.SpellData.Range
                                  * originalDirection.Rotated(skillshot.SpellData.MultipleAngle * i);
                        var skillshotToAdd = new Skillshot(
                            skillshot.DetectionType,
                            skillshot.SpellData,
                            skillshot.StartTick,
                            skillshot.Start,
                            end,
                            skillshot.Unit);
                        DetectedSkillshots.Add(skillshotToAdd);
                    }
                    return;
                }
                if (skillshot.SpellData.SpellName == "UFSlash")
                {
                    skillshot.SpellData.MissileSpeed = 1600 + (int)skillshot.Unit.MoveSpeed;
                }
                if (skillshot.SpellData.SpellName == "SionR")
                {
                    skillshot.SpellData.MissileSpeed = (int)skillshot.Unit.MoveSpeed;
                }
                if (skillshot.SpellData.Invert)
                {
                    var newDirection   = -(skillshot.End - skillshot.Start).Normalized();
                    var end            = skillshot.Start + newDirection * skillshot.Start.Distance(skillshot.End);
                    var skillshotToAdd = new Skillshot(
                        skillshot.DetectionType,
                        skillshot.SpellData,
                        skillshot.StartTick,
                        skillshot.Start,
                        end,
                        skillshot.Unit);
                    DetectedSkillshots.Add(skillshotToAdd);
                    return;
                }
                if (skillshot.SpellData.Centered)
                {
                    var start          = skillshot.Start - skillshot.Direction * skillshot.SpellData.Range;
                    var end            = skillshot.Start + skillshot.Direction * skillshot.SpellData.Range;
                    var skillshotToAdd = new Skillshot(
                        skillshot.DetectionType,
                        skillshot.SpellData,
                        skillshot.StartTick,
                        start,
                        end,
                        skillshot.Unit);
                    DetectedSkillshots.Add(skillshotToAdd);
                    return;
                }
                if (skillshot.SpellData.SpellName == "SyndraE" || skillshot.SpellData.SpellName == "syndrae5")
                {
                    const int Angle = 60;
                    var       edge1 =
                        (skillshot.End - skillshot.Unit.ServerPosition.ToVector2()).Rotated(
                            -Angle / 2f * (float)Math.PI / 180);
                    var edge2 = edge1.Rotated(Angle * (float)Math.PI / 180);
                    foreach (var skillshotToAdd in
                             from minion in
                             GameObjects.EnemyMinions.Where(i => i.Name == "Seed" && i.Distance(skillshot.Unit) < 800)
                             let v = minion.ServerPosition.ToVector2() - skillshot.Unit.ServerPosition.ToVector2()
                                     where edge1.CrossProduct(v) > 0 && v.CrossProduct(edge2) > 0
                                     let start = minion.ServerPosition.ToVector2()
                                                 let end =
                                 skillshot.Unit.ServerPosition.ToVector2()
                                 .Extend(
                                     minion.ServerPosition.ToVector2(),
                                     skillshot.Unit.Distance(minion) > 200 ? 1300 : 1000)
                                 select
                                 new Skillshot(
                                     skillshot.DetectionType,
                                     skillshot.SpellData,
                                     skillshot.StartTick,
                                     start,
                                     end,
                                     skillshot.Unit))
                    {
                        DetectedSkillshots.Add(skillshotToAdd);
                    }
                    return;
                }
                if (skillshot.SpellData.SpellName == "AlZaharCalloftheVoid")
                {
                    var start          = skillshot.End - skillshot.Direction.Perpendicular() * 400;
                    var end            = skillshot.End + skillshot.Direction.Perpendicular() * 400;
                    var skillshotToAdd = new Skillshot(
                        skillshot.DetectionType,
                        skillshot.SpellData,
                        skillshot.StartTick,
                        start,
                        end,
                        skillshot.Unit);
                    DetectedSkillshots.Add(skillshotToAdd);
                    return;
                }
                if (skillshot.SpellData.SpellName == "DianaArc")
                {
                    var skillshotToAdd = new Skillshot(
                        skillshot.DetectionType,
                        SpellDatabase.GetByName("DianaArcArc"),
                        skillshot.StartTick,
                        skillshot.Start,
                        skillshot.End,
                        skillshot.Unit);

                    DetectedSkillshots.Add(skillshotToAdd);
                }
                if (skillshot.SpellData.SpellName == "ZiggsQ")
                {
                    var d1 = skillshot.Start.Distance(skillshot.End);
                    var d2 = d1 * 0.4f;
                    var d3 = d2 * 0.69f;
                    var bounce1SpellData = SpellDatabase.GetByName("ZiggsQBounce1");
                    var bounce2SpellData = SpellDatabase.GetByName("ZiggsQBounce2");
                    var bounce1Pos       = skillshot.End + skillshot.Direction * d2;
                    var bounce2Pos       = bounce1Pos + skillshot.Direction * d3;
                    bounce1SpellData.Delay =
                        (int)(skillshot.SpellData.Delay + d1 * 1000f / skillshot.SpellData.MissileSpeed + 500);
                    bounce2SpellData.Delay =
                        (int)(bounce1SpellData.Delay + d2 * 1000f / bounce1SpellData.MissileSpeed + 500);
                    var bounce1 = new Skillshot(
                        skillshot.DetectionType,
                        bounce1SpellData,
                        skillshot.StartTick,
                        skillshot.End,
                        bounce1Pos,
                        skillshot.Unit);
                    var bounce2 = new Skillshot(
                        skillshot.DetectionType,
                        bounce2SpellData,
                        skillshot.StartTick,
                        bounce1Pos,
                        bounce2Pos,
                        skillshot.Unit);
                    DetectedSkillshots.Add(bounce1);
                    DetectedSkillshots.Add(bounce2);
                }
                if (skillshot.SpellData.SpellName == "ZiggsR")
                {
                    skillshot.SpellData.Delay =
                        (int)(1500 + 1500 * skillshot.End.Distance(skillshot.Start) / skillshot.SpellData.Range);
                }
                if (skillshot.SpellData.SpellName == "JarvanIVDragonStrike")
                {
                    var endPos = Vector2.Zero;
                    foreach (var s in DetectedSkillshots)
                    {
                        if (s.Unit.NetworkId == skillshot.Unit.NetworkId && s.SpellData.Slot == SpellSlot.E)
                        {
                            var extendedE = new Skillshot(
                                skillshot.DetectionType,
                                skillshot.SpellData,
                                skillshot.StartTick,
                                skillshot.Start,
                                skillshot.End + skillshot.Direction * 100,
                                skillshot.Unit);
                            if (!extendedE.IsSafe(s.End))
                            {
                                endPos = s.End;
                            }
                            break;
                        }
                    }
                    foreach (var m in ObjectManager.Get <Obj_AI_Minion>())
                    {
                        if (m.CharData.BaseSkinName == "jarvanivstandard" && m.Team == skillshot.Unit.Team)
                        {
                            var extendedE = new Skillshot(
                                skillshot.DetectionType,
                                skillshot.SpellData,
                                skillshot.StartTick,
                                skillshot.Start,
                                skillshot.End + skillshot.Direction * 100,
                                skillshot.Unit);
                            if (!extendedE.IsSafe(m.Position.ToVector2()))
                            {
                                endPos = m.Position.ToVector2();
                            }
                            break;
                        }
                    }
                    if (endPos.IsValid())
                    {
                        skillshot = new Skillshot(
                            DetectionType.ProcessSpell,
                            SpellDatabase.GetByName("JarvanIVEQ"),
                            Variables.TickCount,
                            skillshot.Start,
                            endPos,
                            skillshot.Unit);
                        skillshot.End       = endPos + 200 * (endPos - skillshot.Start).Normalized();
                        skillshot.Direction = (skillshot.End - skillshot.Start).Normalized();
                    }
                }
            }
            if (skillshot.SpellData.SpellName == "OriannasQ")
            {
                var skillshotToAdd = new Skillshot(
                    skillshot.DetectionType,
                    SpellDatabase.GetByName("OriannaQend"),
                    skillshot.StartTick,
                    skillshot.Start,
                    skillshot.End,
                    skillshot.Unit);
                DetectedSkillshots.Add(skillshotToAdd);
            }
            if (skillshot.SpellData.DisableFowDetection && skillshot.DetectionType == DetectionType.RecvPacket)
            {
                return;
            }
            DetectedSkillshots.Add(skillshot);
        }