Exemplo n.º 1
0
        public override async Task <bool> MoveToSpot(ExGatherTag tag)
        {
            tag.StatusText = "Moving to " + this;

            var result =
                await
                NodeLocation.MoveTo(
                    UseMesh,
                    radius : tag.Distance,
                    name : tag.Node.EnglishName,
                    stopCallback : tag.MovementStopCallback,
                    dismountAtDestination : true);

            if (result)
            {
                var landed = MovementManager.IsDiving || await CommonTasks.Land();

                if (landed && Core.Player.IsMounted)
                {
                    ActionManager.Dismount();
                }

                Navigator.Stop();
                await Coroutine.Yield();

                await tag.CastAura(Ability.Stealth, AbilityAura.Stealth);
            }

            await Coroutine.Yield();

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Dismounts the player.
        /// </summary>
        /// <returns>true if the player is mounted.</returns>
        public static async Task <bool> Dismount()
        {
            if (Core.Player.IsMounted)
            {
                // wait to land
                if (await CommonTasks.Land())
                {
                    // should only take a second or so, but sometimes the landing is off and it misses the ground, 3s before returning.
                    await Coroutine.Wait(3000, () => !MovementManager.IsFlying);
                }

                // stop the player if we're moving.
                if (MovementManager.IsMoving)
                {
                    Navigator.PlayerMover.MoveStop();
                }

                ActionManager.Dismount();
                // wait until dismounted.
                await Coroutine.Wait(5000, () => !Core.Player.IsMounted);
            }

            // return true if the player IS mounted, forcing the routine to go back.
            // return false if the player ISN'T mounted, allowing the routine to continue.
            return(Core.Player.IsMounted);
        }
Exemplo n.º 3
0
            /// <summary>
            /// Lands the Player if Flying.
            /// </summary>
            public static async Task <bool> Land()
            {
                while (true)
                {
                    if (!MovementManager.IsFlying || Core.Me.IsDead)
                    {
                        break;
                    }

                    await CommonTasks.Land();
                    await Sleep(100);
                }

                return(!MovementManager.IsFlying);
            }
Exemplo n.º 4
0
        protected override async Task <bool> Main()
        {
            var immediateDestination = FindImmediateDestination();

            if (AtLocation(Core.Player.Location, immediateDestination))
            {
                var completionMessage = $"Arrived at destination {RoughDestination.Name}";
                if (Land)
                {
                    Log("Landing at destination {0}", RoughDestination.Name);
                    var landed = await CommonTasks.Land();

                    if (landed)
                    {
                        if (Dismount)
                        {
                            ActionManager.Dismount();
                        }
                        BehaviorDone(completionMessage);
                        return(true);
                    }
                    Log("Failed to land at {0}", immediateDestination);
                    return(false);
                }
                BehaviorDone(completionMessage);
                return(false);
            }

            var parameters = new FlyToParameters(immediateDestination)
            {
                CheckIndoors = !IgnoreIndoors
            };

            if (MinHeight > 0)
            {
                parameters.MinHeight = MinHeight;
            }

            await CommonTasks.MountUp();

            await CommonTasks.TakeOff();

            Flightor.MoveTo(parameters);
            return(true);
        }
Exemplo n.º 5
0
            /// <summary>
            /// Lands the Player if Flying.
            /// </summary>
            public static async Task <bool> Land()
            {
                if (!MovementManager.IsFlying)
                {
                    return(false);
                }

                while (MovementManager.IsFlying)
                {
                    await CommonTasks.Land();
                    await Sleep(100);

                    if (!MovementManager.IsFlying)
                    {
                        break;
                    }
                }

                return(true);
            }
Exemplo n.º 6
0
        public override async Task <bool> MoveToSpot(ExGatherTag tag)
        {
            tag.StatusText = "Moving to " + this;

            if (HotSpots == null || HotSpots.Count == 0)
            {
                return(false);
            }

            if (approachLocation == null)
            {
                approachLocation = HotSpots.Shuffle().First();
            }

            var result = await approachLocation.MoveTo(dismountAtDestination : Stealth);

            if (!result)
            {
                return(false);
            }

            var landed = MovementManager.IsDiving || await CommonTasks.Land();

            if (landed && Core.Player.IsMounted && !MovementManager.IsDiving)
            {
                ActionManager.Dismount();
            }

            Navigator.Stop();
            await Coroutine.Yield();

            if (Stealth)
            {
                await tag.CastAura(Ability.Stealth, AbilityAura.Stealth);
            }

            result = await NodeLocation.MoveToOnGroundNoMount(tag.Distance, tag.Node.EnglishName, tag.MovementStopCallback);

            return(result);
        }
Exemplo n.º 7
0
        private static async Task <bool> Land()
        {
            if (!MovementManager.IsFlying || MovementManager.IsSwimming)
            {
                return(true);
            }

            int ticks = 0;

            if (await CommonTasks.CanLand() == CanLandResult.Yes)
            {
                while (ticks < 100 && await CommonTasks.Land())
                {
                    if (!MovementManager.IsFlying)
                    {
                        break;
                    }
                    await Coroutine.Sleep(100);

                    ticks++;
                }

                if (ticks >= 100)
                {
                    Logging.WriteVerbose("Timeout whilst trying to land.");
                }
            }
            else
            {
                var closestObject = GameObjectManager.GameObjects.OrderBy(r => r.DistanceSqr(Core.Me.Location)).FirstOrDefault();
                if (await CommonTasks.DescendTo(closestObject.Y) == DescendToResult.Success)
                {
                    MovementManager.StopDescending();
                    Logging.WriteVerbose("Manual descend complete.");
                }
            }

            return(true);
        }
Exemplo n.º 8
0
        public virtual async Task <bool> MoveToSpot(ExGatherTag tag)
        {
            tag.StatusText = "Moving to " + this;

            var randomApproachLocation = NodeLocation;

            if (MovementManager.IsDiving)
            {
                randomApproachLocation = NodeLocation.AddRandomDirection(3f, SphereType.TopHalf);
            }

            var result = await
                         randomApproachLocation.MoveTo(
                UseMesh,
                radius : tag.Distance,
                name : tag.Node.EnglishName,
                stopCallback : tag.MovementStopCallback);

            if (!result)
            {
                return(false);
            }

            var landed = MovementManager.IsDiving || await CommonTasks.Land();

            if (landed && Core.Player.IsMounted && !MovementManager.IsDiving)
            {
                ActionManager.Dismount();
            }

            Navigator.Stop();
            await Coroutine.Yield();

            result = !MovementManager.IsDiving || await NodeLocation.MoveToOnGroundNoMount(tag.Distance, tag.Node.EnglishName, tag.MovementStopCallback);

            return(result);
        }
        public override async Task <bool> MoveToSpot(ExGatherTag tag)
        {
            tag.StatusText = "Moving to " + this;

            if (ApproachLocation == Vector3.Zero)
            {
                return(false);
            }

            var result =
                await
                ApproachLocation.MoveTo(
                    UseMesh,
                    radius : tag.Distance,
                    name : "Approach Location",
                    stopCallback : tag.MovementStopCallback);

            if (!result)
            {
                return(false);
            }

            var landed = MovementManager.IsDiving || await CommonTasks.Land();

            if (landed && Core.Player.IsMounted && !MovementManager.IsDiving)
            {
                ActionManager.Dismount();
            }

            Navigator.Stop();
            await Coroutine.Yield();

            result = await NodeLocation.MoveToOnGroundNoMount(tag.Distance, tag.Node.EnglishName, tag.MovementStopCallback);

            return(result);
        }
Exemplo n.º 10
0
        private static async Task <bool> LandInFateArea()
        {
            Navigator.PlayerMover.MoveStop();

            var landingLocation = await GetFateLandingLocation();

            if (!landingLocation.Equals(Core.Player.Location))
            {
                Logger.SendLog("Flying to " + landingLocation + " in order to land.");
                while (Core.Player.Location.Distance2D(landingLocation) > 2f)
                {
                    Navigator.PlayerMover.MoveTowards(landingLocation);
                    await Coroutine.Yield();
                }

                Navigator.PlayerMover.MoveStop();
            }

            Logger.SendLog("Attempting to land.");
            await Coroutine.Wait(TimeSpan.FromMilliseconds(MovementSettings.Instance.LandingTimeOut), () => CommonTasks.Land().IsCompleted);

            if (MovementManager.IsFlying)
            {
                Logger.SendErrorLog("Landing failed, trying another location.");
                await LandInFateArea();

                return(true);
            }

            Logger.SendLog("Landing successful.");
            return(true);
        }
Exemplo n.º 11
0
        internal static async Task <bool> FlyToLocation(Vector3 location, float precision, bool land, bool stopOnFateSpawn)
        {
            if (!IsFlightMeshLoaded())
            {
                await NavigateToLocation(location, precision, stopOnFateSpawn);

                return(true);
            }

            if (ActionManager.CanMount != 0 && !Core.Player.IsMounted)
            {
                return(false);
            }

            if (!Core.Player.IsMounted)
            {
                if (Core.Player.InCombat)
                {
                    return(false);
                }

                await MountUp();
            }

            // Ensure precision isn't too strong, else we get flip-flopping.
            if (precision < 2f)
            {
                precision = 2f;
            }

            var path = await GenerateFlightPathToLocation(location);

            if (path == null)
            {
                return(false);
            }

            if (!MovementManager.IsFlying)
            {
                await CommonTasks.TakeOff();
            }

            var enumerablePath = path as IList <Vector3> ?? path.ToList();

            foreach (var step in enumerablePath)
            {
                var processedStep = !enumerablePath.Last().Equals(step) ? ProcessFlightStep(step) : step;
                if (Core.Player.Location.Distance(location) < Core.Player.Location.Distance(processedStep))
                {
                    Logger.SendDebugLog("Destination is closer than next hop. Ending navigation early.");
                    break;
                }

                while (Core.Player.Location.Distance(processedStep) > 2f)
                {
                    if (!Core.Player.IsMounted && ActionManager.AvailableMounts.Any())
                    {
                        Navigator.PlayerMover.MoveStop();
                        if (Core.Player.InCombat)
                        {
                            return(true);
                        }

                        await MountUp();
                    }

                    if (!MovementManager.IsFlying)
                    {
                        Navigator.PlayerMover.MoveStop();
                        await CommonTasks.TakeOff();
                    }

                    if (stopOnFateSpawn && await OracleFateManager.AnyViableFates())
                    {
                        Navigator.PlayerMover.MoveStop();
                        OracleFateManager.ClearPoi("FATE found.");
                        return(true);
                    }

                    if (Core.Player.IsDead)
                    {
                        OracleFateManager.ClearPoi("Died while moving.");
                        return(true);
                    }

                    Logger.SendLog("Flying to hop: " + processedStep);
                    Navigator.PlayerMover.MoveTowards(processedStep);
                    await Coroutine.Yield();
                }
            }

            // Move to destination.
            while (Core.Player.Location.Distance(location) > precision)
            {
                Navigator.PlayerMover.MoveTowards(location);
                await Coroutine.Yield();
            }

            Navigator.PlayerMover.MoveStop();

            if (land && MovementManager.IsFlying && await CommonTasks.CanLand(Core.Player.Location) == CanLandResult.Yes)
            {
                await CommonTasks.Land();
            }

            return(true);
        }