public static int LastMovChangeTime(this Obj_AI_Hero t) { Prediction.AssertInitializationMode(); return(Environment.TickCount - PathTracker.EnemyInfo[t.NetworkId].LastWaypointTick); }
/// <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> internal static Result GetPrediction(Obj_AI_Base target, float width, float delay, float missileSpeed, float range, bool collisionable, SkillshotType type, List <Vector2> path, float avgt, float movt, float avgp, float anglediff, Vector2 from, Vector2 rangeCheckFrom) { Prediction.AssertInitializationMode(); Result result = new Result(); result.Input = new Input(target, delay, missileSpeed, width, range, collisionable, type, from.To3D2(), rangeCheckFrom.To3D2()); result.Unit = target; try { if (type == SkillshotType.SkillshotCircle) { range += width; } //to do: hook logic ? by storing average movement direction etc if (path.Count <= 1 && movt > 100 && (Environment.TickCount - PathTracker.EnemyInfo[target.NetworkId].LastAATick > 300 || !ConfigMenu.CheckAAWindUp)) //if target is not moving, easy to hit (and not aaing) { result.HitChance = HitChance.VeryHigh; result.CastPosition = target.ServerPosition.To2D(); result.UnitPosition = result.CastPosition; result.Lock(); return(result); } if (target is AIHeroClient) { if (((AIHeroClient)target).IsChannelingImportantSpell()) { result.HitChance = HitChance.VeryHigh; result.CastPosition = target.ServerPosition.To2D(); result.UnitPosition = result.CastPosition; result.Lock(); return(result); } if (Environment.TickCount - PathTracker.EnemyInfo[target.NetworkId].LastAATick < 300 && ConfigMenu.CheckAAWindUp) { if (target.AttackCastDelay * 1000 + PathTracker.EnemyInfo[target.NetworkId].AvgOrbwalkTime + avgt - width / 2f / target.MoveSpeed >= GetArrivalTime(target.ServerPosition.To2D().Distance(from), delay, missileSpeed)) { result.HitChance = HitChance.High; result.CastPosition = target.ServerPosition.To2D(); result.UnitPosition = result.CastPosition; result.Lock(); return(result); } } //to do: find a fuking logic if (avgp < 400 && movt < 100 && path.PathLength() <= avgp) { result.HitChance = HitChance.High; result.CastPosition = path.Last(); result.UnitPosition = result.CastPosition; result.Lock(); return(result); } } if (target.IsDashing()) //if unit is dashing { return(GetDashingPrediction(target, width, delay, missileSpeed, range, collisionable, type, from, rangeCheckFrom)); } if (Utility.IsImmobileTarget(target)) //if unit is immobile { return(GetImmobilePrediction(target, width, delay, missileSpeed, range, collisionable, type, from, rangeCheckFrom)); } result = WaypointAnlysis(target, width, delay, missileSpeed, range, collisionable, type, path, avgt, movt, avgp, anglediff, from); float d = result.CastPosition.Distance(target.ServerPosition.To2D()); if (d >= (avgt - movt) * target.MoveSpeed && d >= avgp) { result.HitChance = HitChance.Medium; } result.Lock(); return(result); } finally { //check if movement changed while prediction calculations if (!target.GetWaypoints().SequenceEqual(path)) { result.HitChance = HitChance.Medium; } } }
public static int MovImmobileTime(this Obj_AI_Hero t) { Prediction.AssertInitializationMode(); return(PathTracker.EnemyInfo[t.NetworkId].IsStopped ? Environment.TickCount - PathTracker.EnemyInfo[t.NetworkId].StopTick : 0); }
/// <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) { 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) /*.RotateAroundPoint(from, (1 - pred.UnitPosition.Distance(ObjectManager.Player.ServerPosition.To2D()) / 820f) * (float)Math.PI / 2f)*/; 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 Obj_AI_Hero && ((Obj_AI_Hero)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)); } }