예제 #1
0
        protected async Task Fight()
        {
            if (playerReader.Bits.HasPet && !playerReader.PetHasTarget)
            {
                await input.TapPetAttack("");
            }

            foreach (var item in Keys)
            {
                if (!playerReader.HasTarget)
                {
                    logger.LogInformation($"{GetType().Name}: Lost Target!");
                    await stopMoving.Stop();

                    return;
                }
                else
                {
                    lastKnwonPlayerDirection = playerReader.Direction;
                    lastKnownMinDistance     = playerReader.MinRange;
                    lastKnownMaxDistance     = playerReader.MaxRange;
                }

                if (await castingHandler.CastIfReady(item, item.DelayBeforeCast))
                {
                    if (item.Name == classConfiguration.Approach.Name ||
                        item.Name == classConfiguration.AutoAttack.Name)
                    {
                        await castingHandler.ReactToLastUIErrorMessage($"{GetType().Name}: Fight {item.Name}");
                    }

                    break;
                }
            }
        }
        public async Task <bool> Pull()
        {
            bool hasCast = false;

            //stop combat
            //await this.wowProcess.KeyPress(ConsoleKey.F10, 50);
            await input.TapStopAttack();

            this.playerReader.LastUIErrorMessage = UI_ERROR.NONE;

            if (playerReader.PlayerBitValues.HasPet)
            {
                await input.TapPetAttack();
            }

            foreach (var item in this.Keys)
            {
                var sleepBeforeFirstCast = item.StopBeforeCast && !hasCast && 150 > item.DelayBeforeCast ? 150 : item.DelayBeforeCast;

                var success = await this.castingHandler.CastIfReady(item, sleepBeforeFirstCast);

                hasCast = hasCast || success;

                if (!this.playerReader.HasTarget)
                {
                    return(false);
                }

                if (hasCast && item.WaitForWithinMelleRange)
                {
                    await this.WaitForWithinMelleRange();
                }
            }

            // Wait for combat
            if (hasCast)
            {
                for (int i = 0; i < 40; i++)
                {
                    // wait for combat, for mob to be targetting me or have suffered damage or 2 seconds to have elapsed.
                    // sometimes after casting a ranged attack, we can be in combat before the attack has landed.
                    if (this.playerReader.PlayerBitValues.PlayerInCombat &&
                        (this.playerReader.PlayerBitValues.TargetOfTargetIsPlayer || this.playerReader.TargetHealthPercentage < 99 || i > 20))
                    {
                        return(true);
                    }

                    await Task.Delay(100);
                }
            }

            return(this.playerReader.PlayerBitValues.PlayerInCombat);
        }
        public async Task <bool> Pull()
        {
            if (Keys.Count != 0)
            {
                await input.TapStopAttack();

                await wait.Update(1);
            }

            if (playerReader.Bits.HasPet && !playerReader.PetHasTarget)
            {
                await input.TapPetAttack();
            }

            bool castAny = false;

            foreach (var item in Keys)
            {
                var success = await castingHandler.CastIfReady(item, item.DelayBeforeCast);

                if (success)
                {
                    if (!playerReader.HasTarget)
                    {
                        return(false);
                    }

                    castAny = true;

                    if (item.WaitForWithinMeleeRange)
                    {
                        await WaitForWithinMeleeRange(item, success);
                    }
                }
            }

            if (castAny)
            {
                (bool interrupted, double elapsedMs) = await wait.InterruptTask(1000,
                                                                                () => playerReader.TargetTarget == TargetTargetEnum.TargetIsTargettingMe ||
                                                                                playerReader.TargetTarget == TargetTargetEnum.TargetIsTargettingPet);

                if (!interrupted)
                {
                    Log($"Entered combat after {elapsedMs}ms");
                }
            }

            return(playerReader.Bits.PlayerInCombat);
        }
예제 #4
0
        protected async Task Fight()
        {
            //logger.LogInformation("-");
            if ((DateTime.Now - lastActive).TotalSeconds > 5)
            {
                classConfiguration.Interact.ResetCooldown();
            }

            if (playerReader.PlayerBitValues.HasPet && !playerReader.PetHasTarget)
            {
                await input.TapPetAttack("");
            }

            bool pressed = false;

            foreach (var item in this.Keys)
            {
                bool isFightold = (DateTime.Now - lastActive).TotalSeconds > 5 && (DateTime.Now - lastPulled).TotalSeconds > 5;
                if (item.Name == "Interact" && !isFightold) // don't interact at the start of the fight
                {
                    item.SetClicked();
                    continue;
                }

                pressed = await this.castingHandler.CastIfReady(item);

                if (pressed)
                {
                    break;
                }
            }
            if (!pressed)
            {
                await Task.Delay(20);
            }

            this.lastActive = DateTime.Now;
        }