Exemplo n.º 1
0
        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.");
                }
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
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]);
        }
Exemplo n.º 5
0
        /// <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");
            }
        }