public static void AbandonQuest(string qtitle, string lfs) { // Find quest id in toon log Output.Instance.Log(lfs, "Abandoning Quest '" + qtitle + "' ... "); int idx = FindLogQuest(qtitle, lfs); if (idx == 0) { Output.Instance.Log(lfs, "Not found in toon's quest log"); return; } // Open QuestLogFrame LuaHelper.Exec("ToggleFrame", "QuestLog"); NpcHelper.WaitDialogOpen("QuestLog", lfs); string[] ret = LuaHelper.Exec("SelectAbandonQuest", idx); string aq_name = ret[0]; if (string.IsNullOrEmpty(aq_name)) { throw new QuestProcessingException( "Abandoning preparation procedure didn't return quest name"); } else if (!aq_name.Equals(qtitle)) { throw new QuestProcessingException("Abandoned quest '" + aq_name + "' is different from expected '" + qtitle + "'."); } else { // Wait to get selection activated Thread.Sleep(2000); LuaHelper.Exec("AbandonQuest"); // Wait to get abandon action activated Thread.Sleep(2000); if (FindLogQuest(qtitle, lfs) == 0) { Output.Instance.Log(lfs, "Quest '" + qtitle + "' removed from toon logs"); } else { throw new QuestProcessingException("Abandoned quest '" + qtitle + "' is still in toon quest log after abandon action."); } } }
private static void SelectService(string npc_name, string service, string lfs) { string dialog = null; try { dialog = ServiceFrameTable[service]; } catch { throw new UnknownServiceException(service); } // Get open Frame and make sure it's the correct one string[] dinfo = DoGetNpcDialogInfo(false); if (!dinfo[0].Equals(service)) { // Get available services string[][] glist = GetGossipList(lfs); if ((glist == null) || (glist[0].Length == 0)) { throw new ServiceNotFound(service); } string[] srv = glist[0]; bool f = false; for (int i = 0; i < srv.Length; i++) { if (srv[i].Equals(service)) { Output.Instance.Debug("Selecting service: " + service + " at index: " + i); LuaHelper.Exec("SelectGossipOption", i + 1); Output.Instance.Debug("Waiting " + service + " dialog to open"); WaitDialogOpen(dialog, lfs); f = true; } } if (!f) { throw new ServiceNotFound(service); } } }
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 bool SelectNpcOption(NPC npc, string lua_fname, int idx, string lfs) { // Choose gossip option and check npc again Output.Instance.Debug("Execute: " + lua_fname + "; idx: " + idx); LuaHelper.Exec(lua_fname, idx); if (!AddTargetNpcInfo(npc, lfs)) { return(false); } // After gossip option processed interact with npc again // if (idx < max) // NpcHelper.InteractNpc(npc.Name); return(true); }
public static void LearnSkills(NPC npc, string skill, string lfs) { SelectService(npc.Name, skill, lfs); // Filter by available only LuaHelper.Exec("SetTrainerAvailableFilter"); // Wait few sec to apply filter Thread.Sleep(2000); // Do until all we can afford is learned bool done; do { // Get # of avail services string[] dinfo = LuaHelper.Exec("GetServiceIdxList"); string cur_set = dinfo[0]; done = string.IsNullOrEmpty(cur_set); if (!done) { string[] set1 = cur_set.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries); string[] set2 = set1[0].Split(','); int idx; try { idx = Convert.ToInt32(set2[0]); } catch { throw new Exception("Unable recognize skill index: " + set2[0] + " from class training service list"); } Output.Instance.Log(lfs, "Learning: " + set2[1] + " at idx: " + idx); LuaHelper.Exec("BuyTrainerService", idx); // Wait few sec to apply Thread.Sleep(2000); } } while (!done); // todo close class frame }
public static NPC MoveInteractService(string service, string lfs) { NpcDest dest = FindNearestService(service); if (dest == null) { throw new ServiceNotFountException(service); } // Move to NPC // If it failed it throw exception. I know :) MoveToDest(dest.Waypoint, lfs, "Moving to NPC: '" + dest.Npc.Name + "'"); // Interact with NPC and select given service LuaHelper.TargetUnitByName(dest.Npc.Name); InteractNpc(dest.Npc.Name, false, lfs); return(dest.Npc); }
public static bool IsQuestLogCompleted(int idx) { // Check if quest completed string[] ret = LuaHelper.Exec("IsLogQuestCompleted", idx); return(!string.IsNullOrEmpty(ret[0]) && ret[0].Equals("1")); /* * // Check if quest has objectives. With 0 objectives it's auto-completed by finding quest dest * string[] obj = QuestHelper.GetQuestObjectives(idx); * * for (int i = 0; i < obj.Length; i++) * { * string[] items = obj[i].Split(','); * if (string.IsNullOrEmpty(items[2]) || !items[2].Equals("1")) * return false; * } * * return true; */ }
/// <summary> /// Interact with NPC, wait until NPC frame opens and return type of open frame. /// See description for GetTargetNpcFrameInfo for detail /// Max Waiting delay configured by max_npc_interact_time parameter from app_config element /// </summary> /// <param name="npc_name"></param> /// <returns></returns> public static string[] InteractNpc(string npc_name, bool auto_close, string lfs) { Output.Instance.Log(lfs, "Interacting with NPC '" + npc_name + "' ..."); // TODO Interact with Game Object by name LuaHelper.Exec("InteractWithTarget"); // ProcessManager.Player.ClickToMoveInteract(ProcessManager.Player.CurTargetGuid); // IF NPC doesn't have any quests and just on gossip option the WoW // does use this single option by default /* * DateTime dt = DateTime.Now; * Thread.Sleep(100); * TimeSpan ts = DateTime.Now.Subtract(dt); * * * string[] fparams = null; * string cur_service = null; * while ((cur_service == null) && * (DateTime.Now.Subtract(dt).TotalMilliseconds <= * ProcessManager.AppConfig.MaxNpcInteractTime)) * { * Thread.Sleep(500); * * fparams = DoGetNpcDialogInfo(auto_close); * cur_service = fparams[0]; * } * * if (cur_service == null) * throw new NpcInteractException(); */ string[] fparams; TimedTargetInteract(CheckNpcDialog, new object[] { auto_close }, out fparams); return(fparams); }
private static object[] CheckLogQuest(string title, string lfs) { Output.Instance.Debug(lfs, "Looking for quest index in toon quest log ..."); string[] res = LuaHelper.Exec("FindLogQuest", title); // Trying convert result int idx = 0; try { idx = Convert.ToInt32(res[0]); } catch { } object[] ret = new object[res.Length]; ret[0] = idx; for (int i = 1; i < res.Length; i++) { ret[i] = res[i]; } return(ret); }
private static string[] DoGetNpcDialogInfo(bool auto_close) { return(LuaHelper.Exec("GetNpcDialogInfo", auto_close)); }
private static bool CheckStaticDialog(string dname, out string[] res) { res = LuaHelper.Exec("FindVisibleStaticDialog", dname); return(!string.IsNullOrEmpty(res[0])); }
public static void BindToInn(NPC npc, string lfs) { // Check if NPC targeted WowUnit target = ProcessManager.Player.CurTarget; if (target == null || !target.Name.Equals(npc.Name)) { TargetGameObj(npc, lfs); } // Check NPC has bind service if (!npc.HasInn) { throw new BinderServiceNotFound(); } // Interact with NPC and choose binder service string[] fparams = NpcHelper.GetTargetNpcDialogInfo(npc.Name, lfs); string cur_service = fparams[0]; if ((cur_service == null) || !cur_service.Equals("gossip")) { throw new BinderServiceNotFound(); } // Get list of options string[][] opts = GetGossipList(lfs); if (opts == null) { throw new BinderServiceNotFound(); } // Find binder int idx = 0; for (int i = 0; i < opts[0].Length; i++) { if (opts[0][i].Equals("binder")) { idx = i + 1; break; } } if (idx == 0) { throw new BinderServiceNotFound(); } // Click make inn my home SelectNpcGossipOption(npc, idx, lfs); // Wait for dialog popup string[] dname; TimedTargetInteract(CheckBinderConfirmation, out dname); if (string.IsNullOrEmpty(dname[0])) { throw new BinderServiceNotFound(); } // Confirm bind LuaHelper.Exec("ConfirmBinder", dname[0]); }
public static string[] GetQuestObjectives(Quest q) { string[] ret = LuaHelper.Exec("GetQuestObjectives", q.Title); return(ret); }
/// <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"); } }