Пример #1
0
        public void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            EliteAPI.ChatEntry cl = api.Chat.GetNextChatLine();

            while (cl != null)
            {
                //Trace.WriteLine(string.Format("type:{0} idx1:{1} idx2:{2} {3}", cl.ChatType, cl.Index1, cl.Index2, cl.Text));

                // First appearance will be the selected number.
                Match m = Regex.Match(cl.Text, @"Bonanza Moogle : (?<name>\d+).");
                if (m.Success)
                {
                    // Number found store this until confirmed.
                    numberFound = m.Groups["name"].Value;
                }
                // Confirmation verified, add to the XML
                if (cl.Text == "Bonanza Moogle : Thank you, and good luck, kupo!")
                {
                    Add_Marble(api.Player.Name, numberFound);
                }

                cl = api.Chat.GetNextChatLine();
            }
            Thread.Sleep(TimeSpan.FromSeconds(0.1));
        }
Пример #2
0
        /// <summary>
        /// フォームLoadイベント
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_Load(object sender, EventArgs e)
        {
            if (Control.ModifierKeys == System.Windows.Forms.Keys.Shift)
            {
                this.Width = 470;
            }
#if DEBUG
            this.Width = 470;
#endif

            //pol
            setPolList();
            if (cmbPol.Items.Count < 1)
            {
                MessageBox.Show("FF11を起動してください。", MiscTools.GetAppTitle(), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                System.Environment.Exit(0); //プログラム終了
            }
            cmbPol.SelectedIndex = 0;
            btnPolAttach_Click(this, new EventArgs());
            //チャットクリア
            EliteAPI.ChatEntry cl = api.Chat.GetNextChatLine();
            while (cl != null)
            {
                cl = api.Chat.GetNextChatLine();
            }

            //フォーム初期化
            initForm();

            //timer起動
            timMonitor.Interval = 100;
            timMonitor.Enabled  = true;
            timDebug.Interval   = 100;
            timDebug.Enabled    = true;
        }
Пример #3
0
        public Color BrightenColor(EliteAPI.ChatEntry chatLine)
        {
            Color brighterColor = new Color();
            //how many steps away can the colors be away from each other to be close enough to grayscale
            //this variable's value is subjective, and chosen by the programmer
            int steps = 3;
            //tolerance = 256 colors / 64 in-game 'step' choices * steps
            int tolerance     = 256 / 64 * steps;
            int closeEnoughRG = Math.Abs(chatLine.ChatColor.R - chatLine.ChatColor.G);
            int closeEnoughGB = Math.Abs(chatLine.ChatColor.G - chatLine.ChatColor.B);
            int closeEnoughRB = Math.Abs(chatLine.ChatColor.R - chatLine.ChatColor.B);

            if ((closeEnoughRG <= tolerance) && (closeEnoughGB <= tolerance) && (closeEnoughRB <= tolerance))
            {
                //greatly brighten white and gray text
                brighterColor = RGBHSL.ModifyBrightness(chatLine.ChatColor, 1.85);
            }
            else
            {
                //only slighty brighten color text
                brighterColor = RGBHSL.ModifyBrightness(chatLine.ChatColor, 1.25);
            }

            return(brighterColor);
        }
Пример #4
0
        public Form4(Form1 f)
        {
            this.StartPosition = FormStartPosition.CenterScreen;

            InitializeComponent();

            f1 = f;

            if (f1.setinstance2.Enabled == true)
            {
                #region "== First generate all current chat entries."

                _ELITEAPIPL = new EliteAPI((int)f1.processids.SelectedItem);
                characterNamed_label.Text = "Chatlog for character: " + _ELITEAPIPL.Player.Name + "\n";

                EliteAPI.ChatEntry cl = new EliteAPI.ChatEntry();

                while ((cl = _ELITEAPIPL.Chat.GetNextChatLine()) != null)
                {
                    chatlog_box.AppendText(cl.Text, cl.ChatColor);
                    chatlog_box.AppendText(Environment.NewLine);
                }

                chatlog_box.SelectionStart = chatlog_box.Text.Length;
                chatlog_box.ScrollToCaret();

                #endregion "== First generate all current chat entries."
            }
            else
            {
                chatlog_box.Text          = "No character was selected as the power leveler, close this window and select one.";
                chatlogscan_timer.Enabled = false;
            }
        }
Пример #5
0
        public ChatlogForm(MainForm f)
        {
            this.StartPosition = FormStartPosition.CenterScreen;

            InitializeComponent();

            f1 = f;

            if (f1.setinstance2.Enabled == true)
            {
                #region "== First generate all current chat entries."

                PL = new EliteAPI((int)f1.activeprocessids.SelectedItem);
                characterNamed_label.Text = "Chatlog for character: " + PL.Player.Name + "\n";

                EliteAPI.ChatEntry cl = new EliteAPI.ChatEntry();

                while ((cl = PL.Chat.GetNextChatLine()) != null)
                {
                    chatlog_box.AppendText(cl.Text, cl.ChatColor);
                    chatlog_box.AppendText(Environment.NewLine);
                }

                chatlog_box.SelectionStart = chatlog_box.Text.Length;
                chatlog_box.ScrollToCaret();

                #endregion "== First generate all current chat entries."
            }
            else
            {
                chatlogscan_timer.Enabled = false;
                MessageBox.Show("No character was selected as the power leveler, this can not be opened yet.");
            }
        }
Пример #6
0
        /// <summary>
        /// 実行中のプラグイン名を取得する
        /// </summary>
        /// <returns>プラグイン名</returns>
        public List <string> GetPlugin()
        {
            if (api.Player.LoginStatus != (int)LoginStatus.LoggedIn)
            {
                return(new List <string>());
            }
            chat.Reset();
            api.ThirdParty.SendString("//plugin_list");
            List <string> ret = new List <string>();
            var           cl  = new EliteAPI.ChatEntry();

            for (int i = 0; i < this.MaxLoopCount && !MiscTool.IsRegexString(cl.Text, REGEX_PLUGIN_END); i++)
            {
                while (chat.GetNextChatLine(out cl))
                {
                    if (MiscTool.IsRegexString(cl.Text, REGEX_PLUGIN))
                    {
                        List <string> reg  = MiscTool.GetRegexString(cl.Text, REGEX_PLUGIN);
                        string[]      work = reg[0].Split(',');
                        ret.Add(work[work.Count() - 1]);
                    }
                    else if (MiscTool.IsRegexString(cl.Text, REGEX_PLUGIN_END))
                    {
                        break;
                    }
                }
                Thread.Sleep(this.BaseWait);
            }
            return(ret);
        }
Пример #7
0
        public static void Parse(EliteAPI api)
        {
            EliteAPI.ChatEntry c = api.Chat.GetNextChatLine();
            if (c == null && !Chat.loaded)
            {
                Chat.loaded = true; Chat.SendEcho(api, Chat.loadStr);
            }

            if (c == null || !Chat.loaded)
            {
                return;
            }

            const int party = Chat.Types.partyOut,
                      echo  = Chat.Types.echo;

            int chatType = c.ChatType;

            if (party == chatType)
            {
                ProcessParty(api, c.Text);
            }
            else if (echo == chatType)
            {
                ProcessEcho(api, c.Text);
            }
            else if (api.Player.ZoneId == Nyzul.zoneID /* && systemType == chatType */)
            {
                ProcessNyzul(api, c.Text);
            }
        }
Пример #8
0
 /// <summary>
 /// チャット内容からChatKbnKindを取得する
 /// </summary>
 /// <param name="iCl">チャットライン</param>
 /// <returns>チャット区分</returns>
 private ChatKbnKind getChatKbnFromChatline(EliteAPI.ChatEntry iCl, out List <string> oArgs)
 {
     oArgs = new List <string>();
     foreach (KeyValuePair <ChatKbnKind, string> v in dictionaryChat)
     {
         string searchStr = v.Value;
         if (MiscTool.IsRegexString(iCl.Text, searchStr))
         {
             oArgs = MiscTool.GetRegexString(iCl.Text, searchStr);
             return(v.Key);
         }
     }
     return(ChatKbnKind.Unknown);
 }
Пример #9
0
 /// <summary>
 /// 次のチャットを取得
 /// </summary>
 /// <param name="oChatLine">チャットライン</param>
 /// <returns>True:次のチャットがある場合</returns>
 public bool GetNextChatLine(out EliteAPI.ChatEntry oChatLine)
 {
     for (int i = 0; i < chatLines.Count; i++)
     {
         if (chatLines[i].Index1 > this.currentIndex)
         {
             this.currentIndex = chatLines[i].Index1;
             oChatLine         = chatLines[i];
             return(true);
         }
     }
     oChatLine = new EliteAPI.ChatEntry();
     return(false);
 }
Пример #10
0
        private void chatlogscan_timer_Tick(object sender, EventArgs e)
        {
            #region "== Now add any additional chat entries every set period of time"

            EliteAPI.ChatEntry cl = new EliteAPI.ChatEntry();

            while ((cl = PL.Chat.GetNextChatLine()) != null)
            {
                chatlog_box.AppendText(cl.Text, cl.ChatColor);
                chatlog_box.AppendText(Environment.NewLine);
            }

            #endregion "== Now add any additional chat entries every set period of time"
        }
Пример #11
0
        /// <summary>
        /// バッファに追加
        /// </summary>
        /// <param name="iCl"></param>
        private void AddChatLines(EliteAPI.ChatEntry iCl)
        {
            logger.Trace("チャットバッファに追加:idx1:{0} idx2:{1} {2}", iCl.Index1, iCl.Index2, iCl.Text);
            chatLines.Add(iCl);

            //コマンド受信イベント処理
            if (iCl.ChatType == (int)ChatMode.Echo && iCl.Text.Length > 0)
            {
                string[] cmd = iCl.Text.Split(' ');
                if (cmd.Length >= 1 && cmd[0].ToLower() == "enjoyfishing" && cmd.Length > 1)
                {
                    EventReceivedCommand(cmd.ToList().GetRange(1, cmd.Length - 1));
                }
            }
        }
Пример #12
0
 public ChatTool(EliteAPI iEliteAPI)
 {
     api = iEliteAPI;
     // チャットの初期化
     EliteAPI.ChatEntry cl = new EliteAPI.ChatEntry();
     for (int i = 0; i < Constants.MAX_LOOP_COUNT; i++)
     {
         cl = api.Chat.GetNextChatLine();
         if (cl == null)
         {
             break;
         }
         Thread.Sleep(1);
     }
     Start();
 }
Пример #13
0
        private void SelectPOLIDButton_Click(object sender, RoutedEventArgs e)
        {
            this.processids.SelectedIndex = this.POLID.SelectedIndex;
            api = new EliteAPI((int)this.processids.SelectedItem);
            this.SelectPOLID.Content    = "SELECTED";
            this.SelectPOLID.Background = Brushes.LightGreen;

            EliteAPI.ChatEntry cl = api.Chat.GetNextChatLine();
            while (cl != null)
            {
                cl = api.Chat.GetNextChatLine();
            }

            if (firstSelect == 0)
            {
                backgroundWorker.RunWorkerAsync();
            }
        }
Пример #14
0
        /// <summary>
        /// 実行中のアドオン名を取得する
        /// </summary>
        /// <returns>アドオン名</returns>
        public List <string> GetAddon()
        {
            if (api.Player.LoginStatus != (int)LoginStatus.LoggedIn)
            {
                return(new List <string>());
            }
            chat.Reset();
            api.ThirdParty.SendString("//lua list");
            Thread.Sleep(this.BaseWait);
            api.ThirdParty.SendString("/echo " + REGEX_ADDON_END);

            List <string> ret      = new List <string>();
            var           cl       = new EliteAPI.ChatEntry();
            bool          startFlg = false;

            for (int i = 0; i < this.MaxLoopCount && !MiscTool.IsRegexString(cl.Text, REGEX_ADDON_END); i++)
            {
                while (chat.GetNextChatLine(out cl))
                {
                    if (!startFlg)
                    {
                        if (MiscTool.IsRegexString(cl.Text, REGEX_ADDON_START))
                        {
                            startFlg = true;
                        }
                    }
                    else
                    {
                        if (MiscTool.IsRegexString(cl.Text, REGEX_ADDON_END))
                        {
                            break;
                        }
                        else if (MiscTool.IsRegexString(cl.Text, REGEX_ADDON))
                        {
                            List <string> reg = MiscTool.GetRegexString(cl.Text, REGEX_ADDON);
                            ret.Add(reg[0].Trim());
                        }
                    }
                }
                Thread.Sleep(this.BaseWait);
            }
            return(ret);
        }
Пример #15
0
        /// <summary>
        /// バッファの更新
        /// </summary>
        private void updateChatLine()
        {
            if (api == null || api.Player.LoginStatus != (int)LoginStatus.LoggedIn)
            {
                return;
            }

            EliteAPI.ChatEntry cl;
            EliteAPI.ChatEntry buff = null;
            while ((cl = api.Chat.GetNextChatLine()) != null)
            {
                //タイムスタンプを削除
                cl.Text = RemoveTimeStamp(cl.Text);
                if (buff == null)
                {
                    buff = cl;
                    continue;
                }
                if (buff.Index1 == cl.Index1 || MiscTool.IsRegexString(cl.Text, REGEX_EMINENCE2))
                {
                    buff.Text += cl.Text;
                }
                else
                {
                    AddChatLines(buff);
                    buff = cl;
                }
            }
            if (buff != null)
            {
                AddChatLines(buff);
            }

            if (chatLines.Count > MAX_CHATLINE_INDEX)
            {
                chatLines.RemoveRange(0, chatLines.Count - MAX_CHATLINE_INDEX);
            }
        }
Пример #16
0
        /// <summary>
        /// メインスレッド
        /// </summary>
        private void threadHarakiri()
        {
            chat.CurrentIndex = chat.MaxIndex;
            setHarakiriStatus(HarakiriStatusKind.Normal);
            bool firsttime = true;

            logger.Debug("ハラキリスレッド開始");
            chat.Reset();
            while (this.RunningStatus == RunningStatusKind.Running)
            {
                //未入力チェック
                if (this.HarakiriFishName.Length == 0)
                {
                    setRunningStatus(RunningStatusKind.Stop);
                    setHarakiriStatus(HarakiriStatusKind.Error);
                    setMessage("ハラキリする魚を入力してください");
                    return;
                }
                //鞄に入っている魚の総数を取得
                uint itemId = resource.GetItem(this.HarakiriFishName).ItemID;
                int  remain = GetHarakiriRemain(this.HarakiriFishName);
                if (remain <= 0)
                {
                    setRunningStatus(RunningStatusKind.Stop);
                    if (firsttime)
                    {
                        setHarakiriStatus(HarakiriStatusKind.Error);
                        setMessage("ハラキリする魚が見つかりませんでした");
                    }
                    else
                    {
                        setHarakiriStatus(HarakiriStatusKind.Normal);
                        setMessage("ハラキリが完了しました");
                    }
                    return;
                }
                firsttime = false;
                setMessage(string.Format("ハラキリ中:{0} 残り{1}匹", this.HarakiriFishName, remain));
                //鞄に対象の魚を移動させる
                if (control.GetInventoryItemCount(itemId, StorageContainer.Inventory) <= 0)
                {
                    if (control.GetInventoryItemCount(itemId, StorageContainer.Satchel) > 0)
                    {
                        control.GetItemizer(this.HarakiriFishName, StorageContainer.Satchel);
                    }
                    else if (control.GetInventoryItemCount(itemId, StorageContainer.Sack) > 0)
                    {
                        control.GetItemizer(this.HarakiriFishName, StorageContainer.Sack);
                    }
                    else if (control.GetInventoryItemCount(itemId, StorageContainer.Case) > 0)
                    {
                        control.GetItemizer(this.HarakiriFishName, StorageContainer.Case);
                    }
                }
                //Zaldonの近くかチェック
                if (api.Player.ZoneId != (int)Zone.Selbina ||
                    (api.Entity.GetEntity(NPCID_ZALDON).Distance != 0f && api.Entity.GetEntity(NPCID_ZALDON).Distance > 6))
                {
                    setRunningStatus(RunningStatusKind.Stop);
                    setHarakiriStatus(HarakiriStatusKind.Error);
                    setMessage("セルビナのZaldonの近くで実行してください");
                    return;
                }
                //メニュー開いていたら閉じる
                if (!control.CloseDialog(10))
                {
                    setRunningStatus(RunningStatusKind.Stop);
                    setHarakiriStatus(HarakiriStatusKind.Error);
                    setMessage("エラー:会話を終了させてから実行してください");
                    break;
                }

                //ターゲット設定
                control.SetTargetFromId(NPCID_ZALDON);
                Thread.Sleep(settings.Global.WaitChat);//Wait
                //プレイヤーステータスがstandingになるまで待機
                while (api.Player.Status != (uint)Status.Standing)
                {
                    Thread.Sleep(settings.Global.WaitBase);//wait
                }
                //アイテムトレード
                api.ThirdParty.SendString(string.Format("/item {0} <t>", this.HarakiriFishName));

                //チャット監視開始
                string itemName        = string.Empty;
                int    noResponseCount = 0;
                var    cl = new EliteAPI.ChatEntry();
                while (this.RunningStatus == RunningStatusKind.Running)
                {
                    if (!chat.GetNextChatLine(out cl))
                    {
                        noResponseCount++;
                        if (noResponseCount > 10)
                        {
                            setRunningStatus(RunningStatusKind.Stop);
                            setHarakiriStatus(HarakiriStatusKind.Error);
                            setMessage("ハラキリ対象の魚ですか? 反応無し中止");
                            break;
                        }
                        Thread.Sleep(settings.Global.WaitChat);//wait
                        continue;
                    }
                    //チャット区分の取得
                    List <string> chatKbnArgs = new List <string>();
                    ChatKbnKind   chatKbn     = getChatKbnFromChatline(cl, out chatKbnArgs);
                    logger.Debug("Chat:{0} ChatKbn:{1}", cl.Text, chatKbn);
                    if (chatKbn == ChatKbnKind.Zaldon)
                    {
                        noResponseCount = 0;
                        if (!settings.UseEnternity)
                        {
                            api.ThirdParty.KeyPress(Keys.RETURN);
                        }
                    }
                    else if (chatKbn == ChatKbnKind.NotFound)
                    {
                        noResponseCount = 0;
                        if (!putDatabase(itemName))
                        {
                            setRunningStatus(RunningStatusKind.Stop);
                            setHarakiriStatus(HarakiriStatusKind.Error);
                            setMessage("データベースの更新に失敗しました");
                            break;
                        }
                        EventHarakiriOnce(this.HarakiriFishName, itemName);//イベント発生
                        setMessage("ハラキリ結果:何も見つからなかった");
                        if (!settings.UseEnternity)
                        {
                            api.ThirdParty.KeyPress(Keys.RETURN);
                        }
                    }
                    else if (chatKbn == ChatKbnKind.Found)
                    {
                        noResponseCount = 0;
                        itemName        = chatKbnArgs[0];
                        if (!putDatabase(itemName))
                        {
                            setRunningStatus(RunningStatusKind.Stop);
                            setHarakiriStatus(HarakiriStatusKind.Error);
                            setMessage("データベースの更新に失敗しました");
                            break;
                        }
                        EventHarakiriOnce(this.HarakiriFishName, itemName);//イベント発生
                        setMessage(string.Format("ハラキリ結果:{0}を見つけた", itemName));
                        api.ThirdParty.KeyPress(Keys.RETURN);
                        Thread.Sleep(settings.Global.WaitChat);
                    }
                    if (chatKbn == ChatKbnKind.Found || chatKbn == ChatKbnKind.NotFound)
                    {
                        noResponseCount = 0;
                        Thread.Sleep(2000);
                        //発見したら停止
                        if (chatKbn == ChatKbnKind.Found && settings.Harakiri.StopFound)
                        {
                            setRunningStatus(RunningStatusKind.Stop);
                            setHarakiriStatus(HarakiriStatusKind.Normal);
                            setMessage("アイテムを発見したので停止します");
                        }
                        break;
                    }
                    Thread.Sleep(settings.Global.WaitBase); //wait
                }
                Thread.Sleep(settings.Global.WaitChat);     //wait
            }
            logger.Debug("ハラキリスレッド終了");
        }
 public ChatEventArgs(EliteAPI.ChatEntry line)
 {
     ChatLine = line;
 }
Пример #18
0
        /// <summary>
        /// モニタ用タイマーイベント
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timMonitor_Tick(object sender, EventArgs e)
        {
            //ログイン状態監視
            if (api.Player.Name != null)
            {
                btnExec.Enabled = true;
                //if (string.IsNullOrEmpty(lastPlayerName))
                //{
                //    settings.Load(api.Player.Name);
                //    initForm();
                //}
                lastPlayerName = api.Player.Name;
            }
            else
            {
                btnExec.Enabled = false;
                lastPlayerName  = string.Empty;
            }


            //ダイアログ監視
            List <string> regStr = new List <string>();

            if (api.Menu.IsMenuOpen)
            {
                if (MiscTools.GetRegexString(api.Dialog.GetDialog().Question, Constants.DIALOG_QUESTION_COU1, out regStr))
                {
                    remainTicket   = int.Parse(regStr[0]);
                    lblTicket.Text = regStr[0];
                }
                if (MiscTools.GetRegexString(api.Dialog.GetDialog().Question, Constants.DIALOG_QUESTION_COU4, out regStr))
                {
                    remainTicket   = int.Parse(regStr[0]);
                    lblTicket.Text = regStr[0];
                }
                if (MiscTools.GetRegexString(api.Dialog.GetDialog().Question, Constants.DIALOG_QUESTION_WAYPOINT1, out regStr))
                {
                    remainCp   = int.Parse(regStr[0]);
                    lblCP.Text = int.Parse(regStr[0]).ToString("#,0");
                }
            }
            //チャット監視
            EliteAPI.ChatEntry cl = api.Chat.GetNextChatLine();
            while (cl != null)
            {
                //Console.WriteLine(string.Format("type:{0} idx1:{1} idx2:{2} {3}", cl.ChatType, cl.Index1, cl.Index2, cl.Text));
                if ((cl.ChatType == 152 || cl.ChatType == 144) &&
                    MiscTools.GetRegexString(cl.Text, Constants.CHAT_TICKET_REMAIN, out regStr))
                {
                    remainTicket   = int.Parse(regStr[0]);
                    lblTicket.Text = regStr[0];
                }
                if (cl.ChatType == 148 && MiscTools.GetRegexString(cl.Text, Constants.CHAT_CP_REMAIN, out regStr))
                {
                    if (lblCP.Text != "--")
                    {
                        remainCp  -= int.Parse(regStr[0]);
                        lblCP.Text = remainCp.ToString("#,0");
                    }
                }
                cl = api.Chat.GetNextChatLine();
            }
        }