Exemple #1
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;
             }
         }
     }
 }
Exemple #2
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;
        }