Beispiel #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);
        }
Beispiel #2
0
		public async Task<bool> SelectBait(
			uint baitId,
			ushort baitDelay = 200,
			ushort maxWait = 2000,
			bool closeWindow = true)
		{
			if (!IsValid)
			{
				ActionManager.DoAction(288, GameObjectManager.LocalPlayer);
				await Refresh(maxWait);
				await Behaviors.Sleep(maxWait);
			}

			var result = SendActionResult.None;
			var attempts = 0;
			while ((result != SendActionResult.Success || FishingManager.SelectedBaitItemId != baitId) && attempts++ < 3
				   && Behaviors.ShouldContinue)
			{
				result = SetBait(baitId);
				if (result == SendActionResult.InjectionError)
				{
					await Behaviors.Sleep(500);
				}

				await Behaviors.Wait(maxWait, () => FishingManager.SelectedBaitItemId == baitId);
			}

			if (closeWindow)
			{
				await CloseInstanceGently(interval: 500);
			}

			return result > SendActionResult.InjectionError;
		}
        public override async Task <bool> ExecuteRotation(ExGatherTag tag)
        {
            if (Core.Player.CurrentGP > 399)
            {
                await Wait();

                ActionManager.DoAction(234U, Core.Player);
            }

            return(await base.ExecuteRotation(tag));
        }
Beispiel #4
0
        internal static async Task <bool> CastAura(uint spellId, int delay, int auraId = -1)
        {
            var result = false;

            if (auraId == -1 || !Core.Player.HasAura(

#if !RB_CN
                    (uint)
#endif
                    auraId))
            {
                SpellData spellData;
                if (GatheringManager.ShouldPause(spellData = DataManager.SpellCache[spellId]))
                {
                    await Coroutine.Wait(3500, () => !GatheringManager.ShouldPause(DataManager.SpellCache[spellId]));
                }

                result = ActionManager.DoAction(spellId, Core.Player);
                var ticks = 0;
                while (result == false && ticks++ < 5 && Behaviors.ShouldContinue)
                {
                    result = ActionManager.DoAction(spellId, Core.Player);
                    await Coroutine.Yield();
                }

                if (result)
                {
                    Logger.Instance.Info("Casted Aura -> {0}", spellData.Name);
                }
                else
                {
                    Logger.Instance.Error("Failed to cast Aura -> {0}", spellData.Name);
                }

                //Wait till we have the aura
                await Coroutine.Wait(3500, () => Core.Player.HasAura(

#if !RB_CN
                                         (uint)
#endif
                                         auraId));

                if (delay > 0)
                {
                    await Coroutine.Sleep(delay);
                }
                else
                {
                    await Coroutine.Yield();
                }
            }

            return(result);
        }
Beispiel #5
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);
        }
Beispiel #6
0
        public static async Task <bool> Sprint(int timeout = 500)
        {
            if (ActionManager.IsSprintReady && !Core.Player.IsCasting && !Core.Player.IsMounted && Core.Player.CurrentTP == 1000 &&
                MovementManager.IsMoving)
            {
                ActionManager.Sprint();

                // Maybe use MovementManager speed.
                await Coroutine.Wait(500, () => !ActionManager.IsSprintReady);
            }

            return(true);
        }
Beispiel #7
0
        internal static async Task <bool> Cast(uint id, int delay)
        {
            //TODO: check affinity, cost type, spell type, and add more informational logging and procedures to casting
            //Wait till we can cast the spell
            SpellData spellData;

            if (GatheringManager.ShouldPause(spellData = DataManager.SpellCache[id]))
            {
                await Coroutine.Wait(3500, () => !GatheringManager.ShouldPause(spellData));
            }

            var result = ActionManager.DoAction(id, Core.Player);

            var ticks = 0;

            while (result == false && ticks++ < 10 && Behaviors.ShouldContinue)
            {
                result = ActionManager.DoAction(id, Core.Player);
                await Coroutine.Yield();
            }

            if (result)
            {
                Logger.Instance.Info("Casted Ability -> {0}", spellData.Name);
            }
            else
            {
                Logger.Instance.Error("Failed to cast Ability -> {0}", spellData.Name);
            }

            //Wait till we can cast again
            if (GatheringManager.ShouldPause(spellData))
            {
                await Coroutine.Wait(3500, () => !GatheringManager.ShouldPause(spellData));
            }
            if (delay > 0)
            {
                await Coroutine.Sleep(delay);
            }
            else
            {
                await Coroutine.Yield();
            }

            return(result);
        }
Beispiel #8
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);
        }
Beispiel #9
0
        public override async Task <bool> ExecuteRotation(ExGatherTag tag)
        {
            if (Core.Player.CurrentGP < 400 || tag.GatherItemIsFallback)
            {
                return(true);
            }

            await Wait();

            var ward = WardSkills.FirstOrDefault(w => ActionManager.CanCast(w, Core.Player));

            if (ward > 0)
            {
                ActionManager.DoAction(ward, Core.Player);
                await IncreaseChance(tag);
            }

            return(true);
        }
Beispiel #10
0
 protected async Task <bool> Move()
 {
     if (GatheringManager.WindowOpen)
     {
         Log("Waiting for gathering window to close");
         Thread.Sleep(2000);
     }
     if (FishingManager.State != FishingState.None)
     {
         Log("Stop fishing");
         ActionManager.DoAction("Quit", Core.Me);
         await Coroutine.Wait(5000, () => FishingManager.State == FishingState.None);
     }
     if (ItemIds != null && ItemIds.Length > 0)
     {
         foreach (var id in ItemIds)
         {
             await MoveByItemId((uint)id, NqOnly);
         }
     }
     return(_done = true);
 }
Beispiel #11
0
		protected async Task<bool> TurnIn()
		{
			foreach (var slot in InventoryManager.FilledSlots)
			{
				// Adamantite
				// Chysahl Green
				// Thunderbolt Eel
				// Eventide Jade
				// Periwinkle
				// Tiny Axolotl
				if ((slot.RawItemId == 12538 && slot.Collectability >= 380 && ItemIds.Contains(12538)) ||
				(slot.RawItemId == 12900 && slot.Collectability >= 380 && ItemIds.Contains(12900)) ||
				(slot.RawItemId == 12828 && slot.Collectability >= 579 && ItemIds.Contains(12828)) ||
				(slot.RawItemId == 13760 && slot.Collectability >= 450 && ItemIds.Contains(13760)) ||
				(slot.RawItemId == 13762 && slot.Collectability >= 450 && ItemIds.Contains(13762)) ||
				(slot.RawItemId == 12774 && slot.Collectability >= 321 && ItemIds.Contains(12774)))
				{
					_haveItem = true;
				}
			}
			if (_haveItem)
			{
				Log("Start");
				if (GatheringManager.WindowOpen)
				{
					Log("Waiting for gathering window to close");
					Thread.Sleep(2000);
				}
				if (FishingManager.State != FishingState.None)
				{
					Log("Stop fishing");
					ActionManager.DoAction("Quit", Core.Me);
					await Coroutine.Wait(5000, () => FishingManager.State == FishingState.None);
				}
				if (WorldManager.ZoneId != 478)
				{
					await TeleportTo(478, 75);
				}
				var destination = new Vector3(-18.48964f, 206.4994f, 53.98175f);
				if (Core.Me.Distance(destination) > CharacterSettings.Instance.MountDistance && !Core.Me.IsMounted)
				{
					while (!Core.Me.IsMounted)
					{
						await CommonTasks.MountUp();
					}
				}
				while (Core.Me.Distance(destination) > 1f)
				{
					var sprintDistance = Math.Min(20.0f, CharacterSettings.Instance.MountDistance);
					Navigator.MoveTo(destination);
					await Coroutine.Yield();
					if (Core.Me.Distance(destination) > sprintDistance && !Core.Me.IsMounted)
					{
						ActionManager.Sprint();
						await Coroutine.Sleep(500);
					}
				}
				if (Core.Me.Distance(destination) <= 1f)
				{
					await CommonTasks.StopAndDismount();
				}
				GameObjectManager.GetObjectByNPCId(1012229).Interact();
				await Coroutine.Wait(5000, () => SelectIconString.IsOpen);
				SelectIconString.ClickSlot(0);
				await Coroutine.Sleep(2000);
				foreach (var item in InventoryManager.FilledSlots)
				{
					// Adamantite
					if (item.RawItemId == 12538 && item.Collectability >= 380 && ItemIds.Contains(12538))
					{
						int tick = 0;
						while (item.IsFilled && tick < 3)
						{
							Log("Attempting to Turn In Adamantite Ore");
							RaptureAtkUnitManager.GetWindowByName("ShopExchangeItem").SendAction(2, 0, 0, 1, 16);
							await Coroutine.Sleep(1000);
							RaptureAtkUnitManager.GetWindowByName("ShopExchangeItemDialog").SendAction(1, 0, 0);
							await Coroutine.Wait(1000, () => Request.IsOpen);
							item.Handover();
							await Coroutine.Wait(1000, () => Request.HandOverButtonClickable);
							Request.HandOver();
							await Coroutine.Sleep(2000);
							tick++;
						}
					}
					// Chysahl Green
					if (item.RawItemId == 12900 && item.Collectability >= 380 && ItemIds.Contains(12900))
					{
						int tick = 0;
						while (item.IsFilled && tick < 3)
						{
							Log("Attempting to Turn In Chysahl Green");
							RaptureAtkUnitManager.GetWindowByName("ShopExchangeItem").SendAction(2, 0, 0, 1, 17);
							await Coroutine.Sleep(1000);
							RaptureAtkUnitManager.GetWindowByName("ShopExchangeItemDialog").SendAction(1, 0, 0);
							await Coroutine.Wait(1000, () => Request.IsOpen);
							item.Handover();
							await Coroutine.Wait(1000, () => Request.HandOverButtonClickable);
							Request.HandOver();
							await Coroutine.Sleep(2000);
							tick++;
						}
					}
					// Thunderbolt Eel
					if (item.RawItemId == 12828 && item.Collectability >= 579 && ItemIds.Contains(12828))
					{
						int tick = 0;
						while (item.IsFilled && tick < 3)
						{
							Log("Attempting to Turn In Thunderbolt Eel");
							RaptureAtkUnitManager.GetWindowByName("ShopExchangeItem").SendAction(2, 0, 0, 1, 18);
							await Coroutine.Sleep(1000);
							RaptureAtkUnitManager.GetWindowByName("ShopExchangeItemDialog").SendAction(1, 0, 0);
							await Coroutine.Wait(1000, () => Request.IsOpen);
							item.Handover();
							await Coroutine.Wait(1000, () => Request.HandOverButtonClickable);
							Request.HandOver();
							await Coroutine.Sleep(2000);
							tick++;
						}
					}
					// Eventide Jade
					if (item.RawItemId == 13760 && item.Collectability >= 450 && ItemIds.Contains(13760))
					{
						int tick = 0;
						while (item.IsFilled && tick < 3)
						{
							Log("Attempting to Turn In Eventide Jade");
							RaptureAtkUnitManager.GetWindowByName("ShopExchangeItem").SendAction(2, 0, 0, 1, 19);
							await Coroutine.Sleep(1000);
							RaptureAtkUnitManager.GetWindowByName("ShopExchangeItemDialog").SendAction(1, 0, 0);
							await Coroutine.Wait(1000, () => Request.IsOpen);
							item.Handover();
							await Coroutine.Wait(1000, () => Request.HandOverButtonClickable);
							Request.HandOver();
							await Coroutine.Sleep(2000);
							tick++;
						}
					}
					// Periwinkle
					if (item.RawItemId == 13762 && item.Collectability >= 450 && ItemIds.Contains(13762))
					{
						int tick = 0;
						while (item.IsFilled && tick < 3)
						{
							Log("Attempting to Turn In Periwinkle");
							RaptureAtkUnitManager.GetWindowByName("ShopExchangeItem").SendAction(2, 0, 0, 1, 20);
							await Coroutine.Sleep(1000);
							RaptureAtkUnitManager.GetWindowByName("ShopExchangeItemDialog").SendAction(1, 0, 0);
							await Coroutine.Wait(1000, () => Request.IsOpen);
							item.Handover();
							await Coroutine.Wait(1000, () => Request.HandOverButtonClickable);
							Request.HandOver();
							await Coroutine.Sleep(2000);
							tick++;
						}
					}
					// Tiny Axolotl
					if (item.RawItemId == 12774 && item.Collectability >= 321)
					{
						int tick = 0;
						while (item.IsFilled && tick < 3)
						{
							Log("Attempting to Turn In Tiny Axolotl");
							RaptureAtkUnitManager.GetWindowByName("ShopExchangeItem").SendAction(2, 0, 0, 1, 21);
							await Coroutine.Sleep(1000);
							RaptureAtkUnitManager.GetWindowByName("ShopExchangeItemDialog").SendAction(1, 0, 0);
							await Coroutine.Wait(1000, () => Request.IsOpen);
							item.Handover();
							await Coroutine.Wait(1000, () => Request.HandOverButtonClickable);
							Request.HandOver();
							await Coroutine.Sleep(2000);
							tick++;
						}
					}
				}
				RaptureAtkUnitManager.GetWindowByName("ShopExchangeItem").SendAction(1, 3, uint.MaxValue);
				_haveItem = false;
				await Coroutine.Sleep(500);
				Log("Done");
			}
			else
			{
				Log("Nothing to Turn In");
			}
			return _done = true;
		}
Beispiel #12
0
 internal bool DoAbility(Abilities ability)
 {
     return(ActionManager.DoAction((uint)ability, ExProfileBehavior.Me));
 }
Beispiel #13
0
        protected async Task <bool> Sell()
        {
            if (GatheringManager.WindowOpen)
            {
                Log("Waiting for gathering window to close");
                Thread.Sleep(2000);
            }
            if (FishingManager.State != FishingState.None)
            {
                Log("Stop fishing");
                ActionManager.DoAction("Quit", Core.Me);
                await Coroutine.Wait(5000, () => FishingManager.State == FishingState.None);
            }
            IEnumerable <BagSlot> items;

            if (ItemIds != null)
            {
                items =
                    InventoryManager.FilledSlots.
                    Where(bs => Array.Exists(ItemIds, e => e == bs.RawItemId) && bs.IsSellable);
            }
            else
            {
                Log("You didn't specify anything to sell.");
                return(_done = true);
            }
            var bagSlots = items as BagSlot[] ?? items.ToArray();
            var numItems = bagSlots.Count();

            if (numItems == 0)
            {
                Log("None of the items you requested can be sold.");
                return(_done = true);
            }
            if (WorldManager.ZoneId != 129)
            {
                await TeleportTo(129, 8);
            }
            var destination = new Vector3(-129.1327f, 18.2f, 24.21809f);

            while (Core.Me.Distance(destination) > 1f)
            {
                var sprintDistance = Math.Min(20.0f, CharacterSettings.Instance.MountDistance);
                Navigator.MoveTo(destination);
                await Coroutine.Yield();

                if (Core.Me.Distance(destination) > sprintDistance && !Core.Me.IsMounted && !Core.Me.HasAura(50))
                {
                    ActionManager.Sprint();
                    await Coroutine.Sleep(500);
                }
            }
            GameObjectManager.GetObjectByNPCId(1001204).Interact();
            await Coroutine.Wait(5000, () => Shop.Open);

            if (Shop.Open)
            {
                var i = 1;
                foreach (var bagSlot in bagSlots)
                {
                    string name = bagSlot.Name;
                    Log("Attempting to sell item {0} (\"{1}\") of {2}.", i++, name, numItems);
                    var result = await CommonTasks.SellItem(bagSlot);

                    if (result != SellItemResult.Success)
                    {
                        Log("Unable to sell \"{0}\" due to {1}.", name, result);
                        continue;
                    }
                    await Coroutine.Wait(SellTimeout * 1000, () => !bagSlot.IsFilled || !bagSlot.Name.Equals(name));

                    if (bagSlot.IsFilled && bagSlot.Name.Equals(name))
                    {
                        Log("Timed out awaiting sale of \"{0}\" ({1} seconds).", name, SellTimeout);
                    }
                    else
                    {
                        Log("\"{0}\" sold.", name);
                    }
                    await Coroutine.Sleep(500);
                }
                Shop.Close();
                await Coroutine.Wait(2000, () => !Shop.Open);
            }
            return(_done = true);
        }