Ejemplo n.º 1
0
 public static void Closeit(GMerchant close)
 {
     if (close != null && close.IsRepairVisible)
     {
         GContext.Main.EnableCursorHook();
         close.Close();
         GContext.Main.DisableCursorHook();
     }
 }
Ejemplo n.º 2
0
 public static void ClickRepairButton(GMerchant repr)
 {
     if (repr != null && repr.IsRepairVisible)
     {
         GContext.Main.EnableCursorHook();
         repr.ClickRepairButton();
         GContext.Main.DisableCursorHook();
     }
 }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
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);
            }
        }