/// <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, AIHeroClient target) { #region if common prediction selected if (ConfigMenu.SelectedPrediction.Index == 1) { var pred = s.GetPrediction(target); var result = new Prediction.Result(new Prediction.Input(target, s), target, pred.CastPosition.ToVector2(), pred.UnitPosition.ToVector2(), pred.Hitchance, default(Collision.Result)); result.Lock(false); return(result); } #endregion switch (s.Type) { case SkillshotType.Line: 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.ToVector2(), s.RangeCheckFrom.ToVector2())); case SkillshotType.Circle: 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.ToVector2(), s.RangeCheckFrom.ToVector2())); case SkillshotType.Cone: 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.ToVector2(), s.RangeCheckFrom.ToVector2())); } throw new NotSupportedException("Unknown skill shot type"); }
/// <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, AIHeroClient t, float ringRadius, EloBuddy.SDK.Enumerations.HitChance hc, bool onlyEdge = true, int reactionIgnoreDelay = 0, byte minHit = 1, Vector3?rangeCheckFrom = null, float filterHPPercent = 100) { if (ConfigMenu.SelectedPrediction == 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; } var avgt = t.AvgMovChangeTime() + reactionIgnoreDelay; float movt = t.LastMovChangeTime(); var 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.LSTo2D(), rangeCheckFrom.Value.LSTo2D()); } else { result = CirclePrediction.GetPrediction(t, s.Width, s.Delay, s.Speed, s.Range + ringRadius, s.Collision, t.GetWaypoints(), avgt, movt, avgp, 360, s.From.LSTo2D(), rangeCheckFrom.Value.LSTo2D()); } Drawings.s_DrawTick = Utils.TickCount; Drawings.s_DrawPos = result.CastPosition; Drawings.s_DrawHitChance = result.HitChance.ToString(); Drawings.s_DrawDirection = (result.CastPosition - s.From.LSTo2D()).LSNormalized().LSPerpendicular(); Drawings.s_DrawWidth = (int)ringRadius; if (result.HitChance >= hc) { s.Cast(result.CastPosition); return(true); } return(false); }
/// <summary> /// Gets Prediction result /// </summary> /// <param name="target">Target for spell</param> /// <param name="radius">Spell radius</param> /// <param name="ringRadius">Ring radius</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="path">Waypoints of target</param> /// <param name="avgt">Average reaction time (in ms)</param> /// <param name="movt">Passed time from last movement change (in ms)</param> /// <param name="avgp">Average Path Lenght</param> /// <param name="from">Spell casted position</param> /// <param name="rangeCheckFrom"></param> /// <returns>Prediction result as <see cref="Prediction.Result"/></returns> public static Prediction.Result GetPrediction(Obj_AI_Base target, float radius, float ringRadius, float delay, float missileSpeed, float range, bool collisionable, List<Vector2> path, float avgt, float movt, float avgp, Vector2 from, Vector2 rangeCheckFrom) { //if you are copying it negro; dont forget sprediction credits, ty. Prediction.Result result = CirclePrediction.GetPrediction(target, ringRadius, delay, missileSpeed, range + radius, collisionable, path, avgt, movt, avgp, 360, from, rangeCheckFrom); if (result.HitChance > HitChance.Low) { Vector2 direction = (result.CastPosition - from + target.Direction.To2D()).Normalized(); result.CastPosition -= direction * (radius - ringRadius / 2f); if (result.CastPosition.Distance(from) > range) result.HitChance = HitChance.OutOfRange; } return result; }
/// <summary> /// Spell extension for cast aoe spell with SPrediction /// </summary> /// <param name="minHit">Minimum aoe hits to cast</param> /// <returns></returns> public static bool SPredictionCastAoe(this Spell s, int minHit) { if (minHit < 2) { throw new InvalidOperationException("Minimum aoe hit count cannot be less than 2"); } if (s.Collision) { throw new InvalidOperationException("Collisionable spell"); } Prediction.AoeResult result; switch (s.Type) { case SkillshotType.SkillshotLine: result = LinePrediction.GetAoePrediction(s.Width, s.Delay, s.Speed, s.Range, s.From.LSTo2D(), s.RangeCheckFrom.LSTo2D()); break; case SkillshotType.SkillshotCircle: result = CirclePrediction.GetAoePrediction(s.Width, s.Delay, s.Speed, s.Range, s.From.LSTo2D(), s.RangeCheckFrom.LSTo2D()); break; case SkillshotType.SkillshotCone: result = ConePrediction.GetAoePrediction(s.Width, s.Delay, s.Speed, s.Range, s.From.LSTo2D(), s.RangeCheckFrom.LSTo2D()); break; default: throw new InvalidOperationException("Unknown spell type"); } Drawings.s_DrawTick = Utils.TickCount; Drawings.s_DrawPos = result.CastPosition; Drawings.s_DrawHitChance = string.Format("Aoe Cast (Hits: {0})", result.HitCount); Drawings.s_DrawDirection = (result.CastPosition - s.From.LSTo2D()).LSNormalized().LSPerpendicular(); Drawings.s_DrawWidth = (int)s.Width; if (result.HitCount >= minHit) { return(s.Cast(result.CastPosition)); } 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 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"); }
/// <summary> /// Gets aoe prediction result /// </summary> /// <returns>Prediction result as <see cref="Prediction.Result"/></returns> public static Prediction.AoeResult GetAoeSPrediction(this Spell s) { if (s.Collision) { throw new InvalidOperationException("Collisionable spell"); } switch (s.Type) { case SkillshotType.Line: return(LinePrediction.GetAoePrediction(s.Width, s.Delay, s.Speed, s.Range, s.From.ToVector2(), s.RangeCheckFrom.ToVector2())); case SkillshotType.Circle: return(CirclePrediction.GetAoePrediction(s.Width, s.Delay, s.Speed, s.Range, s.From.ToVector2(), s.RangeCheckFrom.ToVector2())); case SkillshotType.Cone: return(ConePrediction.GetAoePrediction(s.Width, s.Delay, s.Speed, s.Range, s.From.ToVector2(), s.RangeCheckFrom.ToVector2())); } throw new NotSupportedException("Unknown skill shot type"); }
/// <summary> /// Gets Prediction result /// </summary> /// <param name="target">Target for spell</param> /// <param name="radius">Spell radius</param> /// <param name="ringRadius">Ring radius</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="path">Waypoints of target</param> /// <param name="avgt">Average reaction time (in ms)</param> /// <param name="movt">Passed time from last movement change (in ms)</param> /// <param name="avgp">Average Path Lenght</param> /// <param name="from">Spell casted position</param> /// <param name="rangeCheckFrom"></param> /// <returns>Prediction result as <see cref="Prediction.Result" /></returns> public static Prediction.Result GetPrediction(Obj_AI_Base target, float radius, float ringRadius, float delay, float missileSpeed, float range, bool collisionable, List <Vector2> path, float avgt, float movt, float avgp, Vector2 from, Vector2 rangeCheckFrom) { //if you are copying it negro; dont forget sprediction credits, ty. var result = CirclePrediction.GetPrediction(target, ringRadius, delay, missileSpeed, range + radius, collisionable, path, avgt, movt, avgp, 360, from, rangeCheckFrom); if (result.HitChance > EloBuddy.SDK.Enumerations.HitChance.Low) { var direction = (result.CastPosition - from + target.Direction.LSTo2D()).LSNormalized(); result.CastPosition -= direction * (radius - ringRadius / 2f); if (result.CastPosition.LSDistance(from) > range) { result.HitChance = EloBuddy.SDK.Enumerations.HitChance.Unknown; } } return(result); }
public PredictionOutput GetPrediction(EnsoulSharp.SDK.PredictionInput input) { if (input.Aoe && !input.Collision) { switch (input.Type) { case SpellType.Line: return(LinePrediction.GetLineAoePrediction(input.Range, input.Delay, input.Speed, input.Range, input.From.ToVector2(), input.RangeCheckFrom.ToVector2()).ToSDKResult()); case SpellType.Circle: return(CirclePrediction.GetAoePrediction(input.Radius, input.Delay, input.Speed, input.Range, input.From.ToVector2(), input.RangeCheckFrom.ToVector2()).ToSDKResult()); case SpellType.Cone: return(ConePrediction.GetAoePrediction(input.Radius, input.Delay, input.Speed, input.Range, input.From.ToVector2(), input.RangeCheckFrom.ToVector2()).ToSDKResult()); } return(new PredictionOutput()); } var inp = new PredictionInput(input.Unit, input.Delay, input.Speed, input.Radius, input.Range, input.Collision, input.Type, input.From, input.RangeCheckFrom); return(this.GetPrediction(inp).ToSDKResult()); }
/// <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="path">Waypoints of target</param> /// <param name="avgt">Average reaction time (in ms)</param> /// <param name="movt">Passed time from last movement change (in ms)</param> /// <param name="avgp">Average Path Lenght</param> /// <param name="from">Spell casted position</param> /// <param name="rangeCheckFrom"></param> /// <returns>Prediction result as <see cref="Prediction.Result"/></returns> public static Prediction.Result GetPrediction(Obj_AI_Base target, float width, float delay, float missileSpeed, float range, bool collisionable, List <Vector2> path, float avgt, float movt, float avgp, float anglediff, Vector2 from, Vector2 rangeCheckFrom, bool arconly = true) { Prediction.AssertInitializationMode(); if (arconly) { if (target.Distance(from) < width || target.Distance(from) > range * 0.75f) { return(CirclePrediction.GetPrediction(target, width, delay, missileSpeed, range, collisionable, path, avgt, movt, avgp, anglediff, from, rangeCheckFrom)); } var pred = LinePrediction.GetPrediction(target, 80f, delay, missileSpeed, range, collisionable, path, avgt, movt, avgp, anglediff, from, rangeCheckFrom); if (pred.HitChance >= HitChance.Low) { pred.CastPosition = (from + (pred.CastPosition - from).Normalized() * range); float cos = (float)Math.Cos((1 - pred.UnitPosition.Distance(from) / 820f) * Math.PI / 2); float sin = (float)Math.Sin((1 - pred.UnitPosition.Distance(from) / 820f) * Math.PI / 2); float x = cos * (pred.CastPosition.X - from.X) - sin * (pred.CastPosition.Y - from.Y) + from.X; float y = sin * (pred.CastPosition.X - from.X) + cos * (pred.CastPosition.Y - from.Y) + from.Y; pred.CastPosition = new Vector2(x, y); } return(pred); } else { Prediction.Result result = new Prediction.Result(); if (path.Count <= 1) //if target is not moving, easy to hit { result.HitChance = HitChance.Immobile; result.CastPosition = target.ServerPosition.To2D(); result.UnitPosition = result.CastPosition; return(result); } if (target is AIHeroClient && ((AIHeroClient)target).IsChannelingImportantSpell()) { result.HitChance = HitChance.Immobile; result.CastPosition = target.ServerPosition.To2D(); result.UnitPosition = result.CastPosition; return(result); } if (Utility.IsImmobileTarget(target)) { return(Prediction.GetImmobilePrediction(target, width, delay, missileSpeed, range, collisionable, SkillshotType.SkillshotCircle, from, rangeCheckFrom)); } if (target.IsDashing()) { return(Prediction.GetDashingPrediction(target, width, delay, missileSpeed, range, collisionable, SkillshotType.SkillshotCircle, from, rangeCheckFrom)); } float targetDistance = rangeCheckFrom.Distance(target.ServerPosition); float flyTime = 0f; if (missileSpeed != 0) { Vector2 Vt = (path[path.Count - 1] - path[0]).Normalized() * target.MoveSpeed; Vector2 Vs = (target.ServerPosition.To2D() - rangeCheckFrom).Normalized() * missileSpeed; Vector2 Vr = Vs - Vt; flyTime = targetDistance / Vr.Length(); if (path.Count > 5) { flyTime = targetDistance / missileSpeed; } } float t = flyTime + delay + Game.Ping / 2000f + ConfigMenu.SpellDelay / 1000f; result.HitChance = Prediction.GetHitChance(t * 1000f, avgt, movt, avgp, anglediff); #region arc collision test if (result.HitChance > HitChance.Low) { for (int i = 1; i < path.Count; i++) { Vector2 senderPos = rangeCheckFrom; Vector2 testPos = path[i]; float multp = (testPos.Distance(senderPos) / 875.0f); var dianaArc = new SPrediction.Geometry.Polygon( ClipperWrapper.DefineArc(senderPos - new Vector2(875 / 2f, 20), testPos, (float)Math.PI * multp, 410, 200 * multp), ClipperWrapper.DefineArc(senderPos - new Vector2(875 / 2f, 20), testPos, (float)Math.PI * multp, 410, 320 * multp)); if (!ClipperWrapper.IsOutside(dianaArc, target.ServerPosition.To2D())) { result.HitChance = HitChance.VeryHigh; result.CastPosition = testPos; result.UnitPosition = testPos; return(result); } } } #endregion return(CirclePrediction.GetPrediction(target, width, delay, missileSpeed, range, collisionable, path, avgt, movt, avgp, anglediff, from, rangeCheckFrom)); } }
/// <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, AIHeroClient t, HitChance hc, int reactionIgnoreDelay = 0, byte minHit = 1, Vector3?rangeCheckFrom = null, float filterHPPercent = 100) { if (rangeCheckFrom == null) { rangeCheckFrom = ObjectManager.Player.PreviousPosition; } if (t == null) { return(s.Cast()); } if (!s.IsSkillShot) { return(s.Cast(t) == CastStates.SuccessfullyCasted); } #region if common prediction selected if (ConfigMenu.SelectedPrediction.Index == 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); } 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.Line: result = LinePrediction.GetPrediction(t, s.Width, s.Delay, s.Speed, s.Range, s.Collision, waypoints, avgt, movt, avgp, t.LastAngleDiff(), s.From.ToVector2(), s.RangeCheckFrom.ToVector2()); break; case SkillshotType.Circle: result = CirclePrediction.GetPrediction(t, s.Width, s.Delay, s.Speed, s.Range, s.Collision, waypoints, avgt, movt, avgp, t.LastAngleDiff(), s.From.ToVector2(), s.RangeCheckFrom.ToVector2()); break; case SkillshotType.Cone: result = ConePrediction.GetPrediction(t, s.Width, s.Delay, s.Speed, s.Range, s.Collision, waypoints, avgt, movt, avgp, t.LastAngleDiff(), s.From.ToVector2(), s.RangeCheckFrom.ToVector2()); break; default: throw new InvalidOperationException("Unknown spell type"); } Drawings.s_DrawTick = Variables.TickCount; Drawings.s_DrawPos = result.CastPosition; Drawings.s_DrawHitChance = result.HitChance.ToString(); Drawings.s_DrawDirection = (result.CastPosition - s.From.ToVector2()).Normalized().Perpendicular(); Drawings.s_DrawWidth = (int)s.Width; if (result.HitChance >= hc) { s.Cast(result.CastPosition); return(true); } 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="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 (ConfigMenu.SelectedPrediction.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()); } Drawings.s_DrawTick = Utils.TickCount; Drawings.s_DrawPos = result.CastPosition; Drawings.s_DrawHitChance = result.HitChance.ToString(); Drawings.s_DrawDirection = (result.CastPosition - s.From.To2D()).Normalized().Perpendicular(); Drawings.s_DrawWidth = (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); }
/// <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, t.LastAngleDiff(), 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, t.LastAngleDiff(), 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, t.LastAngleDiff(), 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> /// 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="path">Waypoints of target</param> /// <param name="avgt">Average reaction time (in ms)</param> /// <param name="movt">Passed time from last movement change (in ms)</param> /// <param name="avgp">Average Path Lenght</param> /// <param name="from">Spell casted position</param> /// <param name="rangeCheckFrom">Spell range check fropm</param> /// <param name="arconly">Is Arc</param> /// <returns>Prediction result as <see cref="PredictionResult"/></returns> public static PredictionResult GetPrediction(AIBaseClient target, float width, float delay, float missileSpeed, float range, bool collisionable, List <Vector2> path, float avgt, float movt, float avgp, float anglediff, Vector2 from, Vector2 rangeCheckFrom, bool arconly = true) { if (arconly) { if (target.Distance(from) < width || target.Distance(from) > range * 0.75f) { return(CirclePrediction.GetPrediction(target, width, delay, missileSpeed, range, collisionable, path, avgt, movt, avgp, anglediff, from, rangeCheckFrom)); } var pred = LinePrediction.GetLinePrediction(target, 80f, delay, missileSpeed, range, collisionable, path, avgt, movt, avgp, anglediff, from, rangeCheckFrom); if (pred.HitChance >= HitChance.Low) { pred.CastPosition = (from + (pred.CastPosition - from).Normalized() * range); var cos = (float)Math.Cos((1 - pred.UnitPosition.Distance(from) / 820f) * Math.PI / 2); var sin = (float)Math.Sin((1 - pred.UnitPosition.Distance(from) / 820f) * Math.PI / 2); var x = cos * (pred.CastPosition.X - from.X) - sin * (pred.CastPosition.Y - from.Y) + from.X; var y = sin * (pred.CastPosition.X - from.X) + cos * (pred.CastPosition.Y - from.Y) + from.Y; pred.CastPosition = new Vector2(x, y); } return(pred); } var result = new PredictionResult(); if (path.Count <= 1) //if target is not moving, easy to hit { result.HitChance = HitChance.Immobile; result.CastPosition = target.PreviousPosition.ToVector2(); result.UnitPosition = result.CastPosition; return(result); } if (target is AIHeroClient aiHero && aiHero.IsCastingImporantSpell()) { result.HitChance = HitChance.Immobile; result.CastPosition = aiHero.PreviousPosition.ToVector2(); result.UnitPosition = result.CastPosition; return(result); } if (target.IsImmobileTarget()) { return(PredictionExtensions.GetImmobilePrediction(target, width, delay, missileSpeed, range, collisionable, SpellType.Circle, from, rangeCheckFrom)); } if (target.IsDashing()) { return(PredictionExtensions.GetDashingPrediction(target, width, delay, missileSpeed, range, collisionable, SpellType.Circle, from, rangeCheckFrom)); } var targetDistance = rangeCheckFrom.Distance(target.PreviousPosition); var flyTime = 0f; if (missileSpeed != 0) { var Vt = (path[path.Count - 1] - path[0]).Normalized() * target.MoveSpeed; var Vs = (target.PreviousPosition.ToVector2() - rangeCheckFrom).Normalized() * missileSpeed; var Vr = Vs - Vt; flyTime = targetDistance / Vr.Length(); if (path.Count > 5) { flyTime = targetDistance / missileSpeed; } } var t = flyTime + delay + Game.Ping / 2000f + Program.SpellDelay / 1000f; result.HitChance = PredictionExtensions.GetHitChance(t * 1000f, avgt, movt, avgp, anglediff); //arc collision test if (result.HitChance > HitChance.Low) { for (var i = 1; i < path.Count; i++) { var senderPos = rangeCheckFrom; var testPos = path[i]; var multp = (testPos.Distance(senderPos) / 875.0f); var dianaArc = new Geometry.Polygon( ClipperWrapper.DefineArc(senderPos - new Vector2(875 / 2f, 20), testPos, (float)Math.PI * multp, 410, 200 * multp), ClipperWrapper.DefineArc(senderPos - new Vector2(875 / 2f, 20), testPos, (float)Math.PI * multp, 410, 320 * multp)); if (!dianaArc.IsOutside(target.PreviousPosition.ToVector2())) { result.HitChance = HitChance.VeryHigh; result.CastPosition = testPos; result.UnitPosition = testPos; return(result); } } } return(CirclePrediction.GetPrediction(target, width, delay, missileSpeed, range, collisionable, path, avgt, movt, avgp, anglediff, @from, rangeCheckFrom)); }