/// <summary> /// Returns the point where, when casted, the circular spell with hit the maximum amount of minions. /// </summary> public static FarmLocation GetBestCircularFarmLocation(List <Vector2> minionPositions, float width, float range, int useMecMax = 9) { var result = new Vector2(); var minionCount = 0; var startPos = ObjectManager.Player.ServerPosition.To2D(); range = range * range; if (minionPositions.Count == 0) { return(new FarmLocation(result, minionCount)); } /* Use MEC to get the best positions only when there are less than 9 positions because it causes lag with more. */ if (minionPositions.Count <= useMecMax) { var subGroups = GetCombinations(minionPositions); foreach (var subGroup in subGroups) { if (subGroup.Count > 0) { var circle = MEC.GetMec(subGroup); if (circle.Radius <= width && circle.Center.Distance(startPos, true) <= range) { minionCount = subGroup.Count; return(new FarmLocation(circle.Center, minionCount)); } } } } else { foreach (var pos in minionPositions) { if (pos.Distance(startPos, true) <= range) { var count = minionPositions.Count(pos2 => pos.Distance(pos2, true) <= width * width); if (count >= minionCount) { result = pos; minionCount = count; } } } } return(new FarmLocation(result, minionCount)); }
public static Vector2 GetPrediction(Obj_AI_Hero t, Spell s, List <Vector2> path, float avgt, float movt, float filterHPPercent, byte minHit, out HitChance hc, Vector3 rangeCheckFrom) { Vector2 castPos = Prediction.GetPrediction(t, s, path, avgt, movt, out hc, rangeCheckFrom); var posibleTargets = new List <PossibleTarget> { new PossibleTarget { Position = t.ServerPosition.To2D(), Unit = t } }; if (hc >= HitChance.Low) { //Add the posible targets in range: posibleTargets.AddRange(GetPossibleTargets(t, s, rangeCheckFrom, filterHPPercent)); if (posibleTargets.Count < minHit) { hc = HitChance.Impossible; return(castPos); } } while (posibleTargets.Count > 1) { var mecCircle = MEC.GetMec(posibleTargets.Select(h => h.Position).ToList()); if (mecCircle.Radius <= s.Width - 10 && Vector2.DistanceSquared(mecCircle.Center, rangeCheckFrom.To2D()) < s.Range * s.Range) { if (posibleTargets.Count < minHit) { hc = HitChance.Impossible; } return(mecCircle.Center); } float maxdist = -1; var maxdistindex = 1; for (var i = 1; i < posibleTargets.Count; i++) { var distance = Vector2.DistanceSquared(posibleTargets[i].Position, posibleTargets[0].Position); if (distance > maxdist || maxdist.CompareTo(-1) == 0) { maxdistindex = i; maxdist = distance; } } posibleTargets.RemoveAt(maxdistindex); } hc = HitChance.Impossible; return(castPos); }
private static Tuple <Vector3, int> getMECQFarmPos() { var pointsList = new List <Vector2>(); foreach (Obj_AI_Minion current in ObjectManager.Get <Obj_AI_Minion>()) { if (current.IsEnemy && Vector3.Distance(ObjectManager.Player.ServerPosition, current.Position) <= (Q.Range + (W.Width / 2))) { var prediction = Q.GetPrediction(current); var damage = W.GetDamage(current) * 0.75; if (prediction.Hitchance >= HitChance.High && damage > current.Health) { pointsList.Add(prediction.CastPosition.To2D()); } } } while (pointsList.Count != 0) { var circle = MEC.GetMec(pointsList); var numPoints = pointsList.Count; if (circle.Radius <= (W.Width / 2) && numPoints >= 2 && W.IsReady()) { return(Tuple.Create(circle.Center.To3D(), numPoints)); } try { var distance = -1f; var index = 0; var point = pointsList.ElementAt(0); for (int i = 1; i == numPoints; i++) { if (Vector2.Distance(pointsList.ElementAt(i), point) >= distance) { distance = Vector2.Distance(pointsList.ElementAt(i), point); index = i; } } pointsList.RemoveAt(index); } catch (System.ArgumentOutOfRangeException) { Vector3 outOfRange = new Vector3(0); return(Tuple.Create(outOfRange, -1)); } } Vector3 noResult = new Vector3(0); return(Tuple.Create(noResult, -1)); }
/// <summary> /// Uses MEC to get the perfect position on Circle Skillshots /// </summary> /// <param name="targetPositions">Vector2's to target. Example could be all minions inside a range</param> /// <param name="spellWidth">Width of spell (Radius*2)</param> /// <param name="spellRange">Range of spell</param> /// <param name="useMECMax">Just leave this value at default if you don't know what you're doing.</param> /// <returns></returns> public static OptimizedLocation GetOptimizedCircleLocation(List <Vector2> targetPositions, float spellWidth, float spellRange, int useMECMax = 9) { var result = new Vector2(); var targetsHit = 0; var startPos = Player.Instance.ServerPosition.To2D(); spellRange = spellRange * spellRange; if (targetPositions.Count == 0) { return(new OptimizedLocation(result, targetsHit)); } if (targetPositions.Count <= useMECMax) { var subGroups = GetCombinations(targetPositions); foreach (var subGroup in subGroups) { if (subGroup.Count > 0) { var circle = MEC.GetMec(subGroup); if (circle.Radius <= spellWidth && circle.Center.Distance(startPos, true) <= spellRange) { targetsHit = subGroup.Count; return(new OptimizedLocation(circle.Center, targetsHit)); } } } } else { foreach (var pos in targetPositions) { if (pos.Distance(startPos, true) <= spellRange) { var count = targetPositions.Count(pos2 => pos.Distance(pos2, true) <= spellWidth * spellWidth); if (count >= targetsHit) { result = pos; targetsHit = count; } } } } return(new OptimizedLocation(result, targetsHit)); }
public static PredictionOutput GetPrediction(PredictionInput input) { var mainTargetPrediction = Prediction.GetPrediction(input, false, true); var posibleTargets = new List <PossibleTarget> { new PossibleTarget { Position = mainTargetPrediction.UnitPosition.To2D(), Unit = input.Unit } }; if (mainTargetPrediction.Hitchance >= HitChance.Medium) { //Add the posible targets in range: posibleTargets.AddRange(GetPossibleTargets(input)); } while (posibleTargets.Count > 1) { var mecCircle = MEC.GetMec(posibleTargets.Select(h => h.Position).ToList()); if (mecCircle.Radius <= input.RealRadius - 10 && Vector2.DistanceSquared(mecCircle.Center, input.RangeCheckFrom.To2D()) < input.Range * input.Range) { return(new PredictionOutput { AoeTargetsHit = posibleTargets.Select(h => (Obj_AI_Hero)h.Unit).ToList(), CastPosition = mecCircle.Center.To3D(), UnitPosition = mainTargetPrediction.UnitPosition, Hitchance = mainTargetPrediction.Hitchance, Input = input, _aoeTargetsHitCount = posibleTargets.Count }); } float maxdist = -1; var maxdistindex = 1; for (var i = 1; i < posibleTargets.Count; i++) { var distance = Vector2.DistanceSquared(posibleTargets[i].Position, posibleTargets[0].Position); if (distance > maxdist || maxdist.CompareTo(-1) == 0) { maxdistindex = i; maxdist = distance; } } posibleTargets.RemoveAt(maxdistindex); } return(mainTargetPrediction); }
public static PredictionOutput GetPrediction(PredictionInput input) { PredictionOutput prediction = Prediction.GetPrediction(input, false, true); List <AoePrediction.PossibleTarget> list = new List <AoePrediction.PossibleTarget> { new AoePrediction.PossibleTarget { Position = prediction.UnitPosition.ToVector2(), Unit = input.Unit } }; if (prediction.Hitchance >= HitChance.Medium) { list.AddRange(AoePrediction.GetPossibleTargets(input)); } while (list.Count > 1) { var mec = MEC.GetMec((from h in list select h.Position).ToList <Vector2>()); if (mec.Radius <= input.RealRadius - 10f && Vector2.DistanceSquared(mec.Center, input.RangeCheckFrom.ToVector2()) < input.Range * input.Range) { PredictionOutput predictionOutput = new PredictionOutput(); predictionOutput.AoeTargetsHit = (from hero in list select hero.Unit).ToList <AIBaseClient>(); predictionOutput.CastPosition = mec.Center.ToVector3(); predictionOutput.UnitPosition = prediction.UnitPosition; predictionOutput.Hitchance = prediction.Hitchance; predictionOutput.Input = input; predictionOutput._aoeTargetsHitCount = list.Count; return(predictionOutput); } float num = -1f; int index = 1; for (int i = 1; i < list.Count; i++) { float num2 = Vector2.DistanceSquared(list[i].Position, list[0].Position); if (num2 > num || num.CompareTo(-1f) == 0) { index = i; num = num2; } } list.RemoveAt(index); } return(prediction); }
private static Tuple <Vector3, int> GetMecqFarmPos() { List <Vector2> pointsList = (from current in ObjectManager.Get <Obj_AI_Minion>() where current.IsEnemy && Vector3.Distance(ObjectManager.Player.ServerPosition, current.Position) <= (Q.Range + (W.Width / 2)) let prediction = Q.GetPrediction(current) let damage = ObjectManager.Player.GetSpellDamage(current, SpellSlot.W) * 0.75 where prediction.Hitchance >= HitChance.High && damage > current.Health select prediction.CastPosition.To2D()).ToList(); while (pointsList.Count != 0) { MEC.MecCircle circle = MEC.GetMec(pointsList); int numPoints = pointsList.Count; if (circle.Radius <= (W.Width / 2) && numPoints >= 2 && W.IsReady()) { return(Tuple.Create(circle.Center.To3D(), numPoints)); } try { float distance = -1f; int index = 0; Vector2 point = pointsList.ElementAt(0); for (int i = 1; i == numPoints; i++) { if (Vector2.Distance(pointsList.ElementAt(i), point) >= distance) { distance = Vector2.Distance(pointsList.ElementAt(i), point); index = i; } } pointsList.RemoveAt(index); } catch (ArgumentOutOfRangeException) { var outOfRange = new Vector3(0); return(Tuple.Create(outOfRange, -1)); } } var noResult = new Vector3(0); return(Tuple.Create(noResult, -1)); }
private static void CircleFarm(Spell spell, List <Obj_AI_Base> minions, int min, float overrideWidth = -1f) { if (!spell.IsReady() || minions.Count == 0) { return; } var spellWidth = (overrideWidth > 0 ? overrideWidth : spell.Width) + minions.Average(m => m.BoundingRadius); var points = (from minion in minions select spell.GetPrediction(minion) into pred where pred.Hitchance >= HitChance.Medium select pred.UnitPosition.To2D()).ToList(); if (points.Any()) { var possibilities = ListExtensions.ProduceEnumeration(points).Where(p => p.Count >= min).ToList(); if (possibilities.Any()) { var hits = 0; var radius = float.MaxValue; var pos = Vector3.Zero; foreach (var possibility in possibilities) { var mec = MEC.GetMec(possibility); if (mec.Radius < spellWidth) { if (possibility.Count > hits || possibility.Count == hits && radius > mec.Radius) { hits = possibility.Count; radius = mec.Radius; pos = mec.Center.To3D(); } } } if (hits >= min && !pos.Equals(Vector3.Zero)) { spell.Cast(pos); } } } }
private Obj_AI_Base BestRedMinion() { var minions = MinionManager.GetMinions(float.MaxValue, MinionTypes.All, MinionTeam.NotAlly) .Where(Orbwalking.InAutoAttackRange) .ToList(); var possibilities = ListExtensions.ProduceEnumeration(minions.Select(p => p.ServerPosition.To2D()).ToList()) .Where(p => p.Count > 0 && p.Count < 8) .ToList(); var hits = 0; var center = Vector2.Zero; var radius = float.MaxValue; foreach (var possibility in possibilities) { var mec = MEC.GetMec(possibility); if (mec.Radius < W.Width * 1.5f) { if (possibility.Count > hits || possibility.Count == hits && mec.Radius < radius) { hits = possibility.Count; radius = mec.Radius; center = mec.Center; if (hits == minions.Count) { break; } } } } if (hits > 0 && !center.Equals(Vector2.Zero)) { return(minions.OrderBy(m => m.Position.Distance(center.To3D())).FirstOrDefault()); } return(null); }
public void BeforeOrbwalk() { if (ObjectManager.Player.HealthPercent < 25 && ObjectManager.Player.CountEnemiesInRange(1200) > 0) { Spells[E].CastOnUnit(ObjectManager.Player); } if (Orbwalker.ActiveMode == SCommon.Orbwalking.Orbwalker.Mode.None) { Helpers.BallMgr.ClearWorkQueue(); if (ConfigMenu.Item("HTOGGLE").GetValue <KeyBind>().Active) { Harass(); } } if (Orbwalker.ActiveMode == SCommon.Orbwalking.Orbwalker.Mode.None) { if (Spells[R].IsReady() && Helpers.BallMgr.IsBallReady && ConfigMenu.Item("MAUTOR").GetValue <bool>()) { if (CountEnemiesInRangePredicted(Spells[R].Range, 100, 0.75f) >= ConfigMenu.Item("MAUTORHIT").GetValue <Slider>().Value) { Helpers.BallMgr.Post(Helpers.BallMgr.Command.Shockwave, null); } else { if (Spells[Q].IsReady()) { List <Vector2> poses = new List <Vector2>(); foreach (var enemy in HeroManager.Enemies) { if (enemy.IsValidTarget(Spells[Q].Range)) { var pos = LeagueSharp.Common.Prediction.GetPrediction(enemy, 0.75f).UnitPosition.To2D(); if (pos.Distance(ObjectManager.Player.ServerPosition.To2D()) <= 800) { poses.Add(LeagueSharp.Common.Prediction.GetPrediction(enemy, 0.75f).UnitPosition.To2D()); } } } foreach (var list in GetCombinations(poses)) { if (list.Count >= ConfigMenu.Item("MAUTORHIT").GetValue <Slider>().Value) { Vector2 center; float radius; MEC.FindMinimalBoundingCircle(poses, out center, out radius); if (radius < Spells[R].Width && center.Distance(ObjectManager.Player.ServerPosition) < 825f) { Helpers.BallMgr.Post(Helpers.BallMgr.Command.Attack, null, center); Helpers.BallMgr.Post(Helpers.BallMgr.Command.Shockwave, null); return; } } } } } } } }
private Tuple <int, Vector3> BestQPosition(Obj_AI_Base target, List <Obj_AI_Base> targets, HitChance hitChance) { var castPos = Vector3.Zero; var totalHits = 0; try { var enemies = targets.Where(e => e.IsValidTarget(Q.Range * 1.5f)).ToList(); var enemyPositions = new List <Tuple <Obj_AI_Base, Vector3> >(); var circle = new Geometry.Polygon.Circle(Player.Position, Player.BoundingRadius, 30).Points; foreach (var h in enemies) { var ePred = Q.GetPrediction(h); if (ePred.Hitchance >= hitChance) { circle.Add(Player.Position.Extend(ePred.UnitPosition, Player.BoundingRadius).To2D()); enemyPositions.Add(new Tuple <Obj_AI_Base, Vector3>(h, ePred.UnitPosition)); } } var targetPos = target == null ? Vector3.Zero : target.Position; if (target == null) { var possibilities = ListExtensions.ProduceEnumeration(enemyPositions).Where(p => p.Count > 0).ToList(); var count = 0; foreach (var possibility in possibilities) { var mec = MEC.GetMec(possibility.Select(p => p.Item2.To2D()).ToList()); if (mec.Radius < Q.Width && possibility.Count > count) { count = possibility.Count; targetPos = mec.Center.To3D(); } } } if (targetPos.Equals(Vector3.Zero)) { return(new Tuple <int, Vector3>(totalHits, castPos)); } circle = circle.OrderBy(c => c.Distance(targetPos)).ToList(); if (!enemyPositions.Any()) { return(new Tuple <int, Vector3>(totalHits, castPos)); } foreach (var point in circle) { var hits = 0; var containsTarget = false; var direction = Q.Range * (point.To3D() - Player.Position).Normalized().To2D(); var rect1 = new Geometry.Polygon.Rectangle( Player.Position, Player.Position.Extend(Player.Position + direction.To3D(), Q.Range), Q.Width); var rect2 = new Geometry.Polygon.Rectangle( Player.Position, Player.Position.Extend(Player.Position + direction.Rotated(QAngle).To3D(), Q.Range), Q.Width); var rect3 = new Geometry.Polygon.Rectangle( Player.Position, Player.Position.Extend(Player.Position + direction.Rotated(-QAngle).To3D(), Q.Range), Q.Width); foreach (var enemy in enemyPositions) { var bounding = new Geometry.Polygon.Circle(enemy.Item2, enemy.Item1.BoundingRadius * 0.85f); if (bounding.Points.Any(p => rect1.IsInside(p) || rect2.IsInside(p) || rect3.IsInside(p))) { hits++; if (target != null && enemy.Item1.NetworkId.Equals(target.NetworkId)) { containsTarget = true; } } } if ((containsTarget || target == null) && hits > totalHits) { totalHits = hits; castPos = Player.Position.Extend(point.To3D(), Q.Range); if (totalHits >= enemies.Count) { break; } } } } catch (Exception ex) { Global.Logger.AddItem(new LogItem(ex)); } return(new Tuple <int, Vector3>(totalHits, castPos)); }
static void CalcUlt() { if (config.SubMenu("ult").Item("ultEnemy").GetValue <KeyBind>().Active) { predictions.Clear(); enemiesGettingHit.Clear(); AddPredictions(); if (predictions.Count >= config.SubMenu("ult").Item("ultEnemyCount").GetValue <Slider>().Value) { MEC.FindMinimalBoundingCircle(predictions, out circleCenter, out circleRadius); FindFarPoints(); if (predictions.Count >= config.SubMenu("ult").Item("ultEnemyCount").GetValue <Slider>().Value) { MEC.FindMinimalBoundingCircle(predictions, out betterCircleCenter, out betterCircleRadius); if (predictions.Count >= config.SubMenu("ult").Item("ultEnemyCount").GetValue <Slider>().Value&& betterCircleCenter.Distance(ObjectManager.Player.Position) <= R.Range) { draw = true; if (config.SubMenu("ult").SubMenu("misc").Item("useBetterPred").GetValue <bool>() && BetterPredition() >= config.SubMenu("ult").Item("ultEnemyCount").GetValue <Slider>().Value) { Ult(); } else if (!config.SubMenu("ult").SubMenu("misc").Item("useBetterPred").GetValue <bool>()) { Ult(); } } else { draw = false; //Console.WriteLine("Less points: " + predictions.Count.ToString()); } } } } if (R.IsReady()) { foreach (var ally in ObjectManager.Get <AIHeroClient>().Where(x => x.IsAlly && !x.IsDead)) { if (config.SubMenu("ult").SubMenu("allies").Item(ally.ChampionName).GetValue <bool>() && !ally.IsRecalling()) { float flyTime = ObjectManager.Player.Distance(ally) / R.Speed; float healthPrediction = HealthPrediction.GetHealthPrediction(ally, (int)(R.Delay + flyTime)); if (healthPrediction >= 1 && healthPrediction <= config.SubMenu("ult").Item("ultAllyAtXHp").GetValue <Slider>().Value&& ObjectManager.Get <AIHeroClient>().Where(x => x.IsEnemy && !x.IsDead).Count() > 0) { var allyPosPrediction = Prediction.GetPrediction(ally, R.Delay + flyTime); if (allyPosPrediction.CastPosition.Distance(ObjectManager.Player.Position) <= R.Range && allyPosPrediction.Hitchance >= HitChance.Medium) { R.Cast(allyPosPrediction.CastPosition); } } } } } }
private PredictionOutput GetAreaOfEffectPrediction(PredictionInput input, PredictionOutput output) { var targets = new List <PredictionOutput>(); // main target output.AoeTargetsHit = new List <PredictionOutput> { output }; targets.Add(output); foreach (var target in input.AreaOfEffectTargets) { var targetPrediction = this.GetSimplePrediction(input.WithTarget(target)); if (this.IsInRange(input, targetPrediction.UnitPosition)) { targets.Add(targetPrediction); } } switch (input.PredictionSkillshotType) { case PredictionSkillshotType.SkillshotCircle: if (input.AreaOfEffectHitMainTarget) { while (targets.Count > 1) { var mecResult = MEC.GetMec(targets.Select((target) => target.UnitPosition.ToVector2()).ToList()); // add hullradius? if (mecResult.Radius != 0f && mecResult.Radius < input.Radius && this.IsInRange(input, mecResult.Center.ToVector3())) { output.CastPosition = new Vector3( targets.Count <= 2 ? (targets[0].UnitPosition.ToVector2() + targets[1].UnitPosition.ToVector2()) / 2 : mecResult.Center, output.CastPosition.Z); output.AoeTargetsHit = targets.Where((target) => output.CastPosition.IsInRange(target.UnitPosition, input.Radius)).ToList(); break; } var itemToRemove = targets.MaxOrDefault((target) => targets[0].UnitPosition.DistanceSquared(target.UnitPosition)); targets.Remove(itemToRemove); } } else { // TODO: handle the AreaOfEffectHitMainTarget=false case } break; case PredictionSkillshotType.SkillshotCone: break; case PredictionSkillshotType.SkillshotLine: break; default: break; } return(output); }
private void GetAreaOfEffectPrediction(PredictionInput9 input, PredictionOutput9 output) { var targets = new List <PredictionOutput9>(); foreach (var target in input.AreaOfEffectTargets.Where(x => !x.Equals(output.Target))) { var aoeTargetInput = new PredictionInput9 { Target = target, Caster = input.Caster, Delay = input.Delay, Speed = input.Speed, CastRange = input.CastRange, Radius = input.Radius, RequiresToTurn = input.RequiresToTurn }; var aoeTargetOutput = this.GetSimplePrediction(aoeTargetInput); var range = input.SkillShotType == SkillShotType.Line ? input.Range + input.CastRange : input.Range; if (input.Caster.Distance(aoeTargetOutput.CastPosition) < range) { targets.Add(aoeTargetOutput); } } switch (input.SkillShotType) { case SkillShotType.RangedAreaOfEffect: { targets.Insert(0, output); output.CastPosition = input.Target.Position; output.AoeTargetsHit = targets.Where(x => output.CastPosition.IsInRange(x.TargetPosition, input.Radius)).ToList(); if (!output.AoeTargetsHit.Contains(output)) { output.AoeTargetsHit.Add(output); } break; } case SkillShotType.AreaOfEffect: { targets.Insert(0, output); output.CastPosition = input.CastRange > 0 ? input.Caster.InFront(input.CastRange) : input.Caster.Position; output.AoeTargetsHit = targets.Where(x => output.CastPosition.IsInRange(x.TargetPosition, input.Radius)).ToList(); break; } case SkillShotType.Circle: { targets.Insert(0, output); if (targets.Count == 1) { output.AoeTargetsHit.Add(output); } else { while (targets.Count > 1) { var mecResult = MEC.GetMec(targets.Select(x => x.TargetPosition.ToVector2()).ToList()); if (mecResult.Radius > 0 && mecResult.Radius < input.Radius && input.Caster.Distance(mecResult.Center.ToVector3()) < input.Range) { output.CastPosition = new Vector3( targets.Count <= 2 ? (targets[0].TargetPosition.ToVector2() + targets[1].TargetPosition.ToVector2()) / 2 : mecResult.Center, output.CastPosition.Z); output.AoeTargetsHit = targets.Where(x => output.CastPosition.IsInRange(x.TargetPosition, input.Radius)) .ToList(); break; } var itemToRemove = targets.MaxOrDefault(x => targets[0].TargetPosition.DistanceSquared(x.TargetPosition)); targets.Remove(itemToRemove); output.AoeTargetsHit.Add(output); } } break; } case SkillShotType.Cone: { targets.Insert(0, output); if (targets.Count > 1) { // yolo var polygons = new Dictionary <Polygon.Trapezoid, List <PredictionOutput9> >(); if (input.UseBlink) { var targetPosition = output.TargetPosition; var otherTargets = targets.Skip(1).ToList(); foreach (var predictionOutput9 in otherTargets) { var aoeTargetPosition = predictionOutput9.TargetPosition; var averagePosition = (targetPosition + aoeTargetPosition) / 2; var start = targetPosition.Extend2D(aoeTargetPosition, -100); var end = start.Extend2D(aoeTargetPosition, input.Range); var rec = new Polygon.Trapezoid(start, end, input.Radius, input.EndRadius); foreach (var output9 in otherTargets) { if (output9.Target == predictionOutput9.Target) { continue; } var averagePosition2 = (averagePosition + output9.TargetPosition) / 2; var start2 = targetPosition.Extend2D(averagePosition2, -100); var end2 = start2.Extend2D(averagePosition2, input.Range); var rec2 = new Polygon.Trapezoid(start2, end2, input.Radius + 50, input.EndRadius + 50); if (!rec2.IsInside(aoeTargetPosition) || !rec2.IsInside(output9.TargetPosition)) { continue; } rec = rec2; } polygons[rec] = targets.Where(x => rec.IsInside(x.TargetPosition)).ToList(); } } else { var startPosition = input.Caster.Position; foreach (var predictionOutput in targets) { var endPosition = startPosition.Extend2D(predictionOutput.TargetPosition, input.Range); var rec = new Polygon.Trapezoid(startPosition, endPosition, input.Radius * 1.4f, input.EndRadius * 1.8f); if (rec.IsOutside(output.TargetPosition.To2D())) { continue; } polygons[rec] = targets.Where(x => rec.IsInside(x.TargetPosition)).ToList(); } } var polygon = polygons.MaxOrDefault(x => x.Value.Count); if (polygon.Key != null) { var positions = polygon.Value.ToList(); var center = positions.Aggregate(new Vector3(), (sum, pos) => sum + pos.TargetPosition) / positions.Count; if (positions.Count == 0) { output.HitChance = HitChance.Impossible; return; } var max = positions.Max( x => input.UseBlink ? output.TargetPosition.Distance(x.TargetPosition) : input.Caster.Distance(x.TargetPosition)); var range = Math.Min(input.UseBlink ? input.Range : input.CastRange, max); output.CastPosition = input.UseBlink ? output.TargetPosition.Extend2D(center, range) : input.Caster.Position.Extend2D(center, range); output.AoeTargetsHit = polygon.Value; } } else { output.AoeTargetsHit.Add(output); if (input.UseBlink) { input.AreaOfEffect = false; } } if (input.UseBlink) { output.BlinkLinePosition = input.Caster.Distance(output.TargetPosition) > input.CastRange ? input.Caster.Position.Extend2D(output.TargetPosition, input.CastRange) : output.TargetPosition.Extend2D(output.CastPosition, -100); if (input.Caster.Distance(output.BlinkLinePosition) > input.CastRange) { output.HitChance = HitChance.Impossible; } } break; } case SkillShotType.Line: { targets.Insert(0, output); if (targets.Count > 1) { // yolo var polygons = new Dictionary <Polygon.Rectangle, List <PredictionOutput9> >(); if (input.UseBlink) { var targetPosition = output.TargetPosition; var otherTargets = targets.Skip(1).ToList(); foreach (var predictionOutput9 in otherTargets) { var aoeTargetPosition = predictionOutput9.TargetPosition; var averagePosition = (targetPosition + aoeTargetPosition) / 2; var start = targetPosition.Extend2D(aoeTargetPosition, -100); var end = start.Extend2D(aoeTargetPosition, input.Range); var rec = new Polygon.Rectangle(start, end, input.Radius); foreach (var output9 in otherTargets) { if (output9.Target == predictionOutput9.Target) { continue; } var averagePosition2 = (averagePosition + output9.TargetPosition) / 2; var start2 = targetPosition.Extend2D(averagePosition2, -100); var end2 = start2.Extend2D(averagePosition2, input.Range); var rec2 = new Polygon.Rectangle(start2, end2, input.Radius + 50); if (!rec2.IsInside(aoeTargetPosition) || !rec2.IsInside(output9.TargetPosition)) { continue; } rec = rec2; } polygons[rec] = targets.Where(x => rec.IsInside(x.TargetPosition)).ToList(); } } else { var startPosition = input.Caster.Position; foreach (var predictionOutput in targets) { var endPosition = startPosition.Extend2D(predictionOutput.TargetPosition, input.Range); var rec = new Polygon.Rectangle(startPosition, endPosition, input.Radius * 1.3f); if (rec.IsOutside(output.TargetPosition.To2D())) { continue; } polygons[rec] = targets.Where(x => rec.IsInside(x.TargetPosition)).ToList(); } } var polygon = polygons.MaxOrDefault(x => x.Value.Count); if (polygon.Key != null) { var positions = polygon.Value.ToList(); var center = positions.Aggregate(new Vector3(), (sum, pos) => sum + pos.TargetPosition) / positions.Count; if (positions.Count == 0) { output.HitChance = HitChance.Impossible; return; } var max = positions.Max( x => input.UseBlink ? output.TargetPosition.Distance(x.TargetPosition) : input.Caster.Distance(x.TargetPosition)); var range = Math.Min(input.UseBlink ? input.Range : input.CastRange, max); output.CastPosition = input.UseBlink ? output.TargetPosition.Extend2D(center, range) : input.Caster.Position.Extend2D(center, range); output.AoeTargetsHit = polygon.Value; } } else { output.AoeTargetsHit.Add(output); if (input.UseBlink) { input.AreaOfEffect = false; } } if (input.UseBlink) { output.BlinkLinePosition = input.Caster.Distance(output.TargetPosition) > input.CastRange ? input.Caster.Position.Extend2D(output.TargetPosition, input.CastRange) : output.TargetPosition.Extend2D(output.CastPosition, -100); if (input.Caster.Distance(output.BlinkLinePosition) > input.CastRange) { output.HitChance = HitChance.Impossible; } } break; } } }
private static void OnCombo() { var qTarget = TargetSelector.GetTarget(Variables.spells[SpellSlot.Q].Range / 1.5f, TargetSelector.DamageType.Magical); if (Variables.AssemblyMenu.Item("dz191.orianna.combo.q").GetValue <bool>() && Variables.spells[SpellSlot.Q].IsReady() && qTarget.IsValidTarget()) { if (qTarget.IsValidTarget()) { //TODO Q so it gets most targets possible. var qPrediction = Prediction.GetPrediction( qTarget, 0.75f); //Only when health is > 35% if (ObjectManager.Player.HealthPercent >= 35) { var enemyHeroesPositions = HeroManager.Enemies.Select(hero => hero.Position.To2D()).ToList(); var Groups = Helper.GetCombinations(enemyHeroesPositions); //TODO Iterate through all the MEC and pick the best one. foreach (var group in Groups) { if (group.Count >= 3) { var MEC_Circle = MEC.GetMec(group); if (Variables.spells[SpellSlot.Q].IsReady() && MEC_Circle.Center.Distance(ObjectManager.Player) <= Variables.spells[SpellSlot.Q].Range && MEC_Circle.Radius <= Variables.spells[SpellSlot.Q].Range && MEC_Circle.Center.To3D().CountEnemiesInRange(Variables.spells[SpellSlot.Q].Range) >= 3) { Variables.BallManager.ProcessCommand(new Command() { SpellCommand = Commands.Q, Where = MEC_Circle.Center.To3D() }); return; } } } } //If it can find a suitable > 3 enemies position we will Q there. Variables.BallManager.ProcessCommand(new Command() { SpellCommand = Commands.Q, Where = qPrediction.UnitPosition }); } } if (Variables.AssemblyMenu.Item("dz191.orianna.combo.w").GetValue <bool>() && Variables.spells[SpellSlot.W].IsReady()) { var ballPosition = Variables.BallManager.BallPosition; var minWEnemies = Variables.AssemblyMenu.Item("dz191.orianna.combo.minw").GetValue <Slider>().Value; if (ObjectManager.Player.CountEnemiesInRange(Variables.spells[SpellSlot.Q].Range + 250f) > 1) { if (ballPosition.CountEnemiesInRange(Variables.spells[SpellSlot.W].Range) >= minWEnemies) { Variables.BallManager.ProcessCommand(new Command() { SpellCommand = Commands.W, }); } } else { if (ballPosition.CountEnemiesInRange(Variables.spells[SpellSlot.W].Range) > 0) { Variables.BallManager.ProcessCommand(new Command() { SpellCommand = Commands.W, }); } } } if (Variables.AssemblyMenu.Item("dz191.orianna.combo.r").GetValue <bool>() && Variables.spells[SpellSlot.R].IsReady()) { if (ObjectManager.Player.CountEnemiesInRange(Variables.spells[SpellSlot.Q].Range + 250f) > 1 && ObjectManager.Player.CountEnemiesInRange(Variables.spells[SpellSlot.Q].Range + 250f) > 1) { var enemyHeroesPositions = HeroManager.Enemies.Select(hero => hero.Position.To2D()).ToList(); var Groups = Helper.GetCombinations(enemyHeroesPositions); //TODO Iterate through all the MEC and pick the best one. foreach (var group in Groups) { if (group.Count >= Variables.AssemblyMenu.Item("dz191.orianna.combo.minr").GetValue <Slider>().Value) { var MEC_Circle = MEC.GetMec(group); if (Variables.spells[SpellSlot.Q].IsReady() && MEC_Circle.Center.Distance(ObjectManager.Player) <= Variables.spells[SpellSlot.Q].Range && MEC_Circle.Radius <= Variables.spells[SpellSlot.R].Range && MEC_Circle.Center.To3D().CountEnemiesInRange(Variables.spells[SpellSlot.R].Range) >= Variables.AssemblyMenu.Item("dz191.orianna.combo.minr").GetValue <Slider>().Value) { Variables.spells[SpellSlot.Q].Cast(MEC_Circle.Center.To3D()); LeagueSharp.Common.Utility.DelayAction.Add( (int) (Variables.BallManager.BallPosition.Distance(MEC_Circle.Center.To3D()) / Variables.spells[SpellSlot.Q].Speed * 1000 + Variables.spells[SpellSlot.Q].Delay * 1000 + Game.Ping / 2f + 125f), () => { if ( Variables.BallManager.BallPosition.CountEnemiesInRange( Variables.spells[SpellSlot.R].Range) >= Variables.AssemblyMenu.Item("dz191.orianna.combo.minr") .GetValue <Slider>() .Value) { Variables.spells[SpellSlot.R].Cast(); } }); } } } } else { var target = TargetSelector.GetTarget(Variables.spells[SpellSlot.Q].Range / 1.2f, TargetSelector.DamageType.Magical); if (target != null && target.Health + 10f < ObjectManager.Player.GetComboDamage(target, new[] { SpellSlot.Q, SpellSlot.W, SpellSlot.R }) && !(target.Health + 10f < ObjectManager.Player.GetComboDamage(target, new[] { SpellSlot.Q, SpellSlot.W }))) { var rPosition = target.ServerPosition.Extend( ObjectManager.Player.ServerPosition, Variables.spells[SpellSlot.R].Range / 2f); if (Variables.spells[SpellSlot.Q].IsReady() && rPosition.Distance(ObjectManager.Player.ServerPosition) <= Variables.spells[SpellSlot.Q].Range) { Variables.spells[SpellSlot.Q].Cast(rPosition); LeagueSharp.Common.Utility.DelayAction.Add( (int) (Variables.BallManager.BallPosition.Distance(rPosition) / Variables.spells[SpellSlot.Q].Speed * 1000 + Variables.spells[SpellSlot.Q].Delay * 1000 + Game.Ping / 2f + 125f), () => { if ( Variables.BallManager.BallPosition.CountEnemiesInRange( Variables.spells[SpellSlot.R].Range) > 0) { Variables.spells[SpellSlot.R].Cast(); } }); } } } } if (Variables.AssemblyMenu.Item("dz191.orianna.combo.e").GetValue <bool>() && Variables.spells[SpellSlot.E].IsReady()) { //Determine the ally to shield with E or me. if (ObjectManager.Player.Health <= Helper.GetItemValue <Slider>("dz191.orianna.misc.e.percent").Value && ObjectManager.Player.CountEnemiesInRange(1100f) > 0) { //If we're low life the ball always goes to us. Variables.spells[SpellSlot.E].Cast(ObjectManager.Player); return; } //TODO Ally Shielding Logic. } }
public MessageElement(MEC elementCode, byte[] data) : this() { ElementCode = elementCode; Data = data; }
private static void OnCombo() { var qTarget = TargetSelector.GetTarget(Variables.spells[SpellSlot.Q].Range / 1.5f, TargetSelector.DamageType.Magical); if (Variables.AssemblyMenu.Item("dz191.orianna.combo.q").GetValue <bool>() && Variables.spells[SpellSlot.Q].IsReady() && qTarget.IsValidTarget()) { if (qTarget.IsValidTarget()) { //TODO Q so it gets most targets possible. var qPrediction = Prediction.GetPrediction( qTarget, 0.75f); Variables.BallManager.ProcessCommand(new Command() { SpellCommand = Commands.Q, Where = qPrediction.UnitPosition }); } } if (Variables.AssemblyMenu.Item("dz191.orianna.combo.w").GetValue <bool>() && Variables.spells[SpellSlot.W].IsReady()) { var ballPosition = Variables.BallManager.BallPosition; var minWEnemies = Variables.AssemblyMenu.Item("dz191.orianna.combo.minw").GetValue <Slider>().Value; if (ObjectManager.Player.CountEnemiesInRange(Variables.spells[SpellSlot.Q].Range + 250f) > 1) { if (ballPosition.CountEnemiesInRange(Variables.spells[SpellSlot.W].Range) >= minWEnemies) { Variables.BallManager.ProcessCommand(new Command() { SpellCommand = Commands.W, }); } } else { if (ballPosition.CountEnemiesInRange(Variables.spells[SpellSlot.W].Range) > 0) { Variables.BallManager.ProcessCommand(new Command() { SpellCommand = Commands.W, }); } } } if (Variables.AssemblyMenu.Item("dz191.orianna.combo.r").GetValue <bool>() && Variables.spells[SpellSlot.R].IsReady()) { if (ObjectManager.Player.CountEnemiesInRange(Variables.spells[SpellSlot.Q].Range + 250f) > 1 && ObjectManager.Player.CountEnemiesInRange(Variables.spells[SpellSlot.Q].Range + 250f) > 1) { var enemyHeroesPositions = HeroManager.Enemies.Select(hero => hero.Position.To2D()).ToList(); var Groups = Helper.GetCombinations(enemyHeroesPositions); //TODO Iterate through all the MEC and pick the best one. foreach (var group in Groups) { if (group.Count >= Variables.AssemblyMenu.Item("dz191.orianna.combo.minr").GetValue <Slider>().Value) { var MEC_Circle = MEC.GetMec(group); if (Variables.spells[SpellSlot.Q].IsReady() && MEC_Circle.Center.Distance(ObjectManager.Player) <= Variables.spells[SpellSlot.Q].Range && MEC_Circle.Radius <= Variables.spells[SpellSlot.R].Range && MEC_Circle.Center.To3D().CountEnemiesInRange(Variables.spells[SpellSlot.R].Range) >= Variables.AssemblyMenu.Item("dz191.orianna.combo.minr").GetValue <Slider>().Value) { Variables.spells[SpellSlot.Q].Cast(MEC_Circle.Center.To3D()); LeagueSharp.Common.Utility.DelayAction.Add( (int) (Variables.BallManager.BallPosition.Distance(MEC_Circle.Center.To3D()) / Variables.spells[SpellSlot.Q].Speed * 1000 + Variables.spells[SpellSlot.Q].Delay * 1000 + Game.Ping / 2f + 125f), () => { if ( Variables.BallManager.BallPosition.CountEnemiesInRange( Variables.spells[SpellSlot.R].Range) >= Variables.AssemblyMenu.Item("dz191.orianna.combo.minr") .GetValue <Slider>() .Value) { Variables.spells[SpellSlot.R].Cast(); } }); } } } } else { var target = TargetSelector.GetTarget(Variables.spells[SpellSlot.Q].Range / 1.2f, TargetSelector.DamageType.Magical); if (target != null && target.Health + 10f < ObjectManager.Player.GetComboDamage(target, new[] { SpellSlot.Q, SpellSlot.W, SpellSlot.R }) && !(target.Health + 10f < ObjectManager.Player.GetComboDamage(target, new[] { SpellSlot.Q, SpellSlot.W }))) { var rPosition = target.ServerPosition.Extend( ObjectManager.Player.ServerPosition, Variables.spells[SpellSlot.R].Range / 2f); if (Variables.spells[SpellSlot.Q].IsReady() && rPosition.Distance(ObjectManager.Player.ServerPosition) <= Variables.spells[SpellSlot.Q].Range) { Variables.spells[SpellSlot.Q].Cast(rPosition); LeagueSharp.Common.Utility.DelayAction.Add( (int) (Variables.BallManager.BallPosition.Distance(rPosition) / Variables.spells[SpellSlot.Q].Speed * 1000 + Variables.spells[SpellSlot.Q].Delay * 1000 + Game.Ping / 2f + 125f), () => { if ( Variables.BallManager.BallPosition.CountEnemiesInRange( Variables.spells[SpellSlot.R].Range) > 0) { Variables.spells[SpellSlot.R].Cast(); } }); } } } } if (Variables.AssemblyMenu.Item("dz191.orianna.combo.e").GetValue <bool>() && Variables.spells[SpellSlot.E].IsReady()) { //Determine the ally to shield with E or me. if (ObjectManager.Player.Health <= Helper.GetItemValue <Slider>("dz191.orianna.misc.e.percent").Value && ObjectManager.Player.CountEnemiesInRange(1100f) > 0) { //If we're low life the ball always goes to us. Variables.spells[SpellSlot.E].Cast(ObjectManager.Player); return; } /** * var lhAllies = * HeroManager.Allies.Where( * m => * m.HealthPercent < Helper.GetItemValue<Slider>("dz191.orianna.misc.e.percent").Value && * Helper.GetItemValue<bool>($"dz191.orianna.misc.e.shield.{m.ChampionName}") && * m.CountEnemiesInRange(425f) > 1).ToList(); * * if (lhAllies.Any()) * { * Variables.spells[SpellSlot.E].Cast(lhAllies.OrderBy(m => m.Health).FirstOrDefault()); * return; * } * * if (Helper.GetItemValue<bool>("dz191.orianna.misc.e.damage")) * { * foreach (var ally in HeroManager.Allies.Where(ally => ally.IsValidTarget(Variables.spells[SpellSlot.E].Range, false))) * { * var eHits = Helper.getEHits(ally.ServerPosition); * if (eHits.Count() > 2) * { * Variables.spells[SpellSlot.E].Cast(ally); * return; * } * } * } */ } }
private static Tuple <Vector3, int> getMECQPos(Obj_AI_Hero target) { var pointsList = new List <Vector2>(); PredictionOutput targetPred = Q.GetPrediction(target); if (targetPred.Hitchance >= HitChance.High) { pointsList.Add(targetPred.CastPosition.To2D()); } foreach (Obj_AI_Hero current in ObjectManager.Get <Obj_AI_Hero>()) { if (!current.IsMe && current.NetworkId != target.NetworkId && current.IsEnemy && current.IsValidTarget(Q.Range + (R.Width / 2))) { PredictionOutput prediction = Q.GetPrediction(current); if (prediction.Hitchance >= HitChance.High) { pointsList.Add(prediction.CastPosition.To2D()); } } } while (pointsList.Count != 0) { MEC.MecCircle circle = MEC.GetMec(pointsList); int numPoints = pointsList.Count; if (circle.Radius <= (R.Width / 2) && numPoints >= 3 && R.IsReady()) { return(Tuple.Create(circle.Center.To3D(), 3)); } if (circle.Radius <= (W.Width / 2) && numPoints >= 2 && W.IsReady()) { return(Tuple.Create(circle.Center.To3D(), 2)); } if (pointsList.Count == 1) { return(Tuple.Create(circle.Center.To3D(), 1)); } if (circle.Radius <= ((Q.Width / 2) + 50) && numPoints > 1) { return(Tuple.Create(circle.Center.To3D(), 4)); } try { float distance = -1f; int index = 0; Vector2 point = pointsList.ElementAt(0); for (int i = 1; i == numPoints; i++) { if (Vector2.Distance(pointsList.ElementAt(i), point) >= distance) { distance = Vector2.Distance(pointsList.ElementAt(i), point); index = i; } } pointsList.RemoveAt(index); } catch (ArgumentOutOfRangeException) { var outOfRange = new Vector3(0); return(Tuple.Create(outOfRange, -1)); } } var noResult = new Vector3(0); return(Tuple.Create(noResult, -1)); }
private async Task HealingWardController(CancellationToken token) { if (UnitExtensions.HasAghanimsScepter(this.Owner)) { this.SwiftSlash = this.Owner.Spellbook.Spells.FirstOrDefault <Ability>(x => x.Name == "juggernaut_swift_slash"); } if (this.healingWardUnit == null) { return; } var team = this.healingWardUnit.Team; var healingRadius = this.HealingWardAbility.Radius; while ((this.healingWardUnit != null) && this.healingWardUnit.IsValid && this.healingWardUnit.IsAlive) { if (Game.IsPaused) { await Task.Delay(125, token); continue; } var enemyHeroes = EntityManager <Hero> .Entities.Where( x => x.IsAlive && x.IsVisible && (x.Team != team) && (x.Distance2D(this.healingWardUnit) < 1000)) .ToList(); var alliedHeroes = EntityManager <Hero> .Entities.Where( x => x.IsAlive && x.IsVisible && (x.Team == team) && (x.HealthPercent() <= 0.9f) && (x.Distance2D(this.healingWardUnit) < 800)) .OrderBy(x => x.HealthPercent()) .ToList(); if (!alliedHeroes.Any()) { if (!this.Owner.IsAlive) { await Task.Delay(125, token); continue; } alliedHeroes.Add(this.Owner); } var avoidCircles = new List <Polygon.Circle>(enemyHeroes.Count); foreach (var enemyHero in enemyHeroes) { var dangerRange = enemyHero.AttackRange(this.healingWardUnit); dangerRange = enemyHero.IsMelee ? dangerRange * 2f : dangerRange * 1.2f; var circle = new Polygon.Circle(enemyHero.Position, dangerRange); avoidCircles.Add(circle); } var healCircles = new List <Polygon.Circle>(alliedHeroes.Count); foreach (var alliedHero in alliedHeroes) { var circle = new Polygon.Circle(alliedHero.Position, healingRadius); if (avoidCircles.Exists(x => x.Center.Distance(circle.Center) <= Math.Abs(x.Radius - circle.Radius))) { continue; } healCircles.Add(circle); } var hasMoved = false; if (healCircles.Any()) { while (healCircles.Count > 1) { var mecResult = MEC.GetMec(healCircles.Select((target) => target.Center).ToList()); if ((mecResult.Radius != 0f) && (mecResult.Radius < healingRadius)) { var movePos = new Vector3( healCircles.Count <= 2 ? (healCircles[0].Center + healCircles[1].Center) / 2 : mecResult.Center, this.healingWardUnit.Position.Z); if (avoidCircles.TrueForAll(x => !x.IsInside(movePos))) { this.healingWardUnit.Move(movePos); hasMoved = true; break; } } var itemToRemove = healCircles.Where(x => x.Center != this.Owner.Position.ToVector2()) .MaxOrDefault((target) => healCircles[0].Center.DistanceSquared(target.Center)); healCircles.Remove(itemToRemove); } } if (!healCircles.Any() || !hasMoved) { var isOwnerLow = this.Owner.HealthPercent() <= 0.5f; var heroPos = isOwnerLow ? this.Owner.Position : alliedHeroes.First().Position; if (!avoidCircles.Any()) { this.healingWardUnit.Move(heroPos); } else { var z = this.healingWardUnit.Position.Z; var clusterPos = Vector3.Zero; foreach (var avoidCircle in avoidCircles) { clusterPos += avoidCircle.Center.ToVector3(z); } clusterPos /= avoidCircles.Count; var movePos = (clusterPos - heroPos).Normalized(); movePos = heroPos + (movePos * healingRadius * -1f); this.healingWardUnit.Move(movePos); } } await Task.Delay(125, token); } this.healingWardUnit = null; }
public static Result Circle(Spell spell, Obj_AI_Hero target, HitChance hitChance, bool boundingRadius = true, bool extended = true) { try { if (spell == null || target == null) { return(new Result(Vector3.Zero, new List <Obj_AI_Hero>())); } var hits = new List <Obj_AI_Hero>(); var center = Vector3.Zero; var radius = float.MaxValue; var range = spell.Range + (extended ? spell.Width * 0.85f : 0) + (boundingRadius ? target.BoundingRadius * BoundingRadiusMultiplicator : 0); var positions = (from t in GameObjects.EnemyHeroes where t.IsValidTarget(range * 1.5f, true, spell.RangeCheckFrom) let prediction = spell.GetPrediction(t) where prediction.Hitchance >= hitChance select new Position(t, prediction.UnitPosition)).ToList(); var spellWidth = spell.Width; if (positions.Any()) { var mainTarget = positions.FirstOrDefault(p => p.Hero.NetworkId == target.NetworkId); var possibilities = ListExtensions.ProduceEnumeration( positions.Where( p => p.UnitPosition.Distance(mainTarget.UnitPosition) <= spell.Width * 0.85f).ToList()) .Where(p => p.Count > 0 && p.Any(t => t.Hero.NetworkId == mainTarget.Hero.NetworkId)) .ToList(); foreach (var possibility in possibilities) { var mec = MEC.GetMec(possibility.Select(p => p.UnitPosition.To2D()).ToList()); var distance = spell.From.Distance(mec.Center.To3D()); if (mec.Radius < spellWidth && distance < range) { var lHits = new List <Obj_AI_Hero>(); var circle = new Geometry.Polygon.Circle( spell.From.Extend( mec.Center.To3D(), spell.Range > distance ? distance : spell.Range), spell.Width); if (boundingRadius) { lHits.AddRange( from position in positions where new Geometry.Polygon.Circle( position.UnitPosition, position.Hero.BoundingRadius * BoundingRadiusMultiplicator).Points.Any( p => circle.IsInside(p)) select position.Hero); } else { lHits.AddRange( from position in positions where circle.IsInside(position.UnitPosition) select position.Hero); } if ((lHits.Count > hits.Count || lHits.Count == hits.Count && mec.Radius < radius || lHits.Count == hits.Count && spell.From.Distance(circle.Center.To3D()) < spell.From.Distance(center)) && lHits.Any(p => p.NetworkId == target.NetworkId)) { center = circle.Center.To3D2(); radius = mec.Radius; hits.Clear(); hits.AddRange(lHits); } } } if (!center.Equals(Vector3.Zero)) { return(new Result(center, hits)); } } } catch (Exception ex) { Global.Logger.AddItem(new LogItem(ex)); } return(new Result(Vector3.Zero, new List <Obj_AI_Hero>())); }
private async Task OnHealingWardControl(CancellationToken token) { if (this.healingWardUnit == null) { return; } var team = this.healingWardUnit.Team; var healingRadius = this.HealingWard.Radius; while ((this.healingWardUnit != null) && this.healingWardUnit.IsValid && this.healingWardUnit.IsAlive) { if (Game.IsPaused) { await Task.Delay(125, token); continue; } var enemyHeroes = EntityManager <Hero> .Entities.Where(x => x.IsAlive && x.IsVisible && (x.Team != team) && (x.Distance2D(this.healingWardUnit) < 1000)).ToList(); var alliedHeroes = EntityManager <Hero> .Entities.Where(x => x.IsAlive && x.IsVisible && (x.Team == team) && (x.HealthPercent() <= 0.9f) && (x.Distance2D(this.healingWardUnit) < 800)) .OrderBy(x => x.HealthPercent()) .ToList(); if (!alliedHeroes.Any()) { if (!this.Owner.IsAlive) { // nobody is there to heal ... *feelsbadman* await Task.Delay(125, token); continue; } alliedHeroes.Add(this.Owner); } // get areas to avoid with the healing ward var avoidCircles = new List <Polygon.Circle>(enemyHeroes.Count); foreach (var enemyHero in enemyHeroes) { var dangerRange = enemyHero.AttackRange(this.healingWardUnit); dangerRange = enemyHero.IsMelee ? dangerRange * 2f : dangerRange * 1.2f; var circle = new Polygon.Circle(enemyHero.Position, dangerRange); // Log.Debug($"Adding avoid circle {circle.Center} ({circle.Radius})"); avoidCircles.Add(circle); } // find allies which need healing and are not close to enemies var healCircles = new List <Polygon.Circle>(alliedHeroes.Count); foreach (var alliedHero in alliedHeroes) { var circle = new Polygon.Circle(alliedHero.Position, healingRadius); if (avoidCircles.Exists(x => x.Center.Distance(circle.Center) <= Math.Abs(x.Radius - circle.Radius))) { // Log.Debug($"Skipping heal circle {circle.Center} ({circle.Radius})"); continue; } // Log.Debug($"Adding heal circle {circle.Center} ({circle.Radius})"); healCircles.Add(circle); } var hasMoved = false; if (healCircles.Any()) { while (healCircles.Count > 1) { var mecResult = MEC.GetMec(healCircles.Select((target) => target.Center).ToList()); if ((mecResult.Radius != 0f) && (mecResult.Radius < healingRadius)) { var movePos = new Vector3( healCircles.Count <= 2 ? (healCircles[0].Center + healCircles[1].Center) / 2 : mecResult.Center, this.healingWardUnit.Position.Z); if (avoidCircles.TrueForAll(x => !x.IsInside(movePos))) { this.healingWardUnit.Move(movePos); hasMoved = true; break; } } Log.Debug($"removing target since radius {mecResult.Radius} or movePos to dangerous"); var itemToRemove = healCircles.Where(x => x.Center != this.Owner.Position.ToVector2()) .MaxOrDefault((target) => healCircles[0].Center.DistanceSquared(target.Center)); healCircles.Remove(itemToRemove); } } // no safe area available... so just move to the target who needs it most and hope for the best if (!healCircles.Any() || !hasMoved) { var isOwnerLow = this.Owner.HealthPercent() <= 0.5f; var heroPos = isOwnerLow ? this.Owner.Position : alliedHeroes.First().Position; if (!avoidCircles.Any()) { this.healingWardUnit.Move(heroPos); Log.Debug($"No heal + avoid circles, moving to first allied"); } else { var z = this.healingWardUnit.Position.Z; var clusterPos = Vector3.Zero; foreach (var avoidCircle in avoidCircles) { clusterPos += avoidCircle.Center.ToVector3(z); } clusterPos /= avoidCircles.Count; var movePos = (clusterPos - heroPos).Normalized(); movePos = heroPos + (movePos * healingRadius * -1f); this.healingWardUnit.Move(movePos); Log.Debug($"No heal, moving to first allied and away from enemies"); } } await Task.Delay(125, token); } this.healingWardUnit = null; }
public void OnMixed() { if (ObjectManager.Player.ManaPercent < Variables.AssemblyMenu.GetItemValue <Slider>("dzaio.champion.orianna.mixed.mana").Value) { return; } var qTarget = TargetSelector.GetTarget(Variables.Spells[SpellSlot.Q].Range / 1.5f, TargetSelector.DamageType.Magical); if (Variables.Spells[SpellSlot.Q].IsEnabledAndReady(ModesMenuExtensions.Mode.Harrass) && qTarget.IsValidTarget()) { var targetPrediction = LeagueSharp.Common.Prediction.GetPrediction(qTarget, 0.75f); if (ObjectManager.Player.HealthPercent >= 35) { var enemyHeroesPositions = HeroManager.Enemies.Select(hero => hero.Position.To2D()).ToList(); var Groups = PositioningHelper.GetCombinations(enemyHeroesPositions); foreach (var group in Groups) { if (group.Count >= 3) { var Circle = MEC.GetMec(group); if (Circle.Center.To3D().CountEnemiesInRange(Variables.Spells[SpellSlot.Q].Range) >= 2 && Circle.Center.Distance(ObjectManager.Player) <= Variables.Spells[SpellSlot.Q].Range && Circle.Radius <= Variables.Spells[SpellSlot.Q].Width) { this.BallManager.ProcessCommand(new Command() { SpellCommand = Commands.Q, Where = Circle.Center.To3D() }); return; } } } } this.BallManager.ProcessCommand(new Command() { SpellCommand = Commands.Q, Where = targetPrediction.UnitPosition }); } if (Variables.Spells[SpellSlot.W].IsEnabledAndReady(ModesMenuExtensions.Mode.Harrass) && qTarget.IsValidTarget(Variables.Spells[SpellSlot.W].Range)) { var ballLocation = this.BallManager.BallPosition; var minWEnemies = 2; if (ObjectManager.Player.CountEnemiesInRange(Variables.Spells[SpellSlot.Q].Range + 245f) >= 2) { if (ballLocation.CountEnemiesInRange(Variables.Spells[SpellSlot.W].Range) >= minWEnemies) { this.BallManager.ProcessCommand(new Command() { SpellCommand = Commands.W, }); } } else { if (ballLocation.CountEnemiesInRange(Variables.Spells[SpellSlot.W].Range) >= 1) { this.BallManager.ProcessCommand(new Command() { SpellCommand = Commands.W, }); } } } }
public void OnCombo() { var qTarget = TargetSelector.GetTarget(Variables.Spells[SpellSlot.Q].Range / 1.5f, TargetSelector.DamageType.Magical); if (Variables.Spells[SpellSlot.Q].IsEnabledAndReady(ModesMenuExtensions.Mode.Combo) && qTarget.IsValidTarget()) { var targetPrediction = LeagueSharp.Common.Prediction.GetPrediction(qTarget, 0.75f); if (ObjectManager.Player.HealthPercent >= 35) { var enemyHeroesPositions = HeroManager.Enemies.Select(hero => hero.Position.To2D()).ToList(); var Groups = PositioningHelper.GetCombinations(enemyHeroesPositions); foreach (var group in Groups) { if (group.Count >= 3) { var Circle = MEC.GetMec(group); if (Circle.Center.To3D().CountEnemiesInRange(Variables.Spells[SpellSlot.Q].Range) >= 2 && Circle.Center.Distance(ObjectManager.Player) <= Variables.Spells[SpellSlot.Q].Range && Circle.Radius <= Variables.Spells[SpellSlot.Q].Width) { this.BallManager.ProcessCommand(new Command() { SpellCommand = Commands.Q, Where = Circle.Center.To3D() }); return; } } } } this.BallManager.ProcessCommand(new Command() { SpellCommand = Commands.Q, Where = targetPrediction.UnitPosition }); } if (Variables.Spells[SpellSlot.W].IsEnabledAndReady(ModesMenuExtensions.Mode.Combo) && qTarget.IsValidTarget(Variables.Spells[SpellSlot.W].Range)) { var ballLocation = this.BallManager.BallPosition; var minWEnemies = 2; if (ObjectManager.Player.CountEnemiesInRange(Variables.Spells[SpellSlot.Q].Range + 245f) >= 2) { if (ballLocation.CountEnemiesInRange(Variables.Spells[SpellSlot.W].Range) >= minWEnemies) { this.BallManager.ProcessCommand(new Command() { SpellCommand = Commands.W, }); } } else { if (ballLocation.CountEnemiesInRange(Variables.Spells[SpellSlot.W].Range) >= 1) { this.BallManager.ProcessCommand(new Command() { SpellCommand = Commands.W, }); } } } if (Variables.Spells[SpellSlot.R].IsEnabledAndReady(ModesMenuExtensions.Mode.Combo)) { if (ObjectManager.Player.CountEnemiesInRange(Variables.Spells[SpellSlot.Q].Range + 250f) > 1) { var EnemyPositions = HeroManager.Enemies.Select(hero => hero.Position.To2D()).ToList(); var Combinations = PositioningHelper.GetCombinations(EnemyPositions); foreach (var group in Combinations) { if (group.Count >= 2) { var Circle = MEC.GetMec(group); if (Variables.Spells[SpellSlot.Q].IsReady() && Circle.Center.Distance(ObjectManager.Player) <= Variables.Spells[SpellSlot.Q].Range && Circle.Radius <= Variables.Spells[SpellSlot.R].Range && Circle.Center.To3D().CountEnemiesInRange(Variables.Spells[SpellSlot.R].Range) >= 2) { Variables.Spells[SpellSlot.Q].Cast(Circle.Center.To3D()); var arrivalDelay = (int) (BallManager.BallPosition.Distance(Circle.Center.To3D()) / Variables.Spells[SpellSlot.Q].Speed * 1000f + Variables.Spells[SpellSlot.Q].Delay * 1000f + Game.Ping / 2f + 100f); Utility.DelayAction.Add( arrivalDelay, () => { //Extra check just for safety if ( BallManager.BallPosition.CountEnemiesInRange( Variables.Spells[SpellSlot.R].Range) >= 2) { Variables.Spells[SpellSlot.R].Cast(); } }); } } } } else { var targetForQR = TargetSelector.GetTarget( Variables.Spells[SpellSlot.Q].Range / 1.2f, TargetSelector.DamageType.Magical); if (targetForQR.IsValidTarget()) { var QWDamage = ObjectManager.Player.GetComboDamage( targetForQR, new[] { SpellSlot.Q, SpellSlot.W }); var QRDamage = ObjectManager.Player.GetComboDamage( targetForQR, new[] { SpellSlot.Q, SpellSlot.W, SpellSlot.R }); var healthCheck = targetForQR.Health + 10f < QRDamage && !(targetForQR.Health + 10f < QWDamage); if (!healthCheck) { return; } var rPosition = targetForQR.ServerPosition.Extend( ObjectManager.Player.ServerPosition, Variables.Spells[SpellSlot.R].Range / 2f); if (Variables.Spells[SpellSlot.Q].IsEnabledAndReady(ModesMenuExtensions.Mode.Combo) && rPosition.Distance(ObjectManager.Player.ServerPosition) <= Variables.Spells[SpellSlot.Q].Range) { Variables.Spells[SpellSlot.Q].Cast(rPosition); var actionDelay = (int) (BallManager.BallPosition.Distance(rPosition) / Variables.Spells[SpellSlot.Q].Speed * 1000f + Variables.Spells[SpellSlot.Q].Delay * 1000f + Game.Ping / 2f + 100f); Utility.DelayAction.Add( actionDelay, () => { if ( BallManager.BallPosition.CountEnemiesInRange( Variables.Spells[SpellSlot.R].Range) >= 1) { Variables.Spells[SpellSlot.R].Cast(); } }); } } } } }
private void BuildAndSendMessage(MEC elementCode, byte[] messageElementData) { BuildAndSendMessage(new MessageElement(elementCode, messageElementData)); }
// Token: 0x0600004A RID: 74 RVA: 0x0000FBAC File Offset: 0x0000DDAC private void GetAreaOfEffectPrediction(PredictionInput9 input, PredictionOutput9 output) { List <PredictionOutput9> targets = new List <PredictionOutput9>(); IEnumerable <Unit9> areaOfEffectTargets = input.AreaOfEffectTargets; Func <Unit9, bool> < > 9__2; Func <Unit9, bool> predicate; if ((predicate = < > 9__2) == null) { predicate = (< > 9__2 = ((Unit9 x) => !x.Equals(output.Target))); } foreach (Unit9 target in areaOfEffectTargets.Where(predicate)) { PredictionInput9 input2 = new PredictionInput9 { Target = target, Caster = input.Caster, Delay = input.Delay, Speed = input.Speed, CastRange = input.CastRange, Radius = input.Radius, RequiresToTurn = input.RequiresToTurn }; PredictionOutput9 simplePrediction = this.GetSimplePrediction(input2); float num = (input.SkillShotType == SkillShotType.Line) ? (input.Range + input.CastRange) : input.Range; if (input.Caster.Distance(simplePrediction.CastPosition) < num) { targets.Add(simplePrediction); } } switch (input.SkillShotType) { case SkillShotType.AreaOfEffect: targets.Insert(0, output); output.CastPosition = ((input.CastRange > 0f) ? input.Caster.InFront(input.CastRange, 0f, true) : input.Caster.Position); output.AoeTargetsHit = (from x in targets where output.CastPosition.IsInRange(x.TargetPosition, input.Radius) select x).ToList <PredictionOutput9>(); return; case SkillShotType.RangedAreaOfEffect: targets.Insert(0, output); output.CastPosition = input.Target.Position; output.AoeTargetsHit = (from x in targets where output.CastPosition.IsInRange(x.TargetPosition, input.Radius) select x).ToList <PredictionOutput9>(); if (!output.AoeTargetsHit.Contains(output)) { output.AoeTargetsHit.Add(output); return; } break; case SkillShotType.Line: targets.Insert(0, output); if (targets.Count > 1) { Dictionary <Polygon.Rectangle, List <PredictionOutput9> > dictionary = new Dictionary <Polygon.Rectangle, List <PredictionOutput9> >(); if (input.UseBlink) { Vector3 targetPosition = output.TargetPosition; List <PredictionOutput9> list = targets.Skip(1).ToList <PredictionOutput9>(); using (List <PredictionOutput9> .Enumerator enumerator2 = list.GetEnumerator()) { while (enumerator2.MoveNext()) { PredictionOutput9 predictionOutput = enumerator2.Current; Vector3 targetPosition2 = predictionOutput.TargetPosition; Vector3 vector = (targetPosition + targetPosition2) / 2f; Vector3 vector2 = targetPosition.Extend2D(targetPosition2, -100f); Vector3 end = vector2.Extend2D(targetPosition2, input.Range); Polygon.Rectangle rec = new Polygon.Rectangle(vector2, end, input.Radius); foreach (PredictionOutput9 predictionOutput2 in list) { if (!(predictionOutput2.Target == predictionOutput.Target)) { Vector3 to = (vector + predictionOutput2.TargetPosition) / 2f; Vector3 vector3 = targetPosition.Extend2D(to, -100f); Vector3 end2 = vector3.Extend2D(to, input.Range); Polygon.Rectangle rectangle = new Polygon.Rectangle(vector3, end2, input.Radius + 50f); if (rectangle.IsInside(targetPosition2) && rectangle.IsInside(predictionOutput2.TargetPosition)) { rec = rectangle; } } } dictionary[rec] = (from x in targets where rec.IsInside(x.TargetPosition) select x).ToList <PredictionOutput9>(); } goto IL_C36; } } Vector3 position = input.Caster.Position; foreach (PredictionOutput9 predictionOutput3 in targets) { Vector3 end3 = position.Extend2D(predictionOutput3.TargetPosition, input.Range); Polygon.Rectangle rec = new Polygon.Rectangle(position, end3, input.Radius * 1.3f); if (!rec.IsOutside(output.TargetPosition.To2D())) { dictionary[rec] = (from x in targets where rec.IsInside(x.TargetPosition) select x).ToList <PredictionOutput9>(); } } IL_C36: KeyValuePair <Polygon.Rectangle, List <PredictionOutput9> > keyValuePair = dictionary.MaxOrDefault((KeyValuePair <Polygon.Rectangle, List <PredictionOutput9> > x) => x.Value.Count); if (keyValuePair.Key != null) { List <PredictionOutput9> list2 = keyValuePair.Value.ToList <PredictionOutput9>(); Vector3 to2 = list2.Aggregate(default(Vector3), (Vector3 sum, PredictionOutput9 pos) => sum + pos.TargetPosition) / (float)list2.Count; if (list2.Count == 0) { output.HitChance = HitChance.Impossible; return; } float val = list2.Max(delegate(PredictionOutput9 x) { if (!input.UseBlink) { return(input.Caster.Distance(x.TargetPosition)); } return(output.TargetPosition.Distance(x.TargetPosition)); }); float distance = Math.Min(input.UseBlink ? input.Range : input.CastRange, val); output.CastPosition = (input.UseBlink ? output.TargetPosition.Extend2D(to2, distance) : input.Caster.Position.Extend2D(to2, distance)); output.AoeTargetsHit = keyValuePair.Value; } } else { output.AoeTargetsHit.Add(output); if (input.UseBlink) { input.AreaOfEffect = false; } } if (input.UseBlink) { output.BlinkLinePosition = ((input.Caster.Distance(output.TargetPosition) > input.CastRange) ? input.Caster.Position.Extend2D(output.TargetPosition, input.CastRange) : output.TargetPosition.Extend2D(output.CastPosition, -100f)); if (input.Caster.Distance(output.BlinkLinePosition) > input.CastRange) { output.HitChance = HitChance.Impossible; } } break; case SkillShotType.Circle: { targets.Insert(0, output); if (targets.Count == 1) { output.AoeTargetsHit.Add(output); return; } Func <PredictionOutput9, bool> < > 9__4; Func <PredictionOutput9, float> < > 9__5; while (targets.Count > 1) { MEC.MecCircle mec = MEC.GetMec((from x in targets select x.TargetPosition.ToVector2()).ToList <Vector2>()); if (mec.Radius > 0f && mec.Radius < input.Radius && input.Caster.Distance(mec.Center.ToVector3(0f)) < input.Range) { output.CastPosition = new Vector3((targets.Count <= 2) ? ((targets[0].TargetPosition.ToVector2() + targets[1].TargetPosition.ToVector2()) / 2f) : mec.Center, output.CastPosition.Z); PredictionOutput9 output2 = output; IEnumerable <PredictionOutput9> targets3 = targets; Func <PredictionOutput9, bool> predicate2; if ((predicate2 = < > 9__4) == null) { predicate2 = (< > 9__4 = ((PredictionOutput9 x) => output.CastPosition.IsInRange(x.TargetPosition, input.Radius))); } output2.AoeTargetsHit = targets3.Where(predicate2).ToList <PredictionOutput9>(); return; } IEnumerable <PredictionOutput9> targets2 = targets; Func <PredictionOutput9, float> comparer; if ((comparer = < > 9__5) == null) { comparer = (< > 9__5 = ((PredictionOutput9 x) => targets[0].TargetPosition.DistanceSquared(x.TargetPosition))); } PredictionOutput9 item = targets2.MaxOrDefault(comparer); targets.Remove(item); output.AoeTargetsHit.Add(output); } return; } case SkillShotType.Cone: targets.Insert(0, output); if (targets.Count > 1) { Dictionary <Polygon.Trapezoid, List <PredictionOutput9> > dictionary2 = new Dictionary <Polygon.Trapezoid, List <PredictionOutput9> >(); if (input.UseBlink) { Vector3 targetPosition3 = output.TargetPosition; List <PredictionOutput9> list3 = targets.Skip(1).ToList <PredictionOutput9>(); using (List <PredictionOutput9> .Enumerator enumerator2 = list3.GetEnumerator()) { while (enumerator2.MoveNext()) { PredictionOutput9 predictionOutput4 = enumerator2.Current; Vector3 targetPosition4 = predictionOutput4.TargetPosition; Vector3 vector4 = (targetPosition3 + targetPosition4) / 2f; Vector3 vector5 = targetPosition3.Extend2D(targetPosition4, -100f); Vector3 end4 = vector5.Extend2D(targetPosition4, input.Range); Polygon.Trapezoid rec = new Polygon.Trapezoid(vector5, end4, input.Radius, input.EndRadius); foreach (PredictionOutput9 predictionOutput5 in list3) { if (!(predictionOutput5.Target == predictionOutput4.Target)) { Vector3 to3 = (vector4 + predictionOutput5.TargetPosition) / 2f; Vector3 vector6 = targetPosition3.Extend2D(to3, -100f); Vector3 end5 = vector6.Extend2D(to3, input.Range); Polygon.Trapezoid trapezoid = new Polygon.Trapezoid(vector6, end5, input.Radius + 50f, input.EndRadius + 50f); if (trapezoid.IsInside(targetPosition4) && trapezoid.IsInside(predictionOutput5.TargetPosition)) { rec = trapezoid; } } } dictionary2[rec] = (from x in targets where rec.IsInside(x.TargetPosition) select x).ToList <PredictionOutput9>(); } goto IL_751; } } Vector3 position2 = input.Caster.Position; foreach (PredictionOutput9 predictionOutput6 in targets) { Vector3 end6 = position2.Extend2D(predictionOutput6.TargetPosition, input.Range); Polygon.Trapezoid rec = new Polygon.Trapezoid(position2, end6, input.Radius * 1.4f, input.EndRadius * 1.8f); if (!rec.IsOutside(output.TargetPosition.To2D())) { dictionary2[rec] = (from x in targets where rec.IsInside(x.TargetPosition) select x).ToList <PredictionOutput9>(); } } IL_751: KeyValuePair <Polygon.Trapezoid, List <PredictionOutput9> > keyValuePair2 = dictionary2.MaxOrDefault((KeyValuePair <Polygon.Trapezoid, List <PredictionOutput9> > x) => x.Value.Count); if (keyValuePair2.Key != null) { List <PredictionOutput9> list4 = keyValuePair2.Value.ToList <PredictionOutput9>(); Vector3 to4 = list4.Aggregate(default(Vector3), (Vector3 sum, PredictionOutput9 pos) => sum + pos.TargetPosition) / (float)list4.Count; if (list4.Count == 0) { output.HitChance = HitChance.Impossible; return; } float val2 = list4.Max(delegate(PredictionOutput9 x) { if (!input.UseBlink) { return(input.Caster.Distance(x.TargetPosition)); } return(output.TargetPosition.Distance(x.TargetPosition)); }); float distance2 = Math.Min(input.UseBlink ? input.Range : input.CastRange, val2); output.CastPosition = (input.UseBlink ? output.TargetPosition.Extend2D(to4, distance2) : input.Caster.Position.Extend2D(to4, distance2)); output.AoeTargetsHit = keyValuePair2.Value; } } else { output.AoeTargetsHit.Add(output); if (input.UseBlink) { input.AreaOfEffect = false; } } if (input.UseBlink) { output.BlinkLinePosition = ((input.Caster.Distance(output.TargetPosition) > input.CastRange) ? input.Caster.Position.Extend2D(output.TargetPosition, input.CastRange) : output.TargetPosition.Extend2D(output.CastPosition, -100f)); if (input.Caster.Distance(output.BlinkLinePosition) > input.CastRange) { output.HitChance = HitChance.Impossible; return; } } break; default: return; } }