コード例 #1
0
        public override async Task PerformAction()
        {
            if (playerReader.HasTarget)
            {
                if (playerReader.Bits.TargetIsDead)
                {
                    await input.TapClearTarget("Target is dead.");

                    await wait.Update(1);

                    return;
                }

                await stopMoving.StopTurn();

                return;
            }

            if (playerReader.Bits.IsDrowning)
            {
                await StopDrowning();
            }

            await SwitchGatherType();

            if (this.playerReader.Bits.PlayerInCombat && classConfiguration.Mode != Mode.AttendedGather)
            {
                return;
            }

            var timeSinceResetSeconds = (DateTime.Now - LastReset).TotalSeconds;

            if ((DateTime.Now - LastActive).TotalSeconds > 10 || routeToWaypoint.Count == 0 || timeSinceResetSeconds > 80)
            {
                logger.LogInformation("Trying to path a new route.");
                // recalculate next waypoint
                var pointsRemoved = 0;
                while (AdjustNextPointToClosest() && pointsRemoved < 5)
                {
                    pointsRemoved++;
                }
                ;
                await RefillRouteToNextWaypoint(true);

                if (routeToWaypoint.Count == 0)
                {
                    logger.LogError("Didn't found path.");
                }
            }
            else
            {
                var playerLocation = new WowPoint(playerReader.XCoord, playerReader.YCoord, playerReader.ZCoord);
                if (routeToWaypoint.Count > 0)
                {
                    var distanceToRoute = WowPoint.DistanceTo(playerLocation, routeToWaypoint.Peek());
                    if (routeToWaypoint.Count < 1 && distanceToRoute > 200)
                    {
                        logger.LogError($"No route To Waypoint or too far {distanceToRoute}>200");
                        routeToWaypoint.Pop();
                        return;
                    }
                }

                input.SetKeyState(ConsoleKey.UpArrow, true, false);
            }

            await RandomJump();

            var location = new WowPoint(playerReader.XCoord, playerReader.YCoord, playerReader.ZCoord);
            var distance = WowPoint.DistanceTo(location, routeToWaypoint.Peek());
            var heading  = DirectionCalculator.CalculateHeading(location, routeToWaypoint.Peek());

            await AdjustHeading(heading);

            if (lastDistance < distance)
            {
                AdjustNextPointToClosest();

                await playerDirection.SetDirection(heading, routeToWaypoint.Peek(), "Further away");
            }
            else if (!this.stuckDetector.IsGettingCloser())
            {
                // stuck so jump
                input.SetKeyState(ConsoleKey.UpArrow, true, false, "FollowRouteAction 2");
                await wait.Update(1);

                if (HasBeenActiveRecently())
                {
                    await this.stuckDetector.Unstick();

                    distance = WowPoint.DistanceTo(location, routeToWaypoint.Peek());
                }
                else
                {
                    await wait.Update(1);

                    logger.LogInformation("Resuming movement");
                }
            }
            else // distance closer
            {
                await AdjustHeading(heading);
            }

            lastDistance = distance;

            if (distance < PointReachedDistance(MinDistance))
            {
                Log($"Move to next point");

                if (routeToWaypoint.Any())
                {
                    playerReader.ZCoord = routeToWaypoint.Peek().Z;
                    Log($"PlayerLocation.Z = {playerReader.PlayerLocation.Z}");
                }

                ReduceRouteByDistance(MinDistance);

                lastDistance = 999;
                if (routeToWaypoint.Count == 0)
                {
                    wayPoints.Pop();

                    await RefillRouteToNextWaypoint(false);
                }

                this.stuckDetector.SetTargetLocation(this.routeToWaypoint.Peek());

                heading = DirectionCalculator.CalculateHeading(location, routeToWaypoint.Peek());
                await playerDirection.SetDirection(heading, routeToWaypoint.Peek(), "Move to next point");
            }

            // should mount
            await MountIfRequired();

            LastActive = DateTime.Now;

            await wait.Update(1);
        }
コード例 #2
0
        public override async Task PerformAction()
        {
            SendActionEvent(new ActionEventArgs(GoapKey.fighting, false));

            if (await AquireTarget())
            {
                await stopMoving.StopTurn();

                if (playerReader.PlayerClass == PlayerClassEnum.Hunter)
                {
                    if (playerReader.PlayerBitValues.TargetCanBeHostile)
                    {
                        await input.TapInteractKey("approach target as hunter");
                    }
                    else
                    {
                        await input.TapClearTarget("not hostile");
                    }
                }

                return;
            }

            await SwitchGatherType();

            await playerReader.WaitForNUpdate(1);

            if (this.playerReader.PlayerBitValues.PlayerInCombat && this.classConfiguration.Mode != Mode.AttendedGather)
            {
                return;
            }

            var timeSinceResetSeconds = (DateTime.Now - LastReset).TotalSeconds;

            if ((DateTime.Now - LastActive).TotalSeconds > 10 || routeToWaypoint.Count == 0 || timeSinceResetSeconds > 80)
            {
                logger.LogInformation("Trying to path a new route.");
                // recalculate next waypoint
                var pointsRemoved = 0;
                while (AdjustNextPointToClosest() && pointsRemoved < 5)
                {
                    pointsRemoved++;
                }
                ;
                await RefillRouteToNextWaypoint(true);

                if (routeToWaypoint.Count == 0)
                {
                    logger.LogError("Didn't found path.");
                }
            }
            else
            {
                var playerLocation  = new WowPoint(playerReader.XCoord, playerReader.YCoord);
                var distanceToRoute = WowPoint.DistanceTo(playerLocation, routeToWaypoint.Peek());
                if (routeToWaypoint.Count <= 1 && distanceToRoute > 200)
                {
                    logger.LogError("wtf too far away kekw");
                    routeToWaypoint.Pop();
                    return;
                }

                //wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "FollowRouteAction 1");
                input.SetKeyState(ConsoleKey.UpArrow, true, false);
            }

            await RandomJump();

            var location = new WowPoint(playerReader.XCoord, playerReader.YCoord);
            var distance = WowPoint.DistanceTo(location, routeToWaypoint.Peek());
            var heading  = DirectionCalculator.CalculateHeading(location, routeToWaypoint.Peek());

            await AdjustHeading(heading);

            if (lastDistance < distance)
            {
                AdjustNextPointToClosest();

                await playerDirection.SetDirection(heading, routeToWaypoint.Peek(), "Further away");
            }
            else if (!this.stuckDetector.IsGettingCloser())
            {
                // stuck so jump
                input.SetKeyState(ConsoleKey.UpArrow, true, false, "FollowRouteAction 2");
                await Task.Delay(100);

                if (HasBeenActiveRecently())
                {
                    await this.stuckDetector.Unstick();

                    distance = WowPoint.DistanceTo(location, routeToWaypoint.Peek());
                }
                else
                {
                    await Task.Delay(1000);

                    logger.LogInformation("Resuming movement");
                }
            }
            else // distance closer
            {
                await AdjustHeading(heading);
            }

            lastDistance = distance;

            //if (distance < PointReachedDistance((int)(avgDistance / 2)))
            //if (distance < PointReachedDistance(5))
            if (distance < PointReachedDistance(10))
            {
                Log($"Move to next point");

                ReduceRouteByDistance();

                lastDistance = 999;
                if (routeToWaypoint.Count == 0)
                {
                    wayPoints.Pop();

                    await RefillRouteToNextWaypoint(false);
                }

                this.stuckDetector.SetTargetLocation(this.routeToWaypoint.Peek());

                heading = DirectionCalculator.CalculateHeading(location, routeToWaypoint.Peek());
                await playerDirection.SetDirection(heading, routeToWaypoint.Peek(), "Move to next point");
            }

            // should mount
            await MountIfRequired();

            LastActive = DateTime.Now;
        }