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; }
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; } } } }
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; }