/// <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 = GameObjects.EnemyHeroes.Where(p => p.IsValidTarget() && Prediction.GetFastUnitPosition(p, delay, 0, rangeCheckFrom).Distance(rangeCheckFrom) < range); foreach (var enemy in enemies) { List <Vector2> path = enemy.GetWaypoints(); if (path.Count <= 1) { Vector2 from = rangeCheckFrom + (enemy.PreviousPosition.ToVector2() - rangeCheckFrom).Normalized() * range; Vector2 to = from + (enemy.PreviousPosition.ToVector2() - from).Normalized() * vectorLenght; Collision.Result colResult = Collision.GetCollisions(from, to, range, width, delay, vectorSpeed); if (colResult.Objects.HasFlag(Collision.Flags.EnemyChampions)) { int collisionCount = colResult.Units.Count(p => p.IsEnemy && p.Type == GameObjectType.AIHeroClient && p.IsValid); if (collisionCount > result.HitCount) { result = new AoeResult { CastSourcePosition = from, CastTargetPosition = enemy.PreviousPosition.ToVector2(), 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]); Prediction.Result prediction = Prediction.GetPrediction(enemy, width, delay, vectorSpeed, vectorLenght, false, SkillshotType.Line, path, enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), enemy.LastAngleDiff(), point, rangeCheckFrom); if (prediction.HitChance > HitChance.Medium) { Vector2 to = point + (prediction.CastPosition - point).Normalized() * vectorLenght; Collision.Result colResult = Collision.GetCollisions(point, to, range, width, delay, vectorSpeed, false); if (colResult.Objects.HasFlag(Collision.Flags.EnemyChampions)) { int collisionCount = colResult.Units.Count(p => p.IsEnemy && p.Type == GameObjectType.AIHeroClient && p.IsValid); if (collisionCount > result.HitCount) { result = new AoeResult { CastSourcePosition = point, CastTargetPosition = prediction.CastPosition, HitCount = collisionCount, CollisionResult = colResult }; } } } } } } } return(result); }
/// <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 (Obj_AI_Hero 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; }
/// <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) { var result = new AoeResult(); var enemies = HeroManager.Enemies.Where( p => p.LSIsValidTarget() && Prediction.GetFastUnitPosition(p, delay, 0, rangeCheckFrom).LSDistance(rangeCheckFrom) < range); foreach (var enemy in enemies) { var path = enemy.GetWaypoints(); if (path.Count <= 1) { var from = rangeCheckFrom + (enemy.ServerPosition.LSTo2D() - rangeCheckFrom).LSNormalized() * range; var to = from + (enemy.ServerPosition.LSTo2D() - from).LSNormalized() * vectorLenght; var colResult = Collision.GetCollisions(from, to, range, width, delay, vectorSpeed); if (colResult.Objects.HasFlag(Collision.Flags.EnemyChampions)) { var collisionCount = colResult.Units.Count(p => p.IsEnemy && p.IsChampion()); if (collisionCount > result.HitCount) { result = new AoeResult { CastSourcePosition = from, CastTargetPosition = enemy.ServerPosition.LSTo2D(), HitCount = collisionCount, CollisionResult = colResult }; } } } else { if (!enemy.IsDashing()) { for (var i = 0; i < path.Count - 1; i++) { var point = Geometry.ClosestCirclePoint(rangeCheckFrom, range, path[i]); var prediction = Prediction.GetPrediction(enemy, width, delay, vectorSpeed, vectorLenght, false, SkillshotType.SkillshotLine, path, enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(), enemy.LastAngleDiff(), point, rangeCheckFrom); if (prediction.HitChance > HitChance.Medium) { var to = point + (prediction.CastPosition - point).LSNormalized() * vectorLenght; var colResult = Collision.GetCollisions(point, to, range, width, delay, vectorSpeed); if (colResult.Objects.HasFlag(Collision.Flags.EnemyChampions)) { var 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); }