Esempio n. 1
0
        public static async Task <bool> Dismount(byte maxTicks = 100, ushort interval = 100)
        {
            var dismountTicks = 0;

            while (dismountTicks++ < maxTicks && Core.Player.IsMounted && Behaviors.ShouldContinue)
            {
                if (MovementManager.IsFlying)
                {
                    if (Navigator.PlayerMover is FlightEnabledSlideMover)
                    {
                        Navigator.Stop();
                    }
                    else
                    {
                        MovementManager.StartDescending();
                    }
                }
                else
                {
                    ActionManager.Dismount();
                }

                await Wait(interval, () => !Core.Player.IsMounted);
            }

            if (dismountTicks > maxTicks)
            {
                Logger.Instance.Error("Failed to dismount.");
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        protected override async Task <bool> Main()
        {
            if (!ScriptManager.GetCondition(Condition)())
            {
                Logger.Info(Localization.Localization.ExPurify_GetCondition, Condition);
                return(isDone = true);
            }

            await Behaviors.Wait(2000, () => !Window <Gathering> .IsOpen);

            await Behaviors.Wait(2000, () => !GatheringMasterpiece.IsOpen);

            Navigator.Stop();

            var ticks = 0;

            while (MovementManager.IsFlying && ticks++ < 5 && Behaviors.ShouldContinue)
            {
                MovementManager.StartDescending();
                await Coroutine.Wait(500, () => !MovementManager.IsFlying);
            }

            if (ticks > 5)
            {
                Logger.Error(Localization.Localization.ExPurify_Land);
                return(isDone = true);
            }

            await CommonTasks.StopAndDismount();

            if (await Coroutine.Wait(
                    MaxWait,
                    () =>
            {
                if (!ExProfileBehavior.Me.IsMounted)
                {
                    return(true);
                }

                ActionManager.Dismount();
                return(false);
            }))
            {
                await PurifyDialog.ReduceAllItems(InventoryManager.FilledSlots, (ushort)MaxWait);
            }
            else
            {
                Logger.Error(Localization.Localization.ExPurify_Dismount);
            }

            return(isDone = true);
        }
Esempio n. 3
0
        private async Task <bool> UseCordial(CordialType cordialType, int maxTimeoutSeconds = 5)
        {
            if (CordialSpellData.Cooldown.TotalSeconds < maxTimeoutSeconds)
            {
                var cordial = InventoryManager.FilledSlots.FirstOrDefault(slot => slot.RawItemId == (uint)cordialType);

                if (cordial != null)
                {
                    StatusText = Localization.Localization.ExFish_UseCordialWhenAvailable;

                    Logger.Info(
                        Localization.Localization.ExFish_UseCordial,
                        (int)CordialSpellData.Cooldown.TotalSeconds,
                        ExProfileBehavior.Me.CurrentGP);

                    if (await Coroutine.Wait(
                            TimeSpan.FromSeconds(maxTimeoutSeconds),
                            () =>
                    {
                        if (ExProfileBehavior.Me.IsMounted && CordialSpellData.Cooldown.TotalSeconds < 2)
                        {
                            ActionManager.Dismount();
                            return(false);
                        }

                        return(cordial.CanUse(ExProfileBehavior.Me));
                    }))
                    {
                        await Coroutine.Sleep(500);

                        Logger.Info("Using " + cordialType);
                        cordial.UseItem(ExProfileBehavior.Me);
                        await Coroutine.Sleep(1500);

                        return(true);
                    }
                }
                else
                {
                    Logger.Warn(Localization.Localization.ExFish_NoCordial + cordialType);
                }
            }

            return(false);
        }