예제 #1
0
        public void RepairAndVendor()
        {
            if (MerchantFrame.IsOpen)
            {
                MerchantFrame = MerchantFrame.Instance;

                if (MerchantFrame.CanRepair && MerchantFrame.TotalRepairCost < ObjectManager.Player.Money)
                {
                    MerchantFrame.RepairAll();
                }

                var item = Inventory.GetAllItems().Where(x =>
                                                         (GrinderDefault.KeepGreens ? !x.Quality.Equals(Enums.ItemQuality.Uncommon) : true) &&
                                                         (GrinderDefault.KeepBlues ? !x.Quality.Equals(Enums.ItemQuality.Rare) : true) &&
                                                         (GrinderDefault.KeepPurples ? !x.Quality.Equals(Enums.ItemQuality.Epic) : true) &&
                                                         !GrinderDefault.ProtectedItems.Contains(x.Name) && !x.Info.SellPrice.Equals(0)).FirstOrDefault();

                if (item != null)
                {
                    MerchantFrame.VendorByGuid(item.Guid);
                }
                else
                {
                    Vendoring = false;
                }
            }
        }
예제 #2
0
        public override bool Do()
        {
            Helpers.Mount.Dismount();

            while (true)
            {
                Functions.Interact(npc);
                Thread.Sleep(2000);

                if (GossipFrame.IsVisible())
                {
                    PPather.WriteLine("Vendor: Got a gossip frame");
                    if (!GossipFrame.ClickOptionText("browse your"))
                    {
                        return(false);
                    }
                    Thread.Sleep(2000);
                }

                if (MerchantFrame.IsVisible())
                {
                    GMerchant Merchant = new GMerchant();

                    BagManager bm = new BagManager();

                    GItem[] items = bm.GetAllItems();
                    foreach (GItem item in items)
                    {
                        if (ShouldSell(item))
                        {
                            bm.ClickItem(item, true);
                            Thread.Sleep(500);                             // extra delay
                        }
                    }

                    if (Merchant.IsRepairEnabled)                       // Might as well fix it up while we're here.
                    {
                        PPather.WriteLine("Vendor: Repairing");
                        Functions.ClickRepairButton(Merchant);
                    }

                    Functions.Closeit(Merchant);
                }
                else
                {
                    GContext.Main.SendKey("Common.Escape");                     // Close whatever frame popped up
                }
                return(true);
            }
        }
예제 #3
0
        public override bool Do()
        {
            Helpers.Mount.Dismount();

            while (true)
            {
                Functions.Interact(npc);
                Thread.Sleep(1000);

                if (GossipFrame.IsVisible())
                {
                    //PPather.WriteLine("Buy: Got a gossip frame");
                    if (GossipFrame.ClickOptionText("browse your") ||
                        GossipFrame.ClickOptionText("Sid") ||
                        GossipFrame.ClickOptionText("What do you have"))
                    {
                        Thread.Sleep(2000);                         // Lag
                    }
                }

                if (MerchantFrame.IsVisible())
                {
                    GMerchant Merchant = new GMerchant();

                    string[] toBuy;
                    int[]    toBuyQuantities;
                    GetShoppingList(out toBuy, out toBuyQuantities);

                    GSpellTimer sanity = new GSpellTimer(5000);

                    for (int i = 0; i < toBuy.Length; i++)
                    {
                        sanity.Reset();

                        int lastCount = Inventory.GetItemCount(toBuy[i], false);
                        int curCount  = lastCount;

                        do
                        {
                            GContext.Main.EnableCursorHook();
                            if (!Merchant.BuyOnAnyPage(toBuy[i]))
                            {
                                PPather.WriteLine("!Info:Buy: Unable to buy [" + toBuy[i] + "], skipping");
                                break;
                            }
                            Thread.Sleep(2000);

                            curCount = Inventory.GetItemCount(toBuy[i], false);

                            // inventory went up so reset the timer
                            if (curCount > lastCount)
                            {
                                sanity.Reset();
                            }

                            // PPather.WriteLine(string.Format("  {0} -> {1} of {2}", lastCount, curCount, toBuyQuantities[i]));
                            lastCount = curCount;

                            if (sanity.IsReady)
                            {
                                PPather.WriteLine("!Info:Buy: Waiting too long buying [" + toBuy[i] + "], skipping");
                                break;
                            }
                        } while (curCount < toBuyQuantities[i]);
                        GContext.Main.DisableCursorHook();
                    }

                    if (Merchant.IsRepairEnabled)                       // Might as well fix it up while we're here.
                    {
                        PPather.WriteLine("Buy: Repairing");
                        Functions.ClickRepairButton(Merchant);
                    }

                    Functions.Closeit(Merchant);
                }
                else
                {
                    PPather.WriteLine("!Info: Never got merchant frame");
                    GContext.Main.SendKey("Common.Escape");                     // Close whatever frame popped up
                }
                return(true);
            }
        }
예제 #4
0
        private void MERCHANT_HANDLE(MerchantState parState)
        {
            Console.WriteLine("Handling merchant");
            switch (parState)
            {
            case MerchantState.SHOW:
                if (thrMerchUpdate != null && thrMerchUpdate.Status == TaskStatus.Running)
                {
                    Console.WriteLine("Task is stil running. Returning here");
                    return;
                }
                Console.WriteLine("Creating the action");
                Action tmpAction = () =>
                {
                    thrMerchUpdate = new Task(() =>
                    {
                        Console.WriteLine("Checking Vendor Guid");
                        if (ObjectManager.Instance.Player.VendorGuid == 0)
                        {
                            Console.WriteLine("Vendor Guid is 0 ... returning");
                            return;
                        }
                        if (MerchantFrame.IsOpen)
                        {
                            Console.WriteLine("Merchant frame marked as open. Destroying the old object and recreating");
                            MerchantFrame.Destroy();
                        }
                        Console.WriteLine("Creating the new frame");
                        MerchantFrame.Create();
                    });
                    thrMerchUpdate.ContinueWith(task =>
                    {
                        Console.WriteLine("Finalising merchant event");
                        if (!MerchantFrame.IsOpen)
                        {
                            return;
                        }
#if OUTPUT
                        Console.WriteLine("MERCHANT PARSED");
                        Console.WriteLine($"Total items: {MerchantFrame.Instance.Items.Count}");
                        foreach (var v in MerchantFrame.Instance.Items)
                        {
                            Console.WriteLine("\tItem" + v.VendorItemNumber + ": " + v.Name + "\n\tCan Use: " +
                                              v.CanUse + "\n\tPrice: " + v.Price + "\n\tQuantity: " + v.Quantity +
                                              "\n\tAvaible: " + v.NumAvaible + "\n");
                        }
                        Console.WriteLine();
#endif
                        Console.WriteLine("Invoking OnMerchantShow");
                        OnMerchantShow?.Invoke(this, new EventArgs());
                    });
                    thrMerchUpdate.Start();
                };
                Console.WriteLine("Running the action from EndScene");
                DirectX.Instance.Execute(tmpAction, 200);
                break;

            case MerchantState.CLOSE:
                MerchantFrame.Destroy();
                thrMerchUpdate = null;
                OnMerchantClosed?.Invoke(this, new EventArgs());
                break;
            }
        }