private static void ProcessQuestRequest(QuestReq req, Quest q, string lfs) { if (!DoBeforeStart(req, q, lfs)) { return; } GameObject obj = FindQuestGameObj(req, q, lfs); MoveTargetQuestGameObj(req, obj, q, lfs); SelectGameObjQuest(req, obj, q, lfs); DoActionEx(req, q, lfs); }
public static void DoAction(QuestReq req, string lfs) { Output.Instance.Debug(lfs, req.ActionName + "ing quest ..."); if (req.ActionName.Equals("Accept")) { LuaHelper.Exec("AcceptQuest"); } else if (req.ActionName.Equals("Deliver")) { LuaHelper.Exec("DeliverQuest", req.Choice); } // Wait a bit to update log Thread.Sleep(2000); }
public static void MoveTargetQuestGameObj(QuestReq req, GameObject obj, Quest q, string lfs) { try { Output.Instance.Log(lfs, "Moving to quest " + req.NpcDestText + " ..."); NpcHelper.MoveToGameObj(obj, lfs); } catch (CantReachNpcException e1) { throw new QuestSkipException(e1.Message); } catch (Exception e) { throw new QuestSkipException("Unable reach NPC. " + e.Message); } Output.Instance.Debug(lfs, "Reached the quest " + req.NpcDestText + "."); NpcHelper.TargetGameObj(obj, lfs); }
private static bool DoBeforeStart(QuestReq req, Quest q, string lfs) { if (req.QuestStatus.Equals("quest_start")) { // Check if quest already in quest log q.Idx = QuestHelper.FindLogQuest(q.Title, lfs); if (q.Idx > 0) { Output.Instance.Log(lfs, "Quest already accepted"); return(false); } q.State = QuestStates.ACCEPTED; return(true); } else if (req.QuestStatus.Equals("quest_end")) { // Check if quest already in quest log int idx = QuestHelper.FindLogQuest(q.Title, lfs); if (idx == 0) { Output.Instance.Log(lfs, "Quest not in a log list"); return(false); } // Check if quest completed if (!QuestHelper.IsQuestLogCompleted(idx)) { Output.Instance.Log(lfs, "Quest not is not completed"); return(false); } return(true); } else { throw new QuestSkipException( "Unknown quest status '" + req.QuestStatus); } }
public static void SelectGameObjQuest(QuestReq req, GameObject obj, Quest q, string lfs) { string[] dinfo; try { dinfo = NpcHelper.InteractNpc(obj.Name, false, lfs); } catch (NpcInteractException ne) { throw new QuestProcessingException(ne.Message); } catch (Exception e) { throw new Exception("Unable Interact with NPC." + e.Message); } // If NPC has a single quest it can be opened already // null dinfo[0] cause NpcInteractException if (!dinfo[0].Equals(req.QuestStatus)) { // Check if quest available bool avail; try { avail = CheckQuest(q, dinfo, req, lfs); } catch (Exception e) { throw new QuestSkipException(e.Message); } if (!avail) { throw new QuestSkipException("NPC doesn't have a quest"); } } q.State = QuestStates.SELECTED; }
public static void DoActionEx(QuestReq req, Quest q, string lfs) { DoAction(req, lfs); string qtitle = q.Title; // After action q.Idx = QuestHelper.FindLogQuest(qtitle, lfs); if (req.QuestStatus.Equals("quest_start")) { // Check that quest is in toon log if (q.Idx == 0) { throw new QuestSkipException( "Unable find quest in toon log after it been accepted '"); } } else if (req.QuestStatus.Equals("quest_end")) { // Check that quest is in toon log if (q.Idx > 0) { throw new QuestSkipException( "Quest still in toon's quest log after it been delivered"); } } else { throw new QuestSkipException( "Unknown quest status '" + req.QuestStatus); } Output.Instance.Log(lfs, "Quest '" + qtitle + "' successfully " + req.ActionName.ToLower() + "ed'"); q.State = req.FinalState; }
public static GameObject FindQuestGameObj(QuestReq req, Quest q, string lfs) { // Set player current zone WowPlayer player = ProcessManager.Player; player.SetCurrentMapInfo(); string qt = q.Title; // Get quest npc GameObject obj = q.GameObjList[req.NpcId]; if (obj == null) { throw new QuestSkipException( "Quest " + req.NpcDestText + " NPC not found for quest '" + qt); } Output.Instance.Log(lfs, "Located NPC '" + obj.Name + "' as quest " + req.NpcDestText + " for quest '" + qt + "'"); q.State = QuestStates.OBJ_FOUND; return(obj); }
private static void ProcessQuestRequest(QuestReq req, Quest q, string lfs) { if (!DoBeforeStart(req, q, lfs)) return; GameObject obj = FindQuestGameObj(req, q, lfs); MoveTargetQuestGameObj(req, obj, q, lfs); SelectGameObjQuest(req, obj, q, lfs); DoActionEx(req, q, lfs); }
private static bool DoBeforeStart(QuestReq req, Quest q, string lfs) { if (req.QuestStatus.Equals("quest_start")) { // Check if quest already in quest log q.Idx = QuestHelper.FindLogQuest(q.Title, lfs); if (q.Idx > 0) { Output.Instance.Log(lfs, "Quest already accepted"); return false; } q.State = QuestStates.ACCEPTED; return true; } else if (req.QuestStatus.Equals("quest_end")) { // Check if quest already in quest log int idx = QuestHelper.FindLogQuest(q.Title, lfs); if (idx == 0) { Output.Instance.Log(lfs, "Quest not in a log list"); return false; } // Check if quest completed if (!QuestHelper.IsQuestLogCompleted(idx)) { Output.Instance.Log(lfs, "Quest not is not completed"); return false; } return true; } else throw new QuestSkipException( "Unknown quest status '" + req.QuestStatus); }
/// <summary> /// Check if current quest avail /// If it on NPC gossip frame than select it /// If it already open than we fine /// </summary> /// <param name="q">Quest</param> /// <returns>true if NPC has quest</returns> private static bool CheckQuest(Quest q, string[] dinfo, QuestReq req, string lfs) { string cur_service = null; if (dinfo == null) { dinfo = NpcHelper.GetTargetNpcDialogInfo(q.Src.Name, false, lfs); cur_service = dinfo[0]; } else cur_service = dinfo[0]; if (cur_service.Equals("gossip")) { Output.Instance.Debug(lfs, "GossipFrame opened."); Output.Instance.Debug(lfs, "Looking for quest ..."); int idx = QuestHelper.FindGossipQuestIdByTitle(q.Title, req.ProcName); if (idx < 0) return false; // Selecting quest Output.Instance.Debug(lfs, "Selecting quest by Id: " + idx); LuaHelper.Exec("SelectGossip" + req.ProcName + "Quest", idx); // Wait for quest frame pop up try { NpcHelper.WaitDialogOpen("Quest", lfs); } catch (NpcInteractException ne) { throw new QuestProcessingException(ne.Message); } catch (Exception e) { throw new QuestProcessingException( "NPC doesn't show QuestFrame. " + e.Message); } // Call itself again to parse the quest return CheckQuest(q, null, req, lfs); } else if (cur_service.Equals("quest_start")) { Output.Instance.Debug("Parsing quest info line '" + dinfo[1] + "'"); string[] headers = dinfo[1].Split(new string[] { "::" }, StringSplitOptions.None); string title = headers[0]; return (!string.IsNullOrEmpty(title) && title.Equals(q.Title)); } else if (cur_service.Equals("quest_progress")) { // Quest progress // Click continue and check next screen LuaHelper.Exec("CompleteQuest"); // Wait to change quest frame Thread.Sleep(2000); return CheckQuest(q, null, req, lfs); } else if (cur_service.Equals("quest_end")) return true; else // Quest not found nor on gossip frame nor on active frame throw new QuestProcessingException( "Quest not found nor on GossipFrame nor on ActiveFrame"); }
public static void SelectGameObjQuest(QuestReq req, GameObject obj, Quest q, string lfs) { string[] dinfo; try { dinfo = NpcHelper.InteractNpc(obj.Name, false, lfs); } catch (NpcInteractException ne) { throw new QuestProcessingException(ne.Message); } catch (Exception e) { throw new Exception("Unable Interact with NPC." + e.Message); } // If NPC has a single quest it can be opened already // null dinfo[0] cause NpcInteractException if (!dinfo[0].Equals(req.QuestStatus)) { // Check if quest available bool avail; try { avail = CheckQuest(q, dinfo, req, lfs); } catch (Exception e) { throw new QuestSkipException(e.Message); } if (!avail) throw new QuestSkipException("NPC doesn't have a quest"); } q.State = QuestStates.SELECTED; }
public static GameObject FindQuestGameObj(QuestReq req, Quest q, string lfs) { // Set player current zone WowPlayer player = ProcessManager.Player; player.SetCurrentMapInfo(); string qt = q.Title; // Get quest npc GameObject obj = q.GameObjList[req.NpcId]; if (obj == null) throw new QuestSkipException( "Quest " + req.NpcDestText + " NPC not found for quest '" + qt); Output.Instance.Log(lfs, "Located NPC '" + obj.Name + "' as quest " + req.NpcDestText + " for quest '" + qt + "'"); q.State = QuestStates.OBJ_FOUND; return obj; }
public static void DoActionEx(QuestReq req, Quest q, string lfs) { DoAction(req, lfs); string qtitle = q.Title; // After action q.Idx = QuestHelper.FindLogQuest(qtitle, lfs); if (req.QuestStatus.Equals("quest_start")) { // Check that quest is in toon log if (q.Idx == 0) throw new QuestSkipException( "Unable find quest in toon log after it been accepted '"); } else if (req.QuestStatus.Equals("quest_end")) { // Check that quest is in toon log if (q.Idx > 0) throw new QuestSkipException( "Quest still in toon's quest log after it been delivered"); } else throw new QuestSkipException( "Unknown quest status '" + req.QuestStatus); Output.Instance.Log(lfs, "Quest '" + qtitle + "' successfully " + req.ActionName.ToLower() + "ed'"); q.State = req.FinalState; }
public static void DoAction(QuestReq req, string lfs) { Output.Instance.Debug(lfs, req.ActionName + "ing quest ..."); if (req.ActionName.Equals("Accept")) LuaHelper.Exec("AcceptQuest"); else if (req.ActionName.Equals("Deliver")) LuaHelper.Exec("DeliverQuest", req.Choice); // Wait a bit to update log Thread.Sleep(2000); }
/// <summary> /// Check if current quest avail /// If it on NPC gossip frame than select it /// If it already open than we fine /// </summary> /// <param name="q">Quest</param> /// <returns>true if NPC has quest</returns> private static bool CheckQuest(Quest q, string[] dinfo, QuestReq req, string lfs) { string cur_service = null; if (dinfo == null) { dinfo = NpcHelper.GetTargetNpcDialogInfo(q.Src.Name, false, lfs); cur_service = dinfo[0]; } else { cur_service = dinfo[0]; } if (cur_service.Equals("gossip")) { Output.Instance.Debug(lfs, "GossipFrame opened."); Output.Instance.Debug(lfs, "Looking for quest ..."); int idx = QuestHelper.FindGossipQuestIdByTitle(q.Title, req.ProcName); if (idx < 0) { return(false); } // Selecting quest Output.Instance.Debug(lfs, "Selecting quest by Id: " + idx); LuaHelper.Exec("SelectGossip" + req.ProcName + "Quest", idx); // Wait for quest frame pop up try { NpcHelper.WaitDialogOpen("Quest", lfs); } catch (NpcInteractException ne) { throw new QuestProcessingException(ne.Message); } catch (Exception e) { throw new QuestProcessingException( "NPC doesn't show QuestFrame. " + e.Message); } // Call itself again to parse the quest return(CheckQuest(q, null, req, lfs)); } else if (cur_service.Equals("quest_start")) { Output.Instance.Debug("Parsing quest info line '" + dinfo[1] + "'"); string[] headers = dinfo[1].Split(new string[] { "::" }, StringSplitOptions.None); string title = headers[0]; return(!string.IsNullOrEmpty(title) && title.Equals(q.Title)); } else if (cur_service.Equals("quest_progress")) { // Quest progress // Click continue and check next screen LuaHelper.Exec("CompleteQuest"); // Wait to change quest frame Thread.Sleep(2000); return(CheckQuest(q, null, req, lfs)); } else if (cur_service.Equals("quest_end")) { return(true); } else { // Quest not found nor on gossip frame nor on active frame throw new QuestProcessingException( "Quest not found nor on GossipFrame nor on ActiveFrame"); } }