public void Execute() { if (Profile == null) { return; } if (!UpdatedCompletedQuests) { if (WowInterface.EventHookManager.EventDictionary.All(e => e.Key != "QUEST_QUERY_COMPLETE")) { WowInterface.EventHookManager.Subscribe("QUEST_QUERY_COMPLETE", OnGetQuestsCompleted); } if (QueryCompletedQuestsEvent.Run()) { WowInterface.HookManager.LuaQueryQuestsCompleted(); } return; } if (Profile.Quests.Count > 0) { // do i need to recover my hp if (WowInterface.ObjectManager.Player.HealthPercentage < Config.EatUntilPercent && WowInterface.ObjectManager.GetNearEnemies <WowUnit>(WowInterface.ObjectManager.Player.Position, 60.0).Any()) { // wait or eat something if (WowInterface.CharacterManager.HasItemTypeInBag <WowFood>() || WowInterface.CharacterManager.HasItemTypeInBag <WowRefreshment>()) { StateMachine.SetState(BotState.Eating); return; } } IEnumerable <IBotQuest> selectedQuests = Profile.Quests.Peek().Where(e => !e.Returned && !CompletedQuests.Contains(e.Id)); // Drop all quest that are not selected if (WowInterface.ObjectManager.Player.QuestlogEntries.Count() == 25 && DateTime.Now.Subtract(LastAbandonQuestTime).TotalSeconds > 30) { WowInterface.HookManager.LuaAbandonQuestsNotIn(selectedQuests.Select(q => q.Name)); LastAbandonQuestTime = DateTime.Now; } if (selectedQuests.Any()) { IBotQuest notAcceptedQuest = selectedQuests.FirstOrDefault(e => !e.Accepted); // make sure we got all quests if (notAcceptedQuest != null) { if (!notAcceptedQuest.Accepted) { notAcceptedQuest.AcceptQuest(); return; } } else { // do the quests if not all of them are finished if (selectedQuests.Any(e => !e.Finished)) { IBotQuest activeQuest = selectedQuests.FirstOrDefault(e => !e.Finished); activeQuest?.Execute(); } else { // make sure we return all quests IBotQuest notReturnedQuest = selectedQuests.FirstOrDefault(e => !e.Returned); if (notReturnedQuest != null) { if (notReturnedQuest.CompleteQuest()) { CompletedQuests.Add(notReturnedQuest.Id); } return; } } } } else { CompletedQuests.AddRange(Profile.Quests.Dequeue().Select(e => e.Id)); return; } } // filter duplicates CompletedQuests = CompletedQuests.Distinct().ToList(); }
public void Execute() { if (Profile == null) { return; } if (!UpdatedCompletedQuests) { if (Bot.Wow.Events.Events.All(e => e.Key != "QUEST_QUERY_COMPLETE")) { Bot.Wow.Events.Subscribe("QUEST_QUERY_COMPLETE", OnGetQuestsCompleted); } if (QueryCompletedQuestsEvent.Run()) { Bot.Wow.QueryQuestsCompleted(); } return; } if (Profile.Quests.Count > 0) { IEnumerable <IBotQuest> selectedQuests = Profile.Quests.Peek().Where(e => !e.Returned && !CompletedQuests.Contains(e.Id)); // drop all quest that are not selected if (Bot.Player.QuestlogEntries.Count() == 25 && DateTime.UtcNow.Subtract(LastAbandonQuestTime).TotalSeconds > 30) { Bot.Wow.AbandonQuestsNotIn(selectedQuests.Select(q => q.Name)); LastAbandonQuestTime = DateTime.UtcNow; } if (selectedQuests.Any()) { IBotQuest notAcceptedQuest = selectedQuests.FirstOrDefault(e => !e.Accepted); // make sure we got all quests if (notAcceptedQuest != null) { if (!notAcceptedQuest.Accepted) { notAcceptedQuest.AcceptQuest(); return; } } else { // do the quests if not all of them are finished if (selectedQuests.Any(e => !e.Finished)) { IBotQuest activeQuest = selectedQuests.FirstOrDefault(e => !e.Finished); activeQuest?.Execute(); } else { // make sure we return all quests IBotQuest notReturnedQuest = selectedQuests.FirstOrDefault(e => !e.Returned); if (notReturnedQuest != null) { if (notReturnedQuest.CompleteQuest()) { CompletedQuests.Add(notReturnedQuest.Id); } return; } } } } else { CompletedQuests.AddRange(Profile.Quests.Dequeue().Select(e => e.Id)); return; } } // filter duplicates CompletedQuests = CompletedQuests.Distinct().ToList(); }