internal static void Dispose() { try { Script.CachedScripts = new Dictionary <string, IScript>(); // clear cache on Stop. Fsm.StopEngine(); Fight.StopFight(); MovementManager.StopMove(); MountTask.AllowMounting = true; Quest.GetSetIgnoreFight = false; Quest.GetSetIgnoreAllFight = false; Quest.GetSetDismissPet = false; Profile = null; QuestingTask.Cleanup(); EventsListener.UnHookEvent(WoWEventsType.QUEST_DETAIL, callback => Quest.AutoCompleteQuest()); EventsListener.UnHookEvent(WoWEventsType.QUEST_AUTOCOMPLETE, callback => Quest.AutoCompleteQuest()); } catch (Exception e) { Logging.WriteError("Quester > Bot > Bot > Dispose(): " + e); } }
internal static bool Pulse() { try { MountTask.AllowMounting = true; Quest.GetSetIgnoreFight = false; Quest.GetSetIgnoreAllFight = false; Quest.GetSetDismissPet = false; Profile = new QuesterProfile(); QuesterProfileLoader f = new QuesterProfileLoader(); f.ShowDialog(); if (!string.IsNullOrWhiteSpace(QuesterSettings.CurrentSettings.LastProfile) && ((QuesterSettings.CurrentSettings.LastProfileSimple && File.Exists(Application.StartupPath + "\\Profiles\\Quester\\" + QuesterSettings.CurrentSettings.LastProfile)) || (!QuesterSettings.CurrentSettings.LastProfileSimple && File.Exists(Application.StartupPath + "\\Profiles\\Quester\\Grouped\\" + QuesterSettings.CurrentSettings.LastProfile)))) { Profile = QuesterSettings.CurrentSettings.LastProfileSimple ? XmlSerializer.Deserialize <QuesterProfile>(Application.StartupPath + "\\Profiles\\Quester\\" + QuesterSettings.CurrentSettings.LastProfile) : XmlSerializer.Deserialize <QuesterProfile>(Application.StartupPath + "\\Profiles\\Quester\\Grouped\\" + QuesterSettings.CurrentSettings.LastProfile); DumpInfoAboutProfile(QuesterSettings.CurrentSettings.LastProfile, Profile); foreach (Include include in Profile.Includes) { try { if (!Script.Run(include.ScriptCondition)) { continue; } //Logging.Write(Translation.GetText(Translation.Text.SubProfil) + " " + include.PathFile); QuesterProfile profileInclude = XmlSerializer.Deserialize <QuesterProfile>(Application.StartupPath + "\\Profiles\\Quester\\" + include.PathFile); if (profileInclude != null) { // Profile.Includes.AddRange(profileInclude.Includes); Profile.Questers.AddRange(profileInclude.Questers); Profile.Blackspots.AddRange(profileInclude.Blackspots); Profile.AvoidMobs.AddRange(profileInclude.AvoidMobs); Profile.Quests.AddRange(profileInclude.Quests); DumpInfoAboutProfile(include.PathFile, profileInclude); } } catch (Exception e) { MessageBox.Show(Translate.Get(Translate.Id.File_not_found) + ": " + e); Logging.Write(Translate.Get(Translate.Id.File_not_found)); return(false); } } // Now check the integrity by checking we have all NPC required foreach (Profile.Quest q in Profile.Quests) { bool isWorldQuest = q.WorldQuestLocation != null && q.WorldQuestLocation.IsValid; if (!isWorldQuest && q.ItemPickUp == 0 && FindQuesterById(q.PickUp).Entry == 0 && !q.AutoAccepted) { MessageBox.Show("Your profile is missing the definition of NPC entry " + q.PickUp + "\nThe quest is '" + q.Name + "' (" + q.Id + "). Cannot continues!"); return(false); } if (!isWorldQuest && FindQuesterById(q.TurnIn).Entry == 0) { MessageBox.Show("Your profile is missing the definition of NPC entry " + q.TurnIn + "\nThe quest is '" + q.Name + "' (" + q.Id + "). Cannot continues!"); return(false); } foreach (Profile.QuestObjective o in q.Objectives) { if (o.NpcEntry != 0 && FindQuesterById(o.NpcEntry).Entry == 0) { MessageBox.Show("Your profile is missing the definition of NPC entry " + o.NpcEntry + "\nThe quest is '" + q.Name + "' (" + q.Id + "). Cannot continues!"); return(false); } if (o.InternalIndex != 0 && o.Count <= 0 && o.CollectCount <= 0) { MessageBox.Show("Your profile has an objective with an InternalIndex but without proper Count or CollectCount values" + "\nThe quest is '" + q.Name + "' (" + q.Id + "). Cannot continues!"); return(false); } if (o.InternalIndex > 23) { MessageBox.Show("Your profile has an objective with an InternalIndex > 23, which is not possible." + "\nThe quest is '" + q.Name + "' (" + q.Id + "). Cannot continues!"); return(false); } } } Logging.Write("Loaded " + Profile.Quests.Count + " quests"); Profile.Filter(); Logging.Write(Profile.Quests.Count + " quests left after filtering on class/race"); Tasks.QuestingTask.completed = false; Quest.ConsumeQuestsCompletedRequest(); Logging.Write("received " + Quest.FinishedQuestSet.Count + " quests."); } else { return(false); } // Black List: nManagerSetting.AddRangeBlackListZone(new List <nManagerSetting.BlackListZone>(Profile.Blackspots)); // Load CC: CombatClass.LoadCombatClass(); ImportedQuesters = false; // FSM Fsm.States.Clear(); Fsm.AddState(new Pause { Priority = 200 }); Fsm.AddState(new Resurrect { Priority = 150 }); Fsm.AddState(new IsAttacked { Priority = 140 }); Fsm.AddState(new Regeneration { Priority = 130 }); Fsm.AddState(new FlightMasterDiscovery { Priority = 120 }); Fsm.AddState(new Looting { Priority = 110 }); Fsm.AddState(new Travel { Priority = 100 }); Fsm.AddState(new ToTown { Priority = 90 }); Fsm.AddState(new SpecializationCheck { Priority = 80 }); Fsm.AddState(new LevelupCheck { Priority = 70 }); Fsm.AddState(new Trainers { Priority = 60 }); Fsm.AddState(new AutoItemCombiner { Priority = 52 }); Fsm.AddState(new MillingState { Priority = 51 }); Fsm.AddState(new ProspectingState { Priority = 50 }); Fsm.AddState(new Farming { Priority = 30 }); Fsm.AddState(new QuesterState { Priority = 20 }); Fsm.AddState(new MovementLoop { Priority = 10 }); Fsm.AddState(new Idle { Priority = 0 }); foreach (var statePlugin in Plugins.ListLoadedStatePlugins) { Fsm.AddState(statePlugin); } Fsm.States.Sort(); Fsm.StartEngine(7, "FSM Quester"); EventsListener.HookEvent(WoWEventsType.QUEST_DETAIL, callback => Quest.AutoCompleteQuest()); EventsListener.HookEvent(WoWEventsType.QUEST_AUTOCOMPLETE, callback => Quest.AutoCompleteQuest()); return(true); } catch (Exception e) { try { Dispose(); } catch { } Logging.WriteError("Quester > Bot > Bot > Pulse(): " + e); return(false); } }
public override void Run() { // Get or set selected quest if (QuestingTask.CurrentQuest != null) { int id = QuestingTask.CurrentQuest.Id; if (Quest.GetQuestCompleted(id) || id == 0) { QuestingTask.SelectQuest(); return; } if (QuestingTask.CurrentQuest.WorldQuestLocation != null && QuestingTask.CurrentQuest.WorldQuestLocation.IsValid && !Quest.GetLogQuestId().Contains(id)) { // World Quest that we don't have in our inventory if (!QuestingTask.IsWorldQuestAvailable(id)) { // The WorldQuest is no longer available, therefor, it's complete. QuestingTask.SelectQuest(); return; } } } else { QuestingTask.SelectQuest(); return; } // Need PickUp or TurnIn if (QuestingTask.CurrentQuest.Id != -1 && ((Quest.GetLogQuestIsComplete(QuestingTask.CurrentQuest.Id) && QuestingTask.AllForcedObjectiveComplete()) || QuestingTask.CurrentQuest.Objectives.Count <= 0) && Quest.GetLogQuestId().Contains(QuestingTask.CurrentQuest.Id) && QuestingTask.CurrentQuest.ScriptConditionIsFinish.Replace(" ", "").Length <= 0) // TurnIn { QuestingTask.TurnInQuest(); return; } if (QuestingTask.CurrentQuest.Id != -1) { // PickUp if (!Quest.GetLogQuestId().Contains(QuestingTask.CurrentQuest.Id) && !Quest.GetLogQuestIsComplete(QuestingTask.CurrentQuest.Id) && !Quest.IsQuestFlaggedCompletedLUA(QuestingTask.CurrentQuest.Id)) { QuestingTask.PickUpQuest(); if (!Quest.GetLogQuestId().Contains(QuestingTask.CurrentQuest.Id) && Quest.IsQuestFlaggedCompletedLUA(QuestingTask.CurrentQuest.Id)) { Quest.FinishedQuestSet.Add(QuestingTask.CurrentQuest.Id); } return; } } QuestingTask._travelDisabled = false; // reset travel after PickUp worked. (code exclusive for WQ) if (Script.Run(QuestingTask.CurrentQuest.ScriptConditionIsFinish) && QuestingTask.CurrentQuest.ScriptConditionIsFinish.Replace(" ", "").Length > 0) { QuestingTask.TurnInQuest(); return; } // Quest Objective if (QuestingTask.CurrentQuestObjectiveIsFinish() || QuestingTask.CurrentQuestObjective == null) { QuestingTask.SelectNextQuestObjective(); if (QuestingTask.CurrentQuestObjective == null && QuestingTask.CurrentQuest.Objectives.Count > 0) { QuestingTask.ResetQuestObjective(); } if (QuestingTask.CurrentQuestObjectiveIsFinish()) { return; } if (QuestingTask.CurrentQuestObjective == null) { QuestingTask.TurnInQuest(); } return; } // Execute Objective QuestingTask.CurrentQuestObjectiveExecute(); }