/// <summary> /// Gets Prediction result /// </summary> /// <param name="target">Target for spell</param> /// <param name="width">Spell width</param> /// <param name="delay">Spell delay</param> /// <param name="missileSpeed">Spell missile speed</param> /// <param name="range">Spell range</param> /// <param name="collisionable">Spell collisionable</param> /// <param name="type">Spell skillshot type</param> /// <param name="path">Waypoints 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="avgp">Average Path Lenght</param> /// <param name="from">Spell casted position</param> /// <param name="rangeCheckFrom"></param> /// <returns>Prediction result as <see cref="Prediction.Result"/></returns> public static Prediction.Result GetPrediction(Obj_AI_Base target, float width, float delay, float missileSpeed, float range, bool collisionable, List <Vector2> path, float avgt, float movt, float avgp, Vector2 from, Vector2 rangeCheckFrom) { Prediction.AssertInitializationMode(); Prediction.Result result = Prediction.GetPrediction(target, width, delay, missileSpeed, range, collisionable, SkillshotType.SkillshotCircle, path, avgt, movt, avgp, from, rangeCheckFrom); if (result.HitChance >= HitChance.Low && result.HitChance < HitChance.VeryHigh) { if (result.CastPosition.Distance(from) < 875.0f) { Vector2 direction = (result.CastPosition - from).Normalized(); result.CastPosition = from + direction * (875f + width / 2f); var targetHitBox = ClipperWrapper.DefineCircle(Prediction.GetFastUnitPosition(target, delay, missileSpeed, from), target.BoundingRadius); float multp = (result.CastPosition.Distance(from) / 875.0f); var arcHitBox = new VeigSPrediction.Geometry.Polygon( ClipperWrapper.DefineArc(from - new Vector2(875 / 2f, 20), result.CastPosition, (float)Math.PI * multp, 410, 200 * multp), ClipperWrapper.DefineArc(from - new Vector2(875 / 2f, 20), result.CastPosition, (float)Math.PI * multp, 410, 320 * multp)); if (ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(targetHitBox), ClipperWrapper.MakePaths(arcHitBox))) { result.HitChance = (HitChance)(result.HitChance + 1); } } } return(result); }
/// <summary> /// Gets Aoe Prediction result /// </summary> /// <param name="width">Spell width</param> /// <param name="delay">Spell delay</param> /// <param name="missileSpeed">Spell missile speed</param> /// <param name="range">Spell range</param> /// <param name="from">Spell casted position</param> /// <param name="rangeCheckFrom"></param> /// <returns>Prediction result as <see cref="Prediction.AoeResult"/></returns> public static Prediction.AoeResult GetAoePrediction(float width, float delay, float missileSpeed, float range, Vector2 from, Vector2 rangeCheckFrom) { Prediction.AoeResult result = new Prediction.AoeResult(); var enemies = HeroManager.Enemies.Where(p => p.IsValidTarget() && Prediction.GetFastUnitPosition(p, delay, 0, from).Distance(rangeCheckFrom) < range); foreach (AIHeroClient enemy in enemies) { Prediction.Result prediction = GetPrediction(enemy, width, delay, missileSpeed, range, false, enemy.GetWaypoints(), enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), from, rangeCheckFrom); if (prediction.HitChance > HitChance.Medium) { float multp = (result.CastPosition.Distance(from) / 875.0f); var spellHitBox = new VeigSPrediction.Geometry.Polygon( ClipperWrapper.DefineArc(from - new Vector2(875 / 2f, 20), result.CastPosition, (float)Math.PI * multp, 410, 200 * multp), ClipperWrapper.DefineArc(from - new Vector2(875 / 2f, 20), result.CastPosition, (float)Math.PI * multp, 410, 320 * multp)); var collidedEnemies = HeroManager.Enemies.AsParallel().Where(p => ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(ClipperWrapper.DefineCircle(Prediction.GetFastUnitPosition(p, delay, missileSpeed), p.BoundingRadius)), ClipperWrapper.MakePaths(spellHitBox))); int collisionCount = collidedEnemies.Count(); if (collisionCount > result.HitCount) { result = prediction.ToAoeResult(collisionCount, new Collision.Result(collidedEnemies.ToList <Obj_AI_Base>(), Collision.Flags.EnemyChampions)); } } } return(result); }
/// <summary> /// Gets Aoe Prediction result /// </summary> /// <param name="width">Spell width</param> /// <param name="delay">Spell delay</param> /// <param name="missileSpeed">Spell missile speed</param> /// <param name="range">Spell range</param> /// <param name="from">Spell casted position</param> /// <param name="rangeCheckFrom"></param> /// <returns>Prediction result as <see cref="Prediction.AoeResult"/></returns> public static Prediction.AoeResult GetAoePrediction(float width, float delay, float missileSpeed, float range, Vector2 from, Vector2 rangeCheckFrom) { Prediction.AoeResult result = new Prediction.AoeResult(); result.HitCount = 0; var enemies = HeroManager.Enemies.Where(p => p.IsValidTarget() && Prediction.GetFastUnitPosition(p, delay, 0, from).Distance(rangeCheckFrom) < range); if (enemies.Count() > 0) { Vector2 posSummary = Vector2.Zero; enemies.AsParallel().ForAll(p => posSummary += Prediction.GetFastUnitPosition(p, delay, missileSpeed, from)); Vector2 center = posSummary / enemies.Count(); float flyTime = 0; if (missileSpeed != 0) { flyTime = from.Distance(center) / missileSpeed; } posSummary = Vector2.Zero; List <Tuple <Prediction.Result, float> > predictionResults = new List <Tuple <Prediction.Result, float> >(); foreach (AIHeroClient enemy in enemies) { Prediction.Result prediction = GetPrediction(enemy, width, delay + flyTime, 0, range, false, enemy.GetWaypoints(), enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), from, rangeCheckFrom); if (prediction.HitChance > HitChance.Medium) { posSummary += prediction.UnitPosition; predictionResults.Add(new Tuple <Prediction.Result, float>(prediction, enemy.BoundingRadius)); } } if (predictionResults.Count > 0) { center = posSummary / predictionResults.Count; result.CastPosition = center; foreach (Tuple <Prediction.Result, float> res in predictionResults) { if (LeagueSharp.Common.Geometry.CircleCircleIntersection(center, res.Item1.UnitPosition, width, res.Item2).Length > 1) { result.HitCount++; } } } predictionResults.Clear(); GC.Collect(GC.GetGeneration(predictionResults)); } return(result); }
/// <summary> /// Gets Aoe Prediction result /// </summary> /// <param name="width">Spell width</param> /// <param name="delay">Spell delay</param> /// <param name="missileSpeed">Spell missile speed</param> /// <param name="range">Spell range</param> /// <param name="from">Spell casted position</param> /// <param name="rangeCheckFrom"></param> /// <returns>Prediction result as <see cref="Prediction.AoeResult"/></returns> public static Prediction.AoeResult GetAoePrediction(float width, float delay, float missileSpeed, float range, Vector2 from, Vector2 rangeCheckFrom) { Prediction.AoeResult result = new Prediction.AoeResult(); result.HitCount = 0; var enemies = HeroManager.Enemies.Where(p => p.IsValidTarget() && Prediction.GetFastUnitPosition(p, delay, 0, from).Distance(rangeCheckFrom) < range); foreach (AIHeroClient enemy in enemies) { Prediction.Result prediction = GetPrediction(enemy, width, delay, missileSpeed, range, false, enemy.GetWaypoints(), enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), from, rangeCheckFrom); if (prediction.HitChance > HitChance.Medium) { Vector2 to = from + (prediction.CastPosition - from).Normalized() * range; var spellHitBox = ClipperWrapper.DefineSector(from, to, width, range); var collidedEnemies = HeroManager.Enemies.AsParallel().Where(p => !ClipperWrapper.IsOutside(spellHitBox, Prediction.GetFastUnitPosition(p, delay, missileSpeed, from))); int collisionCount = collidedEnemies.Count(); if (collisionCount > result.HitCount) { result = prediction.ToAoeResult(collisionCount, new Collision.Result(collidedEnemies.ToList <Obj_AI_Base>(), Collision.Flags.EnemyChampions)); } } } return(result); }
/// <summary> /// Gets Aoe Prediction result /// </summary> /// <param name="width">Spell width</param> /// <param name="delay">Spell delay</param> /// <param name="missileSpeed">Spell missile speed</param> /// <param name="range">Spell range</param> /// <param name="from">Spell casted position</param> /// <param name="rangeCheckFrom"></param> /// <returns>Prediction result as <see cref="Prediction.AoeResult"/></returns> public static Prediction.AoeResult GetAoePrediction(float width, float delay, float missileSpeed, float range, Vector2 from, Vector2 rangeCheckFrom) { Prediction.AoeResult result = new Prediction.AoeResult(); var enemies = HeroManager.Enemies.Where(p => p.IsValidTarget() && Prediction.GetFastUnitPosition(p, delay, 0, from).Distance(rangeCheckFrom) < range); foreach (AIHeroClient enemy in enemies) { Prediction.Result prediction = GetPrediction(enemy, width, delay, missileSpeed, range, false, enemy.GetWaypoints(), enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), from, rangeCheckFrom); if (prediction.HitChance > HitChance.Medium) { Vector2 to = from + (prediction.CastPosition - from).Normalized() * range; Collision.Result colResult = Collision.GetCollisions(from, to, width, delay, missileSpeed, false); if (colResult.Objects.HasFlag(Collision.Flags.EnemyChampions)) { int collisionCount = colResult.Units.Count(p => p.IsEnemy && p.IsChampion()); if (collisionCount > result.HitCount) { result = prediction.ToAoeResult(collisionCount, colResult); } } } } return(result); }
/// <summary> /// Gets collided units & flags /// </summary> /// <param name="from">Start position</param> /// <param name="to">End position</param> /// <param name="width">Rectangle scale</param> /// <param name="delay">Spell delay</param> /// <param name="missileSpeed">Spell missile speed</param> /// <returns>Collision result as <see cref="Collision.Result"/></returns> public static Result GetCollisions(Vector2 from, Vector2 to, float width, float delay, float missileSpeed = 0, bool isArc = false) { List <Obj_AI_Base> collidedUnits = new List <Obj_AI_Base>(); var spellHitBox = ClipperWrapper.MakePaths(ClipperWrapper.DefineRectangle(from, to, width)); if (isArc) { spellHitBox = ClipperWrapper.MakePaths(new VeigSPrediction.Geometry.Polygon( ClipperWrapper.DefineArc(from - new Vector2(875 / 2f, 20), to, (float)Math.PI * (to.Distance(from) / 875f), 410, 200 * (to.Distance(from) / 875f)), ClipperWrapper.DefineArc(from - new Vector2(875 / 2f, 20), to, (float)Math.PI * (to.Distance(from) / 875f), 410, 320 * (to.Distance(from) / 875f)))); } Flags _colFlags = Flags.None; var collidedMinions = MinionManager.GetMinions(from.Distance(to) + 250, MinionTypes.All, MinionTeam.NotAlly, MinionOrderTypes.None).AsParallel().Where(p => ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(ClipperWrapper.DefineCircle(Prediction.GetFastUnitPosition(p, delay, missileSpeed), p.BoundingRadius + 10)), spellHitBox)); var collidedEnemies = HeroManager.Enemies.AsParallel().Where(p => ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(ClipperWrapper.DefineCircle(Prediction.GetFastUnitPosition(p, delay, missileSpeed), p.BoundingRadius)), spellHitBox)); var collidedAllies = HeroManager.Allies.AsParallel().Where(p => ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(ClipperWrapper.DefineCircle(Prediction.GetFastUnitPosition(p, delay, missileSpeed), p.BoundingRadius)), spellHitBox)); if (collidedMinions != null && collidedMinions.Count() != 0) { collidedUnits.AddRange(collidedMinions); _colFlags |= Flags.Minions; } if (collidedEnemies != null && collidedEnemies.Count() != 0) { collidedUnits.AddRange(collidedEnemies); _colFlags |= Flags.EnemyChampions; } if (collidedAllies != null && collidedAllies.Count() != 0) { collidedUnits.AddRange(collidedAllies); _colFlags |= Flags.AllyChampions; } if (CheckWallCollision(from, to)) { _colFlags |= Flags.Wall; } if (CheckYasuoWallCollision(from, to, width)) { _colFlags |= Flags.YasuoWall; } return(new Result(collidedUnits, _colFlags)); }
/// <summary> /// Checks enemy hero collisions /// </summary> /// <param name="from">Start position</param> /// <param name="to">End position</param> /// <param name="width">Rectangle scale</param> /// <param name="delay">Spell delay</param> /// <param name="missileSpeed">Spell missile speed</param> /// <param name="isArc">Checks collision for arc spell</param> /// <returns>true if collision found</returns> public static bool CheckAllyHeroCollision(Vector2 from, Vector2 to, float width, float delay, float missileSpeed = 0, bool isArc = false) { var spellHitBox = ClipperWrapper.MakePaths(ClipperWrapper.DefineRectangle(from, to, width)); if (isArc) { spellHitBox = ClipperWrapper.MakePaths(new VeigSPrediction.Geometry.Polygon( ClipperWrapper.DefineArc(from - new Vector2(875 / 2f, 20), to, (float)Math.PI * (to.Distance(from) / 875f), 410, 200 * (to.Distance(from) / 875f)), ClipperWrapper.DefineArc(from - new Vector2(875 / 2f, 20), to, (float)Math.PI * (to.Distance(from) / 875f), 410, 320 * (to.Distance(from) / 875f)))); } return(HeroManager.Allies.AsParallel().Any(p => ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(ClipperWrapper.DefineCircle(Prediction.GetFastUnitPosition(p, delay, missileSpeed), p.BoundingRadius)), spellHitBox))); }
/// <summary> /// Gets Aoe Prediction result /// </summary> /// <param name="width">Spell width</param> /// <param name="delay">Spell delay</param> /// <param name="vectorSpeed">Vector speed</param> /// <param name="range">Spell range</param> /// <param name="vectorLenght">Vector lenght</param> /// <param name="rangeCheckFrom"></param> /// <returns>Prediction result as <see cref="Prediction.AoeResult"/></returns> public static AoeResult GetAoePrediction(float width, float delay, float vectorSpeed, float range, float vectorLenght, Vector2 rangeCheckFrom) { AoeResult result = new AoeResult(); var enemies = HeroManager.Enemies.Where(p => p.IsValidTarget() && Prediction.GetFastUnitPosition(p, delay, 0, rangeCheckFrom).Distance(rangeCheckFrom) < range); foreach (AIHeroClient enemy in enemies) { List <Vector2> path = enemy.GetWaypoints(); if (path.Count <= 1) { Vector2 from = rangeCheckFrom + (enemy.ServerPosition.To2D() - rangeCheckFrom).Normalized() * range; Vector2 to = from + (enemy.ServerPosition.To2D() - from).Normalized() * vectorLenght; Collision.Result colResult = Collision.GetCollisions(from, to, width, delay, vectorSpeed); if (colResult.Objects.HasFlag(Collision.Flags.EnemyChampions)) { int collisionCount = colResult.Units.Count(p => p.IsEnemy && p.IsChampion()); if (collisionCount > result.HitCount) { result = new AoeResult { CastSourcePosition = from, CastTargetPosition = enemy.ServerPosition.To2D(), HitCount = collisionCount, CollisionResult = colResult }; } } } else { if (!enemy.IsDashing()) { for (int i = 0; i < path.Count - 1; i++) { Vector2 point = Geometry.ClosestCirclePoint(rangeCheckFrom, range, path[i], path[i + 1]); Prediction.Result prediction = Prediction.GetPrediction(enemy, width, delay, vectorSpeed, vectorLenght, false, SkillshotType.SkillshotLine, path, enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), point, rangeCheckFrom); if (prediction.HitChance > HitChance.Medium) { Vector2 to = point + (prediction.CastPosition - point).Normalized() * vectorLenght; Collision.Result colResult = Collision.GetCollisions(point, to, width, delay, vectorSpeed, false); if (colResult.Objects.HasFlag(Collision.Flags.EnemyChampions)) { int collisionCount = colResult.Units.Count(p => p.IsEnemy && p.IsChampion()); if (collisionCount > result.HitCount) { result = new AoeResult { CastSourcePosition = point, CastTargetPosition = prediction.CastPosition, HitCount = collisionCount, CollisionResult = colResult }; } } } } } } } return(result); }