Class container for a chat line returned from GetNextLine()
Exemple #1
0
        /// <summary>
        /// フィールド箱空け処理
        /// </summary>
        /// <returns>True:正常終了 False:異常終了</returns>
        private Boolean StartField()
        {
            FFACE.ChatTools.ChatLine cl = new FFACE.ChatTools.ChatLine();
            Constant.MumGameInfo gi = _Constant.GetMumGameInfo(_Settings.MumGameId);
            Box box = new Box(BoxTypeKind.Field);
            int boxOpenRemain = _Settings.MumTryCount;
            int targetId = _FFACE.Target.ID;
            SetMessage("FOV・GOV箱空け実行中");
            while (Running)
            {
                //どうする?
                if (_FFACE.Menu.IsOpen && MiscTools.IsRegexString(_FFACE.Menu.DialogText.Question, Constant.DialogStringField1))
                {
                    //開錠するを選択
                    if (!SetDialogOptionIndex(1, true)) return false;
                    if (!WaitOpenDialog(Constant.DialogStringField2, false)) return false;
                }
                //どうする?(残り([0-9]*)回)
                if (_FFACE.Menu.IsOpen && MiscTools.IsRegexString(_FFACE.Menu.DialogText.Question, Constant.DialogStringField2))
                {
                    //残り回数取得
                    if (MiscTools.IsRegexString(_FFACE.Menu.DialogText.Question, Constant.DialogStringField2))
                    {
                        ArrayList al = MiscTools.GetRegexString(_FFACE.Menu.DialogText.Question, Constant.DialogStringField2);
                        box.TryRemainCnt = int.Parse(al[0].ToString());
                    }
                    //string[] r = getMatchDialogQuestionValue(Constant.DialogStringMum3);
                    //box.TryRemainCnt = int.Parse(r[1]);
                    //チャットバッファクリア
                    cl = _FFACE.Chat.GetNextLine(LineSettings.CleanAll);
                    //次の操作取得
                    BoxOperation bo = box.GetNextOperation();
                    if (bo.Operation == BoxOperationKind.INPUTNO)
                    {
                        SetMessage("箱操作:" + bo.InputNo.ToString() + "を入力");
                        if (!SetDialogOptionIndex(1, true)) return false;//数字を入力するを選択
                        if (!_Settings.UseEnternity)
                        {
                            System.Threading.Thread.Sleep(_Settings.BaseWait);
                            _FFACE.Windower.SendKeyPress(KeyCode.EnterKey);
                        }
                        if (!InputNumber(bo.InputNo.ToString(), true)) return false;//数字を入力する
                    }
                    else if (bo.Operation == BoxOperationKind.GETHINTS)
                    {
                        SetMessage("箱操作:カギを調べる");
                        if (!SetDialogOptionIndex(2, true)) return false;//カギを調べるを選択
                    }
                    System.Threading.Thread.Sleep(_Settings.NumberInputWait);
                    setChatToBox(box);
                    SetTextboxText(txtTargets, box.EnableNoLine);

                    //箱空け完了かの判断
                    bo = box.GetNextOperation();
                    if (bo.Operation == BoxOperationKind.OPENSUCCESS){
                        SetMessage("箱開けに成功しました");
                        return true;
                    }
                    else if(bo.Operation == BoxOperationKind.OPENFAILED)
                    {
                        SetMessage("箱開けに失敗しました");
                        return true;
                    }
                    else
                    {
                        //箱をターゲットする
                        if (!SetTargetFromId(targetId)) return false;
                        _FFACE.Windower.SendKeyPress(KeyCode.EnterKey);//ENTER
                        if (!WaitOpenDialog(Constant.DialogStringField1, true)) return false;
                    }
                }
                System.Threading.Thread.Sleep(_Settings.BaseWait);
            }
            return true;
        }
Exemple #2
0
        /// <summary>
        /// キーナンバー99 箱空け処理
        /// </summary>
        /// <returns></returns>
        private Constant.MumStartRet StartMum()
        {
            FFACE.ChatTools.ChatLine cl = new FFACE.ChatTools.ChatLine();
            Constant.MumGameInfo gi = _Constant.GetMumGameInfo(_Settings.MumGameId);
            Box box = new Box(gi.Id);
            int boxOpenRemain = _Settings.MumTryCount;
            SetMessage("MUM箱空け実行中");
            while (Running)
            {
                //どうする?
                if (_FFACE.Menu.IsOpen && MiscTools.IsRegexString(_FFACE.Menu.DialogText.Question, Constant.DialogStringMum1) )
                {
                    box = new Box(gi.Id);
                    SetTextboxText(txtTargets, box.EnableNoLine);
                    switch (gi.Type)
                    {
                        case Constant.MumGameType.BAYLD:
                            if (!SetDialogOptionIndex(1,true)) return Constant.MumStartRet.異常終了;
                            break;
                        case Constant.MumGameType.GIL:
                            if (!SetDialogOptionIndex(2, true)) return Constant.MumStartRet.異常終了;
                            break;
                    }
                    if (!WaitOpenDialog(Constant.DialogStringMum2, false)) return Constant.MumStartRet.異常終了;
                }
                //難易度を選択してください((.*):([0-9]*))
                if (_FFACE.Menu.IsOpen && MiscTools.IsRegexString(_FFACE.Menu.DialogText.Question, Constant.DialogStringMum2))
                {
                    if (!SetDialogOptionIndex(gi.MenuIndex, true)) return Constant.MumStartRet.異常終了;
                    if (!WaitOpenDialog(Constant.DialogStringMum3, false)) return Constant.MumStartRet.異常終了;
                    box = new Box(gi.Id);
                }
                //どうする?(残り([0-9]*)回)
                if (_FFACE.Menu.IsOpen && MiscTools.IsRegexString(_FFACE.Menu.DialogText.Question, Constant.DialogStringMum3))
                {
                    //残り回数取得
                    if (MiscTools.IsRegexString(_FFACE.Menu.DialogText.Question, Constant.DialogStringMum3))
                    {
                        ArrayList al = MiscTools.GetRegexString(_FFACE.Menu.DialogText.Question, Constant.DialogStringMum3);
                        box.TryRemainCnt = int.Parse(al[0].ToString());
                    }
                    //string[] r = getMatchDialogQuestionValue(Constant.DialogStringMum3);
                    //box.TryRemainCnt = int.Parse(r[1]);
                    //チャットバッファクリア
                    cl = _FFACE.Chat.GetNextLine(LineSettings.CleanAll);
                    //次の操作取得
                    BoxOperation bo = box.GetNextOperation();
                    if(bo.Operation == BoxOperationKind.INPUTNO)
                    {
                        SetMessage("箱操作:"+bo.InputNo.ToString()+"を入力");
                        if (!SetDialogOptionIndex(0, true)) return Constant.MumStartRet.異常終了;//数字を入力するを選択
                        if (!_Settings.UseEnternity)
                        {
                            System.Threading.Thread.Sleep(_Settings.BaseWait);
                            _FFACE.Windower.SendKeyPress(KeyCode.EnterKey);
                        }
                        if (!InputNumber(bo.InputNo.ToString(), true)) return Constant.MumStartRet.異常終了;//数字を入力する
                    }
                    else if (bo.Operation == BoxOperationKind.GETHINTS)
                    {
                        SetMessage("箱操作:カギを調べる");
                        if (!SetDialogOptionIndex(1, true)) return Constant.MumStartRet.異常終了;//カギを調べるを選択
                    }
                    //else if (bo.Operation == BoxOperationKind.FINISHED)
                    //{
                    //    return Constant.MumStartRet.正常終了;
                    //}
                    System.Threading.Thread.Sleep(_Settings.NumberInputWait);
                    setChatToBox(box);
                    SetTextboxText(txtTargets, box.EnableNoLine);

                    //箱空け完了かの判断
                    bo = box.GetNextOperation();
                    if (bo.Operation == BoxOperationKind.OPENSUCCESS ||
                        bo.Operation == BoxOperationKind.OPENFAILED)
                    {
                        //残り回数の判定
                        boxOpenRemain--;
                        if (_Settings.MumTryCount != 0)
                        {
                            if (boxOpenRemain > 0)
                            {
                                if (bo.Operation == BoxOperationKind.OPENSUCCESS)
                                {
                                    SetMessage("箱空け成功 残り回数:" + boxOpenRemain);
                                }
                                else
                                {
                                    SetMessage("箱空け失敗 残り回数:" + boxOpenRemain);
                                }
                            }
                        }
                    }
                }
                //もう1度やりますか?
                if (_FFACE.Menu.IsOpen && MiscTools.IsRegexString(_FFACE.Menu.DialogText.Question, Constant.DialogStringMum4))
                {
                    //規定回数開けてたら終了
                    if (_Settings.MumTryCount != 0 &&
                        boxOpenRemain <= 0)
                    {
                        SetMessage("規定回数に達したので停止しました");
                        if (!SetDialogOptionIndex(0, true)) return Constant.MumStartRet.異常終了;
                        return Constant.MumStartRet.指定回数実行;
                    }
                    box = new Box(gi.Id);
                    SetTextboxText(txtTargets, box.EnableNoLine);
                    switch (gi.Type)
                    {
                        case Constant.MumGameType.BAYLD:
                            if (!SetDialogOptionIndex(1,true)) return Constant.MumStartRet.異常終了;
                            break;
                        case Constant.MumGameType.GIL:
                            if (!SetDialogOptionIndex(2, true)) return Constant.MumStartRet.異常終了;
                            break;
                    }
                    if (!WaitOpenDialog(Constant.DialogStringMum3, false)) return Constant.MumStartRet.異常終了;
                }

                System.Threading.Thread.Sleep(_Settings.BaseWait);
            }
            return Constant.MumStartRet.正常終了;
        }
Exemple #3
0
        // Parse Chatlog
        private void Chatlogtimer_Tick(object sender, EventArgs e)
        {
            // Get our new color coded line
            FFACE.ChatTools.ChatLine NewLine = new FFACE.ChatTools.ChatLine();
            NewLine = Session.Chat.GetNextLine(LineSettings.CleanAll);
            string NewLine_Text = "";

            // Check to make sure we have text
            if (NewLine != null)
            {
                NewLine_Text = NewLine.Text;
                // Change the color of the line to match the color in FFXI
                ChatLog.SelectionColor = NewLine.Color;

                // Output our line to the textbox
                ChatLog.AppendText("[" + NewLine.NowDate + "] " + NewLine_Text + Environment.NewLine);

                // Scroll our chatlog window to the last line
                ChatLog.ScrollToCaret();
            }

            //--------------------------------------------------------------------------------
            // PL Auto na spells
            if (AutoNASpells.Checked)
            {
                // Check to ensure line not null
                if (!string.IsNullOrEmpty(NewLine_Text))
                {
                    // Check for paralyzed
                    if (NewLine_Text.Contains(PowerSession.Target.Name) && NewLine_Text.Contains("paralyzed"))
                    {
                        // Fix
                        string Command = "/ma \"Paralyna\" " + PowerSession.Target.Name + "";
                        PowerSession.Windower.SendString(Command);
                    }

                    // Check for blind
                    if (NewLine_Text.Contains(PowerSession.Target.Name) && NewLine_Text.Contains("blind"))
                    {
                        // Fix
                        string Command = "/ma \"Blindna\" " + PowerSession.Target.Name + "";
                        PowerSession.Windower.SendString(Command);
                    }

                    // Check for poisoned
                    if (NewLine_Text.Contains(PowerSession.Target.Name) && NewLine_Text.Contains("poisoned"))
                    {
                        // Fix
                        string Command = "/ma \"Poisona\" " + PowerSession.Target.Name + "";
                        PowerSession.Windower.SendString(Command);
                    }

                    // Check for sleep
                    if (NewLine_Text.Contains(PowerSession.Target.Name) && NewLine_Text.Contains("sleep"))
                    {
                        // Fix
                        string Command = "/ma \"Cure\" " + PowerSession.Target.Name + "";
                        PowerSession.Windower.SendString(Command);
                    }
                }
            }
        }
Exemple #4
0
 /// <summary>
 /// 取得したヒントをBoxクラスへセットする
 /// </summary>
 /// <param name="iBox"></param>
 private void setChatToBox(Box iBox)
 {
     FFACE.ChatTools.ChatLine cl = new FFACE.ChatTools.ChatLine();
     ArrayList al = new ArrayList();
     cl = _FFACE.Chat.GetNextLine(LineSettings.CleanAll);
     while (cl != null)
     {
         al.Add(cl.Text);
         cl = _FFACE.Chat.GetNextLine(LineSettings.CleanAll);
     }
     iBox.SetHints(al);
 }
 /// <summary>
 /// 実行中のアドオン名を取得する
 /// </summary>
 /// <returns>アドオン名</returns>
 public List<string> GetAddon()
 {
     if (pol.FFACE.Player.GetLoginStatus != LoginStatus.LoggedIn) return new List<string>();
     chat.Reset();
     fface.Windower.SendString("//lua list");
     Thread.Sleep(this.BaseWait);
     fface.Windower.SendString("/echo " + REGEX_ADDON_END);
     List<string> ret = new List<string>();
     FFACE.ChatTools.ChatLine cl = new FFACE.ChatTools.ChatLine();
     for (int i = 0; i < this.MaxLoopCount && !MiscTool.IsRegexString(cl.Text, REGEX_ADDON_END); i++)
     {
         while (chat.GetNextChatLine(out cl))
         {
             if (MiscTool.IsRegexString(cl.Text, REGEX_ADDON))
             {
                 List<string> reg = MiscTool.GetRegexString(cl.Text, REGEX_ADDON);
                 ret.Add(reg[0]);
             }
             else if (MiscTool.IsRegexString(cl.Text, REGEX_ADDON_END))
             {
                 break;
             }
         }
         Thread.Sleep(this.BaseWait);
     }
     return ret;
 }
 /// <summary>
 /// 実行中のプラグイン名を取得する
 /// </summary>
 /// <returns>プラグイン名</returns>
 public List<string> GetPlugin()
 {
     if (pol.FFACE.Player.GetLoginStatus != LoginStatus.LoggedIn) return new List<string>();
     chat.Reset();
     fface.Windower.SendString("//plugin_list");
     List<string> ret = new List<string>();
     FFACE.ChatTools.ChatLine cl = new FFACE.ChatTools.ChatLine();
     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;
 }
Exemple #7
0
        /// <summary>
        /// Grab all new chat lines and put them in the appropriate List<>s, 
        /// Increase line added counters as chat lines are added to a List<>,
        /// Keep the List<>s to a maximum size
        /// </summary>
        /// <returns>
        /// How many lines were added at the beginning of the chatLog
        /// so we know how many to parse through for the logs
        /// </returns>
        internal static int NewChat()
        {
            currentLine = FishingForm._FFACE.Chat.GetNextLine();

            while(currentLine != null)
            //while (!string.IsNullOrEmpty(currentLine.Text))
            {
                if(ChatMode.Error != currentLine.Type)
                {
                    chatLog.Insert(0, currentLine);
                    chatLogAdded++;

                    switch(currentLine.Type)
                    {
                        case ChatMode.FishObtained:
                        case ChatMode.FishResult:
                            fishLog.Insert(0, currentLine);
                            fishLogAdded++;
                            break;
                        case ChatMode.SentParty:
                        case ChatMode.RcvdParty:
                            partyLog.Insert(0, currentLine);
                            partyLogAdded++;
                            break;
                        case ChatMode.SentSay:
                        case ChatMode.RcvdSay:
                            sayLog.Insert(0, currentLine);
                            sayLogAdded++;
                            break;
                        case ChatMode.SentLinkShell:
                        case ChatMode.RcvdLinkShell:
                            shellLog.Insert(0, currentLine);
                            shellLogAdded++;
                            break;
                        case ChatMode.SentTell:
                        case ChatMode.RcvdTell:
                            tellLog.Insert(0, currentLine);
                            tellLogAdded++;
                            break;
                        default:
                            break;
                    }

                    currentLine = FishingForm._FFACE.Chat.GetNextLine();
                }
                else
                {
                    return -1;  //ChatMode.Error - try to recover
                }
            }

            //only need to trim the logs if something was added
            if(0 < chatLogAdded)
            {
                TrimLogs();
            }

            return chatLogAdded;
        }
Exemple #8
0
 /// <summary>
 /// 次のチャットを取得
 /// </summary>
 /// <param name="oChatLine">チャットライン</param>
 /// <returns>True:次のチャットがある場合</returns>
 public bool GetNextChatLine(out FFACE.ChatTools.ChatLine oChatLine)
 {
     for (int i = 0; i < chatLines.Count; i++)
     {
         if (chatLines[i].Index > this.currentIndex)
         {
             this.currentIndex = chatLines[i].Index;
             oChatLine = chatLines[i];
             return true;
         }
     }
     oChatLine = new FFACE.ChatTools.ChatLine();
     return false;
 }
        /// <summary>
        /// メインスレッド
        /// </summary>
        private void threadHarakiri()
        {
            chat.CurrentIndex = chat.MaxIndex;
            setHarakiriStatus(HarakiriStatusKind.Normal);
            bool firsttime = true;

            logger.Output(LogLevelKind.DEBUG, "ハラキリスレッド開始");
            while (this.RunningStatus == RunningStatusKind.Running)
            {
                //未入力チェック
                if (this.HarakiriFishName.Length == 0)
                {
                    setRunningStatus(RunningStatusKind.Stop);
                    setHarakiriStatus(HarakiriStatusKind.Error);
                    setMessage("ハラキリする魚を入力してください");
                    return;
                }
                //鞄が満杯?
                //if (fface.Item.InventoryCount >= fface.Item.InventoryMax)
                //{
                //    setRunningStatus(RunningStatusKind.Stop);
                //    setHarakiriStatus(HarakiriStatusKind.Error);
                //    setMessage("鞄が満杯です");
                //    return;
                //}
                //鞄に入っている魚の総数を取得
                int itemId = FFACE.ParseResources.GetItemId(this.HarakiriFishName);
                uint 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 (fface.Item.GetItemCount(itemId, InventoryType.Inventory) <= 0)
                {
                    if (fface.Item.GetItemCount(itemId, InventoryType.Satchel) > 0)
                    {
                        control.GetItem(this.HarakiriFishName, InventoryType.Satchel);
                    }
                    else if (fface.Item.GetItemCount(itemId, InventoryType.Sack) > 0)
                    {
                        control.GetItem(this.HarakiriFishName, InventoryType.Sack);
                    }
                    else if (fface.Item.GetItemCount(itemId, InventoryType.Case) > 0)
                    {
                        control.GetItem(this.HarakiriFishName, InventoryType.Case);
                    }
                }
                //Zaldonの近くかチェック
                if (fface.Player.Zone != Zone.Selbina ||
                    (fface.NPC.Distance(NPCID_ZALDON) != 0f && fface.NPC.Distance(NPCID_ZALDON) > 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(fface.Player.Status != Status.Standing){
                    Thread.Sleep(settings.Global.WaitBase);//wait
                }
                //アイテムトレード
                fface.Windower.SendString(string.Format("/item {0} <t>", this.HarakiriFishName));

                //チャット監視開始
                string itemName = string.Empty;
                int noResponseCount = 0;
                FFACETools.FFACE.ChatTools.ChatLine cl = new FFACE.ChatTools.ChatLine();
                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.Output(LogLevelKind.DEBUG, string.Format("Chat:{0} ChatKbn:{1}", cl.Text, chatKbn));
                    if (chatKbn == ChatKbnKind.Zaldon)
                    {
                        noResponseCount = 0;
                        if (!settings.UseEnternity)
                        {
                            fface.Windower.SendKeyPress(KeyCode.EnterKey);
                        }
                    }
                    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)
                        {
                            fface.Windower.SendKeyPress(KeyCode.EnterKey);
                        }
                    }
                    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));
                        fface.Windower.SendKeyPress(KeyCode.EnterKey);
                        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.Output(LogLevelKind.DEBUG, "ハラキリスレッド終了");
        }
Exemple #10
0
        /// <summary>
        /// メインスレッド
        /// </summary>
        private void threadFishing()
        {
            bool firstTime = true;
            interrupt = new FishingInterrupt(false, false, false, false, false);
            noCatchCount = 0;
            lastRodName = string.Empty;
            lastBaitName = string.Empty;
            lastZoneName = string.Empty;
            chat.CurrentIndex = chat.MaxIndex;
            setFishingStatus(FishingStatusKind.Normal);
            FishHistoryDBFishModel fish = new FishHistoryDBFishModel();

            logger.Output(LogLevelKind.DEBUG, "釣りスレッド開始");
            setMessage("開始しました");

            //メニュー開いていたら閉じる
            if (!control.CloseDialog())
            {
                setRunningStatus(RunningStatusKind.Stop);
                setFishingStatus(FishingStatusKind.Error);
                setMessage("メニューが閉じられない");
                return;
            }

            //着替え
            setEquipGear();
            //魚リスト更新
            EventFished(FishResultStatusKind.Unknown);

            //釣りメインループ
            while (this.RunningStatus == RunningStatusKind.Running)
            {
                //日付が変わったら経過時間クリア
                if (DateTime.Now.Date != lastCastDate.Date)
                {
                    fishHistoryDB = new FishHistoryDB(this.PlayerName, this.EarthDateTime, logger);
                    FishHistoryDBModel history = fishHistoryDB.SelectDayly(this.PlayerName, this.EarthDateTime);
                    this.TimeElapsed = history.TimeElapsed;
                }
                lastCastDate = DateTime.Now.Date;
                //チャット処理
                FFACE.ChatTools.ChatLine cl = new FFACE.ChatTools.ChatLine();
                while (chat.GetNextChatLine(out cl))
                {
                    List<string> chatKbnArgs = new List<string>();
                    ChatKbnKind chatKbn = getChatKbnFromChatline(cl, out chatKbnArgs);
                    logger.Output(LogLevelKind.DEBUG, string.Format("Chat:{0} ChatKbn:{1}", cl.Text, chatKbn));
                }
                //敵からの攻撃感知
                if (this.RunningStatus != RunningStatusKind.Running) break;
                if (interrupt.EnemyAttack)
                {
                    setRunningStatus(RunningStatusKind.Stop);
                    setFishingStatus(FishingStatusKind.Error);
                    setMessage("敵から攻撃されたので停止");
                    //コマンド実行
                    if (settings.Fishing.EnemyAttackCmd)
                    {
                        fface.Windower.SendString(settings.Fishing.EnemyAttackCmdLine);
                    }
                    break;
                }
                //チャット感知
                if (this.RunningStatus != RunningStatusKind.Running) break;
                if (interrupt.ChatReceive)
                {
                    if (settings.Fishing.ChatRestart)
                    {
                        setFishingStatus(FishingStatusKind.Wait);
                        double waitSec = (double)(settings.Fishing.ChatRestartMinute * 60);
                        DateTime restartTime = DateTime.Now.AddMinutes(settings.Fishing.ChatRestartMinute);
                        setMessage(string.Format("チャット感知:再始動待ち {0}(地球時間)まで待機", restartTime.ToString("HH:mm:ss")));
                        wait(waitSec, waitSec);
                        //チャットバッファをクリア
                        FFACE.ChatTools.ChatLine waitCl = new FFACE.ChatTools.ChatLine();
                        while (chat.GetNextChatLine(out waitCl))
                        {
                            Thread.Sleep(10);
                        }
                        //チャット受信フラグクリア
                        interrupt.ChatReceive = false;
                        setFishingStatus(FishingStatusKind.Normal);
                    }
                    else
                    {
                        setRunningStatus(RunningStatusKind.Stop);
                        setFishingStatus(FishingStatusKind.Normal);
                        setMessage("チャットを感知したので停止");
                        break;
                    }
                }
                //入港警告感知
                if (this.RunningStatus != RunningStatusKind.Running) break;
                if (settings.Fishing.EntryPort)
                {
                    if (interrupt.ShipWarning)
                    {
                        setRunningStatus(RunningStatusKind.Stop);
                        setFishingStatus(FishingStatusKind.Normal);
                        setMessage("入港するので停止");
                        break;
                    }
                }
                //エミネンスクリア
                if (this.RunningStatus != RunningStatusKind.Running) break;
                if (settings.Fishing.EminenceClear)
                {
                    if (interrupt.ClearEminence)
                    {
                        setRunningStatus(RunningStatusKind.Stop);
                        setFishingStatus(FishingStatusKind.Normal);
                        setMessage("エミネンスをクリアしたので停止");
                        break;
                    }
                }
                //エリア切り替わり感知
                if (this.RunningStatus != RunningStatusKind.Running) break;
                if (this.lastZoneName.Length > 0 && this.lastZoneName != this.ZoneName)
                {
                    setRunningStatus(RunningStatusKind.Stop);
                    setFishingStatus(FishingStatusKind.Error);
                    setMessage("エリアが切り替わったので停止");
                    break;
                }
                //釣果数
                if (this.RunningStatus != RunningStatusKind.Running) break;
                if (settings.Fishing.MaxCatch)
                {
                    if (this.fishHistoryDB.CatchCount >= settings.Fishing.MaxCatchCount)
                    {
                        setRunningStatus(RunningStatusKind.Stop);
                        setFishingStatus(FishingStatusKind.Normal);
                        setMessage("本日の釣果数が規定値になったので停止");
                        break;
                    }
                }
                //釣果無し
                if (this.RunningStatus != RunningStatusKind.Running) break;
                if (settings.Fishing.MaxNoCatch)
                {
                    if (noCatchCount >= settings.Fishing.MaxNoCatchCount)
                    {
                        setRunningStatus(RunningStatusKind.Stop);
                        setFishingStatus(FishingStatusKind.Normal);
                        setMessage("連続釣果無しが規定値になったので停止");
                        break;
                    }
                }
                //釣りスキル
                if (this.RunningStatus != RunningStatusKind.Running) break;
                if (settings.Fishing.MaxSkill)
                {
                    if (this.FishingSkill >= settings.Fishing.MaxSkillValue)
                    {
                        setRunningStatus(RunningStatusKind.Stop);
                        setFishingStatus(FishingStatusKind.Normal);
                        setMessage("釣りスキルが規定値になったので停止");
                        break;
                    }
                }
                //スニーク
                if (this.RunningStatus != RunningStatusKind.Running) break;
                if (settings.Fishing.SneakFishing && settings.UseCancel)
                {
                    if (interrupt.SneakWarning || !control.IsBuff(StatusEffect.Sneak))
                    {
                        setMessage("スニークをかけます");
                        castSneak();
                        interrupt.SneakWarning = false;
                    }
                }
                //鞄1
                if (this.RunningStatus != RunningStatusKind.Running) break;
                if (this.InventoryCount >= this.InventoryMax)
                {
                    if (!putFish())
                    {
                        if (settings.Fishing.InventoryFullCmd)
                        {
                            fface.Windower.SendString(settings.Fishing.InventoryFullCmdLine);
                        }
                        setRunningStatus(RunningStatusKind.Stop);
                        setFishingStatus(FishingStatusKind.Normal);
                        setMessage("鞄がいっぱいなので停止");
                        break;
                    }
                }
                //竿
                if (this.RunningStatus != RunningStatusKind.Running) break;
                if (this.RodName == string.Empty)
                {
                    if (!string.IsNullOrEmpty(lastRodName) &&
                        !control.IsExistItem(lastRodName, FFACETools.InventoryType.Inventory) &&
                        !control.IsExistItem(lastRodName, FFACETools.InventoryType.Wardrobe))
                    {
                        //予備の竿を鞄へ移動
                        if (!getRodBaitItem(lastRodName))
                        {
                            //竿の修理
                            if (settings.Fishing.RepairRod && settings.UseItemizer)
                            {
                                if (!repairRod(lastRodName))
                                {
                                    setRunningStatus(RunningStatusKind.Stop);
                                    setFishingStatus(FishingStatusKind.Error);
                                    break;
                                }
                                Thread.Sleep(2000);
                            }
                        }
                    }
                    if (!setRod(lastRodName))
                    {
                        setRunningStatus(RunningStatusKind.Stop);
                        setFishingStatus(FishingStatusKind.Error);
                        setMessage("釣り竿を装備していないので停止");
                        //コマンド実行
                        if (settings.Fishing.NoBaitNoRodCmd)
                        {
                            fface.Windower.SendString(settings.Fishing.NoBaitNoRodCmdLine);
                        }
                        break;
                    }
                }
                //エサ
                if (this.RunningStatus != RunningStatusKind.Running) break;
                if (this.BaitName == string.Empty)
                {
                    if (!string.IsNullOrEmpty(lastBaitName) &&
                        !control.IsExistItem(lastBaitName, FFACETools.InventoryType.Inventory) &&
                        !control.IsExistItem(lastBaitName, FFACETools.InventoryType.Wardrobe))
                    {
                        getRodBaitItem(lastBaitName);
                    }
                    if (!setBait(lastBaitName))
                    {
                        setRunningStatus(RunningStatusKind.Stop);
                        setFishingStatus(FishingStatusKind.Error);
                        setMessage("エサを装備していないので停止");
                        //コマンド実行
                        if (settings.Fishing.NoBaitNoRodCmd)
                        {
                            fface.Windower.SendString(settings.Fishing.NoBaitNoRodCmdLine);
                        }
                        break;
                    }
                }
                //鞄2
                if (this.RunningStatus != RunningStatusKind.Running) break;
                if (this.InventoryCount >= this.InventoryMax)
                {
                    if (!putFish())
                    {
                        if (settings.Fishing.InventoryFullCmd)
                        {
                            fface.Windower.SendString(settings.Fishing.InventoryFullCmdLine);
                        }
                        setRunningStatus(RunningStatusKind.Stop);
                        setFishingStatus(FishingStatusKind.Normal);
                        setMessage("鞄がいっぱいなので停止");
                        break;
                    }
                }
                //エンチャントアイテム使用
                if (this.RunningStatus != RunningStatusKind.Running) break;
                if (!useEnchantedItem())
                {
                    setRunningStatus(RunningStatusKind.Stop);
                    setFishingStatus(FishingStatusKind.Error);
                    setMessage("エンチャントアイテムが使用できなかったので停止");
                    break;
                }
                //食事
                if (this.RunningStatus != RunningStatusKind.Running) break;
                if (!useFood())
                {
                    setRunningStatus(RunningStatusKind.Stop);
                    setFishingStatus(FishingStatusKind.Error);
                    setMessage("食事アイテムが使用できなかったので停止");
                    break;
                }
                //ヴァナ時間
                if (this.RunningStatus != RunningStatusKind.Running) break;
                while (settings.Fishing.VanaTime &&
                       this.RunningStatus == RunningStatusKind.Running &&
                       !isHourInRange(this.VanaDateTime, settings.Fishing.VanaTimeFrom, settings.Fishing.VanaTimeTo))
                {
                    setFishingStatus(FishingStatusKind.Wait);
                    setMessage(string.Format("{0}時(ヴァナ時間)になるまで待機中", settings.Fishing.VanaTimeFrom));
                    Thread.Sleep(settings.Global.WaitBase);
                }
                setFishingStatus(FishingStatusKind.Normal);
                //地球時間
                if (this.RunningStatus != RunningStatusKind.Running) break;
                while (settings.Fishing.EarthTime &&
                       this.RunningStatus == RunningStatusKind.Running &&
                       !isHourInRange(this.EarthDateTime, settings.Fishing.EarthTimeFrom, settings.Fishing.EarthTimeTo))
                {
                    setFishingStatus(FishingStatusKind.Wait);
                    setMessage(string.Format("{0}時(地球時間)になるまで待機中", settings.Fishing.EarthTimeFrom));
                    Thread.Sleep(settings.Global.WaitBase);
                }
                setFishingStatus(FishingStatusKind.Normal);
                //リキャスト時間待機(初回は判定しない)
                if (!firstTime && settings.Fishing.RecastTime)
                {
                    wait(settings.Fishing.RecastTimeMin, settings.Fishing.RecastTimeMax, "リキャスト待機中:{0:0.0}s");
                }
                //メニュー開いていたら閉じる
                if (this.RunningStatus != RunningStatusKind.Running) break;
                if (!control.CloseDialog())
                {
                    setRunningStatus(RunningStatusKind.Stop);
                    setFishingStatus(FishingStatusKind.Error);
                    setMessage("メニューが閉じられない");
                    break;
                }

                //魚を釣る
                if (this.RunningStatus != RunningStatusKind.Running) break;
                if (!FishingOnce(out fish))
                {
                    //エラー発生時処理
                    setRunningStatus(RunningStatusKind.Stop);
                    setFishingStatus(FishingStatusKind.Error);
                    break;
                }

                firstTime = false;
                Thread.Sleep(settings.Global.WaitBase);
            }
            logger.Output(LogLevelKind.DEBUG, "釣りスレッド終了");
        }
Exemple #11
0
        /// <summary>
        /// 竿を修理する(合成)
        /// </summary>
        /// <param name="iCrystalName">使用クリスタル</param>
        /// <param name="iBreakRod">修理する竿名</param>
        /// <returns>成功した場合Trueを返す</returns>
        private bool RepairRodSynthesis(string iCrystalName, string iBreakRodName)
        {
            //入力チェック
            if (!control.IsExistItem(iCrystalName, FFACETools.InventoryType.Inventory) ||
                !control.IsExistItem(iBreakRodName, FFACETools.InventoryType.Inventory)) return false;
            //メニュー閉じる
            bool maxLoop = true;
            for (int i = 0; i < Constants.MAX_LOOP_COUNT ; i++)
            {
                if (!fface.Menu.IsOpen)
                {
                    maxLoop = false;
                    break;
                }
                fface.Windower.SendKeyPress(FFACETools.KeyCode.EscapeKey);
                Thread.Sleep(100);
            }
            if (maxLoop) return false;
            //アイテムメニュー表示
            maxLoop = true;
            for (int i = 0; i < Constants.MAX_LOOP_COUNT; i++)
            {
                if (fface.Menu.Selection == "アイテム")
                {
                    maxLoop = false;
                    break;
                }
                fface.Windower.SendKey(FFACETools.KeyCode.LeftCtrlKey, true);
                fface.Windower.SendKey(FFACETools.KeyCode.LetterI, true);
                fface.Windower.SendKey(FFACETools.KeyCode.LeftCtrlKey, false);
                fface.Windower.SendKey(FFACETools.KeyCode.LetterI, false);
                Thread.Sleep(100);
            }
            if (maxLoop) return false;
            //クリスタルの選択
            maxLoop = true;
            bool firstTime = true;
            for (int i = 0; i < 200; i++)
            {
                if (FFACE.ParseResources.GetItemName(fface.Item.SelectedItemID) == iCrystalName)
                {
                    maxLoop = false;
                    break;
                }
                else if (firstTime)
                {
                    for (int j = 0; j < 15; j++)
                    {
                        fface.Windower.SendKeyPress(FFACETools.KeyCode.RightArrow);
                        Thread.Sleep(100);
                    }
                    firstTime = false;
                }
                else
                {
                    fface.Windower.SendKeyPress(FFACETools.KeyCode.UpArrow);
                    Thread.Sleep(100);
                }
            }
            if (maxLoop) return false;
            //クリスタルでリターン押下
            maxLoop = true;
            for (int i = 0; i < Constants.MAX_LOOP_COUNT; i++)
            {
                if (fface.Menu.Selection == "アイテム合成")
                {
                    maxLoop = false;
                    break;
                }
                fface.Windower.SendKeyPress(FFACETools.KeyCode.EnterKey);
                Thread.Sleep(100);
            }
            if (maxLoop) return false;
            //アイテム情報取得
            int itemID = FFACE.ParseResources.GetItemID(iBreakRodName);
            int itemIndex = fface.Item.GetFirstIndexByItemID(itemID, FFACETools.InventoryType.Inventory);
            //合成アイテムのセット
            FFACE.TRADEITEM item = new FFACE.TRADEITEM();
            item.ItemID = (ushort)itemID;
            item.Index = (byte)itemIndex;
            item.Count = 1;

            FFACE.NPCTRADEINFO trade = new FFACE.NPCTRADEINFO();
            Array.Resize(ref trade.items, 1);
            trade.items[0] = item;
            fface.Menu.SetCraftItems(trade);
            //中止ボタンへ移動
            maxLoop = true;
            for (int i = 0; i < Constants.MAX_LOOP_COUNT; i++)
            {
                if (fface.Menu.Help == "中止します。")
                {
                    maxLoop = false;
                    break;
                }
                fface.Windower.SendKeyPress(FFACETools.KeyCode.EscapeKey);
                Thread.Sleep(200);
            }
            if (maxLoop) return false;
            //決定ボタンへ移動
            maxLoop = true;
            for (int i = 0; i < Constants.MAX_LOOP_COUNT; i++)
            {
                if (fface.Menu.Help == "この組み合わせでアイテムを合成します。")
                {
                    maxLoop = false;
                    break;
                }
                fface.Windower.SendKeyPress(FFACETools.KeyCode.UpArrow);
                Thread.Sleep(200);
                fface.Windower.SendKeyPress(FFACETools.KeyCode.RightArrow);
                Thread.Sleep(200);
            }
            if (maxLoop) return false;
            fface.Windower.SendKeyPress(FFACETools.KeyCode.EnterKey);
            //合成終了するまで待機
            for (int i = 0; i < Constants.MAX_LOOP_COUNT; i++)
            {
                if (this.PlayerStatus == FFACETools.Status.Synthing) break;
                Thread.Sleep(settings.Global.WaitBase);
            }
            for (int i = 0; i < Constants.MAX_LOOP_COUNT; i++)
            {
                if (this.PlayerStatus != FFACETools.Status.Synthing) break;
                Thread.Sleep(settings.Global.WaitBase);
            }
            Thread.Sleep(settings.Global.WaitChat);
            //合成ログの確認
            logger.Output(LogLevelKind.DEBUG, "竿の修理:ログ確認");
            FFACE.ChatTools.ChatLine cl = new FFACE.ChatTools.ChatLine();
            for (int i = 0; i < Constants.MAX_LOOP_COUNT; i++)
            {
                if(!chat.GetNextChatLine(out cl)) break;
                //チャット区分の取得
                List<string> chatKbnArgs = new List<string>();
                ChatKbnKind chatKbn = getChatKbnFromChatline(cl, out chatKbnArgs);
                logger.Output(LogLevelKind.DEBUG, string.Format("Chat:{0} ChatKbn:{1}", cl.Text, chatKbn));
                //合成失敗
                if (chatKbn == ChatKbnKind.SynthFailure ||
                    chatKbn == ChatKbnKind.SynthNotEnoughSkill)
                {
                    logger.Output(LogLevelKind.DEBUG, "竿の修理:合成失敗");
                    return false;
                }
                //合成成功
                if (chatKbn == ChatKbnKind.SynthSuccess)
                {
                    logger.Output(LogLevelKind.DEBUG, "竿の修理:合成成功");
                    return true;
                }
                Thread.Sleep(settings.Global.WaitChat);
            }
            logger.Output(LogLevelKind.DEBUG, "竿の修理:合成失敗 タイムアウト");
            return false;
        }
Exemple #12
0
        /// <summary>
        /// 魚を1回釣る
        /// </summary>
        /// <param name="oFish"></param>
        /// <param name="oMessage"></param>
        /// <returns></returns>
        private bool FishingOnce(out FishHistoryDBFishModel oFish)
        {
            //戻り値初期化
            oFish = new FishHistoryDBFishModel();
            oFish.FishName = string.Empty;
            oFish.FishCount = 0;
            oFish.ZoneName = this.ZoneName;
            oFish.RodName = this.RodName;
            oFish.BaitName = this.BaitName;
            oFish.ID1 = 0;
            oFish.ID2 = 0;
            oFish.ID3 = 0;
            oFish.ID4 = 0;
            oFish.Critical = false;
            oFish.ItemType = FishDBItemTypeKind.Unknown;
            oFish.FishType = FishDBFishTypeKind.Unknown;
            oFish.Result = FishResultStatusKind.NoBite;
            oFish.EarthTime = this.EarthDateTime.ToString("yyyy/MM/dd HH:mm:ss");
            oFish.VanaTime = this.VanaDateTimeYmdhms;
            oFish.VanaWeekDay = this.DayType;
            oFish.MoonPhase = this.MoonPhase;
            oFish.X = (float)Math.Round(this.Position.X, 1, MidpointRounding.AwayFromZero);
            oFish.Y = (float)Math.Round(this.Position.Y, 1, MidpointRounding.AwayFromZero);
            oFish.Z = (float)Math.Round(this.Position.Z, 1, MidpointRounding.AwayFromZero);
            oFish.H = (float)Math.Round(this.Position.H, 1, MidpointRounding.AwayFromZero);
            oFish.Skill = this.FishingSkill;
            oFish.SerpentRumors = this.HasSerpentRumors;
            oFish.AnglersAlmanac = this.HasAnglersAlmanac;
            oFish.Mooching = this.HasMooching;
            oFish.FrogFishing = this.HasFrogFishing;

            bool fishedFlg = false;

            setFishingStatus(FishingStatusKind.Normal);
            setMessage(string.Format("キャスト中:{0}x{1}", this.RodNameWithRemain, this.BaitNameWithRemain));

            //キャスト
            while (this.RunningStatus == RunningStatusKind.Running && fface.Player.Status != FFACETools.Status.Fishing)
            {
                fface.Windower.SendString("/fish");
                Thread.Sleep(2000);//wait

                FFACE.ChatTools.ChatLine cl = new FFACE.ChatTools.ChatLine();
                while (chat.GetNextChatLine(out cl))
                {
                    //チャット区分の取得
                    List<string> chatKbnArgs = new List<string>();
                    ChatKbnKind chatKbn = getChatKbnFromChatline(cl, out chatKbnArgs);
                    logger.Output(LogLevelKind.DEBUG, string.Format("Chat:{0} ChatKbn:{1}", cl.Text, chatKbn));
                    //エラーチェック
                    if (chatKbn == ChatKbnKind.CanNotFishing)
                    {
                        setFishingStatus(FishingStatusKind.Error);
                        setMessage("釣りができない場所だったので停止");
                        return false;
                    }
                    else if (chatKbn == ChatKbnKind.NotEquipRod)
                    {
                        setFishingStatus(FishingStatusKind.Error);
                        setMessage("竿を装備していないので停止");
                        return false;
                    }
                    else if (chatKbn == ChatKbnKind.NotEquipBait)
                    {
                        setFishingStatus(FishingStatusKind.Error);
                        setMessage("エサを装備していないので停止");
                        return false;
                    }
                    else if (lastZoneName.Length > 0 && lastZoneName != this.ZoneName)//エリア切り替わり感知
                    {
                        setFishingStatus(FishingStatusKind.Error);
                        setMessage("エリアが切り替わったので停止");
                        return false;
                    }
                    else if (interrupt.ChatReceive) //チャット感知
                    {
                        while (this.PlayerStatus != FFACETools.Status.Standing)
                        {
                            fface.Windower.SendKeyPress(FFACETools.KeyCode.EscapeKey);
                            Thread.Sleep(settings.Global.WaitBase);
                        }
                        return true;
                    }
                    else if (interrupt.EnemyAttack) //敵の攻撃感知
                    {
                        return true;
                    }
                }
            }
            this.lastRodName = this.RodName;
            this.lastBaitName = this.BaitName;
            this.lastZoneName = this.ZoneName;
            while (this.RunningStatus == RunningStatusKind.Running)
            {
                FFACETools.FFACE.ChatTools.ChatLine cl = new FFACE.ChatTools.ChatLine();
                //エリア切り替わり感知
                if (lastZoneName.Length > 0 && lastZoneName != this.ZoneName)
                {
                    setFishingStatus(FishingStatusKind.Error);
                    setMessage("エリアが切り替わったので停止");
                    return false;
                }
                while (chat.GetNextChatLine(out cl))
                {
                    //チャット区分の取得
                    List<string> chatKbnArgs = new List<string>();
                    ChatKbnKind chatKbn = getChatKbnFromChatline(cl, out chatKbnArgs);
                    logger.Output(LogLevelKind.DEBUG, string.Format("Chat:{0} ChatKbn:{1}", cl.Text, chatKbn));

                    if (chatKbn == ChatKbnKind.BaitSmallFish || chatKbn == ChatKbnKind.BaitLargeFish ||
                        chatKbn == ChatKbnKind.BaitItem || chatKbn == ChatKbnKind.BaitMonster)//魚がかかった
                    {
                        //プレイヤステータスがFishBiteになるまで待つ
                        while (this.PlayerStatus != FFACETools.Status.FishBite)
                        {
                            Thread.Sleep(settings.Global.WaitBase);
                        }
                        Thread.Sleep(500);
                        //IDの設定
                        oFish.ID1 = fface.Fish.ID.ID1;
                        oFish.ID2 = fface.Fish.ID.ID2;
                        oFish.ID3 = fface.Fish.ID.ID3;
                        oFish.ID4 = fface.Fish.ID.ID4;
                        //魚名称・タイプの設定
                        FishDBFishModel fish = FishDB.SelectFishFromIDZone(oFish.RodName, oFish.ID1, oFish.ID2, oFish.ID3, oFish.ID4, oFish.ZoneName, false);
                        if (!string.IsNullOrEmpty(fish.FishName))
                        {
                            oFish.FishName = fish.FishName;
                            oFish.FishType = fish.FishType;
                            oFish.FishCount = fish.GetId(oFish.ID1, oFish.ID2, oFish.ID3, oFish.ID4).Count;
                            oFish.Critical = fish.GetId(oFish.ID1, oFish.ID2, oFish.ID3, oFish.ID4).Critical;
                            oFish.ItemType = fish.GetId(oFish.ID1, oFish.ID2, oFish.ID3, oFish.ID4).ItemType;
                        }
                        else
                        {
                            oFish.FishType = getTmpFishTypeFromChat(cl.Text);
                            oFish.FishName = FishDB.GetTmpFishNameFromFishType(oFish.FishType, oFish.ID1, oFish.ID2, oFish.ID3, oFish.ID4);
                        }
                        setMessage(string.Format("格闘中:{0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType)));
                        logger.Output(LogLevelKind.INFO, string.Format("魚ID:{0:000}-{1:000}-{2:000}-{3:000} 魚タイプ:{4} アイテムタイプ:{5}", oFish.ID1, oFish.ID2, oFish.ID3, oFish.ID4, oFish.FishType, oFish.ItemType));
                        //日時の設定
                        oFish.EarthTime = this.EarthDateTime.ToString("yyyy/MM/dd HH:mm:ss");
                        oFish.VanaTime = this.VanaDateTimeYmdhms;
                        oFish.VanaWeekDay = this.DayType;
                        oFish.MoonPhase = this.MoonPhase;
                        //HP0の設定
                        int waitHP0 = MiscTool.GetRandomNumber(settings.Fishing.HP0Min, settings.Fishing.HP0Max);
                        //反応時間待機
                        if (settings.Fishing.ReactionTime && !settings.Fishing.WaitTimeout)
                        {
                            wait(settings.Fishing.ReactionTimeMin, settings.Fishing.ReactionTimeMax, "反応待機中:{0:0.0}s " + GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType));
                        }
                        else
                        {
                            //HP0になった瞬間釣り上げると、HP残ったように表示されてしまうので、ウェイトを入れる
                            Thread.Sleep(settings.Global.WaitChat); //wait
                        }
                        //リリース判定
                        if (!isWantedFish(oFish.RodName, oFish.ID1, oFish.ID2, oFish.ID3, oFish.ID4, oFish.ZoneName, oFish.FishType))
                        {
                            //リリースする
                            logger.Output(LogLevelKind.DEBUG, string.Format("リリースする {0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType)));
                            while (this.PlayerStatus == FFACETools.Status.FishBite)
                            {
                                fface.Windower.SendKeyPress(FFACETools.KeyCode.EscapeKey);
                                Thread.Sleep(settings.Global.WaitBase);
                            }
                            continue;
                        }
                        setMessage(string.Format("格闘中:{0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType)));
                        //釣り格闘

                        while (fface.Fish.HPCurrent > 0 && fface.Player.Status == FFACETools.Status.FishBite)
                        {
                            //強制HP0
                            if (settings.Fishing.HP0)
                            {
                                if (isExecHp0(DateTime.Parse(oFish.EarthTime), waitHP0))
                                {
                                    logger.Output(LogLevelKind.INFO,"制限時間を過ぎたので、魚のHPを強制的にゼロにします");
                                    fface.Fish.SetHP(0);
                                    Thread.Sleep(1000);
                                }
                            }
                            //格闘
                            fface.Fish.FightFish();
                            Thread.Sleep(settings.Global.WaitBase);
                        }
                        //HP0になった瞬間に釣り上げるとFFの画面上ではHPが残ったままになるのでウェイト
                        Thread.Sleep(500);
                        //チャット処理
                        //while(chat.GetNextChatLine(out cl))
                        //{
                        //    ChatKbnKind fightingChatKbn = getChatKbnFromChatline(cl, out chatKbnArgs, ref oChatReceive, ref oEnemyAttack, ref oSneakWarning, ref oShipWarning);
                        //    logger.Output(LogLevelKind.DEBUG, string.Format("Chat:{0} ChatKbn:{1}", cl.Text, fightingChatKbn));
                        //    if (fightingChatKbn == ChatKbnKind.BaitCritical)//クリティカル
                        //    {
                        //        oFish.Critical = true;
                        //    }
                        //}
                        //時間切れのログが表示されるまで待機
                        if (settings.Fishing.WaitTimeout)
                        {
                            logger.Output(LogLevelKind.DEBUG, "時間切れ待機中");
                            setMessage(string.Format("時間切れ待機中:{0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType)));
                            int startIndex = chat.CurrentIndex;
                            bool timeUpOkFlg = false;
                            for (int i = 0; i < 1200; i++)//2分間チャットを監視
                            {
                                if (timeUpOkFlg) break;
                                //釣りが中止された場合、待機処理を中止する
                                if (this.PlayerStatus != FFACETools.Status.FishBite) break;
                                //チャット監視
                                var cl2 = chat.GetChatLine(startIndex, false);
                                foreach (var c in cl2)
                                {
                                    List<string> chatKbnTimeoutArgs = new List<string>();
                                    ChatKbnKind chatKbnTimeout = getChatKbnFromChatline(c, out chatKbnTimeoutArgs);
                                    //logger.Output(LogLevelKind.DEBUG, string.Format("Chat:{0} ChatKbn:{1}", c.Text, chatKbn));
                                    if (chatKbnTimeout == ChatKbnKind.Timeout ||
                                        chatKbnTimeout == ChatKbnKind.NoCatch)
                                    {
                                        //反応時間待機
                                        if (settings.Fishing.ReactionTime)
                                        {
                                            float reactionTimeFrom = (settings.Fishing.ReactionTimeMin <= 4.0f) ? settings.Fishing.ReactionTimeMin : 4.0f;
                                            float reactionTimeTo = (settings.Fishing.ReactionTimeMax <= 4.0f) ? settings.Fishing.ReactionTimeMax : 4.0f;
                                            wait(reactionTimeFrom, reactionTimeTo, "反応待機中:{0:0.0}s " + GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType));
                                        }
                                        timeUpOkFlg = true;
                                        break;
                                    }
                                    else if ( chatKbnTimeout == ChatKbnKind.CatchSingle ||  //{0}は(.*)を手にいれた!"
                                              chatKbnTimeout == ChatKbnKind.CatchMultiple ||//{0}は(.*)を([0-9]*)尾手にいれた!"
                                              chatKbnTimeout == ChatKbnKind.CatchMonster || //{0}はモンスターを釣り上げた!"
                                              chatKbnTimeout == ChatKbnKind.CatchKeyItem || //だいじなもの:(.*)を手にいれた!"
                                              chatKbnTimeout == ChatKbnKind.CatchTempItem ||//テンポラリアイテム:(.*)を手にいれた!"
                                              chatKbnTimeout == ChatKbnKind.LineBreak ||    //釣り糸が切れてしまった。"
                                              chatKbnTimeout == ChatKbnKind.RodBreak ||     //釣り竿が折れてしまった。"
                                              chatKbnTimeout == ChatKbnKind.Timeout ||      //そろそろ逃げられそうだ……!"
                                              chatKbnTimeout == ChatKbnKind.InventoryFull ||//{0}は見事に(.*)を釣り上げたが、これ以上持てないので、仕方なくリリースした。"
                                              chatKbnTimeout == ChatKbnKind.NoBait ||       //何も釣れなかった。"
                                              chatKbnTimeout == ChatKbnKind.Release ||      //あきらめて仕掛けをたぐり寄せた。"
                                              chatKbnTimeout == ChatKbnKind.NoCatch)        //獲物に逃げられてしまった。"
                                    {
                                        timeUpOkFlg = true;
                                        break;
                                    }
                                }
                                Thread.Sleep(100);//wait
                            }
                        }
                        //釣り上げる
                        //プレイヤステータスがFishBite以外になるまで待つ
                        while (this.PlayerStatus == FFACETools.Status.FishBite)
                        {
                            fishedFlg = true;
                            fface.Windower.SendKeyPress(FFACETools.KeyCode.EnterKey);
                            Thread.Sleep(settings.Global.WaitBase);
                        }
                    }
                    else if (chatKbn == ChatKbnKind.CatchSingle)//釣れた
                    {
                        if (!fishedFlg) continue;//釣り上げていない場合は登録しない
                        oFish.FishName = chatKbnArgs[0];
                        oFish.FishCount = 1;
                        oFish.ItemType = FishDBItemTypeKind.Common;
                        oFish.Result = FishResultStatusKind.Catch;
                        //データベースへの登録
                        if (!putDatabase(oFish)) return false;
                        //連続釣果無しカウントクリア
                        noCatchCount = 0;
                        setMessage(string.Format("釣果:{0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType)));
                        //イベント発生
                        EventFished(oFish.Result);
                        //プレイヤステータスがStandingになるまで待つ
                        waitChangePlayerStatus(FFACETools.Status.Standing);
                        return true;
                    }
                    else if (chatKbn == ChatKbnKind.CatchMultiple)//複数釣れた
                    {
                        if (!fishedFlg) continue;//釣り上げていない場合は登録しない
                        oFish.FishName = chatKbnArgs[0];
                        oFish.FishCount = int.Parse(chatKbnArgs[1]);
                        oFish.ItemType = FishDBItemTypeKind.Common;
                        oFish.Result = FishResultStatusKind.Catch;
                        //データベースへの登録
                        if (!putDatabase(oFish)) return false;
                        //連続釣果無しカウントクリア
                        noCatchCount = 0;
                        setMessage(string.Format("釣果:{0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType)));
                        //イベント発生
                        EventFished(oFish.Result);
                        //プレイヤステータスがStandingになるまで待つ
                        waitChangePlayerStatus(FFACETools.Status.Standing);
                        return true;
                    }
                    else if (chatKbn == ChatKbnKind.CatchMonster)//モンスター釣れた
                    {
                        //oFish.FishName = chatKbnArgs[0];
                        oFish.FishCount = 1;
                        oFish.Result = FishResultStatusKind.Catch;
                        //データベースへの登録
                        if (!putDatabase(oFish)) return false;
                        //連続釣果無しカウントクリア
                        noCatchCount = 0;
                        setMessage(string.Format("釣果:{0}", oFish.FishName));
                        //イベント発生
                        EventFished(oFish.Result);
                        //プレイヤステータスがStandingになるまで待つ
                        waitChangePlayerStatus(FFACETools.Status.Standing);
                        return true;
                    }
                    else if (chatKbn == ChatKbnKind.CatchTempItem)//テンポラリアイテム釣れた
                    {
                        if (!fishedFlg) continue;//釣り上げていない場合は登録しない
                        oFish.FishName = chatKbnArgs[0];
                        oFish.FishCount = 1;
                        oFish.ItemType = FishDBItemTypeKind.Temporary;
                        oFish.Result = FishResultStatusKind.Catch;
                        //データベースへの登録
                        if (!putDatabase(oFish)) return false;
                        //連続釣果無しカウントクリア
                        noCatchCount = 0;
                        setMessage(string.Format("釣果:{0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType)));
                        //イベント発生
                        EventFished(oFish.Result);
                        //プレイヤステータスがStandingになるまで待つ
                        waitChangePlayerStatus(FFACETools.Status.Standing);
                        return true;
                    }
                    else if (chatKbn == ChatKbnKind.CatchKeyItem)//だいじなもの釣れた
                    {
                        if (!fishedFlg) continue;//釣り上げていない場合は登録しない
                        oFish.FishName = chatKbnArgs[0];
                        oFish.FishCount = 1;
                        oFish.ItemType = FishDBItemTypeKind.Key;
                        oFish.Result = FishResultStatusKind.Catch;
                        //データベースへの登録
                        if (!putDatabase(oFish)) return false;
                        //連続釣果無しカウントクリア
                        noCatchCount = 0;
                        setMessage(string.Format("釣果:{0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType)));
                        //イベント発生
                        EventFished(oFish.Result);
                        //プレイヤステータスがStandingになるまで待つ
                        waitChangePlayerStatus(FFACETools.Status.Standing);
                        return true;
                    }
                    else if (chatKbn == ChatKbnKind.InventoryFull)//鞄いっぱい
                    {
                        oFish.FishName = chatKbnArgs[0];
                        oFish.FishCount = 1;
                        oFish.Result = FishResultStatusKind.Release;
                        //データベースへの登録
                        if (!putDatabase(oFish)) return false;
                        //連続釣果無しカウントクリア
                        noCatchCount = 0;
                        setMessage(string.Format("釣果:鞄いっぱいでリリース {0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType)));
                        //イベント発生
                        EventFished(oFish.Result);
                        //プレイヤステータスがStandingになるまで待つ
                        waitChangePlayerStatus(FFACETools.Status.Standing);
                        return true;
                    }
                    else if (chatKbn == ChatKbnKind.NoBait)//何も釣れなかった
                    {
                        oFish.Result = FishResultStatusKind.NoBite;
                        //データベースへの登録
                        if (!putDatabase(oFish)) return false;
                        //連続釣果無しカウントアップ
                        noCatchCount++;
                        setMessage(string.Format("釣果:何も釣れなかった {0}連続", noCatchCount));
                        //イベント発生
                        EventFished(oFish.Result);
                        //プレイヤステータスがStandingになるまで待つ
                        waitChangePlayerStatus(FFACETools.Status.Standing);
                        return true;
                    }
                    else if (chatKbn == ChatKbnKind.Release)//リリース
                    {
                        oFish.Result = FishResultStatusKind.Release;
                        //データベースへの登録
                        if (!putDatabase(oFish)) return false;
                        //連続釣果無しカウントクリア
                        noCatchCount = 0;
                        setMessage(string.Format("釣果:リリース {0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType)));
                        //イベント発生
                        EventFished(oFish.Result);
                        //プレイヤステータスがStandingになるまで待つ
                        waitChangePlayerStatus(FFACETools.Status.Standing);
                        return true;
                    }
                    else if (chatKbn == ChatKbnKind.NoCatch)//逃げられた
                    {
                        oFish.Result = FishResultStatusKind.NoCatch;
                        //データベースへの登録
                        if (!putDatabase(oFish)) return false;
                        //連続釣果無しカウントクリア
                        noCatchCount = 0;
                        setMessage(string.Format("釣果:逃げられた {0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType)));
                        //イベント発生
                        EventFished(oFish.Result);
                        //プレイヤステータスがStandingになるまで待つ
                        waitChangePlayerStatus(FFACETools.Status.Standing);
                        return true;
                    }
                    else if (chatKbn == ChatKbnKind.LineBreak)//糸切れ
                    {
                        oFish.Result = FishResultStatusKind.LineBreak;
                        //データベースへの登録
                        if (!putDatabase(oFish)) return false;
                        //連続釣果無しカウントクリア
                        noCatchCount = 0;
                        setMessage(string.Format("釣果:糸切れ {0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType)));
                        //イベント発生
                        EventFished(oFish.Result);
                        //プレイヤステータスがStandingになるまで待つ
                        waitChangePlayerStatus(FFACETools.Status.Standing);
                        return true;
                    }
                    else if (chatKbn == ChatKbnKind.RodBreak)//竿折れ
                    {
                        oFish.Result = FishResultStatusKind.RodBreak;
                        //データベースへの登録
                        if (!putDatabase(oFish)) return false;
                        //連続釣果無しカウントクリア
                        noCatchCount = 0;
                        setMessage(string.Format("釣果:竿折れ {0}", GetViewFishName(oFish.FishName, oFish.FishType, oFish.FishCount, oFish.Critical, oFish.ItemType)));
                        //イベント発生
                        EventFished(oFish.Result);
                        //プレイヤステータスがStandingになるまで待つ
                        waitChangePlayerStatus(FFACETools.Status.Standing);
                        return true;
                    }
                    else if (chatKbn == ChatKbnKind.BaitCritical)//クリティカル
                    {
                        oFish.Critical = true;
                    }
                    else if (interrupt.ChatReceive) //チャット感知
                    {
                        //プレイヤステータスがStandingになるまで待つ
                        while (this.PlayerStatus != FFACETools.Status.Standing)
                        {
                            fface.Windower.SendKeyPress(FFACETools.KeyCode.EscapeKey);
                            Thread.Sleep(settings.Global.WaitBase);
                        }
                        return true;
                    }
                    else if (interrupt.EnemyAttack) //敵の攻撃感知
                    {
                        //プレイヤステータスがStandingになるまで待つ
                        while (this.PlayerStatus != FFACETools.Status.Standing)
                        {
                            fface.Windower.SendKeyPress(FFACETools.KeyCode.EscapeKey);
                            Thread.Sleep(settings.Global.WaitBase);
                        }
                        return true;
                    }
                }
                Thread.Sleep(settings.Global.WaitChat);
            }

            return true;
        }
Exemple #13
0
 /// <summary>
 /// アイテムの使用
 /// </summary>
 /// <param name="iItemname">アイテム名</param>
 /// <returns></returns>
 public bool useItem(string iItemname)
 {
     fface.Windower.SendString(string.Format("/item {0} <me>",iItemname));
     FFACE.ChatTools.ChatLine cl = new FFACE.ChatTools.ChatLine();
     for (int i = 0; i < Constants.MAX_LOOP_COUNT; i++)
     {
         chat.GetNextChatLine(out cl);
         //チャット区分の取得
         List<string> chatKbnArgs = new List<string>();
         ChatKbnKind chatKbn = getChatKbnFromChatline(cl, out chatKbnArgs);
         logger.Output(LogLevelKind.DEBUG, string.Format("Chat:{0} ChatKbn:{1}", cl.Text, chatKbn));
         //失敗
         if (chatKbn == ChatKbnKind.UseItemFailure)
         {
             return false;
         }
         //成功
         if (chatKbn == ChatKbnKind.UseItemSuccess1 ||
             chatKbn == ChatKbnKind.UseItemSuccess2)
         {
             Thread.Sleep(5000);
             return true;
         }
         Thread.Sleep(settings.Global.WaitBase);
     }
     return false;
 }