/// <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> /// 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> /// 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 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); }