/// <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 (Obj_AI_Hero enemy in enemies) { Prediction.Result prediction = GetPrediction(enemy, width, delay, missileSpeed, range, false, enemy.GetWaypoints(), enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), enemy.LastAngleDiff(), from, rangeCheckFrom); if (prediction.HitChance > HitChance.Medium) { float multp = (result.CastPosition.Distance(from) / 875.0f); var spellHitBox = new SPrediction.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(); 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.Path.ToList().To2D(), enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), enemy.LastAngleDiff(), from, rangeCheckFrom); if (prediction.HitChance > HitChance.Medium) { float multp = (result.CastPosition.Distance(from) / 875.0f); var spellHitBox = new SPrediction.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) { var result = new Prediction.AoeResult(); var enemies = HeroManager.Enemies.Where( p => p.LSIsValidTarget() && Prediction.GetFastUnitPosition(p, delay, 0, from).LSDistance(rangeCheckFrom) < range); foreach (var enemy in enemies) { var prediction = GetPrediction(enemy, width, delay, missileSpeed, range, false, enemy.GetWaypoints(), enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), enemy.LastAngleDiff(), from, rangeCheckFrom); if (prediction.HitChance > HitChance.Medium) { var to = from + (prediction.CastPosition - from).LSNormalized() * range; var colResult = Collision.GetCollisions(from, to, range, width, delay, missileSpeed); if (colResult.Objects.HasFlag(Collision.Flags.EnemyChampions)) { var 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) { var result = new Prediction.AoeResult(); var enemies = HeroManager.Enemies.Where( p => p.LSIsValidTarget() && Prediction.GetFastUnitPosition(p, delay, 0, from).LSDistance(rangeCheckFrom) < range); foreach (var enemy in enemies) { var prediction = GetPrediction(enemy, width, delay, missileSpeed, range, false, enemy.GetWaypoints(), enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), enemy.LastAngleDiff(), from, rangeCheckFrom); if (prediction.HitChance > HitChance.Medium) { var to = from + (prediction.CastPosition - from).LSNormalized()*range; var colResult = Collision.GetCollisions(from, to, range, width, delay, missileSpeed); if (colResult.Objects.HasFlag(Collision.Flags.EnemyChampions)) { var 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) { var result = new Prediction.AoeResult { HitCount = 0 }; var enemies = HeroManager.Enemies.Where( p => p.LSIsValidTarget() && Prediction.GetFastUnitPosition(p, delay, 0, from).LSDistance(rangeCheckFrom) < range); if (enemies.Count() > 0) { var posSummary = Vector2.Zero; enemies.AsParallel() .ForAll(p => posSummary += Prediction.GetFastUnitPosition(p, delay, missileSpeed, from)); var center = posSummary / enemies.Count(); float flyTime = 0; if (missileSpeed != 0) { flyTime = from.LSDistance(center) / missileSpeed; } posSummary = Vector2.Zero; var predictionResults = new List <Tuple <Prediction.Result, float> >(); foreach (var enemy in enemies) { var prediction = GetPrediction(enemy, width, delay + flyTime, 0, range, false, enemy.GetWaypoints(), enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), enemy.LastAngleDiff(), from, rangeCheckFrom); if (prediction.HitChance > EloBuddy.SDK.Enumerations.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 (var 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> /// 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) { var result = new Prediction.AoeResult {HitCount = 0}; var enemies = HeroManager.Enemies.Where( p => p.IsValidTarget() && Prediction.GetFastUnitPosition(p, delay, 0, from).LSDistance(rangeCheckFrom) < range); foreach (var enemy in enemies) { var prediction = GetPrediction(enemy, width, delay, missileSpeed, range, false, enemy.GetWaypoints(), enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), enemy.LastAngleDiff(), from, rangeCheckFrom); if (prediction.HitChance > HitChance.Medium) { var to = from + (prediction.CastPosition - from).LSNormalized()*range; var spellHitBox = ClipperWrapper.DefineSector(from, to, width, range); var collidedEnemies = HeroManager.Enemies.AsParallel() .Where( p => !spellHitBox.IsOutside(Prediction.GetFastUnitPosition(p, delay, missileSpeed, from))); var 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) { var result = new Prediction.AoeResult {HitCount = 0}; var enemies = HeroManager.Enemies.Where( p => p.IsValidTarget() && Prediction.GetFastUnitPosition(p, delay, 0, from).Distance(rangeCheckFrom) < range); if (enemies.Count() > 0) { var posSummary = Vector2.Zero; enemies.AsParallel() .ForAll(p => posSummary += Prediction.GetFastUnitPosition(p, delay, missileSpeed, from)); var center = posSummary/enemies.Count(); float flyTime = 0; if (missileSpeed != 0) flyTime = from.Distance(center)/missileSpeed; posSummary = Vector2.Zero; var predictionResults = new List<Tuple<Prediction.Result, float>>(); foreach (var enemy in enemies) { var prediction = GetPrediction(enemy, width, delay + flyTime, 0, range, false, enemy.GetWaypoints(), enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), enemy.LastAngleDiff(), 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 (var 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> /// 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.ToVector2(), s.RangeCheckFrom.ToVector2()); 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) { var result = new Prediction.AoeResult(); var enemies = GameObjects.EnemyHeroes.Where(p => p.IsValidTarget() && Prediction.GetFastUnitPosition(p, delay, 0, from).Distance(rangeCheckFrom) < range); foreach (var enemy in enemies) { Prediction.Result prediction = GetPrediction(enemy, width, delay, missileSpeed, range, false, enemy.GetWaypoints(), enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), enemy.LastAngleDiff(), 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 = GameObjects.EnemyHeroes.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 <AIBaseClient>(), Collision.Flags.EnemyChampions)); } } } return(result); }