Example #1
0
        private static void OrbwalkerBestPosition(Obj_AI_Hero target)
        {
            if (target == null || !target.IsValid || target.IsDead || target.IsZombie || target.IsDashing())
            {
                Orbwalker.SetOrbwalkingPoint(Vector3.Zero);
                return;
            }
            var BestPosition = Vector3.Zero;

            float Wrange = IsWActive ? W.Range - 20 : 350;

            var points = CirclePoints(target.Position, Wrange);

            foreach (var point in points.Where(p => !p.IsWall()))
            {
                if (BestPosition == Vector3.Zero || Game.CursorPos.Distance(point) < Game.CursorPos.Distance(BestPosition))
                {
                    BestPosition = point;
                }
            }

            if (BestPosition == Vector3.Zero)
            {
                Orbwalker.SetOrbwalkingPoint(Vector3.Zero);

            }
            else
            {
                Orbwalker.SetOrbwalkingPoint(BestPosition);
            }
        }
Example #2
0
        public void HandleQ(Obj_AI_Hero comboTarget)
        {
            var QPrediction = Variables.Spells[SpellSlot.Q].GetPrediction(comboTarget);

            if (QPrediction.Hitchance >= HitChance.High)
            {
                var QPushDistance = 250;
                var QAccuracy = 20;
                var PlayerPosition = ObjectManager.Player.ServerPosition;

                var BeamStartPositions = new List<Vector3>()
                    {
                        QPrediction.CastPosition,
                        QPrediction.UnitPosition,
                        comboTarget.ServerPosition,
                        comboTarget.Position
                    };

                if (comboTarget.IsDashing())
                {
                    BeamStartPositions.Add(comboTarget.GetDashInfo().EndPos.To3D());
                }

                var PositionsList = new List<Vector3>();
                var CollisionPositions = new List<Vector3>();

                foreach (var position in BeamStartPositions)
                {
                    var collisionableObjects = Variables.Spells[SpellSlot.Q].GetCollision(position.To2D(),
                        new List<Vector2>() { position.Extend(PlayerPosition, -QPushDistance).To2D() });

                    if (collisionableObjects.Any())
                    {
                        if (collisionableObjects.Any(h => h is Obj_AI_Hero) &&
                            (collisionableObjects.All(h => h.IsValidTarget())))
                        {
                            Variables.Spells[SpellSlot.Q].Cast(QPrediction.CastPosition);
                            break;
                        }

                        for (var i = 0; i < QPushDistance; i += (int)comboTarget.BoundingRadius)
                        {
                            CollisionPositions.Add(position.Extend(PlayerPosition, -i));
                        }
                    }

                    for (var i = 0; i < QPushDistance; i += (int)comboTarget.BoundingRadius)
                    {
                        PositionsList.Add(position.Extend(PlayerPosition, -i));
                    }
                }

                if (PositionsList.Any())
                {
                    //We don't want to divide by 0 Kappa
                    var WallNumber = PositionsList.Count(p => p.IsWall()) * 1.3f;
                    var CollisionPositionCount = CollisionPositions.Count;
                    var Percent = (WallNumber + CollisionPositionCount) / PositionsList.Count;
                    var AccuracyEx = QAccuracy / 100f;
                    if (Percent >= AccuracyEx)
                    {
                        Variables.Spells[SpellSlot.Q].Cast(QPrediction.CastPosition);
                    }

                }
            }
            else if (QPrediction.Hitchance == HitChance.Collision)
            {
                var QCollision = QPrediction.CollisionObjects;
                if (QCollision.Count == 1)
                {
                    Variables.Spells[SpellSlot.Q].Cast(QPrediction.CastPosition);
                }
            }
        }
Example #3
0
        static void Drawing_OnDraw(EventArgs args)
        {
            if (!Menu.Item("switch").GetValue<Boolean>())
                return;

            Target = TargetSelector.GetSelectedTarget() != null ? TargetSelector.GetSelectedTarget() : Player;

            var buffs = string.Empty;

            foreach (var buff in Target.Buffs)
            {
                buffs += "\n" + buff.Name + "[Count: " + buff.Count + "/Duration: " + (buff.EndTime - Game.ClockTime).ToString("0.00") +"],";
            }

            var Mobs = MinionManager.GetMinions(1500, MinionTypes.All, MinionTeam.NotAlly, MinionOrderTypes.MaxHealth);
            var MobsList = string.Empty;

            foreach (var Mob in Mobs)
            {
                MobsList += "\n" + Mob.Name + "[Skinname: " + Mob.SkinName + "/HP: " + Mob.Health + " / " + Mob.MaxHealth + "(" + Mob.HealthPercent.ToString("0.0") + "%)],";
            }

            Render.Circle.DrawCircle(Player.Position, 1500, Color.Red, 10);

            Text.text =
                //"Name: " + Target.Name + NewLine +
                "ChampionName: " + Target.ChampionName + NewLine +
                "SkinName: " + Target.SkinName + NewLine +
                //"Gold: " + Target.Gold + NewLine +
                //"Level: " + Target.Level + NewLine +
                "TotalAttackDamage: " + Utility.TotalAttackDamage(Target) + NewLine +
                "TotalMagicalDamage: " + Utility.TotalMagicalDamage(Target) + NewLine +
                "Armor: " + Target.Armor + NewLine +
                "Health: " + Target.Health + " / " + Target.MaxHealth + " (" + Target.HealthPercent.ToString("0.0") + "%)" + NewLine +
                "Mana: " + Target.Mana + " / " + Target.MaxMana + " (" + Target.HealthPercent.ToString("0.0") + "%)" + NewLine +
                "HPRegenRate: " + Target.HPRegenRate + NewLine +
                "PARRegenRate: " + Target.PARRegenRate + NewLine +
                "Experience: " + Target.Experience + NewLine +
                "Position: " + Target.Position + NewLine +
                "ServerPosition: " + Target.ServerPosition + NewLine +
                "Team: " + Target.Team + NewLine +
                "NetworkId: " + Target.NetworkId + NewLine +
                "MoveSpeed: " + Target.MoveSpeed + NewLine +
                "AttackRange: " + Target.AttackRange + NewLine +
                "RealAutoAttackRange: " + Orbwalking.GetRealAutoAttackRange(Target) + NewLine +
                //"DeathDuration: " + Target.DeathDuration + NewLine +
                "BoundingRadius: " + Target.BoundingRadius + NewLine +
                NewLine +
                "Buffs: " + buffs + NewLine +
                NewLine +
                "IsDead: " + Target.IsDead + NewLine +
                "IsImmovable: " + Target.IsImmovable + NewLine +
                "IsInvulnerable: " + Target.IsInvulnerable + NewLine +
                "IsMoving: " + Target.IsMoving + NewLine +
                "IsPacified: " + Target.IsPacified + NewLine +
                "IsTargetable: " + Target.IsTargetable + NewLine +
                "IsWindingUp: " + Target.IsWindingUp + NewLine +
                "IsZombie: " + Target.IsZombie + NewLine +
                "IsRecalling: " + Target.IsRecalling() + NewLine +
                "IsStunned: " + Target.IsStunned + NewLine +
                "IsRooted: " + Target.IsRooted + NewLine +
                "IsMelee: " + Target.IsMelee() + NewLine +
                "IsDashing: " + Target.IsDashing() + NewLine +
                "IsAlly: " + Target.IsAlly + NewLine +
                "IsCanMove: " + Orbwalking.CanMove(1) + NewLine +
                "UnderTurret: " + Target.UnderTurret() + NewLine +
                NewLine +
                "Mobs: " + MobsList + NewLine +
                NewLine +
                "Game_CursorPos: " + Game.CursorPos + NewLine +
                "Game_ClockTime: " + Game.ClockTime + NewLine +
                "Game_Time: " + Game.Time + NewLine +
                "Game_Type: " + Game.Type + NewLine +
                "Game_Version: " + Game.Version + NewLine +
                "Game_Region: " + Game.Region + NewLine +
                "Game_IP: " + Game.IP + NewLine +
                "Game_Port: " + Game.Port + NewLine +
                "Game_Ping: " + Game.Ping + NewLine +
                "Game_Mode: " + Game.Mode + NewLine +
                "Game_MapId: " + Game.MapId + NewLine +
                "Game_MapName: " + Utility.Map.GetMap().Name
                ;

            Text.OnEndScene();
        }
Example #4
0
        public static bool SpellPrediction(Spell spell, Obj_AI_Hero target,bool collisionable)
        {
            //
            var dist = ObjectManager.Player.Distance(target.Position);
            var pos1 = LeagueSharp.Common.Prediction.GetPrediction(target, dist / spell.Speed).UnitPosition-40;
            var dister = target.Position.Extend(target.GetWaypoints()[1].To3D(), target.GetWaypoints()[1].To3D().Distance(target.Position) + 50);
              //  var pos1 = LeagueSharp.Common.Prediction.GetPrediction(target, dist / spell.Speed).UnitPosition - 40;
            var wts = Drawing.WorldToScreen(target.Position);
            var wtsx = target.GetWaypoints()[1];
            Drawing.DrawLine(wts[0], wts[1], wtsx[0], wtsx[1], 2f, System.Drawing.Color.Red);
            var e = pos1.Distance(target.GetWaypoints()[1].To3D());

            pos1.Extend(target.GetWaypoints()[1].To3D(), -e);
            Render.Circle.DrawCircle(dister, 10, System.Drawing.Color.GreenYellow, 2);
            Render.Circle.DrawCircle(pos1, 10, System.Drawing.Color.BlueViolet, 2);
            //
            var point = PointsAroundTheTarget(target.Position, target.BoundingRadius + 50).FirstOrDefault(t => t.IsWall());
            if (point.X != 0 && point.Y != 0 && point.Z != 0)
            {
                if (MinionCollideLine(ObjectManager.Player.Position, ExtendWallpos(target, point), spell,collisionable)) return false;

                Render.Circle.DrawCircle(ExtendWallpos(target, point), 10, System.Drawing.Color.Brown, 2);
                spell.Cast(ExtendWallpos(target, point));
                return true;
            }
            else
            {
                var range = spell.Range;
                if (target.Position.Distance(ObjectManager.Player.Position) < target.GetWaypoints()[1].Distance(ObjectManager.Player.Position))
                {
                    range -= 100;
                }

                if (!spell.IsInRange(target, range)) return false;

                /*if (target.IsFacing(ObjectManager.Player) && target.Position.Distance(ObjectManager.Player.Position) > target.GetWaypoints()[1].Distance(ObjectManager.Player.Position))
                {
                  if (MinionCollideLine(ObjectManager.Player.Position, target.Position, spell,collisionable)) return false;

                    {
                        Game.PrintChat("Casteando por inface");
                       spell.Cast(target.Position);

                        return true;
                    }

                }*/
                // code of dashes
                if (target.IsDashing())
                {
                    float timeforArrive=(target.Position.Distance(target.GetDashInfo().EndPos.To3D()))/target.GetDashInfo().Speed;
                    float grabtime =( ObjectManager.Player.Position.Distance(target.GetDashInfo().EndPos.To3D())
                                     / spell.Speed)+spell.Delay;
                    if (timeforArrive<grabtime)
                    {
                        spell.Cast(target.GetDashInfo().EndPos);
                        return true;
                    }
                }
               /* if (target.IsImmovable) // check for cc guys
                {
                    if (MinionCollideLine(ObjectManager.Player.Position, target.Position, spell,collisionable)) return false;
                    spell.Cast(target.Position);
                    return true;
                }*/

              //  if(target.IsChannelingImportantSpell())
                if (target.IsWindingUp && !target.IsMelee())
                {
                    if (MinionCollideLine(ObjectManager.Player.Position, target.Position, spell,collisionable)) return false;
                    spell.Cast(target.Position);
                    return true;
                }

                if (target.Position.Distance(ObjectManager.Player.Position) <= 300)
                {
                    CastToDirection( target, spell,collisionable);
                }
                else
                {
                    var oldPos = target.GetWaypoints()[0].To3D();
                   var h = false;
                    Utility.DelayAction.Add(Game.Ping + 1000, () => h = Next(target, oldPos, spell,collisionable));
                    return h;
                }
            }
            return false;
        }
Example #5
0
        private bool IsCondemnable(Obj_AI_Hero hero)
        {
            if (!hero.IsValidTarget(550f) || hero.HasBuffOfType(BuffType.SpellShield) ||
                hero.HasBuffOfType(BuffType.SpellImmunity) || hero.IsDashing()) return false;

            //values for pred calc pP = player position; p = enemy position; pD = push distance
            var pP = ObjectManager.Player.ServerPosition;
            var p = hero.ServerPosition;
            var pD = EPushDistanceSlider.Value;
            var mode = EModeStringList.SelectedValue;

            if (mode == "PRADASMART" && (IsCollisionable(p.Extend(pP, -pD)) || IsCollisionable(p.Extend(pP, -pD / 2f)) ||
                                         IsCollisionable(p.Extend(pP, -pD / 3f))))
            {
                if (!hero.CanMove ||
                    (hero.IsWindingUp))
                    return true;

                var enemiesCount = ObjectManager.Player.CountEnemyHeroesInRange(1200);
                if (enemiesCount > 1 && enemiesCount <= 3)
                {
                    var prediction = E.GetPrediction(hero);
                    for (var i = 15; i < pD; i += 75)
                    {
                        if (i > pD)
                        {
                            var lastPosFlags = NavMesh.GetCollisionFlags(
                            prediction.UnitPosition.ToVector2()
                                .Extend(
                                    pP.ToVector2(),
                                    -pD)
                                .ToVector3());
                            if (lastPosFlags.HasFlag(CollisionFlags.Wall) || lastPosFlags.HasFlag(CollisionFlags.Building))
                            {
                                return true;
                            }
                            return false;
                        }
                        var posFlags = NavMesh.GetCollisionFlags(
                            prediction.UnitPosition.ToVector2()
                                .Extend(
                                    pP.ToVector2(),
                                    -i)
                                .ToVector3());
                        if (posFlags.HasFlag(CollisionFlags.Wall) || posFlags.HasFlag(CollisionFlags.Building))
                        {
                            return true;
                        }
                    }
                    return false;
                }
                else
                {
                    var hitchance = EHitchanceSlider.Value;
                    var angle = 0.20 * hitchance;
                    const float travelDistance = 0.5f;
                    var alpha = new Vector2((float)(p.X + travelDistance * Math.Cos(Math.PI / 180 * angle)),
                        (float)(p.X + travelDistance * Math.Sin(Math.PI / 180 * angle)));
                    var beta = new Vector2((float)(p.X - travelDistance * Math.Cos(Math.PI / 180 * angle)),
                        (float)(p.X - travelDistance * Math.Sin(Math.PI / 180 * angle)));

                    for (var i = 15; i < pD; i += 100)
                    {
                        if (i > pD) return false;
                        if (IsCollisionable(pP.ToVector2().Extend(alpha,
                            i)
                            .ToVector3()) && IsCollisionable(pP.ToVector2().Extend(beta, i).ToVector3())) return true;
                    }
                    return false;
                }
            }

            if (mode == "PRADAPERFECT" &&
                (IsCollisionable(p.Extend(pP, -pD)) || IsCollisionable(p.Extend(pP, -pD / 2f)) ||
                 IsCollisionable(p.Extend(pP, -pD / 3f))))
            {
                if (!hero.CanMove ||
                    (hero.IsWindingUp))
                    return true;

                var hitchance = EHitchanceSlider.Value;
                var angle = 0.20 * hitchance;
                const float travelDistance = 0.5f;
                var alpha = new Vector2((float)(p.X + travelDistance * Math.Cos(Math.PI / 180 * angle)),
                    (float)(p.X + travelDistance * Math.Sin(Math.PI / 180 * angle)));
                var beta = new Vector2((float)(p.X - travelDistance * Math.Cos(Math.PI / 180 * angle)),
                    (float)(p.X - travelDistance * Math.Sin(Math.PI / 180 * angle)));

                for (var i = 15; i < pD; i += 100)
                {
                    if (i > pD)
                    {
                        return IsCollisionable(alpha.Extend(pP.ToVector2(),
                            -pD)
                            .ToVector3()) && IsCollisionable(beta.Extend(pP.ToVector2(), -pD).ToVector3());
                    }
                    if (IsCollisionable(alpha.Extend(pP.ToVector2(),
                        -i)
                        .ToVector3()) && IsCollisionable(beta.Extend(pP.ToVector2(), -i).ToVector3())) return true;
                }
                return false;
            }

            if (mode == "OLDPRADA")
            {
                if (!hero.CanMove ||
                    (hero.IsWindingUp))
                    return true;

                var hitchance = EHitchanceSlider.Value;
                var angle = 0.20 * hitchance;
                const float travelDistance = 0.5f;
                var alpha = new Vector2((float)(p.X + travelDistance * Math.Cos(Math.PI / 180 * angle)),
                    (float)(p.X + travelDistance * Math.Sin(Math.PI / 180 * angle)));
                var beta = new Vector2((float)(p.X - travelDistance * Math.Cos(Math.PI / 180 * angle)),
                    (float)(p.X - travelDistance * Math.Sin(Math.PI / 180 * angle)));

                for (var i = 15; i < pD; i += 100)
                {
                    if (IsCollisionable(pP.ToVector2().Extend(alpha,
                        i)
                        .ToVector3()) || IsCollisionable(pP.ToVector2().Extend(beta, i).ToVector3())) return true;
                }
                return false;
            }

            if (mode == "MARKSMAN")
            {
                var prediction = E.GetPrediction(hero);
                return NavMesh.GetCollisionFlags(
                    prediction.UnitPosition.ToVector2()
                        .Extend(
                            pP.ToVector2(),
                            -pD)
                        .ToVector3()).HasFlag(CollisionFlags.Wall) ||
                       NavMesh.GetCollisionFlags(
                           prediction.UnitPosition.ToVector2()
                               .Extend(
                                   pP.ToVector2(),
                                   -pD / 2f)
                               .ToVector3()).HasFlag(CollisionFlags.Wall);
            }

            if (mode == "SHARPSHOOTER")
            {
                var prediction = E.GetPrediction(hero);
                for (var i = 15; i < pD; i += 100)
                {
                    if (i > pD) return false;
                    var posCF = NavMesh.GetCollisionFlags(
                        prediction.UnitPosition.ToVector2()
                            .Extend(
                                pP.ToVector2(),
                                -i)
                            .ToVector3());
                    if (posCF.HasFlag(CollisionFlags.Wall) || posCF.HasFlag(CollisionFlags.Building))
                    {
                        return true;
                    }
                }
                return false;
            }

            if (mode == "GOSU")
            {
                var prediction = E.GetPrediction(hero);
                for (var i = 15; i < pD; i += 75)
                {
                    var posCF = NavMesh.GetCollisionFlags(
                        prediction.UnitPosition.ToVector2()
                            .Extend(
                                pP.ToVector2(),
                                -i)
                            .ToVector3());
                    if (posCF.HasFlag(CollisionFlags.Wall) || posCF.HasFlag(CollisionFlags.Building))
                    {
                        return true;
                    }
                }
                return false;
            }

            if (mode == "VHR")
            {
                var prediction = E.GetPrediction(hero);
                for (var i = 15; i < pD; i += (int)hero.BoundingRadius) //:frosty:
                {
                    var posCF = NavMesh.GetCollisionFlags(
                        prediction.UnitPosition.ToVector2()
                            .Extend(
                                pP.ToVector2(),
                                -i)
                            .ToVector3());
                    if (posCF.HasFlag(CollisionFlags.Wall) || posCF.HasFlag(CollisionFlags.Building))
                    {
                        return true;
                    }
                }
                return false;
            }

            if (mode == "PRADALEGACY")
            {
                var prediction = E.GetPrediction(hero);
                for (var i = 15; i < pD; i += 75)
                {
                    var posCF = NavMesh.GetCollisionFlags(
                        prediction.UnitPosition.ToVector2()
                            .Extend(
                                pP.ToVector2(),
                                -i)
                            .ToVector3());
                    if (posCF.HasFlag(CollisionFlags.Wall) || posCF.HasFlag(CollisionFlags.Building))
                    {
                        return true;
                    }
                }
                return false;
            }

            if (mode == "FASTEST" &&
                (IsCollisionable(p.Extend(pP, -pD)) || IsCollisionable(p.Extend(pP, -pD / 2f)) ||
                 IsCollisionable(p.Extend(pP, -pD / 3f))))
            {
                return true;
            }

            return false;
        }
Example #6
0
        bool IsCondemnable(Obj_AI_Hero hero)
        {
            if (!hero.IsValidTarget(550f) || hero.HasBuffOfType(BuffType.SpellShield) ||
                hero.HasBuffOfType(BuffType.SpellImmunity) || hero.IsDashing()) return false;
            var pP = Heroes.Player.ServerPosition;
            var pD = 425;

            var prediction = E.GetPrediction(hero);
            for (var i = 15; i < pD; i += 100)
            {
                var posCF = NavMesh.GetCollisionFlags(
                    prediction.UnitPosition.To2D()
                        .Extend(
                            pP.To2D(),
                            -i)
                        .To3D());
                if (posCF.HasFlag(CollisionFlags.Wall) || posCF.HasFlag(CollisionFlags.Building))
                {
                    return true;
                }
            }
            return false;
        }
Example #7
0
        /// <summary>
        /// Gets Predicted position while target is dashing
        /// </summary>
        private static Vector2 GetDashingPrediction(Obj_AI_Hero target, Spell s, out HitChance hc, Vector3 rangeCheckFrom)
        {
            if (target.IsDashing())
            {
                var dashInfo = target.GetDashInfo();

                float dashPassedDistance = (Utils.TickCount - dashInfo.StartTick) / 1000f * dashInfo.Speed;
                Vector2 currentDashPos = dashInfo.StartPos + (dashInfo.EndPos - dashInfo.StartPos).Normalized() * dashPassedDistance;

                float targetDistance = rangeCheckFrom.To2D().Distance(currentDashPos);
                float flyTime = 0f;

                if (s.Speed != 0) //skillshot with a missile
                {
                    Vector2 Vt = (dashInfo.Path[dashInfo.Path.Count - 1] - dashInfo.Path[0]).Normalized() * dashInfo.Speed;
                    Vector2 Vs = (target.ServerPosition.To2D() - rangeCheckFrom.To2D()).Normalized() * s.Speed;
                    Vector2 Vr = Vs - Vt;

                    flyTime = targetDistance / Vr.Length();
                }
                int dashLeftTime = dashInfo.EndTick - Utils.TickCount;
                float t = flyTime + s.Delay + Game.Ping / 1000f;

                if (dashLeftTime >= t * 1000f)
                {
                    float distance = t * dashInfo.Speed;
                    hc = HitChance.Dashing;

                    for (int i = 0; i < dashInfo.Path.Count - 1; i++)
                    {
                        float d = dashInfo.Path[i + 1].Distance(dashInfo.Path[i]);
                        if (distance == d)
                            return dashInfo.Path[i + 1];
                        else if (distance < d)
                            return dashInfo.Path[i] + distance * (dashInfo.Path[i + 1] - dashInfo.Path[i]).Normalized();
                        else distance -= d;
                    }
                }
            }

            hc = HitChance.Impossible;
            return rangeCheckFrom.To2D();
        }
Example #8
0
        /// <summary>
        /// Gets Predicted position
        /// </summary>
        /// <param name="target">Target for spell</param>
        /// <param name="s">Spell to cast</param>
        /// <param name="path">Waypoint of target</param>
        /// <param name="avgt">Average reaction time (in ms)</param>
        /// <param name="movt">Passed time from last movement change (in ms)</param>
        /// <param name="hc">Predicted HitChance</param>
        /// <param name="rangeCheckFrom">Position where spell will be casted from</param>
        /// <returns>Predicted position and HitChance out value</returns>
        public static Vector2 GetPrediction(Obj_AI_Hero target, Spell s, List<Vector2> path, float avgt, float movt, out HitChance hc, Vector3 rangeCheckFrom)
        {
            if (!blInitialized)
                throw new InvalidOperationException("Prediction is not initalized");

            if (target.MovImmobileTime() > 200 || target.AvgMovChangeTime() == 0 || Utility.IsImmobileTarget(target)) //if target is not moving, easy to hit
            {
                hc = HitChance.Immobile;
                return target.ServerPosition.To2D() + target.Direction.To2D().Perpendicular() * s.Width / 2;
            }

            if (target.IsDashing())
                return GetDashingPrediction(target, s, out hc, rangeCheckFrom);

            float targetDistance = rangeCheckFrom.Distance(target.ServerPosition);
            float flyTime = 0f;

            if (s.Speed != 0) //skillshot with a missile
            {
                Vector2 Vt = (path[path.Count - 1] - path[0]).Normalized() * target.MoveSpeed;
                Vector2 Vs = (target.ServerPosition.To2D() - rangeCheckFrom.To2D()).Normalized() * s.Speed;
                Vector2 Vr = Vs - Vt;

                flyTime = targetDistance / Vr.Length();

                if (path.Count > 5) //complicated movement
                    flyTime = targetDistance / s.Speed;
            }

            float t = flyTime + s.Delay + Game.Ping / 1000f;
            float distance = t * target.MoveSpeed;

            //can be improved by checking area of circle
            if (s.Type == SkillshotType.SkillshotCircle) //haven't tested yet.
                distance -= s.Width / 2;

            hc = GetHitChance(t * 1000f, avgt, movt);

            for (int i = 0; i < path.Count - 1; i++)
            {
                float d = path[i + 1].Distance(path[i]);
                if (distance == d)
                    return path[i + 1];
                else if (distance < d)
                    return path[i] + distance * (path[i + 1] - path[i]).Normalized();
                else distance -= d;
            }

            hc = HitChance.Impossible;
            return path[path.Count - 1];
        }
Example #9
0
        /// <summary>
        /// Gets Predicted position for arc
        /// </summary>
        /// <param name="target">Target for spell</param>
        /// <param name="s">Spell to cast</param>
        /// <param name="avgt">Average reaction time (in ms)</param>
        /// <param name="movt">Passed time from last movement change (in ms)</param>
        /// <param name="hc">Predicted HitChance</param>
        /// <param name="rangeCheckFrom">Position where spell will be casted from</param>
        /// <returns>Predicted position and HitChance out value</returns>
        public static Vector2 GetArcPrediction(Obj_AI_Hero target, Spell s, List<Vector2> path, float avgt, float movt, out HitChance hc, Vector3 rangeCheckFrom)
        {
            if (!blInitialized)
                throw new InvalidOperationException("Prediction is not initalized");

            if (target.MovImmobileTime() > 200 || target.AvgMovChangeTime() == 0 || Utility.IsImmobileTarget(target)) //if target is not moving, easy to hit
            {
                hc = HitChance.Immobile;
                return target.ServerPosition.To2D();
            }

            if (target.IsDashing())
                return GetDashingPrediction(target, s, out hc, rangeCheckFrom);

            float targetDistance = rangeCheckFrom.Distance(target.ServerPosition);
            float flyTime = 0f;

            if (s.Speed != 0)
            {
                Vector2 Vt = (path[path.Count - 1] - path[0]).Normalized() * target.MoveSpeed;
                Vector2 Vs = (target.ServerPosition.To2D() - rangeCheckFrom.To2D()).Normalized() * s.Speed;
                Vector2 Vr = Vs - Vt;

                flyTime = targetDistance / Vr.Length();

                if (path.Count > 5)
                    flyTime = targetDistance / s.Speed;
            }

            float t = flyTime + s.Delay + Game.Ping / 1000f;
            float distance = t * target.MoveSpeed;

            hc = GetHitChance(t * 1000f, avgt, movt);

            #region arc collision test
            for (int i = 1; i < path.Count; i++)
            {
                Vector2 senderPos = ObjectManager.Player.ServerPosition.To2D();
                Vector2 testPos = path[i];

                float multp = (testPos.Distance(senderPos) / 875.0f);

                var dianaArc = new ShineCommon.Maths.Geometry.Polygon(
                                ClipperWrapper.DefineArc(senderPos - new Vector2(875 / 2f, 20), testPos, (float)Math.PI * multp, 410, 200 * multp),
                                ClipperWrapper.DefineArc(senderPos - new Vector2(875 / 2f, 20), testPos, (float)Math.PI * multp, 410, 320 * multp));

                if (!ClipperWrapper.IsOutside(dianaArc, target.ServerPosition.To2D()))
                {
                    hc = HitChance.VeryHigh;
                    return testPos;
                }
            }
            #endregion

            for (int i = 0; i < path.Count - 1; i++)
            {
                float d = path[i + 1].Distance(path[i]);
                if (distance == d)
                    return path[i + 1];
                else if (distance < d)
                    return path[i] + distance * (path[i + 1] - path[i]).Normalized();
                else distance -= d;
            }

            hc = HitChance.Impossible;
            return path[path.Count - 1];
        }