/// <summary> /// Auto accepts/completes quests. /// </summary> /// <returns></returns> private bool ExecuteAutoAcceptQuests() { // Auto accept quest if (JournalAccept.IsOpen) { JournalAccept.Accept(); return(true); } // Auto complete quest if (JournalResult.IsOpen) { if (!JournalResult.ButtonClickable) { JournalResult.SelectSlot(0); } if (JournalResult.ButtonClickable) { JournalResult.Complete(); return(true); } } return(false); }
public static async Task <bool> SetJournalComplete() { int ticks = 0; while (ticks < 20 && JournalResult.IsOpen) { JournalResult.Complete(); await Coroutine.Sleep(500); ticks++; } return(true); }
/// <summary> /// Clicks Complete Quest once available. /// </summary> private static async Task <bool> HandleCompleteQuest() { if (!JournalResult.IsOpen || !JournalResult.ButtonClickable) { return(false); } while (JournalResult.ButtonClickable) { JournalResult.Complete(); await Common.Sleep(100); if (!JournalResult.IsOpen || !JournalResult.ButtonClickable) { break; } } return(true); }
protected override Composite CreateBehavior() { return(new PrioritySelector( new Decorator(ret => Talk.DialogOpen, new Action(r => { Talk.Next(); }) ), new Decorator(ret => IsOpen, new Sequence( new Sleep(1, 2), new Action(r => { //Logging.Write("Accepting leve..."); AcceptLeve((uint)LeveId); }), new Sleep(1, 2), new Action(r => { leveopened = true; //Logging.Write("Closing GuildLeve window..."); Close(); }), new Sleep(1, 2) ) ), new Decorator(ret => SelectYesno.IsOpen, new Action(r => { SelectYesno.ClickYes(); }) ), new Decorator(ret => SelectString.IsOpen, new Action(r => { if (!leveopened) { SelectString.ClickLineContains(LeveType); } else { SelectString.ClickSlot(4); } }) ), new Decorator(ret => JournalResult.IsOpen, new Action(r => { JournalResult.Complete(); }) ), new Decorator(ret => interacted && !Core.Player.HasTarget, new Action(r => { _done = true; }) ), new Decorator(ret => Vector3.Distance(Core.Player.Location, XYZ) > 3, CommonBehaviors.MoveTo(r => XYZ, "Moving to PickupLeve location") ), new Decorator(ret => Vector3.Distance(Core.Player.Location, XYZ) <= 3 && MovementManager.IsMoving, ff14bot.Behavior.CommonBehaviors.MoveStop() ), new Decorator(ret => Vector3.Distance(Core.Player.Location, XYZ) <= 3 && !MovementManager.IsMoving && !interacted, new Action(r => { GameObjectManager.GetObjectByNPCId((uint)NpcId).Interact(); interacted = true; }) ), new ActionAlwaysSucceed() )); }
protected override async Task <bool> Main() { if (interactTimeout.Elapsed.TotalSeconds > Timeout) { Logger.Error(Localization.Localization.ExTurnInGuildLeve_TurninTimeout); isDone = true; return(true); } if (!checkedTransport) { checkedTransport = true; StatusText = Localization.Localization.ExTurnInGuildLeve_CheckTransport; var selectYesnoCountWindow = new SelectYesnoCount(); if (await selectYesnoCountWindow.Refresh(2000)) { StatusText = Localization.Localization.ExTurnInGuildLeve_SelectTransport; if (AcceptTransport) { selectYesnoCountWindow.Yes(); await Coroutine.Wait(5000, () => CommonBehaviors.IsLoading); await Coroutine.Wait(System.Threading.Timeout.Infinite, () => !CommonBehaviors.IsLoading); } else { await selectYesnoCountWindow.CloseInstance(); } return(true); } } // Movement if (ExProfileBehavior.Me.Distance(Location) > 3.5) { StatusText = Localization.Localization.ExTurnInGuildLeve_Move + NpcId; await Location.MoveTo(radius : 3.4f, name : " NpcId: " + NpcId); return(true); } if (!interactTimeout.IsRunning) { interactTimeout.Restart(); } // Interact if (Core.Target == null && ExProfileBehavior.Me.Distance(Location) <= 3.5) { return(await InteractWithNpc()); } if (Talk.DialogOpen) { await HandleTalk(); } if (SelectIconString.IsOpen) { if (iconStringIndex == 9001) { iconStringIndex = (uint)SelectIconString.Lines().Count - 1; } // We will just click the last quest and decrement until we have either no quests left or none to turn in. SelectIconString.ClickSlot(--iconStringIndex); await Coroutine.Sleep(500); if (iconStringIndex == uint.MaxValue) { Logger.Warn(Localization.Localization.ExTurnInGuildLeve_NothingToTurnin); isDone = true; return(true); } return(true); } if (SelectString.IsOpen) { var lines = SelectString.Lines(); // If Collect Reward exists, we click that; otherwise we will click Close. (-1 as uint = uint.MaxValue) var index = (uint)lines.IndexOf(CollectRewardText, StringComparer.InvariantCultureIgnoreCase); if (index != uint.MaxValue) { Logger.Info(Localization.Localization.ExTurnInGuildLeve_CollectReward, WorldManager.EorzaTime); SelectString.ClickSlot(index); await Coroutine.Yield(); return(true); } // If yes is an option, click it to turn in more items.(crafting) index = (uint)lines.IndexOf(YesText, StringComparer.InvariantCultureIgnoreCase); if (index != uint.MaxValue) { Logger.Info(Localization.Localization.ExTurnInGuildLeve_TurninMore, WorldManager.EorzaTime); SelectString.ClickSlot(index); await Coroutine.Yield(); return(true); } Logger.Warn(Localization.Localization.ExTurnInGuildLeve_NoRewardsLeft); isDone = true; SelectString.ClickSlot(index); await Coroutine.Yield(); return(true); } if (Request.IsOpen) { var itemCount = Memory.Request.ItemsToTurnIn.Length; var itemId = Memory.Request.ItemId1; IEnumerable <BagSlot> itemSlots = InventoryManager.FilledInventoryAndArmory.Where( bs => bs.RawItemId == itemId && !Blacklist.Contains((uint)bs.Pointer.ToInt32(), BlacklistFlags.Loot)).ToArray(); if (HqOnly) { itemSlots = itemSlots.Where(bs => bs.IsHighQuality); } if (NqOnly) { itemSlots = itemSlots.Where(bs => !bs.IsHighQuality); } var items = itemSlots.Take(itemCount).ToArray(); if (items.Length == 0) { Logger.Warn(Localization.Localization.ExTurnInGuildLeve_NoItemToTurnin, HqOnly, NqOnly, itemId); isDone = true; return(true); } StatusText = Localization.Localization.ExTurnInGuildLeve_TurnIn; var isHq = items.Any(i => i.IsHighQuality); var itemName = items[0].EnglishName; var requestAttempts = 0; while (Request.IsOpen && requestAttempts++ < 5 && Behaviors.ShouldContinue) { foreach (var item in items) { item.Handover(); await Coroutine.Yield(); } await Coroutine.Wait(1000, () => Request.HandOverButtonClickable); if (Request.HandOverButtonClickable) { Request.HandOver(); if (isHq) { await Coroutine.Wait(2000, () => !Request.IsOpen && SelectYesno.IsOpen); } else { await Coroutine.Wait(2000, () => !Request.IsOpen); } } } turnedItemsIn = true; if (SelectYesno.IsOpen) { SelectYesno.ClickYes(); await Coroutine.Yield(); Logger.Info(Localization.Localization.ExTurnInGuildLeve_TurnInHq, itemName, WorldManager.EorzaTime); } else { Logger.Info(Localization.Localization.ExTurnInGuildLeve_TurnInNq, itemName, WorldManager.EorzaTime); } await HandleTalk(); await Coroutine.Wait(2000, () => JournalResult.IsOpen); return(true); } if (JournalResult.IsOpen) { await Coroutine.Wait(2000, () => JournalResult.ButtonClickable); JournalResult.Complete(); Logger.Info(Localization.Localization.ExTurnInGuildLeve_Complete, WorldManager.EorzaTime); await Coroutine.Wait(2000, () => !JournalResult.IsOpen); await HandleTalk(); return(true); } if (!await WaitForOpenWindow()) { if (MultipleQuests) { Logger.Info(Localization.Localization.ExTurnInGuildLeve_OpenWindow); CloseWindows(); ExProfileBehavior.Me.ClearTarget(); } else { isDone = true; } } return(true); }
private static async Task <bool> HelpersMethod() { if (MainSettingsModel.Instance.UseAutoCutscene) { if (QuestLogManager.InCutscene) { if (AgentCutScene.Instance.CanSkip && !SelectString.IsOpen) { AgentCutScene.Instance.PromptSkip(); if (await Coroutine.Wait(600, () => SelectString.IsOpen)) { SelectString.ClickSlot(0); await Coroutine.Sleep(1000); } } } } if (MainSettingsModel.Instance.AutoSprint && ActionManager.IsSprintReady && MovementManager.IsMoving) { ActionManager.Sprint(); } if (MainSettingsModel.Instance.UseAutoTalk) { if (Core.Me.IsAlive) { if (SelectYesno.IsOpen) { SelectYesno.ClickYes(); } } if (Talk.DialogOpen) { Talk.Next(); } //if (Request.IsOpen) //{ // Logger.ATBLog("Handing over any item(s) in your Key Items."); // foreach (var s in InventoryManager.GetBagByInventoryBagId(InventoryBagId.KeyItems)) // { // s.Handover(); // Logger.ATBLog(s.EnglishName); // await Coroutine.Wait(250, () => Request.HandOverButtonClickable); // if (Request.HandOverButtonClickable) { break; } // } // // Logger.ATBLog("Handing over any item(s) in your Inventory."); // foreach (var s in InventoryManager.FilledSlots) // { // s.Handover(); // Logger.ATBLog(s.EnglishName); // await Coroutine.Wait(250, () => Request.HandOverButtonClickable); // if (Request.HandOverButtonClickable) { break; } // } // // if (Request.HandOverButtonClickable) { Request.HandOver(); } // // Logger.ATBLog("Handing over any item(s) in your Armory."); // foreach (var s in InventoryManager.FilledArmorySlots) // { // s.Handover(); // Logger.ATBLog(s.EnglishName); // await Coroutine.Wait(250, () => Request.HandOverButtonClickable); // if (Request.HandOverButtonClickable) { break; } // } // // if (Request.HandOverButtonClickable) { Request.HandOver(); } // else { await Coroutine.Wait(3000, () => !Request.IsOpen); } //} } if (MainSettingsModel.Instance.UseAutoQuest) { if (JournalAccept.IsOpen) { JournalAccept.Accept(); } if (JournalResult.IsOpen) { JournalResult.Complete(); } } return(false); }
protected override async Task <bool> Main() { if (Talk.DialogOpen) { await HandleTalk(); return(true); } if (SelectYesno.IsOpen) { SelectYesno.ClickYes(); await Coroutine.Yield(); return(true); } if (JournalResult.IsOpen) { await Coroutine.Wait(1000, () => JournalResult.ButtonClickable); JournalResult.Complete(); await Coroutine.Yield(); return(true); } // Movement if (ExProfileBehavior.Me.Distance(Location) > 3.5) { StatusText = Localization.Localization.ExPickupGuildLeve_Move + NpcId; await Location.MoveTo(radius : 3.4f, name : " NpcId: " + NpcId); return(true); } if (!interactTimeout.IsRunning) { interactTimeout.Restart(); } // Interact if (Core.Target == null && ExProfileBehavior.Me.Distance(Location) <= 3.5) { await this.Interact(); await Coroutine.Yield(); return(true); } if (SelectString.IsOpen) { if (interactTimeout.Elapsed.TotalSeconds > Timeout || GuildLeve.HasLeves(Ids) || GuildLeve.Allowances == 0) { SelectString.ClickSlot(uint.MaxValue); isDone = true; return(true); } SelectString.ClickLineContains(LeveType); return(true); } var guildLeveWindow = new GuildLeve(); if (guildLeveWindow.IsValid) { if (interactTimeout.Elapsed.TotalSeconds > Timeout || GuildLeve.HasLeves(Ids) || GuildLeve.Allowances == 0) { await guildLeveWindow.CloseInstance(); return(true); } foreach (var leveId in Ids.Where(id => !GuildLeve.HasLeve(id))) { if (GuildLeve.Allowances > 0) { StatusText = Localization.Localization.ExPickupGuildLeve_Pickup + leveId; Logger.Info(Localization.Localization.ExPickupGuildLeve_Pickup2 + leveId); await Coroutine.Sleep(1000); guildLeveWindow.AcceptLeve(leveId); await Coroutine.Yield(); // so our memory lock updates and level allowances change } } await Coroutine.Sleep(1000); return(true); } // Interact if targetting but not null (if combat behaviors prevented the first one) if (ExProfileBehavior.Me.Distance(Location) <= 3.5) { await this.Interact(); return(true); } return(true); }
private async Task <bool> HandleWindows() { while (WindowsOpen()) { if (SelectString.IsOpen) { if (DialogOption > -1) { SelectString.ClickSlot((uint)DialogOption); } SelectString.ClickLineEquals(QuestName); await Coroutine.Sleep(100); } if (SelectIconString.IsOpen) { if (DialogOption > -1) { SelectIconString.ClickSlot((uint)DialogOption); } SelectIconString.ClickLineEquals(QuestName); await Coroutine.Sleep(100); } if (SelectYesno.IsOpen) { SelectYesno.ClickYes(); await Coroutine.Sleep(100); } if (Request.IsOpen) { var items = InventoryManager.FilledInventoryAndArmory.ToArray(); for (int i = 0; i < ItemIds.Length; i++) { BagSlot item; if (RequiresHq[i]) { item = items.FirstOrDefault(z => z.RawItemId == ItemIds[i] && z.IsHighQuality && !usedSlots.Contains(z)); } else { item = items.FirstOrDefault(z => z.RawItemId == ItemIds[i] && !usedSlots.Contains(z)); } item.Handover(); usedSlots.Add(item); } usedSlots.Clear(); Request.HandOver(); await Coroutine.Sleep(100); } if (JournalResult.IsOpen) { if (JournalResult.ButtonClickable) { JournalResult.Complete(); } if (hasRewards) { JournalResult.SelectSlot(RewardSlot); } await Coroutine.Sleep(100); } if (JournalAccept.IsOpen) { JournalAccept.Accept(); await Coroutine.Sleep(100); } if (Talk.DialogOpen) { Talk.Next(); await Coroutine.Sleep(100); } if (QuestLogManager.InCutscene) { if (AgentCutScene.Instance.CanSkip && !SelectString.IsOpen) { AgentCutScene.Instance.PromptSkip(); if (await Coroutine.Wait(600, () => SelectString.IsOpen)) { SelectString.ClickSlot(0); await Coroutine.Sleep(1000); } } } await Coroutine.Yield(); } return(QuestLogManager.InCutscene || Core.Player.HasTarget); }