示例#1
0
文件: BagManager.cs 项目: uvbs/babbot
        public static List <string> GetTooltip(GItem item)
        {
            BagManager       bm      = new BagManager();
            List <string>    text    = new List <string>();
            GInterfaceObject ItemObj = bm.GetItem(item);

            if (ItemObj != null)
            {
                GContext.Main.EnableCursorHook();
                ItemObj.Hover();
                Thread.Sleep(50);
                GInterfaceObject ToolTip = GContext.Main.Interface.GetByName("GameTooltip");
                if (ToolTip != null)
                {
                    foreach (GInterfaceObject child in ToolTip.Children)
                    {
                        if (child.ToString().Contains("GameTooltipText"))
                        {
                            text.Add(child.LabelText);
                        }
                    }
                }
                GContext.Main.DisableCursorHook();
            }
            bm.CloseAllBags();
            return(text);
        }
示例#2
0
 public static List<string> GetTooltip(GItem item)
 {
     BagManager bm = new BagManager();
     List<string> text = new List<string>();
     GInterfaceObject ItemObj = bm.GetItem(item);
     if (ItemObj != null)
     {
         GContext.Main.EnableCursorHook();
         ItemObj.Hover();
         Thread.Sleep(50);
         GInterfaceObject ToolTip = GContext.Main.Interface.GetByName("GameTooltip");
         if (ToolTip != null)
         {
             foreach (GInterfaceObject child in ToolTip.Children)
             {
                 if (child.ToString().Contains("GameTooltipText"))
                     text.Add(child.LabelText);
             }
         }
         GContext.Main.DisableCursorHook();
     }
     bm.CloseAllBags();
     return text;
 }
示例#3
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;
 }
示例#4
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;
             }
         }
     }
 }
示例#5
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;
 }
示例#6
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;
 }
示例#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 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;
        }
示例#9
0
        public static bool Equip(EasyItem E, bool EquipBOE, string slot)
        {
            PPather.WriteLine(LOG_CATEGORY.INFORMATION, "Equip: Attempting to equip {0} [{1}]", E.RealName, slot);
            bool placed = false;
            BagManager bm = new BagManager();
            CharacterFrame.ShowFrame();
            GInterfaceObject BagItemObject = null;
            GInterfaceObject TargetSlotObject;

            TargetSlotObject = GContext.Main.Interface.GetByName("Character" + slot);
            //PPather.WriteLine(LOG_CATEGORY.DEBUG, "Equip: TargetSlotObject = {0}", TargetSlotObject.LabelText);

            GItem[] Items = bm.GetAllItems();
            foreach (GItem Item in Items)
            {
                if (Item.GUID == E.GUID)
                {
                    Thread.Sleep(500);
                    BagItemObject = bm.GetItem(Item);
                    //PPather.WriteLine(LOG_CATEGORY.DEBUG, "Equip: BagItemObject = {0}", BagItemObject.LabelText);
                    //PPather.WriteLine("item: " + BagItemObject.ToString());
                    Functions.Drag(BagItemObject, TargetSlotObject);
                    placed = true;
                    Thread.Sleep(500);
                    string BOEButton = "StaticPopup1Button2";
                    if (EquipBOE)
                        BOEButton = "StaticPopup1Button1";

                    GInterfaceObject ButtonObject = GContext.Main.Interface.GetByName(BOEButton);
                    if (ButtonObject != null && ButtonObject.IsVisible)
                    {
                        if (!EquipBOE) placed = false;
                        GContext.Main.EnableCursorHook();
                        ButtonObject.Hover();
                        ButtonObject.ClickMouse(false);
                        GContext.Main.DisableCursorHook();
                        GContext.Main.ClearTarget();
                    }
                }
            }

            CharacterFrame.HideFrame();

            /* put the old item in bags */
            if (GContext.Main.Interface.CursorItemType != GCursorItemTypes.None)
                Functions.Click(BagItemObject);

            bm.UpdateItems();
            bm.CloseAllBags();

            if (placed)
            {
                Character.ReplaceCurrentlyEquipped(E, slot);
                return true;
            }

            return false;
        }