Пример #1
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]);
        }
Пример #2
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");
            }
        }