/// <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 MidlaneSharp.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> /// Spell extension for cast aoe arc spell with SPrediction /// </summary> /// <param name="minHit">Minimum aoe hits to cast</param> /// <returns></returns> public static bool SPredictionCastAoeArc(this Spell s, int minHit) { if (minHit < 2) { throw new InvalidOperationException("Minimum aoe hit count cannot be less than 2"); } if (s.Collision) { throw new InvalidOperationException("Collisionable spell"); } Prediction.AoeResult result = ArcPrediction.GetAoePrediction(s.Width, s.Delay, s.Speed, s.Range, s.From.To2D(), s.RangeCheckFrom.To2D()); Prediction.lastDrawTick = Utils.TickCount; Prediction.lastDrawPos = result.CastPosition; Prediction.lastDrawHitchance = String.Format("Arc Aoe Cast (Hits: {0})", result.HitCount); Prediction.lastDrawDirection = (result.CastPosition - s.From.To2D()).Normalized().Perpendicular(); Prediction.lastDrawWidth = (int)s.Width; if (result.HitCount >= minHit) { return(s.Cast(result.CastPosition)); } return(false); }
/// <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(); 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 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); }