예제 #1
0
        public static bool EquipNewBag(GItem Item)
        {
            BagManager bm  = new BagManager();
            GContainer bag = (GContainer)GObjectList.FindObject(Item.GUID);

            if (bag != null)
            {
                bm.ClickItem(Item, true);
                for (int p = 1; p <= 4; p++)
                {
                    if (Popup.IsVisible(p))
                    {
                        String text = Popup.GetText(p);
                        PPather.WriteLine("Inventory: Got a popup ('" + text + "')");
                        if (text.Contains("will bind it to you"))
                        {
                            Popup.ClickButton(p, 1);
                        }
                        else
                        {
                            Popup.ClickButton(p, 2);
                        }
                    }
                }
                bm.CloseAllBags();
                return(true);
            }
            bm.CloseAllBags();
            return(false);
        }
예제 #2
0
        public static bool Equip(EasyItem E, bool EquipBOE)
        {
            PPather.WriteLine(LOG_CATEGORY.INFORMATION, "Equip: Attempting to equip {0}", E.RealName);
            BagManager bm = new BagManager();

            //PPather.WriteLine(String.Format("AutoEquipTask: Equipping {0} (GITem name: {1}", E.RealName, E.GItem.Name));
            if (!bm.ClickItem(E.GItem, true))
            {
                PPather.WriteLine(String.Format("Equip: BagManger failed to click item ({0}). Aborting...", E.RealName));
                GContext.Main.Debug(String.Format("Equip: BagManger failed to click item ({0}). Aborting...", E.RealName));
                return(false);
            }
            Thread.Sleep(1000);
            string BOEButton = "StaticPopup1Button2";

            if (EquipBOE)
            {
                BOEButton = "StaticPopup1Button1";
            }
            GInterfaceObject AcceptBOE = GContext.Main.Interface.GetByName(BOEButton);

            if (AcceptBOE != null && AcceptBOE.IsVisible)
            {
                GContext.Main.EnableCursorHook();
                AcceptBOE.Hover();
                AcceptBOE.ClickMouse(false);
                GContext.Main.DisableCursorHook();
                GContext.Main.ClearTarget();
                if (EquipBOE)
                {
                    PPather.WriteLine("Equip: Accepted BOE for " + E.RealName);
                    GContext.Main.Debug("Equip: Accepted BOE for " + E.RealName);
                    bm.CloseAllBags();
                    bm.UpdateItems();
                    //Character.SetCurrent(E.Item.Slot, E, true);
                    Character.ReplaceCurrentlyEquipped(E);
                    return(true);
                }
                else
                {
                    PPather.WriteLine("Equip: Declined BOE for " + E.RealName);
                    GContext.Main.Debug("Equip: Declined BOE for " + E.RealName);
                    bm.CloseAllBags();
                    bm.UpdateItems();
                    return(false);
                }
            }
            Character.ReplaceCurrentlyEquipped(E);
            bm.UpdateItems();
            bm.CloseAllBags();
            return(true);
        }
예제 #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);
            }
        }
예제 #4
0
 public static bool EquipBetterBag()
 {
     GItem[] Items = GObjectList.GetItems();
     foreach (GItem Item in Items)
     {
         if (Item.Type.ToString() == "Container" && !IsEquippedBag(Item.GUID))
         {
             GContainer bag = (GContainer)GObjectList.FindObject(Item.GUID);
             if (bag != null)
             {
                 long[] AllBags = GPlayerSelf.Me.Bags;
                 for (int i = 0; i < AllBags.Length; i++)
                 {
                     GContainer cbag = (GContainer)GObjectList.FindObject(AllBags[i]);
                     if (cbag != null)
                     {
                         if (cbag.SlotCount < bag.SlotCount && !cbag.Name.ToString().ToLower().Contains("ammo") && !cbag.Name.ToString().ToLower().Contains("quiver"))
                         {
                             GInterfaceObject OldBag = GContext.Main.Interface.GetByName("CharacterBag" + i + "Slot");
                             BagManager       bm     = new BagManager();
                             bm.ClickItem(Item, false);
                             Functions.Click(OldBag, false);
                             for (int p = 1; p <= 4; p++)
                             {
                                 if (Popup.IsVisible(p))
                                 {
                                     String text = Popup.GetText(p);
                                     PPather.WriteLine("Inventory: Got a popup ('" + text + "')");
                                     if (text.Contains("will bind it to you"))
                                     {
                                         Popup.ClickButton(p, 1);
                                     }
                                     else
                                     {
                                         Popup.ClickButton(p, 2);
                                     }
                                 }
                             }
                             return(true);
                         }
                     }
                 }
             }
         }
     }
     return(true);
 }
예제 #5
0
 public void Interact()
 {
     if (isUnit())
     {
         Functions.Interact(unit);
     }
     else if (isNode())
     {
         Functions.Interact(node);
     }
     else //item interaction means click the item
     {
         BagManager bm = new BagManager();
         bm.UpdateItems();
         bm.ClickItem(item, true);
     }
 }
예제 #6
0
        public override bool DoActivity()
        {
            BagManager bm = new BagManager();

            GItem[] items = bm.GetAllItems();
            foreach (GItem item in items)
            {
                if (item.Name == vItemName)
                {
                    PPather.WriteLine("Use item " + item.Name);
                    bm.ClickItem(item, true);
                    Thread.Sleep(vItemDelay);
                    TimesUsed++;
                    return(true);
                }
            }
            bm.CloseAllBags();
            bm.UpdateItems();
            return(true); // done
        }
예제 #7
0
        public static bool EquipBetterBag(GItem Item, string BagSlotName)
        {
            GContainer bag = (GContainer)GObjectList.FindObject(Item.GUID);

            if (bag != null)
            {
                long[] AllBags = GPlayerSelf.Me.Bags;
                for (int i = 0; i < AllBags.Length; i++)
                {
                    GContainer cbag = (GContainer)GObjectList.FindObject(AllBags[i]);
                    if (cbag != null)
                    {
                        GInterfaceObject OldBag = GContext.Main.Interface.GetByName(BagSlotName);
                        BagManager       bm     = new BagManager();
                        bm.ClickItem(Item, false);
                        Functions.Click(OldBag, false);
                        for (int p = 1; p <= 4; p++)
                        {
                            if (Popup.IsVisible(p))
                            {
                                String text = Popup.GetText(p);
                                PPather.WriteLine("Inventory: Got a popup ('" + text + "')");
                                if (text.Contains("will bind it to you"))
                                {
                                    Popup.ClickButton(p, 1);
                                }
                                else
                                {
                                    Popup.ClickButton(p, 2);
                                }
                            }
                        }
                        bm.CloseAllBags();
                        return(true);
                    }
                }
            }
            return(false);
        }
예제 #8
0
 public static bool EquipNewBag()
 {
     if (HasFreeBagSlot())
     {
         GItem[] Items = GObjectList.GetItems();
         foreach (GItem Item in Items)
         {
             if (Item.Type.ToString() == "Container" && !IsEquippedBag(Item.GUID))
             {
                 GContainer bag = (GContainer)GObjectList.FindObject(Item.GUID);
                 if (bag != null)
                 {
                     BagManager bm = new BagManager();
                     bm.ClickItem(Item, true);
                     for (int p = 1; p <= 4; p++)
                     {
                         if (Popup.IsVisible(p))
                         {
                             String text = Popup.GetText(p);
                             PPather.WriteLine("Inventory: Got a popup ('" + text + "')");
                             if (text.Contains("will bind it to you"))
                             {
                                 Popup.ClickButton(p, 1);
                             }
                             else
                             {
                                 Popup.ClickButton(p, 2);
                             }
                         }
                     }
                     bm.CloseAllBags();
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
예제 #9
0
        /// <summary>
        /// Goes through your inventory sending up to 12 items.
        /// </summary>
        /// <returns>The number of sent items. 0 implies no items or an error.</returns>
        private int SendMail()
        {
            bMan.CloseAllBags();            // Make sure for sanity
            Functions.Interact(mailbox);
            Thread.Sleep(2000);             // Accomodate for lag


            if (!MailFrame.IsVisible())
            {
                return(0);
            }
            if (!MailFrame.ClickSendMailTab())
            {
                return(0);
            }
            Thread.Sleep(500);             // Give the frame time to show
            if (!SendMailFrame.IsVisible())
            {
                return(0);
            }

            GItem[] bagitems = bMan.GetAllItems();
            int     citems   = 0;       // Mail frame only allows 12 items to be mailed, so we need to count

            foreach (GItem bagitem in bagitems)
            {
                if (ShouldMail(bagitem) && citems < 12)
                {
                    citems++;
                    PPather.WriteLine(string.Format("Mail: Adding {0} to mail, #{1}", bagitem.Name, citems));
                    bMan.ClickItem(bagitem, true);
                    Thread.Sleep(200);                     // Accomodate for lag
                }
            }

            if (citems > 0)
            {
                int coppers = GPlayerSelf.Me.Coinage;
                int total   = citems * 30;
                if (total > coppers)
                {
                    // Not enough money
                    PPather.WriteLine("!Warning:Mail: Not enough money to mail items");
                    return(0);
                }
                SendMailFrame.TypeTo(to);
                Thread.Sleep(200);

                if (SendMailFrame.CanSend())
                {
                    SendMailFrame.ClickSend();
                    Thread.Sleep(2000);                     // Make sure if finishes sending.
                    PPather.WriteLine("Mail: Items have been mailed");
                }
                else
                {
                    PPather.WriteLine("Mail: Unable to send. Button not accessible");
                    citems = 0;
                }
            }

            SendMailFrame.Close();
            bMan.CloseAllBags();
            return(citems);
        }
예제 #10
0
        public static void CheckForScrollsAndElixirs()
        {
            /* check inventory for srolls and elixirs */
            Regex elixirPattern = new Regex("Elixir of.*");
            Regex scrollPattern = new Regex("Scroll of.*");

            foreach (KeyValuePair <long, EasyItem> e in Character.InventoryItems)
            {
                int myLevel   = GPlayerSelf.Me.Level;
                int itemLevel = Convert.ToInt32(e.Value.Item.Required);
                //PPather.WriteLine("AutoEquip: myLevel = {0} , itemLevel = {1} [{2}]", myLevel, itemLevel, e.Value.Item.Name);
                if (itemLevel <= myLevel)
                {
                    Match m = scrollPattern.Match(e.Value.Item.Name);
                    if (m.Success)
                    {
                        BagManager bm       = new BagManager();
                        GItem[]    bagItems = bm.GetAllItems();
                        foreach (GItem bagItem in bagItems)
                        {
                            if (bagItem.Name.Equals(e.Value.Item.Name))
                            {
                                PPather.WriteLine("Inventory: using " + bagItem.Name);
                                GContext.Main.Debug("Inventory: using " + bagItem.Name);
                                if (!bm.ClickItem(bagItem, true))
                                {
                                    PPather.WriteLine("Inventory: BagManger failed to click the item. Aborting...");
                                    break;
                                }
                                Thread.Sleep(500);
                                break;
                            }
                        }
                        bm.CloseAllBags();
                        bm.UpdateItems();
                        continue;
                    }
                    m = elixirPattern.Match(e.Value.Item.Name);
                    if (m.Success)
                    {
                        BagManager bm       = new BagManager();
                        GItem[]    bagItems = bm.GetAllItems();
                        foreach (GItem bagItem in bagItems)
                        {
                            if (bagItem.Name.Equals(e.Value.Item.Name))
                            {
                                PPather.WriteLine("Inventory: using " + bagItem.Name);
                                GContext.Main.Debug("Inventory: using " + bagItem.Name);
                                if (!bm.ClickItem(bagItem, true))
                                {
                                    PPather.WriteLine("Inventory: BagManger failed to click the item. Aborting...");
                                    break;
                                }
                                Thread.Sleep(500);
                                break;
                            }
                        }
                        bm.CloseAllBags();
                        bm.UpdateItems();
                        continue;
                    }
                }
            }
        }