コード例 #1
0
        private async Task <bool> CastInstant(KeyAction item)
        {
            if (item.StopBeforeCast)
            {
                await stopMoving.Stop();

                await wait.Update(1);
            }

            playerReader.CastEvent.ForceUpdate(0);
            int  beforeCastEventValue = playerReader.CastEvent.Value;
            int  beforeSpellId        = playerReader.CastSpellId.Value;
            bool beforeUsable         = addonReader.UsableAction.Is(item);

            await PressKeyAction(item);

            bool   inputNotHappened;
            double inputElapsedMs;

            if (item.AfterCastWaitNextSwing)
            {
                (inputNotHappened, inputElapsedMs) = await wait.InterruptTask(MaxSwingTimeMs,
                                                                              interrupt : () => !addonReader.CurrentAction.Is(item),
                                                                              repeat : async() =>
                {
                    if (classConfig.Approach.GetCooldownRemaining() == 0)
                    {
                        await input.TapApproachKey("");
                    }
                });
            }
            else
            {
                (inputNotHappened, inputElapsedMs) = await wait.InterruptTask(MaxWaitCastTimeMs,
                                                                              interrupt : () =>
                                                                              (beforeSpellId != playerReader.CastSpellId.Value && beforeCastEventValue != playerReader.CastEvent.Value) ||
                                                                              beforeUsable != addonReader.UsableAction.Is(item)
                                                                              );
            }

            if (!inputNotHappened)
            {
                item.LogInformation($" ... instant input {inputElapsedMs}ms");
            }
            else
            {
                item.LogInformation($" ... instant input not registered! {inputElapsedMs}ms");
                return(false);
            }

            item.LogInformation($" ... usable: {beforeUsable}->{addonReader.UsableAction.Is(item)} -- ({(UI_ERROR)beforeCastEventValue}->{(UI_ERROR)playerReader.CastEvent.Value})");

            if (!CastSuccessfull((UI_ERROR)playerReader.CastEvent.Value))
            {
                await ReactToLastCastingEvent(item, $"{item.Name}-{GetType().Name}: CastInstant");

                return(false);
            }
            return(true);
        }
コード例 #2
0
        public override async Task OnEnter()
        {
            await base.OnEnter();

            if (playerReader.Bits.IsMounted)
            {
                await input.TapDismount();
            }

            await input.TapApproachKey($"{GetType().Name}: OnEnter - Face the target and stop");

            await stopMoving.Stop();

            await wait.Update(1);

            pullStart = DateTime.Now;
        }
コード例 #3
0
        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();
        }