/// <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); }
/// <summary> /// Chooses equipment if better than currently equipped (using Item Weights) or items based on higest value. /// </summary> /// <param name="questId"></param> private static async Task <bool> HandleRewards(int questId) { if (!JournalResult.IsOpen) { return(false); } if (!DataManager.QuestCache.TryGetValue((uint)questId, out QuestResult questData)) { return(false); } if (questData.Rewards.Length == 0) { return(false); } var values = questData.Rewards.Select(r => new Score(r)).OrderByDescending(r => r.Value).ToArray(); int chosenSlot; if (values.Select(r => r.Value).Distinct().Count() == 1) { chosenSlot = questData.Rewards.IndexOf(values[0].Reward); } else { var candidateByCost = questData.Rewards .OrderByDescending(r => r.Worth) .FirstOrDefault(); chosenSlot = Array.IndexOf(questData.Rewards, candidateByCost); } JournalResult.SelectSlot(5 + chosenSlot); await Common.Sleep(50); 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); }