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); }
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 bool EquipBetterBag(GItem Item) { 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); } } } bm.CloseAllBags(); return(true); } } } } return(false); }
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 }
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); }
public static void GetInventoryItems() { InventoryItems.Clear(); bm.UpdateItemsSorted(); for (int j = 0; j < bm.Bags.Length; j++) { //PPather.Debug("Charcater: Bags.Length = {0}",bm.Bags.Length); BagManager.Bag b = bm.Bags[j]; if (b.count < 1) { continue; } //PPather.Debug("Characater: Bags[{0}] contains {1} items",j,b.I.Length); bm.OpenBag(b.bag); GItem[] Items = null; if (b.I != null) { Items = b.I; } if (Items == null || Items.Length < 1) { continue; } foreach (GItem Item in Items) { if (Item == null || Item.GUID == 0) { continue; } PPather.Debug("\n\n == ITEM LOOKUP FOR {0} START ==", Item.Name); List <string> tooltip = GetTooltipOnOpenBags(Item); if (tooltip == null || tooltip.Count < 1) { PPather.Debug("Character.GetInventoryItems: tooltip for {0} is emtpy", Item.Name); } else { string tooltipName = tooltip[tooltip.Count - 1]; PPather.Debug("Character.GetInventoryItems: tooltip[0] for {0} is {1}", Item.Name, tooltipName); Item i = ItemManager.get(tooltipName); if (i == null) { PPather.Debug("Character: ItemManager return null, {0} most likely not equippable", tooltipName); continue; } try { EasyItem E = new EasyItem(Item, i, Item.GUID, tooltipName); InventoryItems.Add(Item.GUID, E); PPather.WriteLine(Pather.LOG_CATEGORY.INFORMATION, "Character: {0} added to InventoryItems", tooltipName); //PPather.WriteLine(String.Format("DEBUG: Item.Type = {0} , Item.Quality = {1}",E.GItem.Type.ToString(), E.GItem.Definition.Quality.ToString())); //PPather.WriteLine(String.Format("Charcter: Item [{0}] found in bags", i.Name)); //PPather.WriteLine(String.Format("ToolTip[{0}]: {1}", i.Name, CleanToolTip(tooltip))); } catch (ArgumentException) { PPather.Debug("Character.GetInventoryItems: {0}({1}) is already added to InventoryItems (skipping)", tooltipName, Item.GUID); } } PPather.Debug("\n=== ITEM LOOKUP FOR {0} END ===\n", Item.Name); } } bm.CloseAllBags(); }
/// <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); }
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); }