/// <summary> /// Attemtps To Cast the spell AoE. /// </summary> public static bool CastAOE(this Spell.SpellBase spell, int hitcount, float CustomRange = -1, AIHeroClient target = null) { var skillshot = spell.SetSkillshot(); var range = CustomRange.Equals(-1) ? spell.Range : CustomRange; if (skillshot.Type == SkillShotType.Circular) { foreach (var enemy in EntityManager.Heroes.Enemies.Where(e => e.IsKillable(range))) { var pred = spell.GetPrediction(enemy); var circle = new Geometry.Polygon.Circle(pred.CastPosition, skillshot.Width); foreach (var point in circle.Points) { circle = new Geometry.Polygon.Circle(point, skillshot.Width); foreach (var p in circle.Points.OrderBy(a => a.Distance(pred.CastPosition))) { if (p.CountEnemyHeros(skillshot.Width) >= hitcount) { if (target == null) { Player.CastSpell(spell.Slot, p.To3D()); return(true); } if (target.ServerPosition.IsInRange(p.To3D(), skillshot.Width)) { Player.CastSpell(spell.Slot, p.To3D()); return(true); } } } } } } if (skillshot.Type == SkillShotType.Linear) { return(target != null?spell.CastLineAoE(target, HitChance.Low, hitcount) : EntityManager.Heroes.Enemies.Where(e => e.IsKillable(spell.Range)).Select(e => spell.CastLineAoE(e, HitChance.Low, hitcount)).FirstOrDefault()); } return(skillshot.CastIfItWillHit(hitcount)); }