Esempio n. 1
0
        protected override async Task <bool> RunAsync()
        {
            DutyManager.LeaveActiveDuty();
            await Coroutine.Sleep(5000);

            return(false);
        }
Esempio n. 2
0
        public static async Task StopBusy(bool leaveDuty = true, bool stopFishing = true, bool dismount = true)
        {
            for (var tryStep = 1; tryStep < 6; tryStep++)
            {
                if (!CheckIfBusy(leaveDuty, stopFishing, dismount))
                {
                    break;
                }

                Log($"We're occupied. Trying to exit out. Attempt #{tryStep}");

                if (stopFishing && FishingManager.State != FishingState.None)
                {
                    var quit = ActionManager.CurrentActions.Values.FirstOrDefault(i => i.Id == 299);
                    if (quit != default(SpellData))
                    {
                        Log($"Exiting Fishing.");
                        if (ActionManager.CanCast(quit, Core.Me))
                        {
                            ActionManager.DoAction(quit, Core.Me);
                            await Coroutine.Wait(6000, () => FishingManager.State == FishingState.None);
                        }
                    }
                }

                if (CraftingLog.IsOpen || CraftingManager.IsCrafting || Synthesis.IsOpen)
                {
                    Log($"Closing Crafting Window.");
                    await Lisbeth.ExitCrafting();

                    Synthesis.Close();
                    await Coroutine.Wait(6000, () => !Synthesis.IsOpen);

                    await Coroutine.Wait(1500, () => CraftingLog.IsOpen);

                    CraftingLog.Close();
                    await Coroutine.Wait(6000, () => !CraftingLog.IsOpen);

                    await Coroutine.Wait(6000, () => !CraftingManager.IsCrafting && !MovementManager.IsOccupied);
                }

                if (leaveDuty && DutyManager.InInstance)
                {
                    Log($"Leaving Diadem.");
                    DutyManager.LeaveActiveDuty();

                    if (await Coroutine.Wait(30000, () => CommonBehaviors.IsLoading))
                    {
                        await Coroutine.Yield();

                        await Coroutine.Wait(-1, () => !CommonBehaviors.IsLoading);

                        await Coroutine.Sleep(5000);
                    }
                }

                if (dismount && Core.Me.IsMounted)
                {
                    Log("Dismounting.");
                    ActionManager.Dismount();
                    await Coroutine.Wait(3000, () => !Core.Me.IsMounted);
                }

                if (InSmallTalk)
                {
                    Log("Skipping smalltalk.");
                    await SmallTalk();
                }

                await Coroutine.Sleep(2500);
            }

            if (CheckIfBusy(leaveDuty, stopFishing, dismount))
            {
                Log("Something went wrong, we're still occupied.");
                TreeRoot.Stop("Stopping bot.");
            }
        }
Esempio n. 3
0
        public async Task GatherWeatherNodes()
        {
            if (WorldManager.RawZoneId != 901)
            {
                await EnterDiadem();

                Log($"Waiting for instance time");
                await Coroutine.Wait(5000, () => TimeLeftInDiadem.TotalMinutes > 1);

                Log($"Time left {TimeLeftInDiadem:hh\\:mm\\:ss}");
            }

            lastChange = new WaitTimer(new TimeSpan(0, 7, 0));
            Log($"Current Weather: {WorldManager.CurrentWeather}  {WorldManager.CurrentWeatherId}");

            Random time = new Random();

            int minutes = time.Next(10, 20);
            int sec     = time.Next(0, 59);

            standBy = afkSpots[time.Next(0, afkSpots.Length)];

            while (TimeLeftInDiadem > new TimeSpan(0, minutes, sec))
            {
                switch (WorldManager.CurrentWeatherId)
                {
                case 133:
                    if (lastWeather == 133)
                    {
                        break;
                    }
                    //await FlyTo(new Vector3(-295.9257f, 268.4518f, -370.327f));
                    await MineWeather(ClassJobType.Miner, umbralFlareAbove, umbralFlare);

                    standBy = afkSpots[time.Next(0, afkSpots.Length)];
                    await StandBy();

                    break;

                case 135: if (lastWeather == 135)
                    {
                        break;
                    }
                    await MineWeather(ClassJobType.Miner, umbralLevinAbove, umbralLevin);

                    standBy = afkSpots[time.Next(0, afkSpots.Length)];
                    await StandBy();

                    break;

                case 134: if (lastWeather == 134)
                    {
                        break;
                    }
                    await MineWeather(ClassJobType.Botanist, umbralDuststormAbove, umbralDuststorm);

                    standBy = afkSpots[time.Next(0, afkSpots.Length)];
                    await StandBy();

                    break;

                case 136: if (lastWeather == 136)
                    {
                        break;
                    }
                    await MineWeather(ClassJobType.Botanist, umbralTempestAbove, umbralTempest);

                    standBy = afkSpots[time.Next(0, afkSpots.Length)];
                    await StandBy();

                    break;

                default: await Coroutine.Sleep(1000);

                    if (lastChange.IsFinished)
                    {
                        lastChange.Reset();
                        lastWeather = 0;
                    }

                    await StandBy(); break;
                }

                await Coroutine.Sleep(1000);
            }

            if (DutyManager.InInstance)
            {
                Log($"Out of time: {TimeLeftInDiadem:hh\\:mm\\:ss} Left");
                DutyManager.LeaveActiveDuty();

                if (await Coroutine.Wait(30000, () => CommonBehaviors.IsLoading))
                {
                    await Coroutine.Yield();

                    await Coroutine.Wait(Timeout.Infinite, () => !CommonBehaviors.IsLoading);

                    await Coroutine.Sleep(10000);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Main task executor for the Commence Duty logic.
        /// </summary>
        /// <returns>Returns <c>true</c> if any action was executed, otherwise <c>false</c>.</returns>
        internal new async Task <bool> ExecuteLogic()
        {
            // Do not execute this logic if the botbase is paused
            if (BotBase.Instance.IsPaused)
            {
                return(await Task.FromResult(false));
            }

            if (DutyManager.InInstance)
            {
                if (ShouldVoteMvp())
                {
                    if (await VoteMvp().ExecuteCoroutine())
                    {
                        return(await Task.FromResult(true));
                    }
                }

                if (ShouldLeaveDuty())
                {
                    LogHelper.Instance.Log("Leaving Duty...");
                    DutyManager.LeaveActiveDuty();
                    return(await Task.FromResult(true));
                }

                if (BotBase.Instance.AutoPickUpTreasure && !WorldManager.InPvP)
                {
                    if (GameObjectManager.GetObjectsOfType <Treasure>(true)
                        .FirstOrDefault(i => i.IsTargetable && i.State == 0 && i.Distance2DSqr() < 8) is Treasure treasure)
                    {
                        LogHelper.Instance.Log(treasure);
                        treasure.Interact();
                        Core.Me.ClearTarget();
                        return(await Task.FromResult(true));
                    }
                }
            }



            if (ShouldRegisterDuties())
            {
                try
                {
                    DutyManager.Queue(new InstanceContentResult
                    {
                        Id             = BotBase.Instance.DutyToRegister.Id,
                        IsInDutyFinder = true,
                        ChnName        = BotBase.Instance.DutyToRegister.Name,
                        EngName        = BotBase.Instance.DutyToRegister.Name
                    });
                    LogHelper.Instance.Log($"Queued duty {BotBase.Instance.DutyToRegister.Name}");
                }
                catch (ArgumentException e)
                {
                    LogHelper.Instance.Log(e.Message);
                }
                catch (NullReferenceException e)
                {
                    LogHelper.Instance.Log("Please select a duty to register!");
                }
                //catch (NullReferenceException e)
                //{
                //	LogHelper.Instance.Log();
                //}
                return(await Task.FromResult(true));
            }

            // Play Duty notification sound
            if (ShouldPlayDutyReadySound())
            {
                ShowLogNotification();
                PlayNotificationSound();
                return(await Task.FromResult(true));
            }

            // Auto accept Duty Finder
            if (ShouldAcceptDutyFinder())
            {
                LogHelper.Instance.Log(Localization.Localization.Msg_DutyConfirm);
                ContentsFinderConfirm.Commence();
                WaitHelper.Instance.RemoveWait(@"CommenceDuty.DutyNotificationSound");
                return(await Task.FromResult(true));
            }

            return(await Task.FromResult(false));
        }
Esempio n. 5
0
        public static async Task CheckVentureTask()
        {
            var verified = await VerifiedRetainerData();

            if (!verified)
            {
                return;
            }

            var count = await HelperFunctions.GetNumberOfRetainers();

            var rets = Core.Memory.ReadArray <RetainerInfo>(Offsets.RetainerData, count);
            var now  = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;

            if (rets.Any(i => i.Active && i.VentureTask != 0 && (i.VentureEndTimestamp - now) <= 0 && SpecialCurrencyManager.GetCurrencyCount(SpecialCurrency.Venture) > 2))
            {
                if (FishingManager.State != FishingState.None)
                {
                    var quit = ActionManager.CurrentActions.Values.FirstOrDefault(i => i.Id == 299);
                    if (quit != default(SpellData))
                    {
                        Log($"Exiting Fishing");
                        if (ActionManager.CanCast(quit, Core.Me))
                        {
                            ActionManager.DoAction(quit, Core.Me);
                            await Coroutine.Wait(6000, () => FishingManager.State == FishingState.None);
                        }
                    }
                }

                if (CraftingLog.IsOpen)
                {
                    Log($"Closing Crafting Window");
                    await Lisbeth.ExitCrafting();

                    await Coroutine.Wait(6000, () => !CraftingLog.IsOpen);

                    await Coroutine.Wait(6000, () => !CraftingManager.IsCrafting && !MovementManager.IsOccupied);
                }

                if (DutyManager.InInstance)
                {
                    Log($"Leaving Diadem");
                    DutyManager.LeaveActiveDuty();

                    if (await Coroutine.Wait(30000, () => CommonBehaviors.IsLoading))
                    {
                        await Coroutine.Yield();

                        await Coroutine.Wait(Timeout.Infinite, () => !CommonBehaviors.IsLoading);

                        await Coroutine.Sleep(5000);
                    }
                }

                if (DutyManager.InInstance || CraftingLog.IsOpen || FishingManager.State != FishingState.None || MovementManager.IsOccupied || CraftingManager.IsCrafting)
                {
                    Log("Something went wrong");
                    return;
                }

                var bell = await GoToSummoningBell();

                if (bell == false)
                {
                    LogCritical("No summoning bell near by");
                    return;
                }
                await RetainerRoutine.ReadRetainers(RetainerCheckOnlyVenture);
            }
            else
            {
                Log("No Ventures Complete");
            }
        }