public override void DoWork() { Logging.Debug("Approaching: " + _node.Location); if (_nodeLoc == _node.Location) { if (_approachTimes > 6) { Logging.Write("We tried to approach the same node more than 6 times... does not make sense abort"); FlyingBlackList.Blacklist(_node, 120, true); return; } _approachTimes++; } else { _nodeLoc = _node.Location; _approachTimes = 0; } if (Gather.GatherNode(_node)) { FlyingEngine.UpdateStats(1, 0, 0); if (FlyingSettings.WaitForLoot) { while (ObjectManager.MyPlayer.LootWinOpen && !TimeOut.IsReady) { Thread.Sleep(100); } Latency.Sleep(1300); } if (ObjectManager.MyPlayer.IsInFlightForm) { MoveHelper.Jump(); } } else { if (ObjectManager.ShouldDefend && Mount.IsMounted()) { Logging.Write("ShouldDefend while mounted? Odd"); FlyingBlackList.Blacklist(_node, 120, true); } } if (!ObjectManager.MyPlayer.InVashjir && ObjectManager.MyPlayer.IsSwimming) { Logging.Write("We got into the water, blacklisting node"); FlyingBlackList.AddBadNode(_node); KeyHelper.SendKey("Space"); Thread.Sleep(3000); KeyHelper.ReleaseKey("Space"); } if (!ObjectManager.ShouldDefend && !ObjectManager.MyPlayer.IsInCombat) { LootedBlacklist.Looted(_node); if (ObjectManager.MyPlayer.InVashjir) { KeyHelper.SendKey("Space"); Thread.Sleep(1000); KeyHelper.ReleaseKey("Space"); } } if (!Mount.IsMounted()) { CombatHandler.RunningAction(); CombatHandler.Rest(); } Stuck.Reset(); if (FlyingEngine.CurrentProfile.NaturalRun) { FlyingEngine.Navigation.UseNearestWaypoint(); } else { FlyingEngine.Navigation.UseNearestWaypoint(10); } }
public RunStatus Execute() { if (!IsQueuedMovement) { return(RunStatus.Failure); } if (CurrentMovement == null) { CurrentMovement = _internalQueue.Dequeue(); CurrentMovement.StartPosition = ZetaDia.Me.Position; CurrentMovement.LastStartedTime = DateTime.UtcNow; Stuck.Reset(); } _options = CurrentMovement.Options; if (CurrentMovement.OnUpdate != null) { CurrentMovement.OnUpdate.Invoke(CurrentMovement); } _status.LastStatus = PlayerMover.NavigateTo(CurrentMovement.Destination, CurrentMovement.Name); _status.DistanceToObjective = ZetaDia.Me.Position.Distance(CurrentMovement.Destination); _status.ChangeInDistance = _status.LastPosition.Distance(CurrentMovement.Destination) - _status.DistanceToObjective; _status.LastPosition = ZetaDia.Me.Position; CurrentMovement.Status = _status; if (CurrentMovement.StopCondition != null && CurrentMovement.StopCondition.Invoke(CurrentMovement)) { FailedHandler("StopWhen"); return(RunStatus.Failure); } if (Stuck.IsStuck(_options.ChangeInDistanceLimit, _options.TimeBeforeBlocked)) { FailedHandler("Blocked " + Stuck.LastLogMessage); return(RunStatus.Failure); } if (_status.DistanceToObjective < _options.AcceptableDistance) { SuccessHandler(string.Format("AcceptableDistance: {0}", _options.AcceptableDistance)); return(RunStatus.Success); } if (IsBlacklisted(CurrentMovement)) { FailedHandler("RecentlyFailed"); return(RunStatus.Success); } if (_status.DistanceToObjective > _options.MaxDistance) { FailedHandler(string.Format("MaxDistance: {0}", _options.MaxDistance)); return(RunStatus.Success); } switch (_status.LastStatus) { case MoveResult.ReachedDestination: SuccessHandler(); return(RunStatus.Success); case MoveResult.PathGenerationFailed: case MoveResult.Moved: MovedHandler(); return(RunStatus.Running); case MoveResult.Failed: FailedHandler("Navigation"); return(RunStatus.Failure); default: return(RunStatus.Success); } }