コード例 #1
0
 public static bool AnalyzeQ(PredictionInput input, PredictionOutput output)
 {
     var posList = new List<Vector3> { ObjectManager.Player.ServerPosition, output.CastPosition };
     var collision = Collision.GetCollision(posList, input);
     var minions = collision.Count(collisionObj => collisionObj.IsMinion);
     return minions > 1;
 }
コード例 #2
0
ファイル: MovementPrediction.cs プロジェクト: werdbrian/AIO
        /// <summary>
        ///     The get updated prediction.
        /// </summary>
        /// <param name="input">
        ///     The input.
        /// </param>
        /// <returns>
        ///     The <see cref="PredictionOutput" />.
        /// </returns>
        internal static PredictionOutput GetUpdatedPrediction(PredictionInput input)
        {
            if (Math.Abs(input.Speed - float.MaxValue) < float.Epsilon)
            {
                input.Speed = 90000;
            }

            var toTarget = Vector3.Normalize(input.Unit.ServerPosition - input.From);
            var targetVelocity = CalculateVelocity(
                input.Unit.ServerPosition,
                input.Unit.Path.LastOrDefault(),
                input.Unit.MoveSpeed);

            var a = Vector3.Dot(targetVelocity, targetVelocity) - (input.Speed * input.Speed);
            var b = 2 * Vector3.Dot(targetVelocity, toTarget);
            var c = Vector3.Dot(toTarget, toTarget);

            var p = -b / (2 * a);
            var q = (float)Math.Sqrt((b * b) - 4 * a * c) / (2 * a);

            var theorem1 = p - q;
            var theorem2 = p + q;
            var t = (theorem1 > theorem2 && theorem2 > 0) ? theorem2 : theorem1;

            var result = new PredictionOutput()
                             {
                                 CastPosition = input.Unit.ServerPosition + targetVelocity * (t + input.Delay),
                                 UnitPosition = input.Unit.ServerPosition, Hitchance = HitChance.VeryHigh
                             };

            // Check if the unit position is in range
            if (Math.Abs(input.Range - float.MaxValue) > float.Epsilon)
            {
                if (result.Hitchance >= HitChance.High
                    && input.RangeCheckFrom.Distance(input.Unit.Position, true)
                    > Math.Pow(input.Range + input.Radius * 3 / 4, 2))
                {
                    result.Hitchance = HitChance.Medium;
                }

                if (input.RangeCheckFrom.Distance(result.UnitPosition, true)
                    > Math.Pow(input.Range + (input.Type == SkillshotType.SkillshotCircle ? input.Radius : 0), 2))
                {
                    result.Hitchance = HitChance.OutOfRange;
                }
            }

            // Check for collision
            if (input.Collision)
            {
                var positions = new List<Vector3> { result.UnitPosition, result.CastPosition, input.Unit.Position };
                var originalUnit = input.Unit;
                result.CollisionObjects = Collision.GetCollision(positions, input);
                result.CollisionObjects.RemoveAll(x => x.NetworkId == originalUnit.NetworkId);
                result.Hitchance = result.CollisionObjects.Count > 0 ? HitChance.Collision : result.Hitchance;
            }

            return result;
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: q51251/L-
 public static Vector3 FindHitPosition(PredictionOutput minion)
 {
     Console.WriteLine("Searching hit position");
     int multihit = 0;
     for (int i = -100; i < 100; i = i + 10)
     {
         for (int a = -100; a < 100; a = a + 10)
         {
             Vector3 tempposition = new Vector3(minion.UnitPosition.X + i, minion.UnitPosition.Y + a, minion.UnitPosition.Z);
             multihit = CheckMultiHit(tempposition);
             if (multihit == 1)
             {
                 return tempposition;
             }
         }
     }
         return new Vector3(0,0,0);
 }
コード例 #4
0
			internal static PredictionOutput GetDashingPrediction(PredictionInput input) {
				var dashData = input.Unit.GetDashInfo();
				var result = new PredictionOutput { Input = input };
				//Normal dashes.
				if (!dashData.IsBlink)
				{
					//Mid air:
					var endP = dashData.Path.Last();
					var dashPred = GetPositionOnPath(
						input, new List<Vector2> { input.Unit.ServerPosition.To2D(), endP }, dashData.Speed);
					if (dashPred.Hitchance >= HitChance.High && dashPred.UnitPosition.To2D().Distance(input.Unit.Position.To2D(), endP, true) < 200)
					{
						dashPred.CastPosition = dashPred.UnitPosition;
						dashPred.Hitchance = HitChance.Dashing;
						return dashPred;
					}

					//At the end of the dash:
					if (dashData.Path.PathLength() > 200)
					{
						var timeToPoint = input.Delay / 2f + input.From.To2D().Distance(endP) / input.Speed - 0.25f;
						if (timeToPoint <=
							input.Unit.Distance(endP) / dashData.Speed + input.RealRadius / input.Unit.MoveSpeed)
						{
							return new PredictionOutput
							{
								CastPosition = endP.To3D(),
								UnitPosition = endP.To3D(),
								Hitchance = HitChance.Dashing
							};
						}
					}
					result.CastPosition = dashData.Path.Last().To3D();
					result.UnitPosition = result.CastPosition;

					//Figure out where the unit is going.
				}

				return result;
			}
コード例 #5
0
			internal static PredictionOutput WayPointAnalysis(PredictionOutput result, PredictionInput input) {

				if (!input.Unit.IsValid<Obj_AI_Hero>() || input.Radius == 1)
				{
					result.Hitchance = HitChance.VeryHigh;
					return result;
				}

				//Program.debug("PRED: FOR CHAMPION " + input.Unit.BaseSkinName);

				// CAN'T MOVE SPELLS ///////////////////////////////////////////////////////////////////////////////////

				if (UnitTracker.GetSpecialSpellEndTime(input.Unit) > 0 || input.Unit.HasBuff("Recall"))
				{

					result.Hitchance = HitChance.VeryHigh;
					return result;

				}

				// PREPARE MATH ///////////////////////////////////////////////////////////////////////////////////

				result.Hitchance = HitChance.Medium;

				var lastWaypiont = input.Unit.GetWaypoints().Last().To3D();
				var distanceUnitToWaypoint = lastWaypiont.Distance(input.Unit.ServerPosition);
				var distanceFromToUnit = input.From.Distance(input.Unit.ServerPosition);
				var distanceFromToWaypoint = lastWaypiont.Distance(input.From);

				float speedDelay = distanceFromToUnit / input.Speed;

				if (Math.Abs(input.Speed - float.MaxValue) < float.Epsilon)
					speedDelay = 0;
				else
					speedDelay = distanceFromToUnit / input.Speed;

				float totalDelay = speedDelay + input.Delay;
				float moveArea = input.Unit.MoveSpeed * totalDelay;
				float fixRange = moveArea * 0.5f;
				double angleMove = 30 + (input.Radius / 13) - (totalDelay * 2);
				float backToFront = moveArea * 1.5f;
				float pathMinLen = 1000f;

				if (UnitTracker.GetLastNewPathTime(input.Unit) < 0.1d)
				{
					pathMinLen = 700f + backToFront;
					result.Hitchance = HitChance.High;
				}

				if (input.Type == SkillshotType.SkillshotCircle)
				{
					fixRange -= input.Radius / 2;
				}

				// SPAM CLICK ///////////////////////////////////////////////////////////////////////////////////

				if (UnitTracker.PathCalc(input.Unit))
				{
					if (distanceFromToUnit < input.Range - fixRange)
					{
						result.Hitchance = HitChance.VeryHigh;
						return result;
					}

					result.Hitchance = HitChance.High;
					return result;
				}

				// NEW VISABLE ///////////////////////////////////////////////////////////////////////////////////

				if (UnitTracker.GetLastVisableTime(input.Unit) < 0.08d)
				{
					result.Hitchance = HitChance.Medium;
					return result;
				}

				// SPECIAL CASES ///////////////////////////////////////////////////////////////////////////////////

				if (distanceFromToUnit < 300 || distanceFromToWaypoint < 200)
				{
					result.Hitchance = HitChance.VeryHigh;
					return result;

				}

				// LONG CLICK DETECTION ///////////////////////////////////////////////////////////////////////////////////

				if (distanceUnitToWaypoint > pathMinLen)
				{
					result.Hitchance = HitChance.VeryHigh;
					return result;
				}

				// RUN IN LANE DETECTION ///////////////////////////////////////////////////////////////////////////////////

				if (distanceFromToWaypoint > distanceFromToUnit + fixRange && GetAngle(input.From, input.Unit) < angleMove)
				{
					result.Hitchance = HitChance.VeryHigh;
					return result;
				}

				// FIX RANGE ///////////////////////////////////////////////////////////////////////////////////

				if (distanceFromToWaypoint <= input.Unit.Distance(input.From) && distanceFromToUnit > input.Range - fixRange)
				{
					//debug("PRED: FIX RANGE");
					result.Hitchance = HitChance.Medium;
					return result;
				}

				// AUTO ATTACK LOGIC ///////////////////////////////////////////////////////////////////////////////////

				if (UnitTracker.GetLastAutoAttackTime(input.Unit) < 0.1d)
				{
					if (input.Type == SkillshotType.SkillshotLine && totalDelay < 0.6 + (input.Radius * 0.001))
						result.Hitchance = HitChance.VeryHigh;
					else if (input.Type == SkillshotType.SkillshotCircle && totalDelay < 0.7 + (input.Radius * 0.001))
						result.Hitchance = HitChance.VeryHigh;
					else
						result.Hitchance = HitChance.High;

					return result;
				}

				// STOP LOGIC ///////////////////////////////////////////////////////////////////////////////////

				else
				{
					if (input.Unit.IsWindingUp)
					{
						result.Hitchance = HitChance.High;
						return result;
					}
					else if (input.Unit.Path.Count() == 0 && !input.Unit.IsMoving)
					{
						if (distanceFromToUnit > input.Range - fixRange)
							result.Hitchance = HitChance.Medium;
						else if (UnitTracker.GetLastStopMoveTime(input.Unit) < 0.8d)
							result.Hitchance = HitChance.High;
						else
							result.Hitchance = HitChance.VeryHigh;
						return result;
					}
				}

				// ANGLE HIT CHANCE ///////////////////////////////////////////////////////////////////////////////////

				if (input.Type == SkillshotType.SkillshotLine && input.Unit.Path.Count() > 0 && input.Unit.IsMoving)
				{
					if (GetAngle(input.From, input.Unit) < angleMove)
					{
						result.Hitchance = HitChance.VeryHigh;
						return result;

					}
				}

				// CIRCLE NEW PATH ///////////////////////////////////////////////////////////////////////////////////

				if (input.Type == SkillshotType.SkillshotCircle)
				{
					if (UnitTracker.GetLastNewPathTime(input.Unit) < 0.1d && distanceFromToUnit < input.Range - fixRange && distanceUnitToWaypoint > fixRange)
					{
						result.Hitchance = HitChance.VeryHigh;
						return result;
					}
				}
				//Program.debug("PRED: NO DETECTION");

				return result;
			}
コード例 #6
0
ファイル: Program.cs プロジェクト: guskate/LeagueSharp
 private static void Combo()
 {
     Cast_E("combo");
     var combotarget = TargetSelector.GetTarget(R.Range, TargetSelector.DamageType.Magical);
     var qtarget = TargetSelector.GetTarget(Q.Range, TargetSelector.DamageType.Magical);
     var wtarget = TargetSelector.GetTarget(W.Range, TargetSelector.DamageType.Magical);
     if (combotarget == null) Game.PrintChat("combo target null! tell sosharp");
     var combodmg = ComboDmg(combotarget);
     if (combodmg >= combotarget.Health)
     {
         Cast_R();
         Cast_Q("combo", combotarget);
         Cast_W(combotarget);
         DFG.Cast(combotarget);
         Player.Spellbook.CastSpell(Ignite);
     }
     else
     {
         Cast_Q("combo", qtarget);
         Cast_W(wtarget);
     }
     if (menu.Item("Rifcantkill").GetValue<bool>())
     {
         R.Cast(combotarget, UsePackets());
     }
     if (menu.Item("FlashTibbersanytime").GetValue<bool>())
     {
         FlashTibbers_pi.Aoe = true; FlashTibbers_pi.Collision = false; FlashTibbers_pi.Delay = 250; FlashTibbers_pi.Range = 1000; FlashTibbers_pi.Speed = float.MaxValue; FlashTibbers_pi.Type = SkillshotType.SkillshotCircle; FlashTibbers_pi.Radius = 100;
         FlashTibbers_po = Prediction.GetPrediction(FlashTibbers_pi);
         var flashtibbers_hitcount = FlashTibbers_po.AoeTargetsHitCount;
         var flashtibbers_hitchance = FlashTibbers_po.Hitchance;
         var flashtibbers_targetpos = FlashTibbers_po.UnitPosition;
         if (GetPassiveStacks() == 4 && Player.Spellbook.CanUseSpell(Flash) == SpellState.Ready && flashtibbers_hitcount > menu.Item("FlashTibbersanytimemin").GetValue<int>() && flashtibbers_hitchance >= HitChance.Medium && Player.Distance(FlashTibbers_po.UnitPosition) > R.Range)
         {
             Player.Spellbook.CastSpell(Flash, flashtibbers_targetpos);
             R.Cast(flashtibbers_targetpos, UsePackets());
         }
     }
 }
コード例 #7
0
ファイル: Program.cs プロジェクト: guskate/LeagueSharp
 private static void Cast_R()
 {
     if (menu.Item("FlashTibbers").GetValue<bool>())
     {
         FlashTibbers_pi.Aoe = true; FlashTibbers_pi.Collision = false; FlashTibbers_pi.Delay = 250; FlashTibbers_pi.Range = 1000; FlashTibbers_pi.Speed = float.MaxValue; FlashTibbers_pi.Type = SkillshotType.SkillshotCircle; FlashTibbers_pi.Radius = 100;
         FlashTibbers_po = Prediction.GetPrediction(FlashTibbers_pi);
         var flashtibbers_hitcount = FlashTibbers_po.AoeTargetsHitCount;
         var flashtibbers_hitchance = FlashTibbers_po.Hitchance;
         PredictedTibbers = FlashTibbers_po.UnitPosition;
         if (GetPassiveStacks() == 4 && flashtibbers_hitcount > menu.Item("FlashTibbersmin").GetValue<int>() && flashtibbers_hitchance >= HitChance.Medium && Player.Distance(FlashTibbers_po.UnitPosition) > R.Range)
         {
             Player.Spellbook.CastSpell(Flash, PredictedTibbers);
             R.Cast(PredictedTibbers, UsePackets());
         }
         else if (Player.Distance(FlashTibbers_po.UnitPosition) < R.Range)
         {
             R.Cast(FlashTibbers_po.UnitPosition, UsePackets());
         }
     }
     var target = TargetSelector.GetTarget(R.Range, TargetSelector.DamageType.Magical);
     var minTargets = menu.Item("flashtibbersmin").GetValue<int>();
     if (menu.Item("RcomboOnlyOn4Stacks").GetValue<bool>())
     {
         if (GetPassiveStacks() == 4)
         {
             R.Cast(target, UsePackets());
         }
         else if (GetPassiveStacks() == 3)
         {
             E.Cast();
             if (GetPassiveStacks() == 4)
             {
                 R.Cast(target, UsePackets());
             }
         }
     }
     else
     {
         R.Cast(target, UsePackets());
     }
 }
コード例 #8
0
ファイル: Rumble.cs プロジェクト: yashine59fr/PortAIO-1
 private Vector3 getBestRVector3(Obj_AI_Base target, PredictionOutput targE)
 {
     var otherHeroes =
         HeroManager.Enemies.Where(
             e => e.LSIsValidTarget() && e.NetworkId != target.NetworkId && player.LSDistance(e) < 1000)
             .Select(e => R.GetPrediction(e))
             .Where(o => o.Hitchance > HitChance.High && o.CastPosition.LSDistance(targE.UnitPosition) < 1000);
     if (otherHeroes.Any())
     {
         var best =
             otherHeroes.OrderByDescending(
                 hero =>
                     CombatHelper.GetCollisionCount(
                         target, target.Position.LSExtend(hero.CastPosition, 1000), R.Width,
                         new[] { CollisionableObjects.Heroes })).FirstOrDefault();
         if (best != null)
         {
             return best.CastPosition;
         }
     }
     return Vector3.Zero;
 }
コード例 #9
0
ファイル: Prediction.cs プロジェクト: s5224303/L-Assemblies
        internal static PredictionOutput GetPrediction(PredictionInput input, bool ft, bool checkCollision)
        {
            PredictionOutput result = null;

            if (!input.Unit.IsValidTarget(float.MaxValue, false))
            {
                return(new PredictionOutput());
            }

            if (ft)
            {
                //Increase the delay due to the latency and server tick:
                input.Delay += Game.Ping / 2000f + 0.07f;

                if (input.Aoe)
                {
                    return(AoePrediction.GetPrediction(input));
                }
            }

            //Target too far away.
            if (Math.Abs(input.Range - float.MaxValue) > float.Epsilon &&
                input.Unit.Distance(input.RangeCheckFrom, true) > Math.Pow(input.Range * 1.5, 2))
            {
                return(new PredictionOutput {
                    Input = input
                });
            }

            //Unit is dashing.
            if (input.Unit.IsDashing())
            {
                result = GetDashingPrediction(input);
            }
            else
            {
                //Unit is immobile.
                var remainingImmobileT = UnitIsImmobileUntil(input.Unit);
                if (remainingImmobileT >= 0d)
                {
                    result = GetImmobilePrediction(input, remainingImmobileT);
                }
            }

            //Normal prediction
            if (result == null)
            {
                result = GetStandardPrediction(input);
            }

            //Check if the unit position is in range
            if (Math.Abs(input.Range - float.MaxValue) > float.Epsilon)
            {
                if (result.Hitchance >= HitChance.High &&
                    input.RangeCheckFrom.Distance(input.Unit.Position, true) >
                    Math.Pow(input.Range + input.RealRadius * 3 / 4, 2))
                {
                    result.Hitchance = HitChance.Medium;
                }

                if (input.RangeCheckFrom.Distance(result.UnitPosition, true) >
                    Math.Pow(input.Range + (input.Type == SkillshotType.SkillshotCircle ? input.RealRadius : 0), 2))
                {
                    result.Hitchance = HitChance.OutOfRange;
                }

                /* This does not need to be handled for the updated predictions, but left as a reference.*/

                if (input.RangeCheckFrom.Distance(result.CastPosition, true) > Math.Pow(input.Range, 2))
                {
                    if (result.Hitchance != HitChance.OutOfRange)
                    {
                        result.CastPosition = input.RangeCheckFrom +
                                              input.Range *
                                              (result.UnitPosition - input.RangeCheckFrom).To2D().Normalized().To3D();
                    }
                    else
                    {
                        result.Hitchance = HitChance.OutOfRange;
                    }
                }
            }

            //Check for collision
            if (checkCollision && input.Collision)
            {
                var positions = new List <Vector3> {
                    result.UnitPosition, result.CastPosition, input.Unit.Position
                };
                var originalUnit = input.Unit;
                result.CollisionObjects = Collision.GetCollision(positions, input);
                result.CollisionObjects.RemoveAll(x => x.NetworkId == originalUnit.NetworkId);
                result.Hitchance = result.CollisionObjects.Count > 0 ? HitChance.Collision : result.Hitchance;
            }

            return(result);
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: paodapadaria/LeagueRepo
        public static void CastSpell(Spell QWER, Obj_AI_Base target)
        {
            if (target.Path.Count() > 1)
                return;
            var poutput = QWER.GetPrediction(target);
            if (Game.Time - DrawSpellTime > 0.5)
            {
                DrawSpell = QWER;
                DrawSpellTime = Game.Time;

            }

            DrawSpellPos = poutput;
            if (ColFix  && HitChanceNum == 4)
            {
                if (QWER.Collision && OktwCommon.GetCollision(target, QWER, false, true))
                    return;
            }
            else
            {
                var col = poutput.CollisionObjects.Count(ColObj => ColObj.IsEnemy && ColObj.IsMinion && !ColObj.IsDead);
                if (col > 0)
                {
                    return;
                }
            }

            if ((int)poutput.Hitchance > 4 && target.HasBuffOfType(BuffType.Slow))
            {
                QWER.Cast(poutput.CastPosition);
                return;
            }

            if (target.HasBuff("Recall") || poutput.Hitchance == HitChance.Immobile )
            {
                QWER.Cast(poutput.CastPosition);
                return;
            }

            if (poutput.Hitchance == HitChance.Dashing && QWER.Delay < 0.30f)
            {
                QWER.Cast(poutput.CastPosition);
                return;
            }

            if (HitChanceNum == 4)
            {
                if ((int)poutput.Hitchance < 5)
                    return;

                if (NewWay && (int)poutput.Hitchance < 6)
                    return;

                float fixRange;

                if (RangeFix)
                    fixRange = (target.MoveSpeed * (Player.ServerPosition.Distance(target.ServerPosition) / QWER.Speed + QWER.Delay)) / 2;
                else
                    fixRange = 0;

                if (target.IsWindingUp)
                {

                    if (!tryAA)
                        return;
                    debug("IsWinding: ");
                    if (Player.Distance(target.ServerPosition) < QWER.Range - fixRange)
                    {
                        if (FastMode)
                            QWER.Cast(poutput.CastPosition);
                        else
                            QWER.Cast(target);
                    }

                    return;
                }
                else if (target.Path.Count() == 0 && target.Position == target.ServerPosition )
                {

                    if (IgnoreNoMove)
                        return;
                    debug("NotMove");
                    if (Player.Distance(target.ServerPosition) < QWER.Range - fixRange)
                    {
                        if (FastMode)
                            QWER.Cast(poutput.CastPosition);
                        else
                            QWER.Cast(target);
                    }

                    return;
                }

                var LastWaypiont = target.GetWaypoints().Last().To3D();

                if (target.ServerPosition.Distance(Player.ServerPosition) < LastWaypiont.Distance(Player.ServerPosition) - fixRange)
                {
                    if (FastMode)
                        QWER.Cast(poutput.CastPosition);
                    else
                        QWER.Cast(target);

                    debug("Run" );
                }
                else if (Player.Distance(target.ServerPosition) < QWER.Range - fixRange)
                {
                    float BackToFront = ((target.MoveSpeed * QWER.Delay) + (Player.Distance(target.ServerPosition) / QWER.Speed));
                    float SiteToSite = (BackToFront * 2) - QWER.Width;

                    if ((target.ServerPosition.Distance(LastWaypiont) > SiteToSite
                        || Math.Abs(Player.Distance(LastWaypiont) - Player.Distance(target.ServerPosition)) > BackToFront)
                        || Player.Distance(target.ServerPosition) < SiteToSite + target.BoundingRadius * 2
                        || Player.Distance(LastWaypiont) < BackToFront)
                    {
                        if (FastMode)
                            QWER.Cast(poutput.CastPosition);
                        else
                            QWER.Cast(target);

                        debug("good 2");
                    }
                    else
                        debug("ignore 2");
                }
                else
                    debug("fixed " + fixRange);
            }
            else if (HitChanceNum == 3)
            {
                if ((int)poutput.Hitchance < 5)
                    return;

                var fixRange = (target.MoveSpeed * (Player.ServerPosition.Distance(target.ServerPosition) / QWER.Speed + QWER.Delay)) / 2;
                if (QWER.Delay < 0.3 && (QWER.Speed > 1500 || QWER.Type == SkillshotType.SkillshotCircle) && (target.IsWindingUp || (int)poutput.Hitchance == 6))
                {
                    if (Player.Distance(target.ServerPosition) < QWER.Range - fixRange)
                    {
                        QWER.CastIfHitchanceEquals(target, HitChance.High, true);
                    }
                    return;
                }

                if (target.Path.Count() == 0 && target.Position == target.ServerPosition && !target.IsWindingUp)
                {
                    if (Player.Distance(target.ServerPosition) < QWER.Range - fixRange)
                    {

                        QWER.CastIfHitchanceEquals(target, HitChance.High, true);
                    }
                    return;
                }
                var waypoints = target.GetWaypoints().Last<Vector2>().To3D();

                float BackToFront = ((target.MoveSpeed * QWER.Delay) + (Player.Distance(target.ServerPosition) / QWER.Speed));
                float SiteToSite = (BackToFront * 2) - QWER.Width;

                if ((target.ServerPosition.Distance(waypoints) > SiteToSite
                    || Math.Abs(Player.Distance(waypoints) - Player.Distance(target.Position)) > BackToFront)
                    || Player.Distance(target.Position) < SiteToSite + target.BoundingRadius * 2
                    || Player.Distance(waypoints) < BackToFront
                    )
                {

                    if (waypoints.Distance(Player.Position) <= target.Distance(Player.Position))
                    {
                        if (Player.Distance(target.ServerPosition) < QWER.Range - fixRange)
                        {
                            QWER.CastIfHitchanceEquals(target, HitChance.High, true);
                        }
                    }
                    else
                    {
                        QWER.CastIfHitchanceEquals(target, HitChance.High, true);
                    }
                }

            }
            else if (HitChanceNum == 0)
                QWER.Cast(target, true);
            else if (HitChanceNum == 1)
            {
                if ((int)poutput.Hitchance > 4)
                    QWER.Cast(poutput.CastPosition);
            }
            else if (HitChanceNum == 2)
            {
                List<Vector2> waypoints = target.GetWaypoints();
                if (waypoints.Last<Vector2>().To3D().Distance(poutput.CastPosition) > QWER.Width && (int)poutput.Hitchance > 4)
                {
                    if (waypoints.Last<Vector2>().To3D().Distance(Player.Position) <= target.Distance(Player.Position) || (target.Path.Count() == 0 && target.Position == target.ServerPosition))
                    {
                        if (Player.Distance(target.ServerPosition) < QWER.Range - (poutput.CastPosition.Distance(target.ServerPosition) + target.BoundingRadius))
                        {
                            QWER.Cast(poutput.CastPosition);
                        }
                    }
                    else if ((int)poutput.Hitchance == 5)
                    {
                        QWER.Cast(poutput.CastPosition);
                    }
                }
            }
        }
コード例 #11
0
ファイル: Sona.cs プロジェクト: CupidL0ve/LeagueSharp
        public override void Game_OnGameUpdate(EventArgs args) {

            var autoMana = ((ObjectManager.Player.Mana / ObjectManager.Player.MaxMana) * 100) > GetValue<Slider>("autoMana").Value;

            if (GetValue<bool>("AutoQ") && autoMana) {
                if (Q.IsReady()) {
                    // Cast Q when target is in range
                    var t = SimpleTs.GetTarget(Q.Range, SimpleTs.DamageType.Physical);
                    if (Vector3.Distance(ObjectManager.Player.Position, t.Position) < Q.Range) {
                        ObjectManager.Player.Spellbook.CastSpell(SpellSlot.Q);
                    }
                }
            }

            if (GetValue<bool>("AutoW") && autoMana) {
                if (W.IsReady()) {
                    // Casts when an Ally is below the set HP threshold.
                    if (Utils.AllyBelowHP(GetValue<Slider>("AutoHeal").Value, W.Range)) {
                        ObjectManager.Player.Spellbook.CastSpell(SpellSlot.W);
                    }
                }
            }
 
            if ((!ComboActive && !HarassActive) || (!Orbwalking.CanMove(100)))
                return;
             
            // Vars that grab values based on the menu
            var useQ = GetValue<bool>("UseQ" + (ComboActive ? "C" : "H"));
            var useW = GetValue<bool>("UseW" + (ComboActive ? "C" : "H"));
            var useE = GetValue<bool>("UseEC");
            var useR = GetValue<bool>("UseRC");

            if (useQ && Q.IsReady()) {
                // Cast Q when target is in range
                var t = SimpleTs.GetTarget(Q.Range, SimpleTs.DamageType.Physical);
                if (Vector3.Distance(ObjectManager.Player.Position, t.Position) < Q.Range) {
                    ObjectManager.Player.Spellbook.CastSpell(SpellSlot.Q);
                }
            }

            if (useW && W.IsReady()) {
                // Casts when an Ally is below the set HP threshold.
                if (Utils.AllyBelowHP(GetValue<Slider>("AutoHeal").Value, W.Range)) {
                    ObjectManager.Player.Spellbook.CastSpell(SpellSlot.W);
                }
            }

            if (useE && E.IsReady() && ComboActive) {
                // This uses E just to proc passive :D
                ObjectManager.Player.Spellbook.CastSpell(SpellSlot.E);
            }

            if (useR && R.IsReady() && ComboActive) {
                var t = SimpleTs.GetTarget(R.Range, SimpleTs.DamageType.Physical);
                var ultTar = Utils.GetEnemyHitByR(R, GetValue<Slider>("CountR").Value);
                if (ultTar != null) {
                    R.Cast(ultTar, true);
                    // Attempt at faster cast.
                    //R.CastOnUnit(ultTar, true);
                }
            }

            // Item menu
            if (ComboActive) {
                // Gets the target within frostQueens range (850).
                var target = SimpleTs.GetTarget(840, SimpleTs.DamageType.Physical);
                if (Items.HasItem(FrostQueen) && Items.CanUseItem(FrostQueen)) {
                    // Grab the prediction based on arbitrary values ^.^
                    pred = Prediction.GetPrediction(target, 0.5f, 50f, 1200f);
                    foreach (var slot in ObjectManager.Player.InventoryItems.Where(slot => slot.Id == (ItemId)FrostQueen)) {
                        if (pred.Hitchance >= HitChance.Medium) {
                            slot.UseItem(pred.CastPosition);
                        }
                    }
                }
            }

        }
コード例 #12
0
ファイル: BadaoPrediction.cs プロジェクト: badao/BadaoSeries
        public static PredictionOutput GetBadaoPrediction(this Spell spell, Obj_AI_Base target, bool collideyasuowall = true)
        {
            PredictionOutput result = null;

            if (!target.IsValidTarget(float.MaxValue, false))
            {
                return new PredictionOutput();
            }
            if (target.IsDashing())
            {
                var dashDtata = target.GetDashInfo();
                result = spell.GetBadaoStandarPrediction(target,
                    new List<Vector2>() {target.ServerPosition.To2D(), dashDtata.Path.Last()},dashDtata.Speed);
                if (result.Hitchance >= HitChance.High)
                    result.Hitchance = HitChance.Dashing;
            }
            else
            {
                //Unit is immobile.
                var remainingImmobileT = UnitIsImmobileUntil(target);
                if (remainingImmobileT >= 0d)
                {
                    var timeToReachTargetPosition = spell.Delay + target.Position.To2D().Distance(spell.From.To2D()) / spell.Speed;
                    if (spell.RangeCheckFrom.To2D().Distance(target.Position.To2D()) <= spell.Range)
                    {
                        if (timeToReachTargetPosition <=
                            remainingImmobileT + (target.BoundingRadius + spell.Width - 40)/target.MoveSpeed)
                        {
                            result = new PredictionOutput
                            {
                                CastPosition = target.ServerPosition,
                                UnitPosition = target.ServerPosition,
                                Hitchance = HitChance.Immobile
                            };
                        }

                        else result =  new PredictionOutput
                        {
                            CastPosition = target.ServerPosition,
                            UnitPosition = target.ServerPosition,
                            Hitchance = HitChance.High
                            /*timeToReachTargetPosition - remainingImmobileT + input.RealRadius / input.Unit.MoveSpeed < 0.4d ? HitChance.High : HitChance.Medium*/
                        };
                    }
                    else
                    {
                       result = new PredictionOutput();
                    }
                }
            }
            //Normal prediction
            if (result == null)
            {
                result = spell.GetBadaoStandarPrediction(target,target.GetWaypoints());
            }
            //Check for collision
            if (spell.Collision)
            {
                var positions = new List<Vector3> { result.UnitPosition, result.CastPosition, target.Position };
                var originalUnit = target;
                result.CollisionObjects = spell.GetCollision(positions);
                result.CollisionObjects.RemoveAll(x => x.NetworkId == originalUnit.NetworkId);
                result.Hitchance = result.CollisionObjects.Count > 0 ? HitChance.Collision : result.Hitchance;
            }
            //Check yasuo wall collision
            else if (collideyasuowall)
            {
                var positions = new List<Vector3> { result.UnitPosition, result.CastPosition, target.Position };
                var originalUnit = target;
                result.CollisionObjects = spell.GetCollision(positions);
                result.CollisionObjects.Any(x => x.NetworkId == ObjectManager.Player.NetworkId);
                result.Hitchance = result.CollisionObjects.Any(x => x.NetworkId == ObjectManager.Player.NetworkId) ? HitChance.Collision : result.Hitchance;
            }
            return result;
        }
コード例 #13
0
ファイル: MovementPrediction.cs プロジェクト: werdbrian/AIO
        /// <summary>
        ///     The get updated prediction 2.
        /// </summary>
        /// <param name="input">
        ///     The input.
        /// </param>
        /// <returns>
        ///     The <see cref="PredictionOutput" />.
        /// </returns>
        internal static PredictionOutput GetUpdatedPrediction2(PredictionInput input)
        {
            if (Math.Abs(input.Speed - float.MaxValue) < float.Epsilon)
            {
                input.Speed = 90000;
            }

            var targetVelocity = CalculateVelocity(
                input.Unit.ServerPosition,
                input.Unit.Path.LastOrDefault(),
                input.Unit.MoveSpeed);
            var position = input.Unit.ServerPosition - input.From;
            var cross = Vector3.Cross(position, targetVelocity);
            var discriminant = input.Speed * input.Speed * position.LengthSquared() - cross.LengthSquared();

            if (discriminant < 0.0f)
            {
                return new PredictionOutput
                           {
                               CastPosition = input.Unit.ServerPosition, UnitPosition = input.Unit.ServerPosition,
                               Hitchance = HitChance.VeryHigh
                           };
            }

            var time = (Math.Sqrt(discriminant) + Vector3.Dot(position, targetVelocity))
                       / (input.Speed * input.Speed - targetVelocity.LengthSquared());
            var result = new PredictionOutput()
                             {
                                 CastPosition = input.Unit.ServerPosition + targetVelocity * (float)time,
                                 UnitPosition = input.Unit.ServerPosition, Hitchance = HitChance.VeryHigh
                             };

            // Check if the unit position is in range
            if (Math.Abs(input.Range - float.MaxValue) > float.Epsilon)
            {
                if (result.Hitchance >= HitChance.High
                    && input.RangeCheckFrom.Distance(input.Unit.Position, true)
                    > Math.Pow(input.Range + input.Radius * 3 / 4, 2))
                {
                    result.Hitchance = HitChance.Medium;
                }

                if (input.RangeCheckFrom.Distance(result.UnitPosition, true)
                    > Math.Pow(input.Range + (input.Type == SkillshotType.SkillshotCircle ? input.Radius : 0), 2))
                {
                    result.Hitchance = HitChance.OutOfRange;
                }
            }

            // Check for collision
            if (input.Collision)
            {
                var positions = new List<Vector3> { result.UnitPosition, result.CastPosition, input.Unit.Position };
                var originalUnit = input.Unit;
                result.CollisionObjects = Collision.GetCollision(positions, input);
                result.CollisionObjects.RemoveAll(x => x.NetworkId == originalUnit.NetworkId);
                result.Hitchance = result.CollisionObjects.Count > 0 ? HitChance.Collision : result.Hitchance;
            }

            return result;
        }
コード例 #14
0
 public static bool CheckColision(SPrediction.Prediction.Result prediction) //Returns if a colision is meet
 {
     var commonOutput=new PredictionOutput {Hitchance=prediction.HitChance, CollisionObjects=prediction.CollisionResult.Units, CastPosition=(Vector3)prediction.CastPosition, UnitPosition=(Vector3)prediction.UnitPosition};
     return CheckColision(commonOutput);
 }
コード例 #15
0
 public static bool CheckColision(PredictionOutput prediction) //Returns if a colision is meet
 {
     var colision=prediction.CollisionObjects.Any(obj => !obj.IsChampion()&&obj.IsEnemy);
     //if(colision) Data.Static.Objects.ProjectLogger.WriteLog($"Colision");
     return colision;
 }