Exemplo n.º 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;
        }
Exemplo n.º 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;
        }
        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);
            }
        }
        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;
        }
        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);
        }
Exemplo n.º 6
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;
        }
        public override async Task PerformAction()
        {
            lastPlayerLocation = playerReader.PlayerLocation;
            await wait.Update(1);

            if (!playerReader.Bits.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={playerReader.Bits.PlayerInCombat}, Is Target targetting me={playerReader.Bits.TargetOfTargetIsPlayer}");

                    await stopMoving.Stop();

                    await input.TapClearTarget();

                    await wait.Update(1);

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

                        await input.TapTargetOfTarget();

                        await wait.Update(1);
                    }
                }

                playerWasInCombat = true;
            }

            if (input.ClassConfig.Approach.GetCooldownRemaining() == 0)
            {
                await input.TapApproachKey("");
            }

            lastPlayerDistance = WowPoint.DistanceTo(lastPlayerLocation, playerReader.PlayerLocation);

            if (lastPlayerDistance < 0.05 && playerReader.LastUIErrorMessage == UI_ERROR.ERR_AUTOFOLLOW_TOO_FAR)
            {
                playerReader.LastUIErrorMessage = UI_ERROR.NONE;

                input.SetKeyState(ConsoleKey.UpArrow, true, false, $"{GetType().Name}: Too far, start moving forward!");
                await wait.Update(1);
            }

            if (SecondsSinceApproachStarted > 1 && lastPlayerDistance < 0.05 && !playerReader.Bits.PlayerInCombat)
            {
                await input.TapClearTarget("");

                await wait.Update(1);

                await input.KeyPress(random.Next(2) == 0?ConsoleKey.LeftArrow : ConsoleKey.RightArrow, 1000, $"Seems stuck! Clear Target. Turn away. d: {lastPlayerDistance}");

                approachStart = DateTime.Now;
            }

            if (SecondsSinceApproachStarted > 15 && !playerReader.Bits.PlayerInCombat)
            {
                await input.TapClearTarget("");

                await wait.Update(1);

                await input.KeyPress(random.Next(2) == 0?ConsoleKey.LeftArrow : ConsoleKey.RightArrow, 1000, "Too long time. Clear Target. Turn away.");

                approachStart = DateTime.Now;
            }

            if (playerReader.TargetGuid == initialTargetGuid)
            {
                var initialTargetMinRange = playerReader.MinRange;
                if (!playerReader.Bits.PlayerInCombat)
                {
                    await input.TapNearestTarget("Try to find closer target...");

                    await wait.Update(1);
                }

                if (playerReader.TargetGuid != initialTargetGuid)
                {
                    if (playerReader.HasTarget) // blacklist
                    {
                        if (playerReader.MinRange < initialTargetMinRange)
                        {
                            Log($"Found a closer target! {playerReader.MinRange} < {initialTargetMinRange}");
                            initialMinRange = playerReader.MinRange;
                        }
                        else
                        {
                            initialTargetGuid = -1;
                            await input.TapLastTargetKey($"Stick to initial target!");

                            await wait.Update(1);
                        }
                    }
                    else
                    {
                        Log($"Lost the target due blacklist!");
                    }
                }
            }

            if (initialMinRange < playerReader.MinRange && !playerReader.Bits.PlayerInCombat)
            {
                Log($"We are going away from the target! {initialMinRange} < {playerReader.MinRange}");
                await input.TapClearTarget();

                await wait.Update(1);

                approachStart = DateTime.Now;
            }

            await RandomJump();
        }
        public async Task <bool> CastIfReady(KeyAction item, int sleepBeforeCast = 0)
        {
            if (!CanRun(item))
            {
                return(false);
            }

            if (item.ConsoleKey == 0)
            {
                return(false);
            }

            if (item.Name == classConfig.Approach.Name ||
                item.Name == classConfig.AutoAttack.Name ||
                item.Name == classConfig.Interact.Name)
            {
                await PressKeyAction(item);

                return(true);
            }

            bool beforeUsable = addonReader.UsableAction.Is(item);
            var  beforeForm   = playerReader.Form;

            if (!await SwitchToCorrectStanceForm(beforeForm, item))
            {
                return(false);
            }

            if (beforeForm != playerReader.Form && !beforeUsable && !addonReader.UsableAction.Is(item))
            {
                item.LogInformation(" ... after Form switch still not usable!");
                return(false);
            }

            if (playerReader.Bits.IsAutoRepeatSpellOn_Shoot)
            {
                await input.TapStopAttack("Stop AutoRepeat Shoot");

                await input.TapStopAttack("Stop AutoRepeat Shoot");

                await wait.Update(1);

                (bool interrupted, double elapsedMs) = await wait.InterruptTask(GCD,
                                                                                () => addonReader.UsableAction.Is(item));

                if (!interrupted)
                {
                    item.LogInformation($" ... waited to end Shoot {elapsedMs}ms");
                }
            }

            if (sleepBeforeCast > 0)
            {
                if (item.StopBeforeCast || item.HasCastBar)
                {
                    await stopMoving.Stop();

                    await wait.Update(1);

                    await stopMoving.Stop();

                    await wait.Update(1);
                }

                item.LogInformation($" Wait {sleepBeforeCast}ms before press.");
                await Task.Delay(sleepBeforeCast);
            }

            bool beforeHasTarget = playerReader.HasTarget;
            int  auraHash        = playerReader.AuraCount.Hash;


            if (!await WaitForGCD(item, beforeHasTarget))
            {
                return(false);
            }

            if (!item.HasCastBar)
            {
                if (!await CastInstant(item))
                {
                    // try again after reacted to UI_ERROR
                    if (!await CastInstant(item))
                    {
                        return(false);
                    }
                }
            }
            else
            {
                if (!await CastCastbar(item))
                {
                    // try again after reacted to UI_ERROR
                    if (!await CastCastbar(item))
                    {
                        return(false);
                    }
                }
            }

            if (item.AfterCastWaitBuff)
            {
                (bool notappeared, double elapsedMs) = await wait.InterruptTask(MaxWaitBuffTimeMs, () => auraHash != playerReader.AuraCount.Hash);

                item.LogInformation($" ... AfterCastWaitBuff: Buff: {!notappeared} | pb: {playerReader.AuraCount.PlayerBuff} | pd: {playerReader.AuraCount.PlayerDebuff} | tb: {playerReader.AuraCount.TargetBuff} | td: {playerReader.AuraCount.TargetDebuff} | Delay: {elapsedMs}ms");
            }

            if (item.DelayAfterCast != defaultKeyAction.DelayAfterCast)
            {
                if (item.DelayUntilCombat) // stop waiting if the mob is targetting me
                {
                    item.LogInformation($" ... DelayUntilCombat ... delay after cast {item.DelayAfterCast}ms");

                    var sw = new Stopwatch();
                    sw.Start();
                    while (sw.ElapsedMilliseconds < item.DelayAfterCast)
                    {
                        await wait.Update(1);

                        if (playerReader.Bits.TargetOfTargetIsPlayer)
                        {
                            break;
                        }
                    }
                }
                else if (item.DelayAfterCast > 0)
                {
                    item.LogInformation($" ... delay after cast {item.DelayAfterCast}ms");
                    var result = await wait.InterruptTask(item.DelayAfterCast, () => beforeHasTarget != playerReader.HasTarget);

                    if (!result.Item1)
                    {
                        item.LogInformation($" .... delay after cast interrupted, target changed {result.Item2}ms");
                    }
                    else
                    {
                        item.LogInformation($" .... delay after cast not interrupted {result.Item2}ms");
                    }
                }
            }
            else
            {
                if (item.RequirementObjects.Any())
                {
                    (bool firstReq, double firstReqElapsedMs) = await wait.InterruptTask(SpellQueueTimeMs,
                                                                                         () => !item.CanRun()
                                                                                         );

                    item.LogInformation($" ... instant interrupt: {!firstReq} | CanRun:{item.CanRun()} | Delay: {firstReqElapsedMs}ms");
                }
            }

            if (item.StepBackAfterCast > 0)
            {
                input.SetKeyState(ConsoleKey.DownArrow, true, false, $"Step back for {item.StepBackAfterCast}ms");
                (bool notStepback, double stepbackElapsedMs) =
                    await wait.InterruptTask(item.StepBackAfterCast, () => beforeHasTarget != playerReader.HasTarget);

                if (!notStepback)
                {
                    item.LogInformation($" .... interrupted stepback | lost target? {beforeHasTarget != playerReader.HasTarget} | {stepbackElapsedMs}ms");
                }
                input.SetKeyState(ConsoleKey.DownArrow, false, false);
            }

            if (item.AfterCastWaitNextSwing)
            {
                await wait.Update(1);
            }

            item.ConsumeCharge();
            return(true);
        }