public EvadeResult CalculateEvade(Vector2 anchor, Vector2?awayFrom = null) { var playerPos = Player.Instance.ServerPosition.To2D(); var maxTime = GetTimeAvailable(); var time = Math.Max(0, maxTime - (Game.Ping + ServerTimeBuffer)); var points = GetEvadePoints(awayFrom ?? Player.Instance.Position.To2D()); if (!points.Any()) { Vector2 evadeSpellEvadePoint; //float needed = Player.Instance.Distance(GetClosestEvadePoint2()) / Player.Instance.MoveSpeed * 1000; //if (time < 30000) // Chat.Print("<b><font size='30' color='#FFFFFF'>dt: " + (needed - time) + " for " + Skillshots[0] + "</font></b>"); if (!EvadeSpellManager.TryEvadeSpell(time, this, out evadeSpellEvadePoint)) { return(new EvadeResult(this, GetClosestEvadePoint(playerPos), anchor, maxTime, time, ForceEvade) { IsForced = ForceEvade }); } //can use evade spell CurrentEvadeResult = new EvadeResult(this, evadeSpellEvadePoint, anchor, maxTime, time, true); } if (DoesComfortPointExist(points) && HasToAttendComfort()) { points.RemoveAll(p => !IsComfortPoint(p)); } var evadePoint = points.OrderBy(p => !p.IsUnderTurret()).ThenBy(p => p.Distance(Game.CursorPos)).FirstOrDefault(); return(new EvadeResult(this, evadePoint, anchor, maxTime, time, true)); }
public EvadeResult CalculateEvade(Vector2 anchor, Vector2?awayFrom = null) { var playerPos = Player.Instance.ServerPosition.To2D(); var maxTime = GetTimeAvailable(); var time = Math.Max(0, maxTime - (Game.Ping + ServerTimeBuffer)); var points = GetEvadePoints(awayFrom ?? Player.Instance.Position.To2D()); if (!points.Any()) { Vector2 evadeSpellEvadePoint; if (!EvadeSpellManager.TryEvadeSpell(time, this, out evadeSpellEvadePoint)) { var closest = GetClosestEvadePoint(playerPos); if (HasToAttendComfort() && !DoesComfortPointExist(new[] { closest }) && DontEvadeAtNoComfortPoint) { return(new EvadeResult(this, Vector2.Zero, anchor, 0, 0, false)); } return(new EvadeResult(this, closest, anchor, maxTime, time, ForceEvade) { IsForced = ForceEvade }); } if (HasToAttendComfort() && !DoesComfortPointExist(new [] { evadeSpellEvadePoint }) && DontEvadeAtNoComfortPoint) { return(new EvadeResult(this, Vector2.Zero, anchor, 0, 0, false)); } //can use evade spell CurrentEvadeResult = new EvadeResult(this, evadeSpellEvadePoint, anchor, maxTime, time, true); } if (HasToAttendComfort()) { if (DoesComfortPointExist(points)) { points.RemoveAll(p => !IsComfortPoint(p)); } else if (DontEvadeAtNoComfortPoint) { return(new EvadeResult(this, Vector2.Zero, anchor, 0, 0, false)); } } var evadePoint = points.OrderBy(p => !p.IsUnderTurret()).ThenBy(p => p.Distance(Game.CursorPos)).FirstOrDefault(); return(new EvadeResult(this, evadePoint, anchor, maxTime, time, true)); }
private void SpellbookOnOnCastSpell(Spellbook sender, SpellbookCastSpellEventArgs args) { if (!sender.Owner.IsMe || !EvadeEnabled) { return; } if (SpellBlocker.WillBlock(args.Slot) && IsHeroInDanger()) { args.Process = false; return; } if (BlockDangerousDashes && EvadeSpellManager.IsDashSpell(args.Slot) && !IsHeroInDanger()) { if (!EvadeSpellManager.IsDashSafe(EvadeSpellDatabase.Spells.First(x => x.Slot == args.Slot), args.EndPosition.To2D(), this)) { args.Process = false; } } }
public bool DoEvade(Vector3[] desiredPath = null, PlayerIssueOrderEventArgs args = null) { #region pre if (!EvadeEnabled || Player.Instance.IsDead || Player.Instance.IsDashing()) { LastEvadeResult = null; AutoPathing.StopPath(); return(false); } var hero = Player.Instance; if (args != null && args.Order == GameObjectOrder.AttackUnit) { if (!hero.IsInAutoAttackRange((AttackableUnit)args.Target)) { desiredPath = hero.GetPath(args.Target.Position, true); } } #endregion pre #region execute evade point movement if (LastEvadeResult != null) { var isPathSafe = IsHeroPathSafe(desiredPath); if (!IsHeroInDanger(hero) && isPathSafe) { LastEvadeResult = null; AutoPathing.StopPath(); return(false); } if (!hero.IsMovingTowards(LastEvadeResult.WalkPoint) || !isPathSafe) { AutoPathing.StopPath(); MoveTo(GetExtendedEvade(LastEvadeResult.WalkPoint.To2D()), false); } return(true); } #endregion execute evade point movement #region check evade if (IsHeroInDanger(hero)) { var evade = CalculateEvade(LastIssueOrderPos); if (evade.IsValid && evade.EnoughTime) { if (LastEvadeResult == null || (LastEvadeResult.EvadePoint.Distance(evade.EvadePoint, true) > 500.Pow() && AllowRecalculateEvade)) { LastEvadeResult = evade; } } else if (!evade.EnoughTime) { return(EvadeSpellManager.TryEvadeSpell(evade, this)); } } else if (!IsPathSafe(hero.RealPath()) || (desiredPath != null && !IsPathSafe(desiredPath))) { var evade = CalculateEvade(LastIssueOrderPos, true); if (evade.IsValid) { LastEvadeResult = evade; return(true); } //LastEvadeResult = null; return(desiredPath != null); } #endregion check evade else { AutoPathing.StopPath(); LastEvadeResult = null; } return(false); }