private void OnSkillshotDeleted(EvadeSkillshot skillshot) { if (RestorePosition && !SpellDetector.DetectedSkillshots.Any()) { if (AutoPathing.IsPathing && Player.Instance.IsWalking()) { var destination = AutoPathing.Destination; AutoPathing.StopPath(); Player.IssueOrder(GameObjectOrder.MoveTo, destination.To3DWorld(), false); } else if (LastEvadeResult != null && Player.Instance.IsMovingTowards(LastEvadeResult.EvadePoint)) { Player.IssueOrder(GameObjectOrder.MoveTo, LastIssueOrderPos.To3DWorld(), 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); }