private void OnSkillshotDeleted(EvadeSkillshot skillshot) { if (RestorePosition && !SkillshotDetector.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) { 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); } } if (IsHeroInDanger(hero)) { if (LastEvadeResult != null && (!IsPointSafe(LastEvadeResult.EvadePoint) || LastEvadeResult.Expired())) { // LastEvadeResult = null; } 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 && LastEvadeResult == null && !IsHeroPathSafe(evade, desiredPath)) { return(EvadeSpellManager.ProcessFlash(this)); } } if (LastEvadeResult != null) //&& LastEvadeResult.EvadePoint.Distance(hero) > hero.HitBoxRadius() { var isPathSafe = IsHeroPathSafe(evade, desiredPath); if (!hero.IsMovingTowards(LastEvadeResult.WalkPoint) || !isPathSafe) { AutoPathing.StopPath(); MoveTo(LastEvadeResult.WalkPoint, false); } return(true); } } else if (!IsPathSafe(hero.RealPath()) || (desiredPath != null && !IsPathSafe(desiredPath))) { var path = PathFinding.GetPath(hero.Position.To2D(), LastIssueOrderPos); var evade = CalculateEvade(LastIssueOrderPos); if (evade.IsValid) { path = new[] { evade.EvadePoint }.Concat(path).ToArray(); } if (path.Length > 0 && AutoPathing.Destination.Distance(path.Last(), true) > 50.Pow()) { AutoPathing.DoPath(path); } LastEvadeResult = null; return(desiredPath != null); } else { AutoPathing.StopPath(); LastEvadeResult = null; } return(false); }
public bool DoEvade(Vector3[] desiredPath = null) { if (!EvadeEnabled || Player.Instance.IsDead) { LastEvadeResult = null; AutoPathing.StopPath(); return(false); } var hero = Player.Instance; if (IsHeroInDanger(hero)) { if (LastEvadeResult != null && (!IsPointSafe(LastEvadeResult.EvadePoint) || !IsPathSafe(hero.GetPath(LastEvadeResult.EvadePoint.To3DWorld(), true)) || LastEvadeResult.Expired())) { LastEvadeResult = null; } var evade = CalculateEvade(LastIssueOrderPos); if (evade.IsValid && evade.EnoughTime) { if (LastEvadeResult == null || (LastEvadeResult.EvadePoint.Distance(evade.EvadePoint, true) > 300.Pow() && AllowRecalculateEvade)) { LastEvadeResult = evade; } if (IsHeroPathSafe(evade, desiredPath)) { LastEvadeResult = null; } } else { if (!evade.EnoughTime && LastEvadeResult == null && !IsHeroPathSafe(evade, desiredPath)) { var result = EvadeSpellManager.ProcessFlash(this); if (!result && AlwaysEvade && evade.IsValid) { Player.IssueOrder(GameObjectOrder.MoveTo, evade.EvadePoint.To3DWorld(), false); } return(result); } } if (LastEvadeResult != null) { if (!hero.IsMovingTowards(LastEvadeResult.EvadePoint)) { AutoPathing.StopPath(); Player.IssueOrder(GameObjectOrder.MoveTo, LastEvadeResult.EvadePoint.To3DWorld(), false); } return(true); } } else if (!IsPathSafe(hero.RealPath()) || (desiredPath != null && !IsPathSafe(desiredPath))) { var path = GetPath(hero.Position.To2D(), LastIssueOrderPos); if (path.Length > 0 && AutoPathing.Destination.Distance(path.Last(), true) > 50.Pow()) { AutoPathing.DoPath(path); } LastEvadeResult = null; return(true); } else { AutoPathing.StopPath(); LastEvadeResult = null; } return(false); }