/// <summary> /// Gets Prediction result /// </summary> /// <param name="target">Target</param> /// <returns>Prediction result as <see cref="Prediction.Result"/></returns> public static Prediction.Result GetSPrediction(this Spell s, Obj_AI_Hero target) { switch (s.Type) { case SkillshotType.SkillshotLine: return LinePrediction.GetPrediction(target, s.Width, s.Delay, s.Speed, s.Range, s.Collision, target.GetWaypoints(), target.AvgMovChangeTime(), target.LastMovChangeTime(), target.AvgPathLenght(), target.LastAngleDiff(), s.From.To2D(), s.RangeCheckFrom.To2D()); case SkillshotType.SkillshotCircle: return CirclePrediction.GetPrediction(target, s.Width, s.Delay, s.Speed, s.Range, s.Collision, target.GetWaypoints(), target.AvgMovChangeTime(), target.LastMovChangeTime(), target.AvgPathLenght(), target.LastAngleDiff(), s.From.To2D(), s.RangeCheckFrom.To2D()); case SkillshotType.SkillshotCone: return ConePrediction.GetPrediction(target, s.Width, s.Delay, s.Speed, s.Range, s.Collision, target.GetWaypoints(), target.AvgMovChangeTime(), target.LastMovChangeTime(), target.AvgPathLenght(), target.LastAngleDiff(), s.From.To2D(), s.RangeCheckFrom.To2D()); } throw new NotSupportedException("Unknown skill shot type"); }
public override void Cast(Obj_AI_Hero target, bool force = false, HitChance minChance = HitChance.Low) { if (HasBeenSafeCast() || target == null || target.GetWaypoints().Last().Distance(target) > 50) return; var prediction = Spell.GetPrediction(target, true); if (prediction.Hitchance < minChance) return; SafeCast(() => Spell.Cast(prediction.CastPosition)); }
public static bool IsValidTarget(Obj_AI_Hero target) { if (!IsWhitelisted(target)) return false; var targetPosition = Geometry.PositionAfter(target.GetWaypoints(), 300, (int)target.MoveSpeed); if (target.Distance(ObjectManager.Player.ServerPosition) < 650f && IsCondemnable(ObjectManager.Player.ServerPosition.To2D(), targetPosition, target.BoundingRadius)) { if (target.Path.Length == 0) { var outRadius = (0.3f * target.MoveSpeed) / (float)Math.Cos(2 * Math.PI / 12); int count = 0; for (int i = 1; i <= 12; i++) { var angle = i * 2 * Math.PI / 12; float x = target.Position.X + outRadius * (float)Math.Cos(angle); float y = target.Position.Y + outRadius * (float)Math.Sin(angle); if (IsCondemnable(ObjectManager.Player.ServerPosition.To2D(), new Vector2(x, y), target.BoundingRadius)) count++; } return count >= 4; } else return true; } else { if (TumbleCondemn && s_Champion.Spells[Champion.Q].IsReady()) { var outRadius = 300 / (float)Math.Cos(2 * Math.PI / 12); for (int i = 1; i <= 12; i++) { var angle = i * 2 * Math.PI / 12; float x = ObjectManager.Player.Position.X + outRadius * (float)Math.Cos(angle); float y = ObjectManager.Player.Position.Y + outRadius * (float)Math.Sin(angle); targetPosition = Geometry.PositionAfter(target.GetWaypoints(), 300, (int)target.MoveSpeed); if (targetPosition.Distance(new Vector2(x, y)) < 550f && IsCondemnable(new Vector2(x, y), targetPosition, target.BoundingRadius, 300f)) { s_Champion.Spells[Champion.Q].Cast(new Vector2(x, y)); return false; } } return false; } } return false; }
private static double GetAngle(this Vector3 from, Obj_AI_Hero target) { var c = target.ServerPosition.ToVector2(); var a = target.GetWaypoints().Last(); if (c == a) { return 60; } var b = from.ToVector2(); var ab = Math.Pow(a.X - b.X, 2) + Math.Pow(a.Y - b.Y, 2); var bc = Math.Pow(b.X - c.X, 2) + Math.Pow(b.Y - c.Y, 2); var ac = Math.Pow(a.X - c.X, 2) + Math.Pow(a.Y - c.Y, 2); return Math.Cos((ab + bc - ac) / (2 * Math.Sqrt(ab) * Math.Sqrt(bc))) * 180 / Math.PI; }
/// <summary> /// Spell extension for cast arc spell with SPrediction /// </summary> /// <param name="s">Spell to cast</param> /// <param name="t">Target for spell</param> /// <param name="hc">Minimum HitChance to cast</param> /// <param name="reactionIgnoreDelay">Delay to ignore target's reaction time</param> /// <param name="minHit">Minimum Hit Count to cast</param> /// <param name="rangeCheckFrom">Position where spell will be casted from</param> /// <param name="filterHPPercent">Minimum HP Percent to cast (for target)</param> /// <returns>true if spell has casted</returns> public static bool SPredictionCastArc(this Spell s, Obj_AI_Hero t, HitChance hc, bool arconly = true, int reactionIgnoreDelay = 0, byte minHit = 1, Vector3? rangeCheckFrom = null, float filterHPPercent = 100) { if (ConfigMenu.SelectedPrediction.SelectedIndex == 1) throw new NotSupportedException("Arc Prediction not supported in Common prediction"); if (minHit > 1) return SPredictionCastAoeArc(s, minHit); if (t.HealthPercent > filterHPPercent) return false; if (rangeCheckFrom == null) rangeCheckFrom = ObjectManager.Player.ServerPosition; if (Monitor.TryEnter(PathTracker.EnemyInfo[t.NetworkId].m_lock)) { try { float avgt = t.AvgMovChangeTime() + reactionIgnoreDelay; float movt = t.LastMovChangeTime(); float avgp = t.AvgPathLenght(); var result = ArcPrediction.GetPrediction(t, s.Width, s.Delay, s.Speed, s.Range, s.Collision, t.GetWaypoints(), avgt, movt, avgp, t.LastAngleDiff(), s.From.To2D(), s.RangeCheckFrom.To2D(), arconly); if (result.HitChance >= hc) { s.Cast(result.CastPosition); return true; } Monitor.Pulse(PathTracker.EnemyInfo[t.NetworkId].m_lock); return false; } finally { Monitor.Exit(PathTracker.EnemyInfo[t.NetworkId].m_lock); } } return false; }
private void castR(Obj_AI_Hero target) { if (Config.Item("hitchanceR", true).GetValue<bool>()) { List<Vector2> waypoints = target.GetWaypoints(); if (target.Path.Count() < 2 && (Player.Distance(waypoints.Last<Vector2>().To3D()) - Player.Distance(target.Position)) > 300) { Program.CastSpell(R, target); } } else Program.CastSpell(R, target); }
private static Vector3 PreCastPos(Obj_AI_Hero Hero ,float Delay) { float value = 0f; if (Hero.IsFacing(Player)) { value = (10f - Hero.BoundingRadius); } else { value = -(120f - Hero.BoundingRadius); } var distance = Delay * Hero.MoveSpeed + value; var path = Hero.GetWaypoints(); for (var i = 0; i < path.Count - 1; i++) { var a = path[i]; var b = path[i + 1]; var d = a.Distance(b); if (d < distance) { distance -= d; } else { return (a + distance * (b - a).Normalized()).To3D(); } } return (path[path.Count - 1]).To3D(); }
/// <summary> /// Gets Prediction result /// </summary> /// <param name="target">Target for spell</param> /// <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="collisionable">Spell collisionable</param> /// <param name="type">Spell skillshot type</param> /// <param name="from">Spell casted position</param> /// <returns>Prediction result as <see cref="Prediction.Result"/></returns> public static Prediction.Result GetPrediction(Obj_AI_Hero target, float width, float delay, float missileSpeed, float range, bool collisionable) { return GetPrediction(target, width, delay, missileSpeed, range, collisionable, target.GetWaypoints(), target.AvgMovChangeTime(), target.LastMovChangeTime(), target.AvgPathLenght(), ObjectManager.Player.ServerPosition.To2D(), ObjectManager.Player.ServerPosition.To2D()); }
public static bool IsFaced(Obj_AI_Hero target) { Vector2 LastWaypoint = target.GetWaypoints().Last(); if (LastWaypoint.Distance(Player.Position) < target.Distance(Player.Position)) return true; return false; }
/// <summary> /// Casts spell /// </summary> /// <param name="s">Spell to cast</param> /// <param name="t">Target for spell</param> /// <param name="hc">Minimum HitChance to cast</param> /// <param name="reactionIgnoreDelay">Delay to ignore target's reaction time</param> /// <param name="minHit">Minimum Hit Count to cast</param> /// <param name="rangeCheckFrom">Position where spell will be casted from</param> /// <param name="filterHPPercent">Minimum HP Percent to cast (for target)</param> /// <returns>true if spell has casted</returns> public static bool SPredictionCastArc(this Spell s, Obj_AI_Hero t, HitChance hc, int reactionIgnoreDelay = 0, byte minHit = 1, Vector3? rangeCheckFrom = null, float filterHPPercent = 100) { if (minHit > 1) throw new NotSupportedException("Arc aoe prediction has not supported yet"); if (predMenu != null && predMenu.Item("PREDICTONLIST").GetValue<StringList>().SelectedIndex == 1) throw new NotSupportedException("Arc Prediction not supported in Common prediction"); if (t.HealthPercent > filterHPPercent) return false; if (rangeCheckFrom == null) rangeCheckFrom = ObjectManager.Player.ServerPosition; if (Monitor.TryEnter(EnemyInfo[t.NetworkId].m_lock)) { try { HitChance predictedhc; float avgt = t.AvgMovChangeTime() + reactionIgnoreDelay; float movt = t.LastMovChangeTime(); float avgp = t.AvgPathLenght(); Vector2 pos = GetArcPrediction(t, s, t.GetWaypoints(), avgt, movt, avgp, out predictedhc, rangeCheckFrom.Value); if (rangeCheckFrom.Value.To2D().Distance(pos) > s.Range + s.Width / 2 - t.BoundingRadius) //out of range { Monitor.Pulse(EnemyInfo[t.NetworkId].m_lock); return false; } float multp = (pos.Distance(rangeCheckFrom.Value.To2D()) / 875.0f); var dianaArc = new SPrediction.Geometry.Polygon( ClipperWrapper.DefineArc(rangeCheckFrom.Value.To2D() - new Vector2(875 / 2f, 20), pos, (float)Math.PI * multp, 410, 200 * multp), ClipperWrapper.DefineArc(rangeCheckFrom.Value.To2D() - new Vector2(875 / 2f, 20), pos, (float)Math.PI * multp, 410, 320 * multp)); if (Collision.CheckYasuoWallCollision(dianaArc)) { Monitor.Pulse(EnemyInfo[t.NetworkId].m_lock); return false; } if (predictedhc >= hc) { s.Cast(pos); return true; } Monitor.Pulse(EnemyInfo[t.NetworkId].m_lock); return false; } finally { Monitor.Exit(EnemyInfo[t.NetworkId].m_lock); } } return false; }
/// <summary> /// Gets Prediction result /// </summary> /// <param name="target">Target</param> /// <returns>Prediction result as <see cref="Prediction.Result"/></returns> public static Prediction.Result GetArcSPrediction(this Spell s, Obj_AI_Hero target) { return ArcPrediction.GetPrediction(target, s.Width, s.Delay, s.Speed, s.Range, s.Collision, target.GetWaypoints(), target.AvgMovChangeTime(), target.LastMovChangeTime(), target.AvgPathLenght(), s.From.To2D(), s.RangeCheckFrom.To2D()); }
/// <summary> /// Spell extension for cast vector spell with SPrediction /// </summary> /// <param name="s">Spell to cast</param> /// <param name="t">Target for spell</param> /// <param name="ringRadius">Ring Radius</param> /// <param name="hc">Minimum HitChance to cast</param> /// <param name="reactionIgnoreDelay">Delay to ignore target's reaction time</param> /// <param name="minHit">Minimum Hit Count to cast</param> /// <param name="rangeCheckFrom">Position where spell will be casted from</param> /// <param name="filterHPPercent">Minimum HP Percent to cast (for target)</param> /// <returns>true if spell has casted</returns> public static bool SPredictionCastRing(this Spell s, Obj_AI_Hero t, float ringRadius, HitChance hc, bool onlyEdge = true, int reactionIgnoreDelay = 0, byte minHit = 1, Vector3? rangeCheckFrom = null, float filterHPPercent = 100) { if (Prediction.predMenu != null && Prediction.predMenu.Item("PREDICTONLIST").GetValue<StringList>().SelectedIndex == 1) throw new NotSupportedException("Vector Prediction not supported in Common prediction"); if (minHit > 1) throw new NotSupportedException("Ring aoe prediction not supported yet"); if (t.HealthPercent > filterHPPercent) return false; if (rangeCheckFrom == null) rangeCheckFrom = ObjectManager.Player.ServerPosition; if (Monitor.TryEnter(PathTracker.EnemyInfo[t.NetworkId].m_lock)) { try { float avgt = t.AvgMovChangeTime() + reactionIgnoreDelay; float movt = t.LastMovChangeTime(); float avgp = t.AvgPathLenght(); Prediction.Result result; if (onlyEdge) result = RingPrediction.GetPrediction(t, s.Width, ringRadius, s.Delay, s.Speed, s.Range, s.Collision, t.GetWaypoints(), avgt, movt, avgp, s.From.To2D(), rangeCheckFrom.Value.To2D()); else result = CirclePrediction.GetPrediction(t, s.Width, s.Delay, s.Speed, s.Range + ringRadius, s.Collision, t.GetWaypoints(), avgt, movt, avgp, 360, s.From.To2D(), rangeCheckFrom.Value.To2D()); Prediction.lastDrawTick = Utils.TickCount; Prediction.lastDrawPos = result.CastPosition; Prediction.lastDrawHitchance = result.HitChance.ToString(); Prediction.lastDrawDirection = (result.CastPosition - s.From.To2D()).Normalized().Perpendicular(); Prediction.lastDrawWidth = (int)ringRadius; if (result.HitChance >= hc) { s.Cast(result.CastPosition); return true; } Monitor.Pulse(PathTracker.EnemyInfo[t.NetworkId].m_lock); return false; } finally { Monitor.Exit(PathTracker.EnemyInfo[t.NetworkId].m_lock); } } return false; }
private static void castR(Obj_AI_Hero target) { if (Config.Item("hitchanceR").GetValue<bool>()) { List<Vector2> waypoints = target.GetWaypoints(); if ((ObjectManager.Player.Distance(waypoints.Last<Vector2>().To3D()) - ObjectManager.Player.Distance(target.Position)) > 400) { R.Cast(target, true); } } else R.Cast(target, true); }
public static bool IsValidTarget(Obj_AI_Hero target) { if (!IsWhitelisted(target)) return false; var targetPosition = Geometry.PositionAfter(target.GetWaypoints(), 300, (int)target.MoveSpeed); if (target.Distance(ObjectManager.Player.ServerPosition) < 650f && IsCondemnable(ObjectManager.Player.ServerPosition.To2D(), targetPosition, target.BoundingRadius)) { if (target.Path.Length == 0) { var outRadius = (0.3f * target.MoveSpeed) / (float)Math.Cos(2 * Math.PI / Accuracy); int count = 0; for (int i = 1; i <= Accuracy; i++) { if (count + (Accuracy - i) < Accuracy / 3) return false; var angle = i * 2 * Math.PI / Accuracy; float x = target.Position.X + outRadius * (float)Math.Cos(angle); float y = target.Position.Y + outRadius * (float)Math.Sin(angle); if (IsCondemnable(ObjectManager.Player.ServerPosition.To2D(), new Vector2(x, y), target.BoundingRadius)) count++; } return count >= Accuracy / 3; } else return true; } else { if (TumbleCondemn && s_Champion.Spells[Champion.Q].IsReady()) { var outRadius = 300 / (float)Math.Cos(2 * Math.PI / TumbleCondemnCount); for (int i = 1; i <= TumbleCondemnCount; i++) { var angle = i * 2 * Math.PI / TumbleCondemnCount; float x = ObjectManager.Player.Position.X + outRadius * (float)Math.Cos(angle); float y = ObjectManager.Player.Position.Y + outRadius * (float)Math.Sin(angle); targetPosition = Geometry.PositionAfter(target.GetWaypoints(), 300, (int)target.MoveSpeed); var vec = new Vector2(x, y); if (targetPosition.Distance(vec) < 550f && IsCondemnable(vec, targetPosition, target.BoundingRadius, 300f)) { if (!TumbleCondemnSafe || Tumble.IsSafe(target, vec.To3D2(), false).IsValid()) { s_Champion.Spells[Champion.Q].Cast(vec); break; } } } return false; } } return false; }
private static void CastSpell(Spell QWER, Obj_AI_Hero target, int HitChanceNum) { //HitChance 0 - 2 // example CastSpell(Q, ts, 2); var poutput = QWER.GetPrediction(target); var col = poutput.CollisionObjects.Count(ColObj => ColObj.IsEnemy && ColObj.IsMinion && !ColObj.IsDead); if (target.IsDead || col > 0 || target.Path.Count() > 1) return; if ((target.Path.Count() == 0 && target.Position == target.ServerPosition) || target.HasBuff("Recall")) { QWER.Cast(poutput.CastPosition); return; } if (HitChanceNum == 0) QWER.Cast(target, true); else if (HitChanceNum == 1) { if ((int)poutput.Hitchance > 4) QWER.Cast(poutput.CastPosition); } else if (HitChanceNum == 2) { List<Vector2> waypoints = target.GetWaypoints(); if (waypoints.Last<Vector2>().To3D().Distance(poutput.CastPosition) > QWER.Width && (int)poutput.Hitchance == 5) { if (waypoints.Last<Vector2>().To3D().Distance(Player.Position) <= target.Distance(Player.Position) || (target.Path.Count() == 0 && target.Position == target.ServerPosition)) { if (Player.Distance(target.ServerPosition) < QWER.Range - (poutput.CastPosition.Distance(target.ServerPosition) + target.BoundingRadius)) { QWER.Cast(poutput.CastPosition); } } else if ((int)poutput.Hitchance == 5) { QWER.Cast(poutput.CastPosition); } } } else if (HitChanceNum == 3) { List<Vector2> waypoints = target.GetWaypoints(); float SiteToSite = ((target.MoveSpeed * QWER.Delay) + (Player.Distance(target.ServerPosition) / QWER.Speed) - QWER.Width) * 6; float BackToFront = ((target.MoveSpeed * QWER.Delay) + (Player.Distance(target.ServerPosition) / QWER.Speed)); if (Player.Distance(waypoints.Last<Vector2>().To3D()) < SiteToSite || Player.Distance(target.Position) < SiteToSite) QWER.CastIfHitchanceEquals(target, HitChance.High, true); else if ((target.ServerPosition.Distance(waypoints.Last<Vector2>().To3D()) > SiteToSite || Math.Abs(Player.Distance(waypoints.Last<Vector2>().To3D()) - Player.Distance(target.Position)) > BackToFront)) { if (waypoints.Last<Vector2>().To3D().Distance(Player.Position) <= target.Distance(Player.Position)) { if (Player.Distance(target.ServerPosition) < QWER.Range - (poutput.CastPosition.Distance(target.ServerPosition))) { QWER.Cast(poutput.CastPosition); } } else { QWER.Cast(poutput.CastPosition); } } } else if (HitChanceNum == 4 && (int)poutput.Hitchance > 4) { List<Vector2> waypoints = target.GetWaypoints(); float SiteToSite = ((target.MoveSpeed * QWER.Delay) + (Player.Distance(target.ServerPosition) / QWER.Speed) - QWER.Width) * 6; float BackToFront = ((target.MoveSpeed * QWER.Delay) + (Player.Distance(target.ServerPosition) / QWER.Speed)); if (Player.Distance(waypoints.Last<Vector2>().To3D()) < SiteToSite || Player.Distance(target.Position) < SiteToSite) QWER.CastIfHitchanceEquals(target, HitChance.High, true); else if ((target.ServerPosition.Distance(waypoints.Last<Vector2>().To3D()) > SiteToSite || Math.Abs(Player.Distance(waypoints.Last<Vector2>().To3D()) - Player.Distance(target.Position)) > BackToFront)) { if (waypoints.Last<Vector2>().To3D().Distance(Player.Position) <= target.Distance(Player.Position)) { if (Player.Distance(target.ServerPosition) < QWER.Range - (poutput.CastPosition.Distance(target.ServerPosition))) { QWER.Cast(poutput.CastPosition); } } else { QWER.Cast(poutput.CastPosition); } } } }
/// <summary> /// Gets Prediction result /// </summary> /// <param name="target">Target</param> /// <param name="vectorLenght">Vector Lenght</param> /// <returns>Prediction result as <see cref="Prediction.Vector.Result"/></returns> public static VectorPrediction.Result GetVectorSPrediction(this Spell s, Obj_AI_Hero target, float vectorLenght) { return VectorPrediction.GetPrediction(target, s.Width, s.Delay, s.Speed, s.Range, vectorLenght, target.GetWaypoints(), target.AvgMovChangeTime(), target.LastMovChangeTime(), target.AvgPathLenght(), s.RangeCheckFrom.To2D()); }
/// <summary> /// Casts spell /// </summary> /// <param name="s">Spell to cast</param> /// <param name="t">Target for spell</param> /// <param name="hc">Minimum HitChance to cast</param> /// <param name="reactionIgnoreDelay">Delay to ignore target's reaction time</param> /// <param name="minHit">Minimum Hit Count to cast</param> /// <param name="rangeCheckFrom">Position where spell will be casted from</param> /// <param name="filterHPPercent">Minimum HP Percent to cast (for target)</param> /// <returns>true if spell has casted</returns> public static bool SPredictionCast(this Spell s, Obj_AI_Hero t, HitChance hc, int reactionIgnoreDelay = 0, byte minHit = 1, Vector3? rangeCheckFrom = null, float filterHPPercent = 100) { if (rangeCheckFrom == null) rangeCheckFrom = ObjectManager.Player.ServerPosition; if (t == null) return s.Cast(); if (!s.IsSkillshot) return s.Cast(t) == Spell.CastStates.SuccessfullyCasted; #region if common prediction selected if (predMenu != null && predMenu.Item("PREDICTONLIST").GetValue<StringList>().SelectedIndex == 1) { var pout = s.GetPrediction(t, minHit > 1); if (minHit > 1) if (pout.AoeTargetsHitCount >= minHit) return s.Cast(pout.CastPosition); else return false; if (pout.Hitchance >= hc) return s.Cast(pout.CastPosition); else return false; } #endregion if (minHit > 1) return Aoe.SPredictionCast(s, t, hc, reactionIgnoreDelay, minHit, rangeCheckFrom, filterHPPercent); if (s.Collision && minHit > 1) throw new InvalidOperationException("You can't use collisionable spells with aoe"); if (t.HealthPercent > filterHPPercent) return false; if (Monitor.TryEnter(EnemyInfo[t.NetworkId].m_lock)) { try { HitChance predictedhc; float avgt = t.AvgMovChangeTime() + reactionIgnoreDelay; float movt = t.LastMovChangeTime(); float avgp = t.AvgPathLenght(); var waypoints = t.GetWaypoints(); //PATCH WARNING Vector2 pos = GetPredictionMethod2(t, s, waypoints, avgt, movt, avgp, out predictedhc, rangeCheckFrom.Value); //if (waypoints.PathLength() / t.MoveSpeed < 1f) // pos = GetPredictionMethod2(t, s, waypoints, avgt, movt, avgp, out predictedhc, rangeCheckFrom.Value); //else // pos = GetPrediction(t, s, waypoints, avgt, movt, avgp, out predictedhc, rangeCheckFrom.Value); if (rangeCheckFrom.Value.To2D().Distance(pos) > s.Range + (s.Type == SkillshotType.SkillshotCircle ? s.Width / 2 : 0) - t.BoundingRadius) //out of range { Monitor.Pulse(EnemyInfo[t.NetworkId].m_lock); return false; } lastDrawTick = Utils.TickCount; lastDrawPos = pos; lastDrawHitchance = predictedhc.ToString(); lastDrawDirection = (pos - rangeCheckFrom.Value.To2D()).Normalized().Perpendicular(); lastDrawWidth = (int)s.Width; if (s.Collision && Collision.CheckCollision(rangeCheckFrom.Value.To2D(), pos, s, true, false, true)) { lastDrawHitchance = HitChance.Collision.ToString(); Monitor.Pulse(EnemyInfo[t.NetworkId].m_lock); return false; } if (predictedhc >= hc) { s.Cast(pos); return true; } Monitor.Pulse(EnemyInfo[t.NetworkId].m_lock); return false; } finally { Monitor.Exit(EnemyInfo[t.NetworkId].m_lock); } } return false; }
/// <summary> /// Spell extension for cast spell with SPrediction /// </summary> /// <param name="s">Spell to cast</param> /// <param name="t">Target for spell</param> /// <param name="hc">Minimum HitChance to cast</param> /// <param name="reactionIgnoreDelay">Delay to ignore target's reaction time</param> /// <param name="minHit">Minimum Hit Count to cast</param> /// <param name="rangeCheckFrom">Position where spell will be casted from</param> /// <param name="filterHPPercent">Minimum HP Percent to cast (for target)</param> /// <returns>true if spell has casted</returns> public static bool SPredictionCast(this Spell s, Obj_AI_Hero t, HitChance hc, int reactionIgnoreDelay = 0, byte minHit = 1, Vector3? rangeCheckFrom = null, float filterHPPercent = 100) { if (rangeCheckFrom == null) rangeCheckFrom = ObjectManager.Player.ServerPosition; if (t == null) return s.Cast(); if (!s.IsSkillshot) return s.Cast(t) == Spell.CastStates.SuccessfullyCasted; #region if common prediction selected if (Prediction.predMenu != null && Prediction.predMenu.Item("PREDICTONLIST").GetValue<StringList>().SelectedIndex == 1) { var pout = s.GetPrediction(t, minHit > 1); if (minHit > 1) if (pout.AoeTargetsHitCount >= minHit) return s.Cast(pout.CastPosition); else return false; if (pout.Hitchance >= hc) return s.Cast(pout.CastPosition); else return false; } #endregion if (minHit > 1) return SPredictionCastAoe(s, minHit); if (t.HealthPercent > filterHPPercent) return false; if (Monitor.TryEnter(PathTracker.EnemyInfo[t.NetworkId].m_lock)) { try { float avgt = t.AvgMovChangeTime() + reactionIgnoreDelay; float movt = t.LastMovChangeTime(); float avgp = t.AvgPathLenght(); var waypoints = t.GetWaypoints(); Prediction.Result result; switch (s.Type) { case SkillshotType.SkillshotLine: result = LinePrediction.GetPrediction(t, s.Width, s.Delay, s.Speed, s.Range, s.Collision, waypoints, avgt, movt, avgp, s.From.To2D(), s.RangeCheckFrom.To2D()); break; case SkillshotType.SkillshotCircle: result = CirclePrediction.GetPrediction(t, s.Width, s.Delay, s.Speed, s.Range, s.Collision, waypoints, avgt, movt, avgp, s.From.To2D(), s.RangeCheckFrom.To2D()); break; case SkillshotType.SkillshotCone: result = ConePrediction.GetPrediction(t, s.Width, s.Delay, s.Speed, s.Range, s.Collision, waypoints, avgt, movt, avgp, s.From.To2D(), s.RangeCheckFrom.To2D()); break; default: throw new InvalidOperationException("Unknown spell type"); } Prediction.lastDrawTick = Utils.TickCount; Prediction.lastDrawPos = result.CastPosition; Prediction.lastDrawHitchance = result.HitChance.ToString(); Prediction.lastDrawDirection = (result.CastPosition - s.From.To2D()).Normalized().Perpendicular(); Prediction.lastDrawWidth = (int)s.Width; if (result.HitChance >= hc) { s.Cast(result.CastPosition); return true; } Monitor.Pulse(PathTracker.EnemyInfo[t.NetworkId].m_lock); return false; } finally { Monitor.Exit(PathTracker.EnemyInfo[t.NetworkId].m_lock); } } return false; }
/// <summary> /// Casts aoe spell /// </summary> /// <param name="s">Spell to cast</param> /// <param name="t">Target for spell</param> /// <param name="hc">Minimum HitChance to cast</param> /// <param name="minHit">Minimum Hit Count to cast</param> /// <param name="rangeCheckFrom">Position where spell will be casted from</param> /// <param name="filterHPPercent">Minimum HP Percent to cast (for target)</param> /// <returns>true if spell has casted</returns> internal static bool SPredictionCast(Spell s, Obj_AI_Hero t, HitChance hc, int reactionIgnoreDelay = 0, byte minHit = 2, Vector3? rangeCheckFrom = null, float filterHPPercent = 0) { if (!blInitialized) throw new Exception("Prediction is not initalized"); if (rangeCheckFrom == null) rangeCheckFrom = ObjectManager.Player.ServerPosition; if (Monitor.TryEnter(EnemyInfo[t.NetworkId].m_lock)) { try { HitChance predictedhc = HitChance.Impossible; float avgt = t.AvgMovChangeTime() + reactionIgnoreDelay; float movt = t.LastMovChangeTime(); float avgp = t.AvgPathLenght(); Vector2 pos = ObjectManager.Player.ServerPosition.To2D(); switch (s.Type) { case SkillshotType.SkillshotLine: pos = Line.GetPrediction(t, s, t.GetWaypoints(), avgt, movt, avgp, filterHPPercent, minHit, out predictedhc, rangeCheckFrom.Value); break; case SkillshotType.SkillshotCircle: pos = Circle.GetPrediction(t, s, t.GetWaypoints(), avgt, movt, avgp, filterHPPercent, minHit, out predictedhc, rangeCheckFrom.Value); break; case SkillshotType.SkillshotCone: pos = Cone.GetPrediction(t, s, t.GetWaypoints(), avgt, movt, avgp, filterHPPercent, minHit, out predictedhc, rangeCheckFrom.Value); break; } if (predictedhc >= hc) { s.Cast(pos); return true; } Monitor.Pulse(EnemyInfo[t.NetworkId].m_lock); return false; } finally { Monitor.Exit(EnemyInfo[t.NetworkId].m_lock); } } return false; }
/// <summary> /// Spell extension for cast vector spell with SPrediction /// </summary> /// <param name="s">Spell to cast</param> /// <param name="t">Target for spell</param> /// <param name="vectorLenght">Vector lenght</param> /// <param name="hc">Minimum HitChance to cast</param> /// <param name="reactionIgnoreDelay">Delay to ignore target's reaction time</param> /// <param name="minHit">Minimum Hit Count to cast</param> /// <param name="rangeCheckFrom">Position where spell will be casted from</param> /// <param name="filterHPPercent">Minimum HP Percent to cast (for target)</param> /// <returns>true if spell has casted</returns> public static bool SPredictionCastVector(this Spell s, Obj_AI_Hero t, float vectorLenght, HitChance hc, int reactionIgnoreDelay = 0, byte minHit = 1, Vector3? rangeCheckFrom = null, float filterHPPercent = 100) { if (minHit > 1) throw new NotSupportedException("Vector aoe prediction has not supported yet"); if (Prediction.predMenu != null && Prediction.predMenu.Item("PREDICTONLIST").GetValue<StringList>().SelectedIndex == 1) throw new NotSupportedException("Vector Prediction not supported in Common prediction"); if (t.HealthPercent > filterHPPercent) return false; if (rangeCheckFrom == null) rangeCheckFrom = ObjectManager.Player.ServerPosition; if (Monitor.TryEnter(PathTracker.EnemyInfo[t.NetworkId].m_lock)) { try { float avgt = t.AvgMovChangeTime() + reactionIgnoreDelay; float movt = t.LastMovChangeTime(); float avgp = t.AvgPathLenght(); var result = VectorPrediction.GetPrediction(t, s.Width, s.Delay, s.Speed, s.Range, vectorLenght, t.GetWaypoints(), avgt, movt, avgp, s.RangeCheckFrom.To2D()); if (result.HitChance >= hc) { s.Cast(result.CastSourcePosition, result.CastTargetPosition); return true; } Monitor.Pulse(PathTracker.EnemyInfo[t.NetworkId].m_lock); return false; } finally { Monitor.Exit(PathTracker.EnemyInfo[t.NetworkId].m_lock); } } return false; }
private static void CastSpell(Spell QWER, Obj_AI_Hero target, int HitChanceNum) { //HitChance 0 - 2 // example CastSpell(Q, ts, 2); var poutput = QWER.GetPrediction(target); var col = poutput.CollisionObjects.Count(ColObj => ColObj.IsEnemy && ColObj.IsMinion && !ColObj.IsDead); if (QWER.Collision && col > 0) return; if (HitChanceNum == 0) QWER.Cast(target, true); else if (HitChanceNum == 1) { if ((int)poutput.Hitchance > 4) QWER.Cast(poutput.CastPosition); } else if (HitChanceNum == 2) { if ((target.IsFacing(ObjectManager.Player) && (int)poutput.Hitchance == 5) || (target.Path.Count() == 0 && target.Position == target.ServerPosition)) { if (ObjectManager.Player.Distance(target.Position) < QWER.Range - ((target.MoveSpeed * QWER.Delay) + (Player.Distance(target.Position) / QWER.Speed) + (target.BoundingRadius * 2))) { QWER.Cast(poutput.CastPosition); } } else if ((int)poutput.Hitchance == 5) { QWER.Cast(poutput.CastPosition); } } else if (HitChanceNum == 3) { List<Vector2> waypoints = target.GetWaypoints(); float SiteToSite = ((target.MoveSpeed * QWER.Delay) + (Player.Distance(target.ServerPosition) / QWER.Speed)) * 6 - QWER.Width; float BackToFront = ((target.MoveSpeed * QWER.Delay) + (Player.Distance(target.ServerPosition) / QWER.Speed)); if (ObjectManager.Player.Distance(waypoints.Last<Vector2>().To3D()) < SiteToSite || ObjectManager.Player.Distance(target.Position) < SiteToSite) QWER.CastIfHitchanceEquals(target, HitChance.High, true); else if (target.Path.Count() < 2 && (target.ServerPosition.Distance(waypoints.Last<Vector2>().To3D()) > SiteToSite || Math.Abs(ObjectManager.Player.Distance(waypoints.Last<Vector2>().To3D()) - ObjectManager.Player.Distance(target.Position)) > BackToFront || target.HasBuffOfType(BuffType.Slow) || target.HasBuff("Recall") || (target.Path.Count() == 0 && target.Position == target.ServerPosition) )) { if (target.IsFacing(ObjectManager.Player) || target.Path.Count() == 0) { if (ObjectManager.Player.Distance(target.Position) < QWER.Range - ((target.MoveSpeed * QWER.Delay) + (Player.Distance(target.Position) / QWER.Speed) + (target.BoundingRadius * 2))) QWER.CastIfHitchanceEquals(target, HitChance.High, true); } else { QWER.CastIfHitchanceEquals(target, HitChance.High, true); } } } else if (HitChanceNum == 4 && (int)poutput.Hitchance > 4) { List<Vector2> waypoints = target.GetWaypoints(); float SiteToSite = ((target.MoveSpeed * QWER.Delay) + (Player.Distance(target.ServerPosition) / QWER.Speed)) * 6 - QWER.Width; float BackToFront = ((target.MoveSpeed * QWER.Delay) + (Player.Distance(target.ServerPosition) / QWER.Speed)); if (ObjectManager.Player.Distance(waypoints.Last<Vector2>().To3D()) < SiteToSite || ObjectManager.Player.Distance(target.Position) < SiteToSite) QWER.CastIfHitchanceEquals(target, HitChance.High, true); else if (target.Path.Count() < 2 && (target.ServerPosition.Distance(waypoints.Last<Vector2>().To3D()) > SiteToSite || Math.Abs(ObjectManager.Player.Distance(waypoints.Last<Vector2>().To3D()) - ObjectManager.Player.Distance(target.Position)) > BackToFront || target.HasBuffOfType(BuffType.Slow) || target.HasBuff("Recall") || (target.Path.Count() == 0 && target.Position == target.ServerPosition) )) { // max range fix if (target.IsFacing(ObjectManager.Player) || target.Path.Count() == 0) { if (ObjectManager.Player.Distance(target.Position) < QWER.Range - ((target.MoveSpeed * QWER.Delay) + (Player.Distance(target.Position) / QWER.Speed) + (target.BoundingRadius * 2))) QWER.CastIfHitchanceEquals(target, HitChance.High, true); } else { QWER.CastIfHitchanceEquals(target, HitChance.High, true); } } } }
public static bool SpellPrediction(Spell spell, Obj_AI_Hero target,bool collisionable) { // var dist = ObjectManager.Player.Distance(target.Position); var pos1 = LeagueSharp.Common.Prediction.GetPrediction(target, dist / spell.Speed).UnitPosition-40; var dister = target.Position.Extend(target.GetWaypoints()[1].To3D(), target.GetWaypoints()[1].To3D().Distance(target.Position) + 50); // var pos1 = LeagueSharp.Common.Prediction.GetPrediction(target, dist / spell.Speed).UnitPosition - 40; var wts = Drawing.WorldToScreen(target.Position); var wtsx = target.GetWaypoints()[1]; Drawing.DrawLine(wts[0], wts[1], wtsx[0], wtsx[1], 2f, System.Drawing.Color.Red); var e = pos1.Distance(target.GetWaypoints()[1].To3D()); pos1.Extend(target.GetWaypoints()[1].To3D(), -e); Render.Circle.DrawCircle(dister, 10, System.Drawing.Color.GreenYellow, 2); Render.Circle.DrawCircle(pos1, 10, System.Drawing.Color.BlueViolet, 2); // var point = PointsAroundTheTarget(target.Position, target.BoundingRadius + 50).FirstOrDefault(t => t.IsWall()); if (point.X != 0 && point.Y != 0 && point.Z != 0) { if (MinionCollideLine(ObjectManager.Player.Position, ExtendWallpos(target, point), spell,collisionable)) return false; Render.Circle.DrawCircle(ExtendWallpos(target, point), 10, System.Drawing.Color.Brown, 2); spell.Cast(ExtendWallpos(target, point)); return true; } else { var range = spell.Range; if (target.Position.Distance(ObjectManager.Player.Position) < target.GetWaypoints()[1].Distance(ObjectManager.Player.Position)) { range -= 100; } if (!spell.IsInRange(target, range)) return false; /*if (target.IsFacing(ObjectManager.Player) && target.Position.Distance(ObjectManager.Player.Position) > target.GetWaypoints()[1].Distance(ObjectManager.Player.Position)) { if (MinionCollideLine(ObjectManager.Player.Position, target.Position, spell,collisionable)) return false; { Game.PrintChat("Casteando por inface"); spell.Cast(target.Position); return true; } }*/ // code of dashes if (target.IsDashing()) { float timeforArrive=(target.Position.Distance(target.GetDashInfo().EndPos.To3D()))/target.GetDashInfo().Speed; float grabtime =( ObjectManager.Player.Position.Distance(target.GetDashInfo().EndPos.To3D()) / spell.Speed)+spell.Delay; if (timeforArrive<grabtime) { spell.Cast(target.GetDashInfo().EndPos); return true; } } /* if (target.IsImmovable) // check for cc guys { if (MinionCollideLine(ObjectManager.Player.Position, target.Position, spell,collisionable)) return false; spell.Cast(target.Position); return true; }*/ // if(target.IsChannelingImportantSpell()) if (target.IsWindingUp && !target.IsMelee()) { if (MinionCollideLine(ObjectManager.Player.Position, target.Position, spell,collisionable)) return false; spell.Cast(target.Position); return true; } if (target.Position.Distance(ObjectManager.Player.Position) <= 300) { CastToDirection( target, spell,collisionable); } else { var oldPos = target.GetWaypoints()[0].To3D(); var h = false; Utility.DelayAction.Add(Game.Ping + 1000, () => h = Next(target, oldPos, spell,collisionable)); return h; } } return false; }
private void castR(Obj_AI_Hero target) { if (Config.Item("hitchanceR").GetValue<bool>()) { List<Vector2> waypoints = target.GetWaypoints(); if (target.Path.Count() < 2 && (Player.Distance(waypoints.Last<Vector2>().To3D()) - Player.Distance(target.Position)) > 400) { R.CastIfHitchanceEquals(target, HitChance.High, true); } } else R.Cast(target, true); }
public static bool SpellPrediction(Spell spell, Obj_AI_Hero target,bool collisionable) { // var dist = ObjectManager.Player.Distance(target.Position); var pos1 = LeagueSharp.Common.Prediction.GetPrediction(target, dist / spell.Speed).UnitPosition; var e = pos1.Distance(target.GetWaypoints()[1].To3D()); pos1.Extend(target.GetWaypoints()[1].To3D(), -e); Render.Circle.DrawCircle(pos1, 10, System.Drawing.Color.BlueViolet, 2); // var point = PointsAroundTheTarget(target.Position, target.BoundingRadius + 50).FirstOrDefault(t => t.IsWall()); if (point.X != 0 && point.Y != 0 && point.Z != 0) { if (MinionCollideLine(ObjectManager.Player.Position, ExtendWallpos(target, point), spell,collisionable)) return false; Render.Circle.DrawCircle(ExtendWallpos(target, point), 10, System.Drawing.Color.Brown, 2); spell.Cast(ExtendWallpos(target, point)); return true; } else { var range = spell.Range; if (target.Position.Distance(ObjectManager.Player.Position) < target.GetWaypoints()[1].Distance(ObjectManager.Player.Position)) { range -= 100; } if (!spell.IsInRange(target, range)) return false; if (target.IsFacing(ObjectManager.Player) && target.Position.Distance(ObjectManager.Player.Position) > target.GetWaypoints()[1].Distance(ObjectManager.Player.Position)) { if (MinionCollideLine(ObjectManager.Player.Position, target.Position, spell,collisionable)) return false; spell.Cast(target.Position); return true; } // float speed = if (target.IsImmovable) // check for cc guys { if (MinionCollideLine(ObjectManager.Player.Position, target.Position, spell,collisionable)) return false; spell.Cast(target.Position); return true; } // if(target.IsChannelingImportantSpell()) if (target.IsWindingUp && !target.IsMelee()) { if (MinionCollideLine(ObjectManager.Player.Position, target.Position, spell,collisionable)) return false; spell.Cast(target.Position); return true; } if (target.Position.Distance(ObjectManager.Player.Position) <= 300) { CastToDirection( target, spell,collisionable); } else { var oldPos = target.GetWaypoints()[0].To3D(); var h = false; Utility.DelayAction.Add(Game.Ping + 1000, () => h = Next(target, oldPos, spell,collisionable)); return h; } } return false; }
/// <summary> /// Gets Prediction result /// </summary> /// <param name="target">Target for spell</param> /// <param name="width">Vector 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> /// <returns>Prediction result as <see cref="Prediction.Vector.Result"/></returns> public static Result GetPrediction(Obj_AI_Hero target, float width, float delay, float vectorSpeed, float range, float vectorLenght) { return GetPrediction(target, width, delay, vectorSpeed, range, vectorSpeed, target.GetWaypoints(), target.AvgMovChangeTime(), target.LastMovChangeTime(), target.AvgPathLenght(), ObjectManager.Player.ServerPosition.To2D()); }
public static Vector3 WayPoint(Obj_AI_Hero hero) { return hero.GetWaypoints()[hero.GetWaypoints().Count - 1].To3D(); }
private void castR(Obj_AI_Hero target) { var inx = Config.Item("hitchanceR").GetValue<Slider>().Value; if (inx == 0) { R.Cast(R.GetPrediction(target).CastPosition); } else if (inx == 1) { R.Cast(target); } else if (inx == 2) { Program.CastSpell(R, target); } else if (inx == 3) { List<Vector2> waypoints = target.GetWaypoints(); if ((Player.Distance(waypoints.Last<Vector2>().To3D()) - Player.Distance(target.Position)) > 400) { Program.CastSpell(R, target); } } }
/// <Q> /// <param name="target"></param> private void CastQ(Obj_AI_Hero target) { if (!Q.IsReady() || !isValidTarget(target) || target == null || !ManaManager()) return; var a = Q.GetPrediction(target, true); var b = target.GetWaypoints().Count; if (a.Hitchance == HitChance.Immobile || a.Hitchance == HitChance.Dashing) { Q.CastIfHitchanceEquals(target, HitChance.High); } else if (b <= 2) { Q.CastIfHitchanceEquals(target, HitChance.High); } else if (b > 2) { Q.CastIfHitchanceEquals(target, HitChance.VeryHigh); } }
private static void CastSpell(Spell QWER, Obj_AI_Hero target, int HitChanceNum) { //HitChance 0 - 2 // example CastSpell(Q, ts, 2); if (HitChanceNum == 0) QWER.Cast(target, true); else if (HitChanceNum == 1) QWER.CastIfHitchanceEquals(target, HitChance.VeryHigh, true); else if (HitChanceNum == 2) { if (QWER.Delay < 0.3) QWER.CastIfHitchanceEquals(target, HitChance.Dashing, true); QWER.CastIfHitchanceEquals(target, HitChance.Immobile, true); QWER.CastIfWillHit(target, 2, true); if (target.Path.Count() < 2) QWER.CastIfHitchanceEquals(target, HitChance.VeryHigh, true); } else if (HitChanceNum == 3) { List<Vector2> waypoints = target.GetWaypoints(); //debug("" + target.Path.Count() + " " + (target.Position == target.ServerPosition) + (waypoints.Last<Vector2>().To3D() == target.ServerPosition)); if (QWER.Delay < 0.3) QWER.CastIfHitchanceEquals(target, HitChance.Dashing, true); QWER.CastIfHitchanceEquals(target, HitChance.Immobile, true); QWER.CastIfWillHit(target, 2, true); float SiteToSite = ((target.MoveSpeed * QWER.Delay) + (Player.Distance(target.ServerPosition) / QWER.Speed)) * 6 - QWER.Width; float BackToFront = ((target.MoveSpeed * QWER.Delay) + (Player.Distance(target.ServerPosition) / QWER.Speed)); if (ObjectManager.Player.Distance(waypoints.Last<Vector2>().To3D()) < SiteToSite || ObjectManager.Player.Distance(target.Position) < SiteToSite) QWER.CastIfHitchanceEquals(target, HitChance.High, true); else if (target.Path.Count() < 2 && (target.ServerPosition.Distance(waypoints.Last<Vector2>().To3D()) > SiteToSite || Math.Abs(ObjectManager.Player.Distance(waypoints.Last<Vector2>().To3D()) - ObjectManager.Player.Distance(target.Position)) > BackToFront || target.HasBuffOfType(BuffType.Slow) || target.HasBuff("Recall") || (target.Path.Count() == 0 && target.Position == target.ServerPosition) )) { if (target.IsFacing(ObjectManager.Player) || target.Path.Count() == 0) { if (ObjectManager.Player.Distance(target.Position) < QWER.Range - ((target.MoveSpeed * QWER.Delay) + (Player.Distance(target.Position) / QWER.Speed))) QWER.CastIfHitchanceEquals(target, HitChance.High, true); } else { QWER.CastIfHitchanceEquals(target, HitChance.High, true); } } } else if (HitChanceNum == 4 && (int)QWER.GetPrediction(target).Hitchance > 4) { List<Vector2> waypoints = target.GetWaypoints(); //debug("" + target.Path.Count() + " " + (target.Position == target.ServerPosition) + (waypoints.Last<Vector2>().To3D() == target.ServerPosition)); if (QWER.Delay < 0.3) QWER.CastIfHitchanceEquals(target, HitChance.Dashing, true); QWER.CastIfHitchanceEquals(target, HitChance.Immobile, true); QWER.CastIfWillHit(target, 2, true); float SiteToSite = ((target.MoveSpeed * QWER.Delay) + (Player.Distance(target.ServerPosition) / QWER.Speed)) * 6 - QWER.Width; float BackToFront = ((target.MoveSpeed * QWER.Delay) + (Player.Distance(target.ServerPosition) / QWER.Speed)); if (ObjectManager.Player.Distance(waypoints.Last<Vector2>().To3D()) < SiteToSite || ObjectManager.Player.Distance(target.Position) < SiteToSite) QWER.CastIfHitchanceEquals(target, HitChance.High, true); else if (target.Path.Count() < 2 && (target.ServerPosition.Distance(waypoints.Last<Vector2>().To3D()) > SiteToSite || Math.Abs(ObjectManager.Player.Distance(waypoints.Last<Vector2>().To3D()) - ObjectManager.Player.Distance(target.Position)) > BackToFront || target.HasBuffOfType(BuffType.Slow) || target.HasBuff("Recall") || (target.Path.Count() == 0 && target.Position == target.ServerPosition) )) { if (target.IsFacing(ObjectManager.Player) || target.Path.Count() == 0) { if (ObjectManager.Player.Distance(target.Position) < QWER.Range - ((target.MoveSpeed * QWER.Delay) + (Player.Distance(target.Position) / QWER.Speed))) QWER.CastIfHitchanceEquals(target, HitChance.High, true); } else { QWER.CastIfHitchanceEquals(target, HitChance.High, true); } } } }
/// <summary> /// Casts spell /// </summary> /// <param name="s">Spell to cast</param> /// <param name="t">Target for spell</param> /// <param name="hc">Minimum HitChance to cast</param> /// <param name="reactionIgnoreDelay">Delay to ignore target's reaction time</param> /// <param name="minHit">Minimum Hit Count to cast</param> /// <param name="rangeCheckFrom">Position where spell will be casted from</param> /// <param name="filterHPPercent">Minimum HP Percent to cast (for target)</param> /// <returns>true if spell has casted</returns> public static bool Cast(this Spell s, Obj_AI_Hero t, HitChance hc, int reactionIgnoreDelay = 0, byte minHit = 1, Vector3? rangeCheckFrom = null, float filterHPPercent = 100) { if (rangeCheckFrom == null) rangeCheckFrom = ObjectManager.Player.ServerPosition; if (minHit > 1) return Aoe.Cast(s, t, hc, reactionIgnoreDelay, minHit, rangeCheckFrom, filterHPPercent); if (t.HealthPercent > filterHPPercent) return false; if (Monitor.TryEnter(EnemyInfo[t.NetworkId].m_lock)) { try { HitChance predictedhc; float avgt = t.AvgMovChangeTime() + reactionIgnoreDelay; float movt = t.LastMovChangeTime(); Vector2 pos = GetPrediction(t, s, t.GetWaypoints(), avgt, movt, out predictedhc, rangeCheckFrom.Value); if (rangeCheckFrom.Value.To2D().Distance(pos) > s.Range + (s.Type == SkillshotType.SkillshotCircle ? s.Width / 2 : 0)) //out of range { Monitor.Pulse(EnemyInfo[t.NetworkId].m_lock); return false; } if (s.Collision && s.GetCollision(rangeCheckFrom.Value.To2D(), new List<Vector2> { pos }).Exists(q => q.IsEnemy)) //needs update { Monitor.Pulse(EnemyInfo[t.NetworkId].m_lock); return false; } if (predictedhc >= hc) { s.Cast(pos); return true; } Monitor.Pulse(EnemyInfo[t.NetworkId].m_lock); return false; } finally { Monitor.Exit(EnemyInfo[t.NetworkId].m_lock); } } return false; }