FFACETools Structure for setTradeItems
Ejemplo n.º 1
0
        static void synth()
        {
            // WriteLine("example: mitaru -synth \"Ice Crystal,Grape Juice,Holy Water:1,White Honey:1\"");
            FFACE.TimerTools.VanaTime time = fface.Timer.GetVanaTime();
            Console.WriteLine("dayArgument=" + dayArgument.ToString());
                while (!match(dayArgument.ToString(),fface.Timer.GetVanaTime().ToString()) && !terminated)
                {
                    Console.WriteLine(fface.Timer.GetVanaTime().ToString());
                    Thread.Sleep(3000);
                }

            while (!terminated)
            {
                WriteLine("Begin Synth");
                while (fface.Menu.IsOpen && loop && !match("Synthesis",fface.Menu.Selection))
                {
                    KeyPress(KeyCode.EscapeKey);
                }
                WriteLine("Waiting for standup");

                WaitStatus("Standing");

                string recipe = "Ice Crystal,Grape Juice,Holy Water:1,White Honey:1";
                recipe = synthArgument;
                string[] ingredients = recipe.Split(',');
                try
                {
                    ingredients = System.IO.File.ReadAllLines(synthArgument);
                }
                catch (Exception e)
                {
                }

                windower.SendKey(KeyCode.LeftCtrlKey, true);
                windower.SendKeyPress(KeyCode.LetterI);
                windower.SendKey(KeyCode.LeftCtrlKey, false);

                SelectItem(ingredients[0]);
                if (terminated)
                    return;
                WaitMenu("Select the items");

                KeyPress(KeyCode.RightArrow); Thread.Sleep(10);
                KeyPress(KeyCode.RightArrow); Thread.Sleep(10);
                KeyPress(KeyCode.RightArrow); Thread.Sleep(10);
                KeyPress(KeyCode.RightArrow); Thread.Sleep(10);

                FFACE.NPCTRADEINFO npcTradeInfo = new FFACE.NPCTRADEINFO();
                npcTradeInfo.items = new FFACE.TRADEITEM[ingredients.Length-1];
                bool[] used = new bool[80];
                for (int i = 1; i < ingredients.Length; i++)
                {
                    string[] ingredient = ingredients[i].Split(':');
                    int count = 1;
                    ingredient[0] = ingredient[0].Trim();
                    if (ingredient.Length > 1)
                        count = Int32.Parse(ingredient[1]);
                    bool found = false;
                    for (int j = 0; j < 80; j++)
                    {
                        FFACE.ItemTools.InventoryItem item = null;
                        try
                        {
                            item = fface.Item.GetInventoryItem(j);

                            //WriteLine("item " + j + ": " + item);
                            // WriteLine("ingredient[0]=" + ingredient[0]);
                            //WriteLine("FFACE.ParseResources.GetItemName(item.ID)=" +FFACE.ParseResources.GetItemName(item.ID));
                            if (match(ingredient[0], FFACE.ParseResources.GetItemName(item.ID)) &&
                                (item.Count >= count) && !used[j] && item.Flag != 5)
                            {
                                WriteLine("\t" + ingredient[0]);
                                //WriteLine("item.Flag=" + item.Flag);
                                //WriteLine("item.Extra=" + item.Extra);
                                //WriteLine("index=" + item.Index);
                                //WriteLine("used[j]=" + used[j]+",j="+j);
                                //WriteLine("ID="+item.ID);
                                //WriteLine("count=" + count);
                                used[j] = true;
                                npcTradeInfo.items[i - 1].Count = (byte)count;
                                npcTradeInfo.items[i - 1].Index = item.Index;
                                npcTradeInfo.items[i - 1].ItemID = item.ID;

                                //WriteLine("npcTradeInfo=" + npcTradeInfo);
                                found = true;
                                break;
                            }
                        }
                        catch (Exception e)
                        {
                            continue;
                        }
                    }
                    if (!found)
                    {
                        WriteLine(ingredient[0] + " not found");
                        return;
                    }

                }
                fface.Menu.SetCraftItems(npcTradeInfo);
                KeyPress(KeyCode.EnterKey);

                Thread.Sleep(3000);

                while (fface.Player.IsSynthing())
                {
                    Console.Write(".");
                    Thread.Sleep(100);
                }

                if (!loop)
                    break;
            }
        }
Ejemplo n.º 2
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;
        }