コード例 #1
0
        public override async Task PerformAction()
        {
            var targetLocation = this.classConfiguration.WrongZone.ExitZoneLocation;

            SendActionEvent(new ActionEventArgs(GoapKey.fighting, false));

            await Task.Delay(200);

            input.SetKeyState(ConsoleKey.UpArrow, true, false, "FollowRouteAction 5");

            if (this.playerReader.Bits.PlayerInCombat)
            {
                return;
            }

            if ((DateTime.Now - LastActive).TotalSeconds > 10)
            {
                this.stuckDetector.SetTargetLocation(targetLocation);
            }

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

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

                if (HasBeenActiveRecently())
                {
                    await this.stuckDetector.Unstick();
                }
                else
                {
                    await Task.Delay(1000);

                    logger.LogInformation("Resuming movement");
                }
            }
            else // distance closer
            {
                var diff1 = Math.Abs(RADIAN + heading - playerReader.Direction) % RADIAN;
                var diff2 = Math.Abs(heading - playerReader.Direction - RADIAN) % RADIAN;

                if (Math.Min(diff1, diff2) > 0.3)
                {
                    await playerDirection.SetDirection(heading, targetLocation, "Correcting direction");
                }
            }

            lastDistance = distance;

            LastActive = DateTime.Now;
        }
コード例 #2
0
        public override async Task PerformAction()
        {
            if (!await IsDead())
            {
                return;
            }

            if (NeedsToReset)
            {
                Reset();
                this.stuckDetector.SetTargetLocation(points.Peek());
            }

            await Task.Delay(200);

            var    location = new WowPoint(playerReader.XCoord, playerReader.YCoord);
            double distance = 0;
            double heading  = 0;

            if (points.Count == 0)
            {
                logger.LogInformation("No points left");
                return;
            }
            else
            {
                distance = DistanceTo(location, points.Peek());
                heading  = DirectionCalculator.CalculateHeading(location, points.Peek());
            }

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

                if (HasBeenActiveRecently())
                {
                    await stuckDetector.Unstick();
                }
                else
                {
                    await Task.Delay(1000);

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

            lastDistance = distance;

            if (distance < 30 && points.Any())
            {
                logger.LogInformation($"Move to next point");
                points.Pop();
                lastDistance = 999;
                if (points.Count > 0)
                {
                    heading = DirectionCalculator.CalculateHeading(location, points.Peek());
                    await playerDirection.SetDirection(heading, points.Peek(), "Move to next point");

                    this.stuckDetector.SetTargetLocation(points.Peek());
                }
            }

            LastActive = DateTime.Now;
        }
コード例 #3
0
        public override async Task PerformAction()
        {
            if (NeedsToReset)
            {
                while (true && this.playerReader.PlayerBitValues.DeadStatus)
                {
                    this.corpseLocation = new WowPoint(playerReader.CorpseX, playerReader.CorpseY);
                    if (this.corpseLocation.X > 0)
                    {
                        break;
                    }
                    logger.LogInformation($"Waiting for corpse location to update {playerReader.CorpseX},{playerReader.CorpseY}");
                    await Task.Delay(1000);
                }
                logger.LogInformation($"Corpse location is {playerReader.CorpseX},{playerReader.CorpseY}");

                await Reset();

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

                Deaths.Add(this.corpseLocation);
            }

            await Task.Delay(200);

            if (!this.playerReader.PlayerBitValues.DeadStatus)
            {
                return;
            }

            var    location = new WowPoint(playerReader.XCoord, playerReader.YCoord);
            double distance = 0;
            double heading  = 0;

            if (points.Count == 0)
            {
                points.Push(this.playerReader.CorpseLocation);
                distance = DistanceTo(location, corpseLocation);
                heading  = DirectionCalculator.CalculateHeading(location, corpseLocation);
                this.logger.LogInformation("no more points, heading to corpse");
                await playerDirection.SetDirection(heading, this.playerReader.CorpseLocation, "Heading to corpse");

                wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "WalkToCorpse");
                this.stuckDetector.SetTargetLocation(points.Peek());
            }
            else
            {
                distance = DistanceTo(location, points.Peek());
                heading  = DirectionCalculator.CalculateHeading(location, points.Peek());
            }

            if (lastDistance < distance)
            {
                await playerDirection.SetDirection(heading, points.Peek(), "Further away");
            }
            else if (!this.stuckDetector.IsGettingCloser())
            {
                // stuck so jump
                wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "WalkToCorpseAction");
                await Task.Delay(100);

                if (HasBeenActiveRecently())
                {
                    await stuckDetector.Unstick();
                }
                else
                {
                    await Task.Delay(1000);

                    logger.LogInformation("Resuming movement");
                }
            }
            else // distance closer
            {
                var diff1 = Math.Abs(RADIAN + heading - playerReader.Direction) % RADIAN;
                var diff2 = Math.Abs(heading - playerReader.Direction - RADIAN) % RADIAN;

                if (Math.Min(diff1, diff2) > 0.3)
                {
                    await playerDirection.SetDirection(heading, points.Peek(), "Correcting direction");
                }
            }

            lastDistance = distance;

            if (distance < 40 && points.Any())
            {
                logger.LogInformation($"Move to next point");
                points.Pop();
                lastDistance = 999;
                if (points.Count > 0)
                {
                    heading = DirectionCalculator.CalculateHeading(location, points.Peek());
                    await playerDirection.SetDirection(heading, points.Peek(), "Move to next point");

                    this.stuckDetector.SetTargetLocation(points.Peek());
                }
            }

            LastActive = DateTime.Now;
        }
コード例 #4
0
        public async Task Unstick()
        {
            await wowProcess.KeyPress(ConsoleKey.Spacebar, 500);

            logger.LogInformation($"Stuck for {actionDurationSeconds}s, last tried to unstick {unstickSeconds}s ago. Unstick seconds={unstickSeconds}.");

            if (actionDurationSeconds > 240)
            {
                // stuck for 4 minutes
                logger.LogInformation("Stuck for 4 minutes");
                SendActionEvent(new ActionEventArgs(GoapKey.abort, true));
                await Task.Delay(120000);
            }

            if (unstickSeconds > 5)
            {
                int strafeDuration = (int)(1000 + (((double)actionDurationSeconds * 1000) / 12));

                if (strafeDuration > 20000)
                {
                    strafeDuration = 20000;
                }

                if (actionDurationSeconds > 20)
                {
                    // back up a bit, added "remove" move forward
                    wowProcess.SetKeyState(ConsoleKey.DownArrow, true, false, "StuckDetector_back_up");
                    wowProcess.SetKeyState(ConsoleKey.UpArrow, false, false, "StuckDetector");
                    await Task.Delay(strafeDuration);

                    wowProcess.SetKeyState(ConsoleKey.DownArrow, false, false, "StuckDetector");
                }
                this.stopMoving?.Stop();

                // stuck for 20 seconds
                var r = random.Next(0, 100);
                if (r < 50)
                {
                    logger.LogInformation($"Trying to unstick by strafing left for {strafeDuration}ms");
                    wowProcess.SetKeyState(ConsoleKey.A, true, false, "StuckDetector");
                    await Task.Delay(strafeDuration);

                    wowProcess.SetKeyState(ConsoleKey.A, false, false, "StuckDetector");
                }
                else
                {
                    logger.LogInformation($"Trying to unstick by strafing right for {strafeDuration}ms");
                    wowProcess.SetKeyState(ConsoleKey.D, true, false, "StuckDetector");
                    await Task.Delay(strafeDuration);

                    wowProcess.SetKeyState(ConsoleKey.D, false, false, "StuckDetector");
                }

                await wowProcess.TapStopKey();

                wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "StuckDetector");

                var heading = DirectionCalculator.CalculateHeading(this.playerReader.PlayerLocation, targetLocation);
                await playerDirection.SetDirection(heading, targetLocation, "Move to next point");

                LastUnstickAttemptTimer.Reset();
                LastUnstickAttemptTimer.Start();
            }
            else
            {
                await wowProcess.KeyPress(ConsoleKey.Spacebar, 500);
            }
        }
コード例 #5
0
        public override async Task PerformAction()
        {
            // is corpse visible
            if (this.playerReader.CorpseX < 1 && this.playerReader.CorpseX < 1)
            {
                await this.stopMoving.Stop();

                logger.LogInformation($"Waiting for corpse location to update update before performing action. Corpse is @ {playerReader.CorpseX},{playerReader.CorpseY}");
                await Task.Delay(5000);

                NeedsToReset = true;
                return;
            }

            if (NeedsToReset)
            {
                await this.stopMoving.Stop();

                while (this.playerReader.PlayerBitValues.DeadStatus)
                {
                    this.corpseLocation = new WowPoint(playerReader.CorpseX, playerReader.CorpseY);
                    if (this.corpseLocation.X >= 1 || this.corpseLocation.Y > 0)
                    {
                        break;
                    }
                    logger.LogInformation($"Waiting for corpse location to update {playerReader.CorpseX},{playerReader.CorpseY}");
                    await Task.Delay(1000);
                }
                logger.LogInformation($"Corpse location is {playerReader.CorpseX},{playerReader.CorpseY}");

                await Reset();

                Deaths.Add(this.corpseLocation);
            }

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

            if (timeSinceResetSeconds > 80)
            {
                await this.stopMoving.Stop();

                logger.LogInformation("We have been dead for over 1 minute, trying to path a new route.");
                await this.Reset();
            }

            await Task.Delay(200);

            if (!this.playerReader.PlayerBitValues.DeadStatus)
            {
                return;
            }

            var    location = new WowPoint(playerReader.XCoord, playerReader.YCoord);
            double distance = 0;
            double heading  = 0;

            if (points.Count == 0)
            {
                await Reset();

                if (!points.Any())
                {
                    points.Push(this.playerReader.CorpseLocation);
                    distance = DistanceTo(location, corpseLocation);
                    heading  = DirectionCalculator.CalculateHeading(location, corpseLocation);
                    this.logger.LogInformation("no more points, heading to corpse");
                    await playerDirection.SetDirection(heading, this.playerReader.CorpseLocation, "Heading to corpse");

                    input.SetKeyState(ConsoleKey.UpArrow, true, false, "WalkToCorpse");
                    this.stuckDetector.SetTargetLocation(points.Peek());
                }
            }
            else
            {
                distance = DistanceTo(location, points.Peek());
                heading  = DirectionCalculator.CalculateHeading(location, points.Peek());
            }

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

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

                    // give up if we have been dead for 10 minutes
                    var timeDeadSeconds = (DateTime.Now - LastEventReceived).TotalSeconds;
                    if (timeDeadSeconds > 600)
                    {
                        logger.LogInformation("We have been dead for 10 minutes and seem to be stuck.");
                        SendActionEvent(new ActionEventArgs(GOAP.GoapKey.abort, true));
                        await Task.Delay(10000);

                        return;
                    }

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

                    logger.LogInformation("Resuming movement");
                }
            }
            else // distance closer
            {
                var diff1 = Math.Abs(RADIAN + heading - playerReader.Direction) % RADIAN;
                var diff2 = Math.Abs(heading - playerReader.Direction - RADIAN) % RADIAN;

                if (Math.Min(diff1, diff2) > 0.3)
                {
                    await playerDirection.SetDirection(heading, points.Peek(), "Correcting direction");
                }
            }

            lastDistance = distance;

            if (distance < PointReachedDistance() && points.Any())
            {
                while (distance < PointReachedDistance() && points.Any())
                {
                    points.Pop();
                    if (points.Any())
                    {
                        distance = WowPoint.DistanceTo(location, points.Peek());
                    }
                }

                lastDistance = 999;
                if (points.Count > 0)
                {
                    heading = DirectionCalculator.CalculateHeading(location, points.Peek());
                    await playerDirection.SetDirection(heading, points.Peek(), "Move to next point");

                    this.stuckDetector.SetTargetLocation(points.Peek());
                }
            }

            LastActive = DateTime.Now;
        }
コード例 #6
0
        public override async Task PerformAction()
        {
            SendActionEvent(new ActionEventArgs(GoapKey.fighting, false));

            await Task.Delay(200);

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

            if ((DateTime.Now - LastActive).TotalSeconds > 10 || routeToWaypoint.Count == 0)
            {
                await FillRouteToDestination();
            }
            else
            {
                wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "VendorGoal 1");
            }

            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)
            {
                await playerDirection.SetDirection(heading, routeToWaypoint.Peek(), "Further away");
            }
            else if (!this.stuckDetector.IsGettingCloser())
            {
                // stuck so jump
                wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "VendorGoal 2");
                await Task.Delay(100);

                if (HasBeenActiveRecently())
                {
                    await this.stuckDetector.Unstick();
                }
                else
                {
                    await Task.Delay(1000);

                    logger.LogInformation("Resuming movement");
                }
            }

            lastDistance = distance;

            if (distance < PointReachedDistance())
            {
                logger.LogInformation($"Move to next point");

                ReduceRoute();

                lastDistance = 999;
                if (routeToWaypoint.Count == 0)
                {
                    await this.stopMoving.Stop();

                    distance = WowPoint.DistanceTo(location, this.GetTargetLocation());
                    if (distance > 50)
                    {
                        await FillRouteToDestination();
                    }

                    if (routeToWaypoint.Count == 0)
                    {
                        await MoveCloserToTarget(400);
                        await MoveCloserToTarget(100);

                        // we have reached the target location
                        await InteractWithTarget();
                    }
                }

                if (routeToWaypoint.Count == 0)
                {
                    return;
                }

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

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

                distance = WowPoint.DistanceTo(location, routeToWaypoint.Peek());

                if (this.classConfiguration.Blink.ConsoleKey != 0 && this.playerReader.ManaPercentage > 90 && this.playerReader.PlayerLevel < 40 && distance > 200)
                {
                    await wowProcess.KeyPress(this.classConfiguration.Blink.ConsoleKey, 120, this.classConfiguration.Blink.Name);
                }
            }

            // should mount
            await MountIfRequired();

            LastActive = DateTime.Now;
        }
コード例 #7
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;
        }
コード例 #8
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);
        }
コード例 #9
0
        public override async Task PerformAction()
        {
            SendActionEvent(new ActionEventArgs(GoapKey.fighting, false));
            if (this.classConfiguration.Mode == Mode.AttendedGather && this.lastGatherClick.AddSeconds(3) < DateTime.Now && this.classConfiguration.GatherFindKeyConfig.Count > 0)
            {
                lastGatherKey++;
                if (lastGatherKey >= this.classConfiguration.GatherFindKeyConfig.Count)
                {
                    lastGatherKey = 0;
                }

                await wowProcess.KeyPress(classConfiguration.GatherFindKeyConfig[lastGatherKey].ConsoleKey, 200, "Gatherkey 1");

                lastGatherClick = DateTime.Now;
            }

            if (points.Count == 0)
            {
                RefillPoints(true);
                this.stuckDetector.SetTargetLocation(this.points.Peek());
            }

            await Task.Delay(200);

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

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

            if ((DateTime.Now - LastActive).TotalSeconds > 10)
            {
                var pointsRemoved = 0;
                this.stuckDetector.SetTargetLocation(this.points.Peek());
                while (AdjustNextPointToClosest() && pointsRemoved < 5)
                {
                    pointsRemoved++;
                }
                ;
            }

            await RandomJump();

            if (this.classConfiguration.Mode != Mode.AttendedGather)
            {
                // press tab
                if (!this.playerReader.PlayerBitValues.PlayerInCombat && (DateTime.Now - lastTab).TotalMilliseconds > 1100)
                {
                    //new PressKeyThread(this.wowProcess, ConsoleKey.Tab);
                    if (await LookForTarget())
                    {
                        if (this.playerReader.HasTarget)
                        {
                            logger.LogInformation("Has target!");
                            return;
                        }
                    }
                }
            }

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

            if (this.classConfiguration.Mode == Mode.AttendedGather)
            {
                await AdjustHeading(heading);
            }

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

                if (HasBeenActiveRecently())
                {
                    await this.stuckDetector.Unstick();
                }
                else
                {
                    await Task.Delay(1000);

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

            lastDistance = distance;

            if (distance < PointReachedDistance())
            {
                logger.LogInformation($"Move to next point");

                points.Pop();
                lastDistance = 999;
                if (points.Count == 0)
                {
                    RefillPoints();
                }

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

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

                if (this.classConfiguration.Blink.ConsoleKey != 0 && this.playerReader.ManaPercentage > 90 && this.playerReader.PlayerLevel < 40)
                {
                    await wowProcess.KeyPress(this.classConfiguration.Blink.ConsoleKey, 120, this.classConfiguration.Blink.Name);
                }
            }

            // should mount
            if (shouldMount && !this.playerReader.PlayerBitValues.IsMounted && !playerReader.PlayerBitValues.PlayerInCombat)
            {
                if (this.classConfiguration.Mode != Mode.AttendedGather)
                {
                    shouldMount = false;
                    if (await LookForTarget())
                    {
                        return;
                    }
                }

                logger.LogInformation("Mounting if level >=40 (druid 30) and no NPC in sight");
                if (!this.npcNameFinder.MobsVisible)
                {
                    if (this.playerReader.PlayerLevel >= 40 && this.playerReader.PlayerClass != PlayerClassEnum.Druid)
                    {
                        await wowProcess.TapStopKey();

                        await Task.Delay(500);

                        await wowProcess.Mount(this.playerReader);
                    }
                    if (this.playerReader.PlayerLevel >= 30 && this.playerReader.PlayerClass == PlayerClassEnum.Druid)
                    {
                        this.classConfiguration.ShapeshiftForm
                        .Where(s => s.ShapeShiftFormEnum == ShapeshiftForm.Druid_Travel)
                        .ToList()
                        .ForEach(async k => await this.wowProcess.KeyPress(k.ConsoleKey, 325));
                    }
                }
                else
                {
                    logger.LogInformation("Not mounting as can see NPC.");
                }
                wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "FollowRouteAction 3");
            }

            LastActive = DateTime.Now;
        }
コード例 #10
0
        public async Task Unstick()
        {
            await wowProcess.KeyPress(ConsoleKey.Spacebar, 500);

            logger.LogInformation($"Stuck for {actionDurationSeconds}s, last tried to unstick {unstickSeconds}s ago. Unstick seconds={unstickSeconds}.");

            if (actionDurationSeconds > 240)
            {
                // stuck for 4 minutes
                logger.LogInformation("Stuck for 4 minutes");
                SendActionEvent(new ActionEventArgs(GoapKey.abort, true));
                await Task.Delay(120000);
            }

            if (unstickSeconds > 2)
            {
                int actionDuration = (int)(1000 + (((double)actionDurationSeconds * 1000) / 8));

                if (actionDuration > 20000)
                {
                    actionDuration = 20000;
                }

                if (actionDurationSeconds > 10)
                {
                    // back up a bit, added "remove" move forward
                    logger.LogInformation($"Trying to unstick by backing up for {actionDuration}ms");
                    wowProcess.SetKeyState(ConsoleKey.DownArrow, true, false, "StuckDetector_back_up");
                    wowProcess.SetKeyState(ConsoleKey.UpArrow, false, false, "StuckDetector");
                    await Task.Delay(actionDuration);

                    wowProcess.SetKeyState(ConsoleKey.DownArrow, false, false, "StuckDetector");
                }
                this.stopMoving?.Stop();

                // Turn
                var r            = random.Next(0, 2);
                var key          = r == 0 ? ConsoleKey.A : ConsoleKey.D;
                var turnDuration = random.Next(0, 800) + 200;
                logger.LogInformation($"Trying to unstick by turning for {turnDuration}ms");
                wowProcess.SetKeyState(key, true, false, "StuckDetector");
                await Task.Delay(turnDuration);

                wowProcess.SetKeyState(key, false, false, "StuckDetector");

                // Move forward
                var strafeDuration = random.Next(0, 2000) + actionDurationSeconds;
                logger.LogInformation($"Trying to unstick by moving forward after turning for {strafeDuration}ms");
                wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "StuckDetector");
                await Task.Delay(strafeDuration);

                await wowProcess.KeyPress(ConsoleKey.Spacebar, 500);

                var heading = DirectionCalculator.CalculateHeading(this.playerReader.PlayerLocation, targetLocation);
                await playerDirection.SetDirection(heading, targetLocation, "Move to next point");

                LastUnstickAttemptTimer.Reset();
                LastUnstickAttemptTimer.Start();
            }
            else
            {
                await wowProcess.KeyPress(ConsoleKey.Spacebar, 500);
            }
        }
コード例 #11
0
        public override async Task PerformAction()
        {
            SendActionEvent(new ActionEventArgs(GoapKey.fighting, false));

            await SwitchGatherType();

            //await Task.Delay(200);

            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);
            }
            else
            {
                wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "FollowRouteAction 1");
            }

            await RandomJump();

            if (await AquireTarget())
            {
                return;
            }

            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
                wowProcess.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())
            {
                logger.LogInformation($"Move to next point");

                ReduceRoute();

                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");

                await BlinkIfMage();
            }

            // should mount
            await MountIfRequired();

            LastActive = DateTime.Now;
        }
コード例 #12
0
        public async Task ReactToLastUIErrorMessage(string source)
        {
            //var lastError = playerReader.LastUIErrorMessage;
            switch (playerReader.LastUIErrorMessage)
            {
            case UI_ERROR.NONE:
                break;

            case UI_ERROR.CAST_START:
                break;

            case UI_ERROR.CAST_SUCCESS:
                break;

            case UI_ERROR.ERR_SPELL_FAILED_STUNNED:
                int debuffCount = playerReader.AuraCount.PlayerDebuff;
                if (debuffCount != 0)
                {
                    logger.LogInformation($"{source} -- React to {UI_ERROR.ERR_SPELL_FAILED_STUNNED} -- Wait till losing debuff!");
                    await wait.While(() => debuffCount == playerReader.AuraCount.PlayerDebuff);

                    await wait.Update(1);

                    playerReader.LastUIErrorMessage = UI_ERROR.NONE;
                }
                else
                {
                    logger.LogInformation($"{source} -- Didn't know how to react {UI_ERROR.ERR_SPELL_FAILED_STUNNED} when PlayerDebuffCount: {debuffCount}");
                }
                break;

            case UI_ERROR.ERR_SPELL_OUT_OF_RANGE:
                if (playerReader.Class == PlayerClassEnum.Hunter && playerReader.IsInMeleeRange)
                {
                    logger.LogInformation($"{source} -- As a Hunter didn't know how to react {UI_ERROR.ERR_SPELL_OUT_OF_RANGE}");
                    return;
                }

                logger.LogInformation($"{source} -- React to {UI_ERROR.ERR_SPELL_OUT_OF_RANGE} -- Face enemy and start moving forward");
                await input.TapInteractKey("");

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

                await wait.Update(1);

                playerReader.LastUIErrorMessage = UI_ERROR.NONE;
                break;

            case UI_ERROR.ERR_BADATTACKFACING:

                if (playerReader.IsInMeleeRange)
                {
                    logger.LogInformation($"{source} -- React to {UI_ERROR.ERR_BADATTACKFACING} -- Interact!");
                    await input.TapInteractKey("");
                }
                else
                {
                    logger.LogInformation($"{source} -- React to {UI_ERROR.ERR_BADATTACKFACING} -- Turning 180!");

                    double desiredDirection = playerReader.Direction + Math.PI;
                    desiredDirection = desiredDirection > Math.PI * 2 ? desiredDirection - (Math.PI * 2) : desiredDirection;
                    await direction.SetDirection(desiredDirection, new WowPoint(0, 0), "");
                }

                await wait.Update(1);

                playerReader.LastUIErrorMessage = UI_ERROR.NONE;
                break;

            case UI_ERROR.SPELL_FAILED_MOVING:
                logger.LogInformation($"{source} -- React to {UI_ERROR.SPELL_FAILED_MOVING} -- Stop moving!");

                await stopMoving.Stop();

                await wait.Update(1);

                playerReader.LastUIErrorMessage = UI_ERROR.NONE;
                break;

            case UI_ERROR.ERR_SPELL_FAILED_ANOTHER_IN_PROGRESS:
                logger.LogInformation($"{source} -- React to {UI_ERROR.ERR_SPELL_FAILED_ANOTHER_IN_PROGRESS} -- Wait till casting!");
                await wait.While(() => playerReader.IsCasting);

                await wait.Update(1);

                playerReader.LastUIErrorMessage = UI_ERROR.NONE;
                break;

            case UI_ERROR.ERR_SPELL_COOLDOWN:
                logger.LogInformation($"{source} -- Cant react to {UI_ERROR.ERR_SPELL_FAILED_ANOTHER_IN_PROGRESS}");

                await wait.Update(1);

                playerReader.LastUIErrorMessage = UI_ERROR.NONE;
                break;

            case UI_ERROR.ERR_BADATTACKPOS:
                if (playerReader.Bits.IsAutoRepeatSpellOn_AutoAttack)
                {
                    logger.LogInformation($"{source} -- React to {UI_ERROR.ERR_BADATTACKPOS} -- Interact!");
                    await input.TapInteractKey("");

                    await stopMoving.Stop();

                    await wait.Update(1);

                    playerReader.LastUIErrorMessage = UI_ERROR.NONE;
                }
                else
                {
                    logger.LogInformation($"{source} -- Didn't know how to React to {playerReader.LastUIErrorMessage}");
                }
                break;

            default:
                logger.LogInformation($"{source} -- Didn't know how to React to {playerReader.LastUIErrorMessage}");
                break;
                //case UI_ERROR.ERR_SPELL_FAILED_S:
                //case UI_ERROR.ERR_BADATTACKPOS:
                //case UI_ERROR.ERR_SPELL_OUT_OF_RANGE:
                //case UI_ERROR.ERR_AUTOFOLLOW_TOO_FAR:
                //    this.playerReader.LastUIErrorMessage = UI_ERROR.NONE;
                //    break;
            }
        }
コード例 #13
0
        public override async Task PerformAction()
        {
            SendActionEvent(new ActionEventArgs(GoapKey.fighting, false));
            if (this.classConfiguration.Mode == Mode.AttendedGather && this.lastGatherClick.AddSeconds(3) < DateTime.Now && this.classConfiguration.GatherFindKeyConfig.Count > 0)
            {
                lastGatherKey++;
                if (lastGatherKey >= this.classConfiguration.GatherFindKeyConfig.Count)
                {
                    lastGatherKey = 0;
                }

                await wowProcess.KeyPress(classConfiguration.GatherFindKeyConfig[lastGatherKey].ConsoleKey, 200, "Gatherkey 1");

                lastGatherClick = DateTime.Now;
            }

            await Task.Delay(200);

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

            if ((DateTime.Now - LastActive).TotalSeconds > 10 || routeToWaypoint.Count == 0)
            {
                // recalculate next waypoint
                var pointsRemoved = 0;
                while (AdjustNextPointToClosest() && pointsRemoved < 5)
                {
                    pointsRemoved++;
                }
                ;
                await RefillRouteToNextWaypoint(true);
            }
            else
            {
                wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "FollowRouteAction 1");
            }

            await RandomJump();

            if (this.classConfiguration.Mode != Mode.AttendedGather)
            {
                // press tab
                if (!this.playerReader.PlayerBitValues.PlayerInCombat && (DateTime.Now - lastTab).TotalMilliseconds > 1100)
                {
                    //new PressKeyThread(this.wowProcess, ConsoleKey.Tab);
                    if (await LookForTarget())
                    {
                        if (this.playerReader.HasTarget)
                        {
                            logger.LogInformation("Has target!");
                            return;
                        }
                    }
                }
            }

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

            //if (this.classConfiguration.Mode == Mode.AttendedGather)
            //{
            await AdjustHeading(heading);

            //}

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

                if (HasBeenActiveRecently())
                {
                    await this.stuckDetector.Unstick();
                }
                else
                {
                    await Task.Delay(1000);

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

            lastDistance = distance;

            if (distance < PointReachedDistance())
            {
                logger.LogInformation($"Move to next point");

                ReduceRoute();

                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");

                distance = WowPoint.DistanceTo(location, routeToWaypoint.Peek());

                if (this.classConfiguration.Blink.ConsoleKey != 0 && this.playerReader.ManaPercentage > 90 && this.playerReader.PlayerLevel < 40 &&
                    distance > 200
                    )
                {
                    await wowProcess.KeyPress(this.classConfiguration.Blink.ConsoleKey, 120, this.classConfiguration.Blink.Name);
                }
            }

            // should mount
            await MountIfRequired();

            LastActive = DateTime.Now;
        }