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); } }
private bool NeedMail() { BagManager bMan = new BagManager(); bMan.UpdateItems(); GItem[] bitems = bMan.GetAllItems(); List <string> items = GetItems(); foreach (GItem bitem in bitems) { if (bitem.Definition.Quality == GItemQuality.Common && GetMailWhites() && ValidItem(bitem)) { return(true); } if (bitem.Definition.Quality == GItemQuality.Uncommon && GetMailGreens() && ValidItem(bitem)) { return(true); } if (bitem.Definition.Quality == GItemQuality.Rare && GetMailBlues() && ValidItem(bitem)) { return(true); } if (bitem.Definition.Quality == GItemQuality.Epic && GetMailEpics() && ValidItem(bitem)) { return(true); } foreach (string item in items) { if (bitem.Name.Contains(item) && ValidItem(bitem)) { if (!GetFullStacksOnly()) { return(true); } else { PPather.WriteLine(string.Format("[{0}]x{1} ==? {2}", bitem.Name, bitem.StackSize, bitem.Definition.StackSize)); if (bitem.StackSize == bitem.Definition.StackSize) { 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 }
/// <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); }