public void MoveStop() { if (!IsLanding) { InnerMover.MoveStop(); IsMovingTowardsLocation = false; } // TODO: Check can land!! if (!IsLanding && (FlightMovementArgs.ForceLanding || GameObjectManager.LocalPlayer.Location.IsGround(4.5f))) { IsLanding = true; ForceLanding(); } }
public void MoveTowards(Vector3 location) { if (ShouldFly && !MovementManager.IsFlying && !IsTakingOff) { IsTakingOff = true; IsMovingTowardsLocation = true; EnsureFlying(); } if (!IsTakingOff) { lastDestination = location; IsMovingTowardsLocation = true; InnerMover.MoveTowards(location); } }
public void MoveTowards(Vector3 location) { if (IsLanding && location.Distance3D(Core.Me.Location) < CharacterSettings.Instance.MountDistance) { ForceLanding(); return; } if (ShouldFly && !MovementManager.IsFlying && !IsTakingOff) { IsTakingOff = true; IsMovingTowardsLocation = true; EnsureFlying(); } if (!IsTakingOff) { IsMovingTowardsLocation = true; InnerMover.MoveTowards(location); } }
public void ForceLanding() { #if RB_CN if (MovementManager.IsFlying) #else if (MovementManager.IsFlying && !IsDiving) #endif { if (!landingStopwatch.IsRunning) { landingStopwatch.Restart(); } if (!totalLandingStopwatch.IsRunning) { totalLandingStopwatch.Restart(); } if (landingTask == null) { lock (landingTaskLock) { if (landingTask == null) { Logger.Info(Localization.Localization.FlightEnabledSlideMover_LandStart); landingTask = Task.Factory.StartNew( () => { try { while (MovementManager.IsFlying && Behaviors.ShouldContinue && !IsMovingTowardsLocation) { if (landingStopwatch.ElapsedMilliseconds < 2000) { // TODO: possible check to see if floor is more than 80 or 100 below us to not bother? or check for last destination and compare the Y value of the floor. MovementManager.StartDescending(); } else { if (totalLandingStopwatch.ElapsedMilliseconds > 10000) { Logger.Error(Localization.Localization.FlightEnabledSlideMover_LandFailed); InnerMover.MoveStop(); return; } if (landingCoroutine == null || landingCoroutine.IsFinished) { var move = Core.Player.Location.AddRandomDirection2D(10).GetFloor(8); MovementManager.StopDescending(); MovementManager.Jump(); landingCoroutine = new Coroutine(() => move.MoveToNoMount(false, 0.8f)); Logger.Info(Localization.Localization.FlightEnabledSlideMover_LandNew, move); } if (!landingCoroutine.IsFinished && MovementManager.IsFlying) { Logger.Verbose(Localization.Localization.FlightEnabledSlideMover_LandResumed); while (!landingCoroutine.IsFinished && MovementManager.IsFlying && Behaviors.ShouldContinue && !IsMovingTowardsLocation) { landingCoroutine.Resume(); Thread.Sleep(66); } } if (MovementManager.IsFlying) { landingStopwatch.Restart(); } } Thread.Sleep(33); } } finally { if (IsMovingTowardsLocation) { Logger.Warn(Localization.Localization.FlightEnabledSlideMover_LandCancelled, totalLandingStopwatch.Elapsed); InnerMover.MoveStop(); } else { Logger.Info(Localization.Localization.ExFlyTo_Landing, totalLandingStopwatch.Elapsed); } totalLandingStopwatch.Reset(); landingStopwatch.Reset(); if (Coroutine.Current != landingCoroutine && landingCoroutine != null) { landingCoroutine.Dispose(); } landingCoroutine = null; IsLanding = false; landingTask = null; } }); } } } } else { IsLanding = false; } }
public void EnsureFlying() { if (!MovementManager.IsFlying && ActionManager.CanMount == 0) { if (!takeoffStopwatch.IsRunning) { takeoffStopwatch.Restart(); } if (takeoffTask == null) { lock (takeoffTaskLock) { if (takeoffTask == null) { Logger.Info(Localization.Localization.FlightEnabledSlideMover_TakeoffStart); takeoffTask = Task.Factory.StartNew( () => { try { while (!MovementManager.IsFlying && Behaviors.ShouldContinue && IsMovingTowardsLocation) { if (takeoffStopwatch.ElapsedMilliseconds > 10000) { Logger.Error(Localization.Localization.FlightEnabledSlideMover_TakeoffFailed); InnerMover.MoveStop(); IsTakingOff = false; return; } if (coroutine == null || coroutine.IsFinished) { Logger.Verbose(Localization.Localization.FlightEnabledSlideMover_TakeoffNew); coroutine = new Coroutine(() => CommonTasks.TakeOff()); } if (!coroutine.IsFinished && !MovementManager.IsFlying && Behaviors.ShouldContinue) { Logger.Verbose(Localization.Localization.FlightEnabledSlideMover_TakeoffResumed); coroutine.Resume(); } Thread.Sleep(66); } } finally { if (!IsMovingTowardsLocation) { Logger.Warn(Localization.Localization.FlightEnabledSlideMover_TakeoffCancelled, takeoffStopwatch.Elapsed); } else { Logger.Info(Localization.Localization.FlightEnabledSlideMover_Takeoff, takeoffStopwatch.Elapsed); } takeoffStopwatch.Reset(); IsTakingOff = false; takeoffTask = null; } }); } } } } else { IsTakingOff = false; } }
public void ForceLanding() { if (!IsDiving && MovementManager.IsFlying) { Logger.Info("Landing Task Started: {0} {1}", IsDiving, MovementManager.IsFlying); if (!landingStopwatch.IsRunning) { landingStopwatch.Restart(); } if (!totalLandingStopwatch.IsRunning) { totalLandingStopwatch.Restart(); } if (landingTask == null) { lock (landingTaskLock) { if (landingTask == null) { Logger.Info(Localization.Localization.FlightEnabledSlideMover_LandStart); landingTask = Task.Factory.StartNew( () => { Coroutine landingCoroutine = null; try { //the landingCoroutine might not be disposed of properly if the user should change zones or stop the bot. //let's shut it down for them. while (!IsDiving && MovementManager.IsFlying && Behaviors.ShouldContinue && !IsMovingTowardsLocation && TreeRoot.IsRunning) { if (landingStopwatch.ElapsedMilliseconds < 2000) { // TODO: possible check to see if floor is more than 80 or 100 below us to not bother? or check for last destination and compare the Y value of the floor. MovementManager.StartDescending(); } else { if (totalLandingStopwatch.ElapsedMilliseconds > 10000) { Logger.Error(Localization.Localization.FlightEnabledSlideMover_LandFailed); InnerMover.MoveStop(); return; } if (landingCoroutine == null || landingCoroutine.IsFinished) { var move = Core.Player.Location.AddRandomDirection2D(10).GetFloor(8); MovementManager.StopDescending(); MovementManager.Jump(); landingCoroutine = new Coroutine(async() => await move.MoveToNoMount(false, 0.8f)); Logger.Info(Localization.Localization.FlightEnabledSlideMover_LandNew, move); } if (!landingCoroutine.IsFinished && MovementManager.IsFlying && !IsDiving) { Logger.Verbose(Localization.Localization.FlightEnabledSlideMover_LandResumed); while (!IsDiving && !landingCoroutine.IsFinished && MovementManager.IsFlying && Behaviors.ShouldContinue && !IsMovingTowardsLocation && TreeRoot.IsRunning) { landingCoroutine.Resume(); Thread.Sleep(66); } } if (MovementManager.IsFlying && !IsDiving) { landingStopwatch.Restart(); } } Thread.Sleep(33); } } finally { MovementManager.StopDescending(); if (IsMovingTowardsLocation) { Logger.Warn(Localization.Localization.FlightEnabledSlideMover_LandCancelled, totalLandingStopwatch.Elapsed); InnerMover.MoveStop(); } else { Logger.Info(Localization.Localization.ExFlyTo_Landing, totalLandingStopwatch.Elapsed); } totalLandingStopwatch.Reset(); landingStopwatch.Reset(); if (Coroutine.Current != landingCoroutine) { landingCoroutine?.Dispose(); } IsLanding = false; landingTask = null; } }); } } } } else { IsLanding = false; } }