public EnsoulSharp.SDK.PredictionOutput GetPrediction(EnsoulSharp.SDK.PredictionInput input, bool ft, bool checkCollision) { var ChangeInput = new Sebby.PredictionInput() { From = input.From, RangeCheckFrom = input.RangeCheckFrom, Aoe = input.Aoe, Collision = input.Collision, CollisionObjects = input.CollisionObjects ?? new CollisionObjects[1], Delay = input.Delay, Radius = input.Radius, Range = input.Range, Speed = input.Speed, Type = input.Type, Unit = input.Unit, Source = ObjectManager.Player, }; var GetPred = Sebby.Prediction.GetPrediction(ChangeInput, ft, checkCollision); var OutPut = new EnsoulSharp.SDK.PredictionOutput() { AoeTargetsHitCount = GetPred.AoeTargetsHitCount, AoeTargetsHit = GetPred.AoeTargetsHit, Hitchance = (EnsoulSharp.SDK.HitChance)GetPred.Hitchance, CastPosition = GetPred.CastPosition, UnitPosition = GetPred.UnitPosition, CollisionObjects = GetPred.CollisionObjects, }; return(OutPut); }
public PredictionOutput GetPrediction(EnsoulSharp.SDK.PredictionInput input) { if (input.Aoe && !input.Collision) { switch (input.Type) { case SpellType.Line: return(LinePrediction.GetLineAoePrediction(input.Range, input.Delay, input.Speed, input.Range, input.From.ToVector2(), input.RangeCheckFrom.ToVector2()).ToSDKResult()); case SpellType.Circle: return(CirclePrediction.GetAoePrediction(input.Radius, input.Delay, input.Speed, input.Range, input.From.ToVector2(), input.RangeCheckFrom.ToVector2()).ToSDKResult()); case SpellType.Cone: return(ConePrediction.GetAoePrediction(input.Radius, input.Delay, input.Speed, input.Range, input.From.ToVector2(), input.RangeCheckFrom.ToVector2()).ToSDKResult()); } return(new PredictionOutput()); } var inp = new PredictionInput(input.Unit, input.Delay, input.Speed, input.Radius, input.Range, input.Collision, input.Type, input.From, input.RangeCheckFrom); return(this.GetPrediction(inp).ToSDKResult()); }
public PredictionOutput GetPrediction(EnsoulSharp.SDK.PredictionInput input, bool ft, bool checkCollision) { var inp = new PredictionInput(input.Unit, input.Delay, input.Speed, input.Radius, input.Range, checkCollision, input.Type, input.From, input.RangeCheckFrom); return(this.GetPrediction(inp).ToSDKResult()); }
/// <summary> /// Returns the list of the units that the skill-shot will hit before reaching the set positions. /// </summary> /// <param name="positions"> /// The positions. /// </param> /// <param name="input"> /// The input. /// </param> /// <returns> /// A list of <c>AIBaseClient</c>s which the input collides with. /// </returns> public static List <AIBaseClient> GetCollision(List <Vector3> positions, PredictionInput input) { var result = new List <AIBaseClient>(); foreach (var position in positions) { if (input.CollisionObjects.HasFlag(CollisionableObjects.Minions)) { foreach (var minion in GameObjects.EnemyMinions.Where( minion => minion.IsValidTarget( Math.Min(input.Range + input.Radius + 100, 2000), true, input.RangeCheckFrom))) { input.Unit = minion; var minionPrediction = Movement.GetPrediction(input, false, false); if (minionPrediction.UnitPosition.ToVector2() .DistanceSquared(input.From.ToVector2(), position.ToVector2(), true) <= Math.Pow(input.Radius + 15 + minion.BoundingRadius, 2)) { result.Add(minion); } } } if (input.CollisionObjects.HasFlag(CollisionableObjects.Heroes)) { foreach (var hero in GameObjects.EnemyHeroes.Where( hero => hero.IsValidTarget( Math.Min(input.Range + input.Radius + 100, 2000), true, input.RangeCheckFrom))) { input.Unit = hero; var prediction = Movement.GetPrediction(input, false, false); if (prediction.UnitPosition.ToVector2() .DistanceSquared(input.From.ToVector2(), position.ToVector2(), true) <= Math.Pow(input.Radius + 50 + hero.BoundingRadius, 2)) { result.Add(hero); } } } if (input.CollisionObjects.HasFlag(CollisionableObjects.Walls)) { var step = position.Distance(input.From) / 20; for (var i = 0; i < 20; i++) { var p = input.From.ToVector2().Extend(position.ToVector2(), step * i); if (NavMesh.GetCollisionFlags(p.X, p.Y).HasFlag(CollisionFlags.Wall)) { result.Add(GameObjects.Player); } } } if (input.CollisionObjects.HasFlag(CollisionableObjects.YasuoWall)) { if (!GameObjects.EnemyHeroes .Any( hero => hero.IsValidTarget(float.MaxValue, false) && hero.CharacterName == "Yasuo")) { break; } foreach (var effectEmitter in GameObjects.ParticleEmitters) { if (effectEmitter.IsValid && Regex.IsMatch(effectEmitter.Name, @"Yasuo_.+_w_windwall_enemy_\d", RegexOptions.IgnoreCase)) { var wall = effectEmitter; var level = wall.Name.Substring(wall.Name.Length - 2, 2); 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; if (wallStart.Intersection(wallEnd, position.ToVector2(), input.From.ToVector2()).Intersects) { var t = Variables.TickCount + (((wallStart.Intersection(wallEnd, position.ToVector2(), input.From.ToVector2()) .Point.Distance(input.From) / input.Speed) + input.Delay) * 1000); if (t < wall.RestartTime + 4000) { result.Add(GameObjects.Player); break; } } } } } } return(result.Distinct().ToList()); }
/// <summary> /// Returns an Area-of-Effect line prediction from a prediction input source. /// </summary> /// <param name="input"> /// <see cref="PredictionInput" /> input /// </param> /// <returns> /// <see cref="PredictionOutput" /> output /// </returns> public static PredictionOutput GetLinePrediction(PredictionInput input) { var mainTargetPrediction = Movement.GetPrediction(input, false, true); var posibleTargets = new List <PossibleTarget> { new PossibleTarget { Position = mainTargetPrediction.UnitPosition.ToVector2(), Unit = input.Unit } }; if (mainTargetPrediction.Hitchance >= HitChance.Medium) { // Add the posible targets in range: posibleTargets.AddRange(GetPossibleTargets(input)); } if (posibleTargets.Count > 1) { var candidates = new List <Vector2>(); foreach (var targetCandidates in posibleTargets.Select( target => GetCandidates(input.From.ToVector2(), target.Position, input.Radius, input.Range)) ) { candidates.AddRange(targetCandidates); } var bestCandidateHits = -1; var bestCandidate = default(Vector2); var bestCandidateHitPoints = new List <Vector2>(); var positionsList = posibleTargets.Select(t => t.Position).ToList(); foreach (var candidate in candidates) { if ( GetHits( input.From.ToVector2(), candidate, input.Radius + (input.Unit.BoundingRadius / 3) - 10, new List <Vector2> { posibleTargets[0].Position }).Count() == 1) { var hits = GetHits(input.From.ToVector2(), candidate, input.Radius, positionsList).ToList(); var hitsCount = hits.Count; if (hitsCount >= bestCandidateHits) { bestCandidateHits = hitsCount; bestCandidate = candidate; bestCandidateHitPoints = hits.ToList(); } } } if (bestCandidateHits > 1) { float maxDistance = -1; Vector2 p1 = default(Vector2), p2 = default(Vector2); // Center the position for (var i = 0; i < bestCandidateHitPoints.Count; i++) { for (var j = 0; j < bestCandidateHitPoints.Count; j++) { var startP = input.From.ToVector2(); var endP = bestCandidate; var proj1 = positionsList[i].ProjectOn(startP, endP); var proj2 = positionsList[j].ProjectOn(startP, endP); var dist = bestCandidateHitPoints[i].DistanceSquared(proj1.LinePoint) + bestCandidateHitPoints[j].DistanceSquared(proj2.LinePoint); if (dist >= maxDistance && (proj1.LinePoint - positionsList[i]).AngleBetween( proj2.LinePoint - positionsList[j]) > 90) { maxDistance = dist; p1 = positionsList[i]; p2 = positionsList[j]; } } } return(new PredictionOutput { Hitchance = mainTargetPrediction.Hitchance, AoeHitCount = bestCandidateHits, UnitPosition = mainTargetPrediction.UnitPosition, CastPosition = ((p1 + p2) * 0.5f).ToVector3(), Input = input }); } } return(mainTargetPrediction); }
/// <summary> /// Returns an Area-of-Effect cone prediction from a prediction input source. /// </summary> /// <param name="input"> /// <see cref="PredictionInput" /> input /// </param> /// <returns> /// <see cref="PredictionOutput" /> output /// </returns> public static PredictionOutput GetConePrediction(PredictionInput input) { var mainTargetPrediction = Movement.GetPrediction(input, false, true); var posibleTargets = new List <PossibleTarget> { new PossibleTarget { Position = mainTargetPrediction.UnitPosition.ToVector2(), Unit = input.Unit } }; if (mainTargetPrediction.Hitchance >= HitChance.Medium) { // Add the posible targets in range: posibleTargets.AddRange(GetPossibleTargets(input)); } if (posibleTargets.Count > 1) { var candidates = new List <Vector2>(); foreach (var target in posibleTargets) { target.Position = target.Position - input.From.ToVector2(); } for (var i = 0; i < posibleTargets.Count; i++) { for (var j = 0; j < posibleTargets.Count; j++) { if (i != j) { var p = (posibleTargets[i].Position + posibleTargets[j].Position) * 0.5f; if (!candidates.Contains(p)) { candidates.Add(p); } } } } var bestCandidateHits = -1; var bestCandidate = default(Vector2); var positionsList = posibleTargets.Select(t => t.Position).ToList(); foreach (var candidate in candidates) { var hits = GetHits(candidate, input.Range, input.Radius, positionsList); if (hits > bestCandidateHits) { bestCandidate = candidate; bestCandidateHits = hits; } } if (bestCandidateHits > 1 && input.From.DistanceSquared(bestCandidate) > 50 * 50) { return(new PredictionOutput { Hitchance = mainTargetPrediction.Hitchance, AoeHitCount = bestCandidateHits, UnitPosition = mainTargetPrediction.UnitPosition, CastPosition = bestCandidate.ToVector3(), Input = input }); } } return(mainTargetPrediction); }