Ejemplo n.º 1
0
        protected bool CanRun(KeyConfiguration item)
        {
            if (!string.IsNullOrEmpty(item.CastIfAddsVisible))
            {
                var needAdds = bool.Parse(item.CastIfAddsVisible);
                if (needAdds != npcNameFinder.PotentialAddsExist)
                {
                    item.LogInformation($"Only cast if adds exist = {item.CastIfAddsVisible} and it is {npcNameFinder.PotentialAddsExist}");
                    return(false);
                }
            }

            return(item.CanRun());
        }
Ejemplo n.º 2
0
        public async Task <bool> CastIfReady(KeyConfiguration item, GoapAction source, int sleepBeforeCast = 0)
        {
            if (!CanRun(item))
            {
                return(false);
            }

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

            if (!await SwitchToCorrectShapeShiftForm(item))
            {
                return(false);
            }

            if (this.playerReader.IsShooting)
            {
                await TapInteractKey("Stop casting shoot");

                await Task.Delay(1500); // wait for shooting to end
            }

            if (sleepBeforeCast > 0)
            {
                item.LogInformation($" Wait before {sleepBeforeCast}.");
                await Task.Delay(sleepBeforeCast);
            }

            await PressKey(item.ConsoleKey, item.Name, item.PressDuration);

            item.SetClicked();

            if (!item.HasCastBar)
            {
                item.LogInformation($" ... delay after cast {item.DelayAfterCast}");
                await Task.Delay(item.DelayAfterCast);
            }
            else
            {
                await Task.Delay(300);

                if (!this.playerReader.IsCasting && this.playerReader.HasTarget)
                {
                    await this.InteractOnUIError();

                    item.LogInformation($"Not casting, pressing it again");
                    await PressKey(item.ConsoleKey, item.Name, item.PressDuration);

                    await Task.Delay(300);

                    if (!this.playerReader.IsCasting && this.playerReader.HasTarget)
                    {
                        item.LogInformation($"Still not casting !");
                        await this.InteractOnUIError();

                        return(false);
                    }
                }

                item.LogInformation(" waiting for cast bar to end.");
                for (int i = 0; i < 15000; i += 100)
                {
                    if (!this.playerReader.IsCasting)
                    {
                        await Task.Delay(100);

                        break;
                    }

                    if (source.GetType() == typeof(PullTargetAction) &&
                        this.playerReader.PlayerBitValues.PlayerInCombat &&
                        !this.playerReader.PlayerBitValues.TargetOfTargetIsPlayer &&
                        this.playerReader.IsCasting &&
                        this.playerReader.TargetHealthPercentage > 99
                        )
                    {
                        if (!this.playerReader.TargetIsFrostbitten)
                        {
                            await this.wowProcess.KeyPress(ConsoleKey.UpArrow, 200, "Stop cast as picked up an add, my mob is not targetting me.");

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

                            break;
                        }
                    }

                    await Task.Delay(100);
                }
            }

            return(true);
        }