Пример #1
0
        public Motion(Motion motion)
        {
            // copy constructor
            IsAutonomous = motion.IsAutonomous;
            MovementType = motion.MovementType;
            MotionFlags  = motion.MotionFlags;
            Stance       = motion.Stance;

            if (motion.MotionState != null)
            {
                MotionState = new InterpretedMotionState(motion.MotionState);
            }

            TargetGuid = motion.TargetGuid;

            if (motion.Position != null)
            {
                Position = new Position(motion.Position);
            }

            if (motion.MoveToParameters != null)
            {
                MoveToParameters = new MoveToParameters(motion.MoveToParameters);
            }

            RunRate        = motion.RunRate;
            DesiredHeading = motion.DesiredHeading;
        }
Пример #2
0
        internal static async Task <bool> MoveOutOfIdyllshire()
        {
            Logger.SendLog("We're in Idyllshire, moving to The Dravanian Hinterlands.");
            await MountUp();

            var movementParams = new MoveToParameters
            {
                Destination       = "Idyllshire Exit",
                Location          = new Vector3(142.6006f, 207f, 114.136f),
                DistanceTolerance = 5f
            };

            while (Core.Player.Distance(movementParams.Location) > 5f)
            {
                Navigator.MoveTo(movementParams);
                await Coroutine.Yield();
            }

            Navigator.Stop();
            Core.Player.SetFacing(0.9709215f);
            MovementManager.MoveForwardStart();

            await Coroutine.Sleep(TimeSpan.FromSeconds(2));

            await Coroutine.Wait(TimeSpan.MaxValue, () => !CommonBehaviors.IsLoading);

            await Coroutine.Sleep(TimeSpan.FromSeconds(2));

            return(true);
        }
Пример #3
0
        public override MoveResult MoveTo(MoveToParameters location)
        {
            //if we aren't in POTD default to the original mover right away.
            if (!Constants.Maps.ContainsKey(WorldManager.RawZoneId))
            {
                return(Original.MoveTo(location));
            }

            SetupDetour();
            AddBlackspots();
            WallCheck();

            if (AvoidanceManager.Avoids.Any(r => r.IsPointInAvoid(location.Location)))
            {
                Logger.Warn("Location is in sidestep avoidance - ##AVOID##");
                if (!AvoidanceManager.Avoids.Any(r => r.IsPointInAvoid(Core.Me.Location)))
                {
                    Logger.Error("Forcing stop");
                    MovementManager.MoveStop();
                }

                // CommonTasks.StopMoving("Wait for avoidance");
                return(MoveResult.PathGenerationFailed);
            }
            location.WorldState = new WorldState {
                MapId = WorldManager.ZoneId, Walls = wallList, Avoids = trapList
            };
            return(Original.MoveTo(location));
        }
Пример #4
0
        public override MoveResult MoveTo(MoveToParameters location)
        {
            //if (AvoidanceManager.IsRunningOutOfAvoid)
            //    return MoveResult.Moving;
            if (!DutyManager.InInstance)
            {
                return(Original.MoveTo(location));
            }

            //if we aren't in POTD default to the original mover right away.
            if (!Constants.Maps.ContainsKey(WorldManager.RawZoneId))
            {
                return(Original.MoveTo(location));
            }

            SetupDetour();

            AddBlackspots();
            WallCheck();

            location.WorldState = new WorldState {
                MapId = WorldManager.ZoneId, Walls = wallList, Avoids = trapList
            };
            return(Original.MoveTo(location));
        }
Пример #5
0
        internal static async Task <bool> Main(uint aetheryteId)
        {
            Logger.SendLog("Binding to the aetheryte crystal.");
            var aetheryteObject = GetAetheryteObject(aetheryteId);

            if (aetheryteObject == null)
            {
                Logger.SendErrorLog("Could not find an aetheryte crystal.");
                return(false);
            }

            if (!WorldManager.CanFly)
            {
                var movementParams = new MoveToParameters
                {
                    Destination       = "Aetheryte crystal",
                    Location          = aetheryteObject.Location,
                    DistanceTolerance = 8f
                };

                while (aetheryteObject.Distance(Core.Player) > 8f)
                {
                    Navigator.MoveTo(movementParams);
                    await Coroutine.Yield();
                }

                Navigator.Stop();
            }
            else
            {
                while (aetheryteObject.Distance(Core.Player) > 8f)
                {
                    Core.Player.Face(aetheryteObject);
                    Navigator.PlayerMover.MoveTowards(aetheryteObject.Location);
                    await Coroutine.Yield();
                }

                Navigator.PlayerMover.MoveStop();
            }

            aetheryteObject.Interact();
            await Coroutine.Sleep(MainSettings.Instance.ActionDelay);

            SelectString.ClickLineContains("Set Home Point");
            await Coroutine.Sleep(MainSettings.Instance.ActionDelay);

            SelectYesno.ClickYes();
            await Coroutine.Sleep(MainSettings.Instance.ActionDelay);

            Logger.SendLog("Home point bound successfully.");

            return(true);
        }
Пример #6
0
        public override MoveResult MoveTo(MoveToParameters parameters)
        {
            if (generatingPath)
            {
                return(MoveResult.GeneratingPath);
            }

            if (!playerMover.IsDiving && (!playerMover.CanFly || (parameters.MapId != null && parameters.MapId != -1 && parameters.MapId != WorldManager.ZoneId) || (!MovementManager.IsFlying && !playerMover.ShouldFlyTo(parameters.Location))))
            {
                return(Original.MoveTo(parameters));
            }

            var currentLocation = GameObjectManager.LocalPlayer.Location;

            if (parameters.Location.DistanceSqr(currentLocation) > PathPrecisionSqr)
            {
                if (ShouldGeneratePath(parameters.Location))
                {
                    generatingPath   = true;
                    origin           = currentLocation;
                    finalDestination = requestedDestination = parameters.Location;
                    pathGeneratorStopwatch.Restart();
                    logger.Info("Generating path on {0} from {1} to {2}", WorldManager.ZoneId, origin, finalDestination);
                    GeneratePath(origin, finalDestination).ContinueWith(HandlePathGenerationResult);
                    return(MoveResult.GeneratingPath);
                }

                if (CurrentPath.Count == 0)
                {
                    return(MoveResult.ReachedDestination);
                }

                return(MoveToNextHop(parameters.Destination));
            }

            logger.Info("Navigation reached current destination. Within {0}", currentLocation.Distance(parameters.Location));

            requestedDestination = Vector3.Zero;
            playerMover.MoveStop();
            CurrentPath.Reset();

            return(MoveResult.Done);
        }
Пример #7
0
        internal static async Task <bool> NavigateToLocation(Vector3 location, float precision, bool stopOnFateSpawn)
        {
            var movementParams = new MoveToParameters
            {
                Location          = location,
                DistanceTolerance = precision
            };

            while (Core.Player.Location.Distance(location) > precision)
            {
                if (ActionManager.CanMount == 0 && !Core.Player.IsMounted && IsMountNeeded(Core.Player.Location.Distance(location)) &&
                    ActionManager.AvailableMounts.Any())
                {
                    Navigator.Stop();
                    if (Core.Player.InCombat)
                    {
                        return(true);
                    }

                    await MountUp();
                }

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

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

                Navigator.MoveTo(movementParams);
                await Coroutine.Yield();
            }

            Navigator.Clear();
            return(true);
        }
Пример #8
0
        public void Pack(BinaryWriter writer)
        {
            writer.Write(ObjectMovementSequence);
            writer.Write(ObjectServerControlSequence);
            writer.Write(Autonomous);
            writer.Align();
            writer.Write((byte)MovementType);
            writer.Write((byte)OptionFlags);
            writer.Write((ushort)Stance);
            switch (MovementType)
            {
            case MovementType.InterpertedMotionState:
                State.Pack(writer);
                if ((OptionFlags & MovementOption.StickToObject) != 0)
                {
                    writer.Write(StickyObject);
                }
                break;

            case MovementType.MoveToObject:
                writer.Write(Target);
                Origin.Pack(writer);
                MoveToParameters.Pack(writer);
                writer.Write(MyRunRate);
                break;

            case MovementType.MoveToPosition:
                Origin.Pack(writer);
                MoveToParameters.Pack(writer);
                writer.Write(MyRunRate);
                break;

            case MovementType.TurnToObject:
                writer.Write(Target);
                writer.Write(DesiredHeading);
                TurnToParameters.Pack(writer);
                break;

            case MovementType.TurnToPosition:
                TurnToParameters.Pack(writer);
                break;
            }
        }
Пример #9
0
        public void Unpack(BinaryReader reader)
        {
            ObjectMovementSequence      = reader.ReadUInt16();
            ObjectServerControlSequence = reader.ReadUInt16();
            Autonomous = reader.ReadUInt16();
            reader.Align();
            MovementType = (MovementType)reader.ReadByte();
            OptionFlags  = (MovementOption)reader.ReadByte();
            Stance       = (StanceMode)reader.ReadUInt16();
            switch (MovementType)
            {
            case MovementType.InterpertedMotionState:
                State.Unpack(reader);
                if ((OptionFlags & MovementOption.StickToObject) != 0)
                {
                    StickyObject = reader.ReadUInt32();
                }
                break;

            case MovementType.MoveToObject:
                Target = reader.ReadUInt32();
                Origin.Unpack(reader);
                MoveToParameters.Unpack(reader);
                MyRunRate = reader.ReadSingle();
                break;

            case MovementType.MoveToPosition:
                Origin.Unpack(reader);
                MoveToParameters.Unpack(reader);
                MyRunRate = reader.ReadSingle();
                break;

            case MovementType.TurnToObject:
                Target         = reader.ReadUInt32();
                DesiredHeading = reader.ReadSingle();
                TurnToParameters.Unpack(reader);
                break;

            case MovementType.TurnToPosition:
                TurnToParameters.Unpack(reader);
                break;
            }
        }
        /// <inheritdoc/>
        public override async Task <bool> Run()
        {
            if (_waypoints == null)
            {
                _waypoints = _routeCalculator.Calculate(WorldManager.ZoneId, Core.Player.Location);
            }

            if (_current == null)
            {
                if (_waypoints.Count == 0)
                {
                    // Nowhere left to go (end of dungeon?)
                    Logger.LogInformation(Translations.LOG_NAVIGATION_NO_WAYPOINT);

                    return(PASS_EXECUTION);
                }
                else
                {
                    _current = _waypoints.Dequeue();
                    Logger.LogInformation(Translations.LOG_NAVIGATION_NEW_WAYPOINT, _current.ZoneId, _current.SubZoneId, _current.Location);
                }
            }

            if (_current.Location.Distance(Core.Player.Location) > _minDistance)
            {
                if (_moveParams == null)
                {
                    _moveParams = new MoveToParameters(_current.Location, _current.Description);
                }

                await CommonTasks.MoveAndStop(_moveParams, _minDistance, stopInRange : true);
            }
            else
            {
                _moveParams = null;
                _current    = null;
                Logger.LogInformation(Translations.LOG_NAVIGATION_REACHED_WAYPOINT, _current.Description);
            }

            return(HANDLED_EXECUTION);
        }
Пример #11
0
        private static async Task <bool> MoveToTurnInNpc(GameObject turnInNpc)
        {
            if (turnInNpc == null || !turnInNpc.IsValid)
            {
                return(false);
            }

            Logger.SendLog("Moving to interact with " + turnInNpc.Name + ".");
            var movementParams = new MoveToParameters
            {
                Destination       = turnInNpc.Name,
                Location          = turnInNpc.Location,
                DistanceTolerance = 3f
            };

            while (Core.Player.Distance2D(turnInNpc.Location) > 3f)
            {
                if (!turnInNpc.IsValid)
                {
                    Navigator.Stop();
                    return(false);
                }

                if (!Core.Player.IsMounted && OracleMovementManager.IsMountNeeded(Core.Player.Location.Distance(turnInNpc.Location)) &&
                    ActionManager.AvailableMounts.Any())
                {
                    Navigator.Stop();
                    if (!Core.Player.InCombat)
                    {
                        await OracleMovementManager.MountUp();
                    }
                }

                Navigator.MoveTo(movementParams);
                await Coroutine.Yield();
            }

            Navigator.Stop();
            return(true);
        }
        private static async Task <bool> TryNavigator(Vector3 destination, float?distanceTolerance, string destinationName = null)
        {
            MoveToParameters moveToParams = new MoveToParameters(destination);

            if (distanceTolerance.HasValue)
            {
                moveToParams.DistanceTolerance = distanceTolerance.Value;
            }

            // If we can navigate to destination, use navigator...
            var moveResult = Navigator.MoveTo(moveToParams);

            if (moveResult.IsSuccessful())
            {
                return(true);
            }

            // Make sure we are on ground if navigation failed.
            if (StyxWoW.Me.IsFlying)
            {
                if (await CommonCoroutines.LandAndDismount("For ground navigation"))
                {
                    return(true);
                }
            }

            if (destinationName == null)
            {
                destinationName = destination.ToString();
            }
            QBCLog.DeveloperInfo(
                "Navigator unable to move from {0} to destination({1}, {2}) on ground --try MovementBy=\"FlightorPreferred\".",
                WoWMovement.ActiveMover.Location,
                destinationName,
                destination.ToString());
            return(false);
        }
Пример #13
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                MoveToParameters moveParams = new MoveToParameters();

                _errorLabel.Text = string.Empty;

                moveParams.BaseAngle = Single.Parse(_baseText.Text);
                moveParams.ShoulderAngle = Single.Parse(_shoulderText.Text);
                moveParams.ElbowAngle = Single.Parse(_elbowText.Text);
                moveParams.GripAngle = Single.Parse(_wristText.Text);
                moveParams.GripRotation = Single.Parse(_gripRotationText2.Text);
                moveParams.Grip = Single.Parse(_gripText2.Text);
                moveParams.Time = Single.Parse(_timeText2.Text);

                _fromWinformPort.Post(new FromWinformMsg(FromWinformMsg.MsgEnum.MoveTo, null, moveParams));
            }
            catch
            {
                _errorLabel.Text = "Invalid Value";
            }
        }
Пример #14
0
 public override MoveResult MoveTo(MoveToParameters parameters)
 {
     return(MoveResult.Failed);
 }
Пример #15
0
        public override MoveResult MoveTo(MoveToParameters location)
        {
            //if (AvoidanceManager.IsRunningOutOfAvoid)
            //    return MoveResult.Moving;

            //if we aren't in POTD default to the original mover right away.
            if (!Constants.Maps.ContainsKey(WorldManager.RawZoneId))
            {
                return(Original.MoveTo(location));
            }

            SetupDetour();

            AddBlackspots();
            WallCheck();

            if (AvoidanceManager.Avoids.Any(r => r.IsPointInAvoid(location.Location)))
            {
                Logger.Warn("Location is in sidestep avoidance - ##AVOID##");
                if (AvoidanceManager.Avoids.Any(r => r.IsPointInAvoid(Core.Me.Location)))
                {
                    return(MoveResult.PathGenerationFailed);
                }
                Logger.Error("Forcing stop");
                MovementManager.MoveStop();

                return(MoveResult.PathGenerationFailed);
            }

            location.WorldState = new WorldState {
                MapId = WorldManager.ZoneId, Walls = wallList, Avoids = trapList
            };
            location.DistanceTolerance = 2f;
            //location.
            var result = Original.MoveTo(location);

            //Logger.Debug($"Move result: {result} Successful: {result.IsSuccessful()}");

            switch (result)
            {
            case MoveResult.Failed:
                break;

            case MoveResult.Failure:
                break;

            case MoveResult.ReachedDestination:
                break;

            case MoveResult.PathGenerating:
                break;

            case MoveResult.PathGenerationFailed:
                location.WorldState = new WorldState
                {
                    MapId = WorldManager.ZoneId, Walls = wallList, Avoids = new HashSet <BoundingCircle>()
                };
                location.DistanceTolerance = 3f;
                return(Original.MoveTo(location));

                break;

            case MoveResult.PathGenerated:
                break;

            case MoveResult.UnstuckAttempt:
                break;

            case MoveResult.Done:
                break;

            case MoveResult.Moving:
                break;

            case MoveResult.Moved:
                break;

            case MoveResult.GeneratingPath:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(result);
        }