private static void TriggerOnDetectSkillshot(DetectionType detectionType,
            SpellData spellData,
            int startT,
            Vector2 start,
            Vector2 end,
            Obj_AI_Base unit)
        {
            var skillshot = new Skillshot(detectionType, spellData, startT, start, end, unit);

            if (OnDetectSkillshot != null)
            {
                OnDetectSkillshot(skillshot);
            }
        }
예제 #2
0
 private static void OnDeleteMissile(Skillshot skillshot, Obj_SpellMissile missile)
 {
     if (skillshot.SpellData.SpellName == "VelkozQ")
     {
         var spellData = SpellDatabase.GetByName("VelkozQSplit");
         var direction = skillshot.Direction.Perpendicular();
         if (DetectedSkillshots.Count(s => s.SpellData.SpellName == "VelkozQSplit") == 0)
         {
             for (int i = -1; i <= 1; i = i + 2)
             {
                 var skillshotToAdd = new Skillshot(
                     DetectionType.ProcessSpell, spellData, Environment.TickCount, missile.Position.To2D(),
                     missile.Position.To2D() + i * direction * spellData.Range, skillshot.Unit);
                 DetectedSkillshots.Add(skillshotToAdd);
             }
         }
     }
 }
예제 #3
0
        private static void OnDetectSkillshot(Skillshot skillshot)
        {
            bool alreadyAdded = false;

            foreach (Skillshot 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;
                }
            }

            //Check if the skillshot is from an ally.
            if (skillshot.Unit.Team == ObjectManager.Player.Team)
            {
                return;
            }

            //Check if the skillshot is too far away.
            if (skillshot.Start.Distance(ObjectManager.Player.ServerPosition.To2D()) >
                (skillshot.SpellData.Range + skillshot.SpellData.Radius + 1000) * 1.5)
            {
                return;
            }

            //Add the skillshot to the detected skillshot list.
            if (!alreadyAdded)
            {
                //Multiple skillshots like twisted fate Q.
                if (skillshot.DetectionType == DetectionType.ProcessSpell)
                {
                    if (skillshot.SpellData.MultipleNumber != -1)
                    {
                        var originalDirection = skillshot.Direction;

                        for (int 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.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")
                    {
                        int angle = 60;
                        var edge1 =
                            (skillshot.End - skillshot.Unit.ServerPosition.To2D()).Rotated(
                                -angle / 2 * (float)Math.PI / 180);
                        var edge2 = edge1.Rotated(angle * (float)Math.PI / 180);

                        foreach (Obj_AI_Minion minion in ObjectManager.Get<Obj_AI_Minion>())
                        {
                            Vector2 v = minion.ServerPosition.To2D() - skillshot.Unit.ServerPosition.To2D();
                            if (minion.Name == "Seed" && edge1.CrossProduct(v) > 0 && v.CrossProduct(edge2) > 0 &&
                                minion.Distance(skillshot.Unit) < 800 &&
                                (minion.Team != ObjectManager.Player.Team))
                            {
                                Vector2 start = minion.ServerPosition.To2D();
                                var end = skillshot.Unit.ServerPosition.To2D()
                                    .Extend(
                                        minion.ServerPosition.To2D(),
                                        skillshot.Unit.Distance(minion) > 200 ? 1300 : 1000);

                                var skillshotToAdd = new Skillshot(
                                    skillshot.DetectionType, skillshot.SpellData, skillshot.StartTick, start, end,
                                    skillshot.Unit);
                                DetectedSkillshots.Add(skillshotToAdd);
                            }
                        }
                        return;
                    }

                    if (skillshot.SpellData.SpellName == "AlZaharCalloftheVoid")
                    {
                        Vector2 start = skillshot.End - skillshot.Direction.Perpendicular() * 400;
                        Vector2 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 == "ZiggsQ")
                    {
                        var d1 = skillshot.Start.Distance(skillshot.End);
                        float d2 = d1 * 0.4f;
                        float d3 = d2 * 0.69f;

                        var bounce1SpellData = SpellDatabase.GetByName("ZiggsQBounce1");
                        var bounce2SpellData = SpellDatabase.GetByName("ZiggsQBounce2");

                        Vector2 bounce1Pos = skillshot.End + skillshot.Direction * d2;
                        Vector2 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 = new Vector2();

                        foreach (Skillshot s in DetectedSkillshots)
                        {
                            if (s.Unit.NetworkId == skillshot.Unit.NetworkId && s.SpellData.Slot == SpellSlot.E)
                            {
                                endPos = s.End;
                            }
                        }

                        foreach (Obj_AI_Minion m in ObjectManager.Get<Obj_AI_Minion>())
                        {
                            if (m.BaseSkinName == "jarvanivstandard" && m.Team == skillshot.Unit.Team &&
                                skillshot.IsDanger(m.Position.To2D()))
                            {
                                endPos = m.Position.To2D();
                            }
                        }

                        if (!endPos.IsValid())
                        {
                            return;
                        }

                        skillshot.End = endPos + 200 * (endPos - skillshot.Start).Normalized();
                        skillshot.Direction = (skillshot.End - skillshot.Start).Normalized();
                    }
                }

                if (skillshot.SpellData.SpellName == "OriannasQ")
                {
                    var endCSpellData = SpellDatabase.GetByName("OriannaQend");

                    var skillshotToAdd = new Skillshot(
                        skillshot.DetectionType, endCSpellData, skillshot.StartTick, skillshot.Start, skillshot.End,
                        skillshot.Unit);

                    DetectedSkillshots.Add(skillshotToAdd);
                }

                //Dont allow fow detection.
                if (skillshot.SpellData.DisableFowDetection && skillshot.DetectionType == DetectionType.RecvPacket)
                {
                    return;
                }
            #if DEBUG
                Console.WriteLine(Environment.TickCount + "Adding new skillshot: " + skillshot.SpellData.SpellName);
            #endif

                DetectedSkillshots.Add(skillshot);
            }
        }
예제 #4
0
        public static Vector2 GetCollisionPoint(Skillshot skillshot)
        {
            var collisions = new List<DetectedCollision>();
            var from = skillshot.GetMissilePosition(0);
            skillshot.ForceDisabled = false;
            foreach (var cObject in skillshot.SpellData.CollisionObjects)
            {
                switch (cObject)
                {
                    case CollisionObjectTypes.Minion:

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

                        {
                            var pred = FastPrediction(
                                from, minion,
                                Math.Max(0, skillshot.SpellData.Delay - (Utils.TickCount - skillshot.StartTick)),
                                skillshot.SpellData.MissileSpeed);
                            var pos = pred.PredictedPos;
                            var w = skillshot.SpellData.RawRadius + (!pred.IsMoving ? (minion.BoundingRadius - 15) : 0) -
                                    pos.Distance(from, skillshot.End, true);
                            if (w > 0)
                            {
                                collisions.Add(
                                    new DetectedCollision
                                    {
                                        Position =
                                            pos.ProjectOn(skillshot.End, skillshot.Start).LinePoint +
                                            skillshot.Direction * 30,
                                        Unit = minion,
                                        Type = CollisionObjectTypes.Minion,
                                        Distance = pos.Distance(from),
                                        Diff = w,
                                    });
                            }
                        }

                        break;

                    case CollisionObjectTypes.Champions:
                        if (!Config.collision["HeroCollision"].Cast<CheckBox>().CurrentValue)
                        {
                            break;
                        }
                        foreach (var hero in
                            ObjectManager.Get<AIHeroClient>()
                                .Where(
                                    h =>
                                        (h.IsValidTarget(1200) && h.Team == ObjectManager.Player.Team && !h.IsMe ||
                                         Config.TestOnAllies && h.Team != ObjectManager.Player.Team)))
                        {
                            var pred = FastPrediction(
                                from, hero,
                                Math.Max(0, skillshot.SpellData.Delay - (Utils.TickCount - skillshot.StartTick)),
                                skillshot.SpellData.MissileSpeed);
                            var pos = pred.PredictedPos;

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

                    case CollisionObjectTypes.YasuoWall:
                        if (!Config.collision["YasuoCollision"].Cast<CheckBox>().CurrentValue)
                        {
                            break;
                        }
                        if (
                            !ObjectManager.Get<AIHeroClient>()
                                .Any(
                                    hero =>
                                        hero.IsValidTarget(float.MaxValue) &&
                                        hero.Team == ObjectManager.Player.Team && hero.ChampionName == "Yasuo"))
                        {
                            break;
                        }
                        GameObject wall = null;
                        foreach (var gameObject in ObjectManager.Get<GameObject>())
                        {
                            if (gameObject.IsValid &&
                                System.Text.RegularExpressions.Regex.IsMatch(
                                    gameObject.Name, "_w_windwall.\\.troy",
                                    System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                            {
                                wall = gameObject;
                            }
                        }
                        if (wall == null)
                        {
                            break;
                        }
                        var level = wall.Name.Substring(wall.Name.Length - 6, 1);
                        var wallWidth = (300 + 50 * Convert.ToInt32(level));


                        var wallDirection = (wall.Position.To2D() - YasuoWallCastedPos).Normalized().Perpendicular();
                        var wallStart = wall.Position.To2D() + wallWidth / 2 * wallDirection;
                        var wallEnd = wallStart - wallWidth * wallDirection;
                        var wallPolygon = new Geometry.Rectangle(wallStart, wallEnd, 75).ToPolygon();
                        var intersection = new Vector2();
                        var intersections = new List<Vector2>();

                        for (var i = 0; i < wallPolygon.Points.Count; i++)
                        {
                            var inter =
                                wallPolygon.Points[i].Intersection(
                                    wallPolygon.Points[i != wallPolygon.Points.Count - 1 ? i + 1 : 0], from,
                                    skillshot.End);
                            if (inter.Intersects)
                            {
                                intersections.Add(inter.Point);
                            }
                        }

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

                        break;
                }
            }

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

            return result;
        }
예제 #5
0
        private static void OnDetectSkillshot(Skillshot skillshot)
        {
            //Check if the skillshot is already added.
            var alreadyAdded = false;

            if (Config.Menu.Item("DisableFow").GetValue<bool>() && !skillshot.Unit.IsVisible)
            {
                return;
            }
                
            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;
                }
            }

            //Check if the skillshot is from an ally.
            if (skillshot.Unit.Team == ObjectManager.Player.Team && !Config.TestOnAllies)
            {
                return;
            }

            //Check if the skillshot is too far away.
            if (skillshot.Start.Distance(PlayerPosition) >
                (skillshot.SpellData.Range + skillshot.SpellData.Radius + 1000) * 1.5)
            {
                return;
            }

            //Add the skillshot to the detected skillshot list.
            if (!alreadyAdded || skillshot.SpellData.DontCheckForDuplicates)
            {
                //Multiple skillshots like twisted fate Q.
                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 == "TaricE" && (skillshot.Unit as Obj_AI_Hero).ChampionName == "Taric")
                    {
                        var target = HeroManager.AllHeroes.FirstOrDefault(h => h.Team == skillshot.Unit.Team && h.IsVisible && h.HasBuff("taricwleashactive"));
                        if (target != null)
                        {
                            var start = target.ServerPosition.To2D();
                            var direction = (skillshot.OriginalEnd - start).Normalized();
                            var end = start + direction * skillshot.SpellData.Range;
                            var skillshotToAdd = new Skillshot(
                                    skillshot.DetectionType, skillshot.SpellData, skillshot.StartTick,
                                    start, end, target)
                            {
                              OriginalEnd = skillshot.OriginalEnd
                            };
                            DetectedSkillshots.Add(skillshotToAdd);
                        }
                    }

                    if (skillshot.SpellData.SpellName == "SyndraE" || skillshot.SpellData.SpellName == "syndrae5")
                    {
                        var angle = 60;
                        var edge1 =
                            (skillshot.End - skillshot.Unit.ServerPosition.To2D()).Rotated(
                                -angle / 2 * (float) Math.PI / 180);
                        var edge2 = edge1.Rotated(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);
                        }

                        foreach (var minion in ObjectManager.Get<Obj_AI_Minion>())
                        {
                            if (minion.Name == "Seed" && !minion.IsDead && (minion.Team != ObjectManager.Player.Team || Config.TestOnAllies))
                            {
                                positions.Add(minion.ServerPosition.To2D());
                            }
                        }
                        Console.WriteLine(positions.Count + " positions to check");
                        foreach (var position in positions)
                        {
                            var v = position - skillshot.Unit.ServerPosition.To2D();
                            if (edge1.CrossProduct(v) > 0 && v.CrossProduct(edge2) > 0 &&
                                position.Distance(skillshot.Unit) < 800 )
                            {
                                var start = position;
                                var end = skillshot.Unit.ServerPosition.To2D()
                                    .Extend(
                                        position,
                                        skillshot.Unit.Distance(position) > 200 ? 1300 : 1000);

                                var startTime = skillshot.StartTick;

                                startTime += (int)(150 + skillshot.Unit.Distance(position) / 2.5f);
                                var skillshotToAdd = new Skillshot(
                                    skillshot.DetectionType, skillshot.SpellData, startTime, start, end,
                                    skillshot.Unit);
                                DetectedSkillshots.Add(skillshotToAdd);
                            }
                        }
                        return;
                    }

                    if (skillshot.SpellData.SpellName == "MalzaharQ")
                    {
                        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 == "ZyraQ")
                    {
                        var start = skillshot.End - skillshot.Direction.Perpendicular() * 450;
                        var end = skillshot.End + skillshot.Direction.Perpendicular() * 450;
                        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 = new Vector2();

                        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.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.To2D()))
                                {
                                    endPos = m.Position.To2D();
                                }
                                break;
                            }
                        }

                        if (endPos.IsValid())
                        {
                            skillshot = new Skillshot(DetectionType.ProcessSpell, SpellDatabase.GetByName("JarvanIVEQ"), Utils.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);
                }


                //Dont allow fow detection.
                if (skillshot.SpellData.DisableFowDetection && skillshot.DetectionType == DetectionType.RecvPacket)
                {
                    return;
                }
#if DEBUG
                Console.WriteLine(Utils.TickCount + "Adding new skillshot: " + skillshot.SpellData.SpellName);
#endif

                DetectedSkillshots.Add(skillshot);
            }
        }
예제 #6
0
        private static void OnDetectSkillshot(Skillshot skillshot)
        {
            //Check if the skillshot is already added.
            var alreadyAdded = false;

            foreach (var item in DetectedSkillshots)
            {
                if (item.SpellData.SpellName == skillshot.SpellData.SpellName && item.End.Distance(skillshot.End) <= 50)
                {
                    alreadyAdded = true;
                }
            }

            //Check if the skillshot is from an ally.
            if (skillshot.Unit.Team == ObjectManager.Player.Team && !Config.TestOnAllies)
                return;

            //Check if the skillshot is too far away.
            if (skillshot.Start.Distance(ObjectManager.Player.ServerPosition.To2D()) > skillshot.SpellData.Range * 1.5)
                return;

            //Add the skillshot to the detected skillshot list.
            if (!alreadyAdded)
            {
                //Multiple skillshots like twisted fate Q.
                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 = 1500 + (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;
                    }
                }

                //Dont allow fow detection.
                if (skillshot.SpellData.DisableFowDetection && skillshot.DetectionType == DetectionType.RecvPacket)
                    return;

                DetectedSkillshots.Add(skillshot);
            }
        }
예제 #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:

                    if (!Config.collision["MinionCollision"].Cast <CheckBox>().CurrentValue)
                    {
                        break;
                    }
                    foreach (var minion in
                             MinionManager.GetMinions(
                                 from.To3D(), 1200, MinionTypes.All,
                                 skillshot.Unit.Team == Player.Instance.Team
                                    ? MinionTeam.NotAlly
                                    : MinionTeam.NotAllyForEnemy))
                    {
                        var pred = FastPrediction(
                            from, minion,
                            Math.Max(0, skillshot.SpellData.Delay - (Utils.TickCount - skillshot.StartTick)),
                            skillshot.SpellData.MissileSpeed);
                        var pos = pred.PredictedPos;
                        var w   = skillshot.SpellData.RawRadius + (!pred.IsMoving ? (minion.BoundingRadius - 15) : 0) -
                                  pos.Distance(from, skillshot.End, true);
                        if (w > 0)
                        {
                            collisions.Add(
                                new DetectedCollision
                            {
                                Position =
                                    pos.ProjectOn(skillshot.End, skillshot.Start).LinePoint +
                                    skillshot.Direction * 30,
                                Unit     = minion,
                                Type     = CollisionObjectTypes.Minion,
                                Distance = pos.Distance(from),
                                Diff     = w,
                            });
                        }
                    }

                    break;

                case CollisionObjectTypes.Champions:
                    if (!Config.collision["HeroCollision"].Cast <CheckBox>().CurrentValue)
                    {
                        break;
                    }
                    foreach (var hero in
                             ObjectManager.Get <AIHeroClient>()
                             .Where(
                                 h =>
                                 (h.IsValidTarget(1200, false) && h.Team == Player.Instance.Team && !h.IsMe ||
                                  Config.TestOnAllies && h.Team != Player.Instance.Team)))
                    {
                        var pred = FastPrediction(
                            from, Player.Instance,
                            Math.Max(0, skillshot.SpellData.Delay - (Utils.TickCount - skillshot.StartTick)),
                            skillshot.SpellData.MissileSpeed);
                        var pos = pred.PredictedPos;

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

                case CollisionObjectTypes.YasuoWall:
                    if (!Config.collision["YasuoCollision"].Cast <CheckBox>().CurrentValue)
                    {
                        break;
                    }
                    if (
                        !ObjectManager.Get <AIHeroClient>()
                        .Any(
                            hero =>
                            Player.Instance.IsValidTarget(float.MaxValue, false) &&
                            Player.Instance.Team == Player.Instance.Team && Player.Instance.ChampionName == "Yasuo"))
                    {
                        break;
                    }
                    GameObject wall = null;
                    foreach (var gameObject in ObjectManager.Get <GameObject>())
                    {
                        if (gameObject.IsValid &&
                            System.Text.RegularExpressions.Regex.IsMatch(
                                gameObject.Name, "_w_windwall.\\.troy",
                                System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                        {
                            wall = gameObject;
                        }
                    }
                    if (wall == null)
                    {
                        break;
                    }
                    var level     = wall.Name.Substring(wall.Name.Length - 6, 1);
                    var wallWidth = (300 + 50 * Convert.ToInt32(level));


                    var wallDirection = (wall.Position.To2D() - YasuoWallCastedPos).Normalized().Perpendicular();
                    var wallStart     = wall.Position.To2D() + wallWidth / 2 * wallDirection;
                    var wallEnd       = wallStart - wallWidth * wallDirection;
                    var wallPolygon   = new Geometry.Rectangle(wallStart, wallEnd, 75).ToPolygon();
                    var intersection  = new Vector2();
                    var intersections = new List <Vector2>();

                    for (var i = 0; i < wallPolygon.Points.Count; i++)
                    {
                        var inter =
                            wallPolygon.Points[i].Intersection(
                                wallPolygon.Points[i != wallPolygon.Points.Count - 1 ? i + 1 : 0], from,
                                skillshot.End);
                        if (inter.Intersects)
                        {
                            intersections.Add(inter.Point);
                        }
                    }

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

                    break;
                }
            }

            Vector2 result;

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

            return(result);
        }
예제 #8
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.To2D()).Rotated(
                            -Angle / 2f * (float)Math.PI / 180);
                    var edge2 = edge1.Rotated(Angle * (float)Math.PI / 180);
                    foreach (var skillshotToAdd in
                        from minion in
                            ObjectManager.Get<Obj_AI_Minion>()
                                .Where(x => x.IsEnemy)
                                .Where(i => i.Name == "Seed" && i.Distance(skillshot.Unit) < 800)
                        let v = minion.ServerPosition.To2D() - skillshot.Unit.ServerPosition.To2D()
                        where edge1.CrossProduct(v) > 0 && v.CrossProduct(edge2) > 0
                        let start = minion.ServerPosition.To2D()
                        let end =
                            skillshot.Unit.ServerPosition.To2D()
                                .Extend(
                                    minion.ServerPosition.To2D(), 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.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.To2D()))
                            {
                                endPos = m.Position.To2D();
                            }
                            break;
                        }
                    }
                    if (endPos.IsValid())
                    {
                        skillshot = new Skillshot(
                            DetectionType.ProcessSpell, SpellDatabase.GetByName("JarvanIVEQ"), Environment.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);
        }
예제 #9
0
        public static Vector2 GetCollisionPoint(Skillshot skillshot)
        {
            var collisions = new List <DetectedCollision>();
            var from       = skillshot.GetMissilePosition(0);

            skillshot.ForceDisabled = false;

            foreach (var cObject in skillshot.SpellData.CollisionObjects)
            {
                switch (cObject)
                {
                case CollisionObjectTypes.Minion:
                    if (!Config.collision["MinionCollision"].GetValue <MenuBool>().Value)
                    {
                        break;
                    }

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

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

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

                        if (w > 0)
                        {
                            collisions.Add(
                                new DetectedCollision
                            {
                                Position = pos.ProjectOn(skillshot.End, skillshot.Start).LinePoint + skillshot.Direction * 30,
                                Unit     = minion,
                                Type     = CollisionObjectTypes.Minion,
                                Distance = pos.Distance(from),
                                Diff     = w
                            });
                        }
                    }

                    break;

                case CollisionObjectTypes.Champions:
                    if (!Config.collision["HeroCollision"].GetValue <MenuBool>().Value)
                    {
                        break;
                    }

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

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

                        if (w > 0)
                        {
                            collisions.Add(
                                new DetectedCollision
                            {
                                Position = pos.ProjectOn(skillshot.End, skillshot.Start).LinePoint + skillshot.Direction * 30,
                                Unit     = hero,
                                Type     = CollisionObjectTypes.Minion,
                                Distance = pos.Distance(from),
                                Diff     = w
                            });
                        }
                    }

                    break;

                case CollisionObjectTypes.YasuoWall:
                    if (!Config.collision["YasuoCollision"].GetValue <MenuBool>().Value)
                    {
                        break;
                    }

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

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

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

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

                            for (var i = 0; i < wallPolygon.Points.Count; i++)
                            {
                                var inter = wallPolygon.Points[i].Intersection(
                                    wallPolygon.Points[i != wallPolygon.Points.Count - 1 ? i + 1 : 0], from, skillshot.End);
                                if (inter.Intersects)
                                {
                                    intersections.Add(new Tuple <Vector2, float>(inter.Point, wall.RestartTime));
                                }
                            }
                        }
                    }

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

                    break;

                case CollisionObjectTypes.Wall:
                    break;
                }
            }

            var result = Vector2.Zero;

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

            return(result);
        }
예제 #10
0
        public static bool wontHitOnDash(Skillshot ss, Obj_AI_Base jumpOn)
        {
            float currentDashSpeed = 700 + Player.MoveSpeed;//At least has to be like this
            //Get intersection point
            Vector2 intersectionPoint = YasMath.LineIntersectionPoint(Player.Position.To2D(), V2E(Player.Position, jumpOn.Position, 475), ss.Start, ss.End);
            //Time when yasuo will be in intersection point
             float arrivingTime = Vector2.Distance(Player.Position.To2D(), intersectionPoint) / currentDashSpeed;
            //Estimated skillshot position
             Vector2 skillshotPosition = ss.GetMissilePosition((int)(arrivingTime*1000));

            if (Vector2.DistanceSquared(skillshotPosition, intersectionPoint) <
                (ss.SpellData.Radius + Player.BoundingRadius))
                return false;
            return true;
        }
예제 #11
0
        public static void useWSmart(Skillshot skillShot)
        {
            //try douge with E if cant windWall

            if (!W.IsReady())
                return;
            if (skillShot.IsAboutToHit(250, Player))
            {
                var sd = SpellDatabase.GetByMissileName(skillShot.SpellData.MissileSpellName);
                if (sd == null)
                    return;

                //If enabled
                if (!YasuoSharp.EvadeSpellEnabled(sd.MenuItemName))
                    return;

                //if only dangerous
                if (YasuoSharp.Config.Item("wwDanger").GetValue<bool>() &&
                    !YasuoSharp.skillShotIsDangerous(sd.MenuItemName))
                    return;

                //Console.WriteLine("dmg: " + missle.SpellCaster.GetSpellDamage(Player, sd.SpellName));
                float spellDamage = (float)skillShot.Unit.GetSpellDamage(Player, sd.SpellName);
                int procHp = (int)((spellDamage / Player.MaxHealth) * 100);

                if (procHp < YasuoSharp.Config.Item("wwDmg").GetValue<Slider>().Value && Player.Health - spellDamage > 0)
                    return;

                Vector3 blockwhere = Player.ServerPosition + Vector3.Normalize(skillShot.MissilePosition.To3D() - Player.ServerPosition) * 10; // missle.Position;
                W.Cast(blockwhere);
            }
        }
예제 #12
0
        public static void useEtoSafe(Skillshot skillShot)
        {
            if (!E.IsReady())
                return;
            Console.WriteLine("try to safe");
            float closest = float.MaxValue;
            Obj_AI_Base closestTarg = null;
            float currentDashSpeed = 700 + Player.MoveSpeed;
            foreach (Obj_AI_Base enemy in ObjectManager.Get<Obj_AI_Base>().Where(ob => ob.NetworkId != skillShot.Unit.NetworkId && enemyIsJumpable(ob) && ob.Distance(Player) < E.Range))
            {
                var pPos = Player.Position.To2D();
                Vector2 posAfterE = V2E(Player.Position, enemy.Position, 475);

                if (isSafePoint(posAfterE).IsSafe && wontHitOnDash(skillShot,enemy)/* && skillShot.IsSafePath(new List<Vector2>() { posAfterE }, 0, (int)currentDashSpeed, 0).IsSafe*/)
                {
                    float curDist = Vector2.DistanceSquared(Game.CursorPos.To2D(), posAfterE);
                    if (curDist < closest)
                    {
                        closestTarg = enemy;
                        closest = curDist;
                    }
                }
            }
            if (closestTarg != null)
                useENormal(closestTarg);
        }