public async Task PressKey(ConsoleKey key, string description = "", int duration = 50)
        {
            if (lastKeyPressed == classConfig.Interact.ConsoleKey)
            {
                var distance = WowPoint.DistanceTo(classConfig.Interact.LastClickPostion, this.playerReader.PlayerLocation);

                if (distance > 1)
                {
                    logger.LogInformation($"Stop moving: We have moved since the last interact: {distance}");
                    await input.TapStopKey();

                    classConfig.Interact.SetClicked();
                    await playerReader.WaitForNUpdate(1);
                }
            }

            await input.KeyPress(key, duration, description);

            lastKeyPressed = key;
        }
Exemplo n.º 2
0
        private async Task MountIfRequired()
        {
            if (shouldMount && !this.playerReader.PlayerBitValues.IsMounted && !playerReader.PlayerBitValues.PlayerInCombat)
            {
                if (this.classConfiguration.Mode != Mode.AttendedGather)
                {
                    shouldMount = false;
                    //if (await LookForTarget()) { return; }
                }

                Log("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 input.TapStopKey();

                        await Task.Delay(500);

                        await input.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.input.KeyPress(k.ConsoleKey, 325));
                    }
                }
                else
                {
                    logger.LogInformation("Not mounting as can see NPC.");
                }
                input.SetKeyState(ConsoleKey.UpArrow, true, false, "FollowRouteAction 3");
            }
        }
        public override async Task PerformAction()
        {
            await input.TapStopAttack();

            this.playerReader.LastUIErrorMessage = UI_ERROR.NONE;

            if ((DateTime.Now - LastActive).TotalSeconds > 5)
            {
                PullStartTime = DateTime.Now;
            }
            LastActive = DateTime.Now;

            /*
             * if ((DateTime.Now - PullStartTime).TotalSeconds > 30)
             * {
             *  //await wowProcess.KeyPress(ConsoleKey.F3, 50); // clear target
             *  await wowProcess.TapClearTarget();
             *  await this.wowProcess.KeyPress(ConsoleKey.RightArrow, 1000, "Turn after pull timeout");
             *  return;
             * }
             */

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

            if (playerReader.PlayerBitValues.IsMounted)
            {
                logger.LogInformation($"Dismount");
                await input.Dismount();
            }

            if (ShouldStopBeforePull)
            {
                logger.LogInformation($"Stop approach");
                await this.stopMoving.Stop();

                await input.TapStopAttack();

                await input.TapStopKey();
            }

            bool pulled = await Pull();

            if (!pulled)
            {
                if (HasPickedUpAnAdd)
                {
                    logger.LogInformation($"Combat={this.playerReader.PlayerBitValues.PlayerInCombat}, Is Target targetting me={this.playerReader.PlayerBitValues.TargetOfTargetIsPlayer}");
                    logger.LogInformation($"Add on approach");

                    await this.stopMoving.Stop();

                    await input.TapStopKey();

                    //await wowProcess.KeyPress(ConsoleKey.F3, 50); // clear target
                    //await wowProcess.TapClearTarget();

                    await input.TapNearestTarget();

                    if (this.playerReader.HasTarget && playerReader.PlayerBitValues.TargetInCombat)
                    {
                        if (this.playerReader.TargetTarget == TargetTargetEnum.TargetIsTargettingMe)
                        {
                            return;
                        }
                    }

                    await input.TapClearTarget();

                    return;
                }


                if (!this.stuckDetector.IsMoving())
                {
                    await this.stuckDetector.Unstick();
                }

                await Interact();

                await this.playerReader.WaitForNUpdate(1);
            }
            else
            {
                this.SendActionEvent(new ActionEventArgs(GoapKey.pulled, true));
                this.playerReader.LastUIErrorMessage = UI_ERROR.NONE;
            }
        }
        public override async Task PerformAction()
        {
            if (playerReader.PlayerBitValues.IsMounted)
            {
                await input.Dismount();
            }

            if (NeedsToReset)
            {
                this.stuckDetector.ResetStuckParameters();
            }

            var location = playerReader.PlayerLocation;

            if (!playerReader.PlayerBitValues.PlayerInCombat)
            {
                playerWasInCombat = false;
            }
            else
            {
                // we are in combat
                if (!playerWasInCombat && HasPickedUpAnAdd)
                {
                    logger.LogInformation("WARN Bodypull -- Looks like we have an add on approach");
                    logger.LogInformation($"Combat={this.playerReader.PlayerBitValues.PlayerInCombat}, Is Target targetting me={this.playerReader.PlayerBitValues.TargetOfTargetIsPlayer}");

                    await this.stopMoving.Stop();

                    await input.TapClearTarget();

                    await input.TapStopKey();

                    if (playerReader.PetHasTarget)
                    {
                        await this.input.TapTargetPet();

                        await this.input.TapTargetOfTarget();
                    }
                }

                playerWasInCombat = true;
            }

            await this.TapInteractKey("ApproachTargetAction 1");

            await this.playerReader.WaitForNUpdate(1);

            var newLocation = playerReader.PlayerLocation;

            if ((location.X == newLocation.X && location.Y == newLocation.Y && SecondsSinceLastFighting > 5) ||
                this.playerReader.LastUIErrorMessage == UI_ERROR.ERR_AUTOFOLLOW_TOO_FAR)
            {
                input.SetKeyState(ConsoleKey.UpArrow, true, false, "ApproachTargetAction");
                await Wait(100, () => false);

                await input.TapJump();

                this.playerReader.LastUIErrorMessage = UI_ERROR.NONE;
            }

            await RandomJump();

            //
            int approachSeconds = (int)(this.stuckDetector.actionDurationSeconds);

            if (approachSeconds > 20)
            {
                await this.stuckDetector.Unstick();

                await this.TapInteractKey("ApproachTargetAction unstick");

                await Task.Delay(250);
            }

            if (playerReader.WithInCombatRange && (
                    playerReader.PlayerClass == PlayerClassEnum.Rogue ||
                    playerReader.PlayerClass == PlayerClassEnum.Warrior ||
                    playerReader.PlayerClass == PlayerClassEnum.Paladin))
            {
                Log("WithInCombatRange -- Strictly melee -- Wait a moment");
                await stopMoving.Stop();

                await this.TapInteractKey("ApproachTargetAction engage");

                await Task.Delay(200);
            }
        }