static public void buyItem(uint id, uint count) { bool found = false; foreach (MerchantItem mi in MerchantFrame.Instance.GetAllMerchantItems()) { if (mi.ItemId == id) { // since BuyItem can only by up to 20 items we need to run it multiple times when buying over 20 items int stacks = (int)(count / 20); int leftovers = (int)(count % 20); if (count >= 20) { //using (new FrameLock()) // framelock was causing DCs //{ for (int i = 0; i < stacks; i++) { MerchantFrame.Instance.BuyItem(mi.Index, 20); } if (leftovers > 0) { MerchantFrame.Instance.BuyItem(mi.Index, leftovers); } //} } else { MerchantFrame.Instance.BuyItem(mi.Index, leftovers); } found = true; break; } } Professionbuddy.Log("item {0} {1}", id, found ? "bought " : "not found"); }
protected override RunStatus Run(object context) { if (!IsDone) { if ((Bank == BankType.Guild && !IsGbankFrameVisible) || (Bank == BankType.Personal && !Util.IsBankFrameOpen)) { MoveToBanker(); } else { if (_itemsSW == null) { _itemsSW = new Stopwatch(); _itemsSW.Start(); } else if (_itemsSW.ElapsedMilliseconds < Professionbuddy.Ping * 1.5) { return(RunStatus.Running); } if (ItemList == null) { ItemList = BuildItemList(); } // no bag space... if (me.FreeNormalBagSlots <= MinFreeBagSlots || ItemList.Count == 0) { IsDone = true; } else { KeyValuePair <uint, int> kv = ItemList.FirstOrDefault(); bool done = false; if (Bank == BankType.Personal) { done = GetItemFromBank(kv.Key, kv.Value); } else { done = GetItemFromGBank(kv.Key, kv.Value); } if (done) { ItemList.Remove(kv.Key); } } _itemsSW.Reset(); _itemsSW.Start(); } if (IsDone) { Professionbuddy.Log("Removed Item:[{0}] from {1} Bank", ItemID, Bank); } else { return(RunStatus.Running); } } return(RunStatus.Failure); }
// Credits to Inrego // Index are {0}=ItemID, {1}=Amount // returns 1 if item is found, otherwise -1 public static void BuyItem(uint id, uint count) { //bool found = false; //foreach (MerchantItem mi in MerchantFrame.Instance.GetAllMerchantItems()) //{ // if (mi.ItemId == id) // { // // since BuyItem can only by up to 20 items we need to run it multiple times when buying over 20 items // var stacks = (int)(count / 20); // var leftovers = (int)(count % 20); // if (count >= 20) // { // //using (new FrameLock()) // framelock was causing DCs // //{ // for (int i = 0; i < stacks; i++) // MerchantFrame.Instance.BuyItem(mi.Index, 20); // if (leftovers > 0) // MerchantFrame.Instance.BuyItem(mi.Index, leftovers); // //} // } // else // MerchantFrame.Instance.BuyItem(mi.Index, leftovers); // found = true; // break; // } //} string lua = string.Format(BuyItemFormat, id, count); bool found = Lua.GetReturnVal <int>(lua, 0) == 1; Professionbuddy.Log("item {0} {1}", id, found ? "bought " : "not found"); }
public void Load() { string absPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Pb.CurrentProfile.XmlPath), Path); if (ProfileManager.XmlLocation != absPath) { try { if (ProfileType == LoadProfileType.Honorbuddy) { Professionbuddy.Log("Loading Profile :{0}, previous profile was {1}", absPath, ProfileManager.XmlLocation); if (string.IsNullOrEmpty(Path)) { ProfileManager.LoadEmpty(); } else if (System.IO.File.Exists(absPath)) { ProfileManager.LoadNew(absPath); } else { Logging.Write(System.Drawing.Color.Red, "Unable to load profile {0}", Path); } } else { Professionbuddy.LoadProfile(absPath); } } catch (Exception ex) { Professionbuddy.Err(ex.ToString()); } } }
protected override RunStatus Run(object context) { if (!IsDone) { if (!timeout.IsRunning) { timeout.Start(); } try { if (timeout.ElapsedMilliseconds >= Timeout || CanRunDelegate(null)) { timeout.Stop(); timeout.Reset(); Professionbuddy.Log("Wait Action Completed"); IsDone = true; } else { return(RunStatus.Running); } } catch (Exception ex) { Professionbuddy.Err("Wait:({0})\n{1}", Condition, ex); } } return(RunStatus.Failure); }
public bool ChangeBot() { BotBase bot = BotManager.Instance.Bots.FirstOrDefault(b => b.Key.Contains(BotName)).Value; if (bot == null) { Professionbuddy.Err("ChangeBotAction was unable to find the following bot {0}", BotName); return(false); } Professionbuddy.Log("ChangeBotAction: Switching to {0}", BotName); new Thread(() => { try { TreeRoot.Stop(); } catch (Exception ex) { Logging.Write("ChangeBot: " + ex.ToString()); } finally { BotManager.Instance.SetCurrent(bot); Thread.Sleep(3000); TreeRoot.Start(); } }).Start(); return(true); }
protected override RunStatus Run(object context) { if (!IsDone) { if (TrainerFrame.Instance == null || !TrainerFrame.Instance.IsVisible || !ObjectManager.Me.GotTarget || (ObjectManager.Me.GotTarget && ObjectManager.Me.CurrentTarget.Entry != NpcEntry)) { WoWPoint movetoPoint = _loc; WoWUnit unit = ObjectManager.GetObjectsOfType <WoWUnit>().Where(o => o.Entry == NpcEntry). OrderBy(o => o.Distance).FirstOrDefault(); if (unit != null) { movetoPoint = WoWMathHelper.CalculatePointFrom(Me.Location, unit.Location, 3); } else if (movetoPoint == WoWPoint.Zero) { movetoPoint = MoveToAction.GetLocationFromDB(MoveToAction.MoveToType.NpcByID, NpcEntry); } if (movetoPoint != WoWPoint.Zero && ObjectManager.Me.Location.Distance(movetoPoint) > 4.5) { Util.MoveTo(movetoPoint); } else if (unit != null) { if (Me.IsMoving) { WoWMovement.MoveStop(); } unit.Target(); unit.Interact(); } if (GossipFrame.Instance != null && GossipFrame.Instance.IsVisible && GossipFrame.Instance.GossipOptionEntries != null) { foreach (GossipEntry ge in GossipFrame.Instance.GossipOptionEntries) { if (ge.Type == GossipEntry.GossipEntryType.Trainer) { GossipFrame.Instance.SelectGossipOption(ge.Index); return(RunStatus.Success); } } } return(RunStatus.Success); } if (!_concludingStopWatch.IsRunning) { Lua.DoString("SetTrainerServiceTypeFilter('available', 1) BuyTrainerService(0) "); _concludingStopWatch.Start(); } else if (_concludingStopWatch.ElapsedMilliseconds >= 3000) { _concludingStopWatch.Reset(); Professionbuddy.Log("Training Completed "); IsDone = true; } } return(RunStatus.Failure); }
protected override RunStatus Run(object context) { if (!IsDone) { WoWObject obj = null; if (InteractType == InteractActionType.NPC) { if (Entry != 0) { obj = ObjectManager.GetObjectsOfType <WoWUnit>().Where(u => u.Entry == Entry).OrderBy( u => u.Distance).FirstOrDefault(); } else if (ObjectManager.Me.GotTarget) { obj = ObjectManager.Me.CurrentTarget; } } else if (InteractType == InteractActionType.GameObject) { obj = ObjectManager.GetObjectsOfType <WoWGameObject>().OrderBy(u => u.Distance).FirstOrDefault( u => (Entry > 0 && u.Entry == Entry) || (u.SubType == GameObjectType && (GameObjectType != WoWGameObjectType.SpellFocus || (GameObjectType == WoWGameObjectType.SpellFocus && u.SpellFocus == SpellFocus)))); } if (obj != null) { WoWPoint moveToLoc = WoWMathHelper.CalculatePointFrom(Me.Location, obj.Location, 3); if (moveToLoc.Distance(Me.Location) > 4) { Util.MoveTo(moveToLoc); } else { if (InteractDelay > 0 && (!_interactSw.IsRunning || _interactSw.ElapsedMilliseconds < InteractDelay)) { _interactSw.Start(); } else { _interactSw.Reset(); obj.Interact(); IsDone = true; } } } if (!IsDone) { return(RunStatus.Success); } Professionbuddy.Log("InteractAction complete"); } return(RunStatus.Failure); }
bool CancelAuction(AuctionEntry ae) { int numCanceled = Lua.GetReturnVal <int>(String.Format("local A =GetNumAuctionItems('owner') local cnt=0 for i=A,1,-1 do local name,_,cnt,_,_,_,_,_,_,buyout,_,_,_,sold,id=GetAuctionItemInfo('owner', i) if id == {0} and sold ~= 1 and {2} > {1} and (buyout/cnt) > {2} then CancelAuction(i) cnt=cnt+1 end end return cnt", ae.Id, MinBuyout.TotalCopper, ae.LowestBo), 0); if (numCanceled > 0) { Professionbuddy.Log("Canceled {0} x{1}", ae.Name, numCanceled); } return(true); }
bool CancelAuction(AuctionEntry ae) { string lua = String.Format(CancelAuctionLuaFormat, ae.Id, MinBuyout.TotalCopper, ae.LowestBo); var numCanceled = Lua.GetReturnVal <int>(lua, 0); if (numCanceled > 0) { Professionbuddy.Log("Canceled {0} x{1}", ae.Name, numCanceled); } return(true); }
public static bool CanDisenchant(this WoWItem item) { if (item.ItemInfo.StatsCount == 0 && item.ItemInfo.RandomPropertiesId == 0) { //Professionbuddy.Log("We cannot disenchant {0} found in bag {1} at slot {2} because it has no stats.", // item.Name, item.BagIndex + 1, item.BagSlot + 1); return(false); } int enchantingLevel = ObjectManager.Me.GetSkill(SkillLine.Enchanting).CurrentValue; int[,] deList = null; if (item.Quality == WoWItemQuality.Uncommon) { deList = UncommonItemDeList; } else if (item.Quality == WoWItemQuality.Rare) { deList = RareItemDeList; } else if (item.Quality == WoWItemQuality.Epic) { deList = EpicItemDeList; } // returns true if item is found in the dictionary and player meets the level requirement if (deList != null) { int x = 0; int iLevel = item.ItemInfo.Level; for (x = 0; x < deList.Length / 2; x++) { int a = deList[x, 1]; if (iLevel <= deList[x, 1]) { Professionbuddy.Log("We can disenchant {0} found in bag {1} at slot {2}", item.Name, item.BagIndex + 1, item.BagSlot + 1); return(enchantingLevel >= deList[x, 0]); } } } Professionbuddy.Log("We cannot disenchant {0} found in bag {1} at slot {2}", item.Name, item.BagIndex + 1, item.BagSlot + 1); return(false); }
public static bool CanDisenchant(this WoWItem item, int skillLevel) { ItemInfo itemInfo = item.ItemInfo; if (itemInfo.StatsCount == 0 && itemInfo.RandomPropertiesId == 0 && itemInfo.RandomSuffixId == 0) { //Professionbuddy.Log("We cannot disenchant {0} found in bag {1} at slot {2} because it has no stats.", // item.Name, item.BagIndex + 1, item.BagSlot + 1); return(false); } int[,] deList = null; if (item.Quality == WoWItemQuality.Uncommon) { deList = UncommonItemDeList; } else if (item.Quality == WoWItemQuality.Rare) { deList = RareItemDeList; } else if (item.Quality == WoWItemQuality.Epic) { deList = EpicItemDeList; } // returns true if item is found in the dictionary and player meets the level requirement if (deList != null) { int x; int iLevel = item.ItemInfo.Level; for (x = 0; x < deList.Length / 2; x++) { if (iLevel <= deList[x, 1] && skillLevel >= deList[x, 0]) { Professionbuddy.Log("We can disenchant {0} found in bag {1} at slot {2}", item.Name, item.BagIndex + 1, item.BagSlot + 1); return(true); } } } Professionbuddy.Log("We cannot disenchant {0} found in bag {1} at slot {2}. SkillLevel: {3}", item.Name, item.BagIndex + 1, item.BagSlot + 1, skillLevel); return(false); }
static public void ChangeBot(string name) { if (_botIsChanging) { Professionbuddy.Log("Must wait for previous ChangeBot to finish before calling ChangeBot again."); return; } BotBase bot = BotManager.Instance.Bots.FirstOrDefault(b => b.Key.Contains(name)).Value; if (BotManager.Current == bot) { return; } if (bot != null) { // execute from GUI thread since this thread will get aborted when switching bot _botIsChanging = true; Application.Current.Dispatcher.BeginInvoke( new System.Action(() => { bool isRunning = TreeRoot.IsRunning; BotManager.Instance.SetCurrent(bot); if (isRunning) { Professionbuddy.Log("Restarting HB in 3 seconds"); _timer = new Timer(new TimerCallback((o) => { TreeRoot.Start(); Professionbuddy.Log("Restarting HB"); _botIsChanging = false; }), null, 3000, Timeout.Infinite); } } )); Professionbuddy.Log("Changing bot to {0}", name); } else { Professionbuddy.Err("Bot {0} does not exist", name); } }
// indexes are {0} = ItemID, {1} = amount to deposit /// <summary> /// Withdraws items from gbank /// </summary> /// <param name="id">item ID</param> /// <param name="amount">amount to withdraw.</param> /// <returns>the amount withdrawn.</returns> public int GetItemFromGBank(uint id, int amount) { if (_queueServerSW == null) { _queueServerSW = new Stopwatch(); _queueServerSW.Start(); Lua.DoString("for i=GetNumGuildBankTabs(), 1, -1 do QueryGuildBankTab(i) end "); Professionbuddy.Log("Queuing server for gbank info"); return(0); } if (_queueServerSW.ElapsedMilliseconds < 2000) { return(0); } string lua = string.Format(WithdrawItemFromGBankLuaFormat, id, amount); var retVal = Lua.GetReturnVal <int>(lua, 0); // -1 means no item was found. if (retVal == -1) { Professionbuddy.Log("No items with entry {0} could be found in gbank", id); } return(retVal); }
protected override RunStatus Run(object context) { if (!IsDone) { if (MerchantFrame.Instance == null || !MerchantFrame.Instance.IsVisible) { WoWPoint movetoPoint = loc; WoWUnit unit = null; if (_entry == 0) { _entry = NpcEntry; } if (_entry == 0) { MoveToAction.GetLocationFromDB(MoveToAction.MoveToType.NearestVendor, 0); var npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId, ObjectManager.Me.Location, UnitNPCFlags.Vendor); _entry = (uint)npcResults.Entry; movetoPoint = npcResults.Location; } unit = ObjectManager.GetObjectsOfType <WoWUnit>().Where(o => o.Entry == _entry). OrderBy(o => o.Distance).FirstOrDefault(); if (unit != null) { movetoPoint = unit.Location; } else if (movetoPoint == WoWPoint.Zero) { movetoPoint = MoveToAction.GetLocationFromDB(MoveToAction.MoveToType.NpcByID, NpcEntry); } if (movetoPoint != WoWPoint.Zero && ObjectManager.Me.Location.Distance(movetoPoint) > 4.5) { Util.MoveTo(movetoPoint); } else if (unit != null) { unit.Target(); unit.Interact(); } if (GossipFrame.Instance != null && GossipFrame.Instance.IsVisible && GossipFrame.Instance.GossipOptionEntries != null) { foreach (GossipEntry ge in GossipFrame.Instance.GossipOptionEntries) { if (ge.Type == GossipEntry.GossipEntryType.Vendor) { GossipFrame.Instance.SelectGossipOption(ge.Index); return(RunStatus.Running); } } } } else { if (SellItemType == SellItemActionType.Specific) { List <uint> idList = new List <uint>(); string[] entries = ItemID.Split(','); if (entries != null && entries.Length > 0) { foreach (var entry in entries) { uint temp = 0; uint.TryParse(entry.Trim(), out temp); idList.Add(temp); } } else { Professionbuddy.Err("No ItemIDs are specified"); IsDone = true; return(RunStatus.Failure); } List <WoWItem> itemList = ObjectManager.Me.BagItems.Where(u => idList.Contains(u.Entry)).Take((int)Count).ToList(); if (itemList != null) { using (new FrameLock()) { foreach (WoWItem item in itemList) { item.UseContainerItem(); } } } } else { List <WoWItem> itemList = null; IEnumerable <WoWItem> itemQuery = from item in me.BagItems where !Pb.ProtectedItems.Contains(item.Entry) select item; switch (SellItemType) { case SellItemActionType.Greys: itemList = itemQuery.Where(i => i.Quality == WoWItemQuality.Poor).ToList(); break; case SellItemActionType.Whites: itemList = itemQuery.Where(i => i.Quality == WoWItemQuality.Common).ToList(); break; case SellItemActionType.Greens: itemList = itemQuery.Where(i => i.Quality == WoWItemQuality.Uncommon).ToList(); break; } if (itemList != null) { using (new FrameLock()) { foreach (WoWItem item in itemList) { item.UseContainerItem(); } } } } Professionbuddy.Log("SellItemAction Completed for {0}", ItemID); IsDone = true; } return(RunStatus.Running); } return(RunStatus.Failure); }
public bool GetItemFromGBank(uint id, int amount) { if (queueServerSW == null) { queueServerSW = new Stopwatch(); queueServerSW.Start(); Lua.DoString("for i=GetNumGuildBankTabs(), 1, -1 do QueryGuildBankTab(i) end "); Professionbuddy.Log("Queuing server for gbank info"); return(false); } if (queueServerSW.ElapsedMilliseconds < 2000) { return(false); } string lua = string.Format( "local tabnum = GetNumGuildBankTabs() " + "local bagged = 0 " + "local amount = {1} " + "if GuildBankFrame and GuildBankFrame:IsVisible() then " + "for tab = 1,tabnum do " + "local _,_,iv,_,_, rw = GetGuildBankTabInfo(tab) " + "if iv then " + "SetCurrentGuildBankTab(tab) " + "local sawItem = 0 " + "for slot = 1, 98 do " + "local _,c,l=GetGuildBankItemInfo(tab, slot) " + "local id = tonumber(string.match(GetGuildBankItemLink(tab, slot) or '','|Hitem:(%d+)')) " + "if l == nil and id == {0} then " + "sawItem = 1 " + "if c + bagged <= amount then " + "AutoStoreGuildBankItem(tab, slot) " + "bagged = bagged + c " + "else " + "local itemf = GetItemFamily(id) " + "for bag =4 ,0 ,-1 do " + "local fs,bfamily = GetContainerNumFreeSlots(bag) " + "if fs > 0 and (bfamily == 0 or bit.band(itemf, bfamily) > 0) then " + "local freeSlots = GetContainerFreeSlots(bag) " + "SplitGuildBankItem(tab, slot, amount-bagged) " + "PickupContainerItem(bag, freeSlots[1]) " + "return bagged " + "end " + "end " + "end " + "end " + "end " + "end " + "end " + "if sawItem == 0 then return -1 else return bagged end " + "end " + "return -2 " , id, amount); Professionbuddy.Log("Attempting to withdraw items"); int retVal = Lua.GetReturnVal <int>(lua, 0); // -1 means no item was found. if (retVal == -1) { Professionbuddy.Log("No items with entry {0} could be found in gbank", id); } else if (retVal == -2) // frame was not visible { Professionbuddy.Log("Guildbank frame was not visible, skipping withdrawl"); } queueServerSW = null; return(true); }
protected override RunStatus Run(object context) { if (!IsDone) { if (me.IsFlying) { return(RunStatus.Failure); } if (LootFrame.Instance != null && LootFrame.Instance.IsVisible) { LootFrame.Instance.LootAll(); return(RunStatus.Running); } if (!me.IsCasting && (!castTimer.IsRunning || castTimer.ElapsedMilliseconds >= timeToWait)) { List <WoWItem> ItemList = BuildItemList(); if (ItemList == null || ItemList.Count == 0) { IsDone = true; Professionbuddy.Log("Done {0}ing", ActionType); } else { // skip 'locked' items int index = 0; for (; index <= ItemList.Count; index++) { if (!ItemList[index].IsDisabled) { break; } } if (index < ItemList.Count) { if (ItemList[index].Guid == lastItemGuid && lastStackSize == ItemList[index].StackCount) { if (++tries >= 3) { Professionbuddy.Log("Unable to {0} {1}, BlackListing", Name, ItemList[index].Name); if (!blacklistedItems.Contains(lastItemGuid)) { blacklistedItems.Add(lastItemGuid); } return(RunStatus.Running); } } else { tries = 0; } WoWSpell spell = WoWSpell.FromId(spellId); if (spell != null) { TreeRoot.GoalText = string.Format("{0}ing {1}", ActionType, ItemList[index].Name); //Lua.DoString("CastSpellByID({0}) UseContainerItem({1}, {2})", // spellId, ItemList[index].BagIndex + 1, ItemList[index].BagSlot + 1); spell.CastOnItem(ItemList[index]); lastItemGuid = ItemList[index].Guid; lastStackSize = ItemList[index].StackCount; castTimer.Reset(); castTimer.Start(); } else { IsDone = true; } } } } if (!IsDone) { return(RunStatus.Running); } } return(RunStatus.Failure); }
public int PutItemInGBank(uint id, int amount, uint tab) { using (new FrameLock()) { if (_queueServerSW == null) { _queueServerSW = new Stopwatch(); _queueServerSW.Start(); Lua.DoString("for i=GetNumGuildBankTabs(), 1, -1 do QueryGuildBankTab(i) end SetCurrentGuildBankTab({0}) ", tab == 0 ? 1 : tab); Professionbuddy.Log("Queuing server for gbank info"); return(0); } if (_queueServerSW.ElapsedMilliseconds < 2000) { return(0); } if (_bankSlots == null) { _bankSlots = GetBankSlotInfo(); } var tabCnt = Lua.GetReturnVal <int>("return GetNumGuildBankTabs()", 0); var currentTab = Lua.GetReturnVal <int>("return GetCurrentGuildBankTab()", 0); IEnumerable <BankSlotInfo> slotsInCurrentTab = _bankSlots.Where(slotI => slotI.Bag == currentTab); WoWItem itemToDeposit = Me.CarriedItems.OrderBy(item => item.StackCount) .FirstOrDefault(item => item.Entry == id && !item.IsDisabled); if (itemToDeposit != null) { int depositAmount = amount > 0 && amount < (int)itemToDeposit.StackCount ? amount : (int)itemToDeposit.StackCount; BankSlotInfo emptySlot = slotsInCurrentTab.FirstOrDefault(slotI => slotI.StackSize == 0); BankSlotInfo partialStack = slotsInCurrentTab .FirstOrDefault(slotI => slotI.ItemID == id && slotI.MaxStackSize - slotI.StackSize >= depositAmount); if (partialStack != null || emptySlot != null) { bool slotIsEmpty = partialStack == null; int bSlotIndex = slotIsEmpty ? _bankSlots.IndexOf(emptySlot) : _bankSlots.IndexOf(partialStack); _bankSlots[bSlotIndex].StackSize += itemToDeposit.StackCount; if (slotIsEmpty) { _bankSlots[bSlotIndex].ItemID = itemToDeposit.Entry; _bankSlots[bSlotIndex].MaxStackSize = itemToDeposit.ItemInfo.MaxStackSize; } if (depositAmount == itemToDeposit.StackCount) { itemToDeposit.UseContainerItem(); } else { Lua.DoString("SplitContainerItem({0},{1},{2}) PickupGuildBankItem({3},{4})", itemToDeposit.BagIndex + 1, itemToDeposit.BagSlot + 1, depositAmount, _bankSlots[bSlotIndex].Bag, _bankSlots[bSlotIndex].Slot); } return(depositAmount); } if (tab > 0) { Professionbuddy.Log("Guild Tab: {0} is full", tab); return(-1); } if (tab == 0 && currentTab < tabCnt) { Lua.DoString("SetCurrentGuildBankTab({0})", currentTab + 1); return(0); } } return(-1); } }
protected override RunStatus Run(object context) { if (!IsDone) { if (MoveType != MoveToType.Location) { _loc = GetLocationFromType(MoveType, Entry); if (_loc == WoWPoint.Zero) { if (_locationDb == WoWPoint.Zero) { _locationDb = GetLocationFromDB(MoveType, Entry); } _loc = _locationDb; } if (_loc == WoWPoint.Zero) { Professionbuddy.Err("MoveToAction Failed.. Unable to find location from Database"); IsDone = true; return(RunStatus.Failure); } } if (Entry > 0 && (!ObjectManager.Me.GotTarget || ObjectManager.Me.CurrentTarget.Entry != Entry)) { WoWUnit unit = ObjectManager.GetObjectsOfType <WoWUnit>(true).FirstOrDefault(u => u.Entry == Entry); if (unit != null) { unit.Target(); } } float speed = ObjectManager.Me.MovementInfo.CurrentSpeed; Navigator.PathPrecision = speed > 7 ? (SpeedModifer * speed) / 7f : SpeedModifer; if (ObjectManager.Me.Location.Distance(_loc) > Navigator.PathPrecision) { if (Pathing == NavigationType.ClickToMove) { WoWMovement.ClickToMove(_loc); } else { Util.MoveTo(_loc); } } else { if (!_concludingSw.IsRunning) { _concludingSw.Start(); } else if (_concludingSw.ElapsedMilliseconds >= 2000) { IsDone = true; Professionbuddy.Log("MoveTo Action completed for type {0}", MoveType); _concludingSw.Stop(); _concludingSw.Reset(); } } if (!IsDone) { return(RunStatus.Success); } } return(RunStatus.Failure); }
protected override RunStatus Run(object context) { if (!IsDone) { if ((Bank == BankType.Guild && !Util.IsGbankFrameVisible) || (Bank == BankType.Personal && !Util.IsBankFrameOpen)) { MoveToBanker(); } else { if (_itemsSW == null) { _itemsSW = new Stopwatch(); _itemsSW.Start(); } else if (_itemsSW.ElapsedMilliseconds < Util.WoWPing * 3) { return(RunStatus.Success); } if (_itemList == null) { _itemList = BuildItemList(); } // no bag space... if (Me.FreeNormalBagSlots <= MinFreeBagSlots || _itemList.Count == 0) { IsDone = true; } else { uint itemID = _itemList.Keys.FirstOrDefault(); bool done; if (Bank == BankType.Personal) { done = GetItemFromBank(itemID, _itemList[itemID]); } else { // throttle the amount of items being withdrawn from gbank per sec if (!_gbankItemThrottleSW.IsRunning) { _gbankItemThrottleSW.Start(); } if (_gbankItemThrottleSW.ElapsedMilliseconds < GbankItemThrottle) { return(RunStatus.Success); } int ret = GetItemFromGBank(itemID, _itemList[itemID]); if (ret >= 0) { _gbankItemThrottleSW.Reset(); _gbankItemThrottleSW.Start(); } _itemList[itemID] = ret < 0 ? 0 : _itemList[itemID] - ret; done = _itemList[itemID] <= 0; } if (done) { if (itemID == 0) { Professionbuddy.Log("Done withdrawing all items from {0} Bank", Bank); } else { Professionbuddy.Log("Done withdrawing itemID:{0} from {1} Bank", itemID, Bank); } _itemList.Remove(itemID); } } _itemsSW.Reset(); _itemsSW.Start(); } return(RunStatus.Success); } return(RunStatus.Failure); }
protected override RunStatus Run(object context) { if (!IsDone) { WoWPoint movetoPoint = _loc; if (MailFrame.Instance == null || !MailFrame.Instance.IsVisible) { if (AutoFindMailBox || movetoPoint == WoWPoint.Zero) { _mailbox = ObjectManager.GetObjectsOfType <WoWGameObject>().Where( o => o.SubType == WoWGameObjectType.Mailbox) .OrderBy(o => o.Distance).FirstOrDefault(); } else { _mailbox = ObjectManager.GetObjectsOfType <WoWGameObject>().Where( o => o.SubType == WoWGameObjectType.Mailbox && o.Location.Distance(_loc) < 10) .OrderBy(o => o.Distance).FirstOrDefault(); } if (_mailbox != null) { movetoPoint = WoWMathHelper.CalculatePointFrom(Me.Location, _mailbox.Location, 3); } if (movetoPoint == WoWPoint.Zero) { Professionbuddy.Err(Pb.Strings["Error_UnableToFindMailbox"]); return(RunStatus.Failure); } if (movetoPoint.Distance(ObjectManager.Me.Location) > 4.5) { Util.MoveTo(movetoPoint); } else if (_mailbox != null) { _mailbox.Interact(); } return(RunStatus.Success); } // Mail Frame is open.. // item split in proceess if (_itemSplitSW.IsRunning && _itemSplitSW.ElapsedMilliseconds <= 2000) { return(RunStatus.Success); } if (_itemList == null) { _itemList = BuildItemList(); } if (_itemList.Count == 0) { //Professionbuddy.Debug("Sending any remaining items already in SendMail item slots. Mail subject will be: {0} ",_mailSubject); Lua.DoString( "for i=1,ATTACHMENTS_MAX_SEND do if GetSendMailItem(i) ~= nil then SendMail (\"{0}\",\"{1}\",'') end end ", CharacterSettings.Instance.MailRecipient.ToFormatedUTF8(), _mailSubject != null ? _mailSubject.ToFormatedUTF8() : " "); //Professionbuddy.Debug("Done sending mail"); IsDone = true; return(RunStatus.Failure); } MailFrame.Instance.SwitchToSendMailTab(); uint itemID = _itemList.Keys.FirstOrDefault(); WoWItem item = Me.BagItems.FirstOrDefault(i => i.Entry == itemID); _mailSubject = item != null ? item.Name : " "; if (string.IsNullOrEmpty(_mailSubject)) { _mailSubject = " "; } Professionbuddy.Debug("MailItem: sending {0}", itemID); int ret = MailItem(itemID, _itemList[itemID]); // we need to wait for item split to finish if ret == 0 // format indexs are MailRecipient=0, Mail subject=1 string mailToLua = string.Format(MailItemsFormat, CharacterSettings.Instance.MailRecipient.ToFormatedUTF8(), _mailSubject.ToFormatedUTF8()); var mailItemsRet = Lua.GetReturnVal <int>(mailToLua, 0); if (ret == 0 || mailItemsRet == 1) { _itemSplitSW.Reset(); _itemSplitSW.Start(); return(RunStatus.Success); } _itemList[itemID] = ret < 0 ? 0 : _itemList[itemID] - ret; bool done = _itemList[itemID] <= 0; if (done) { _itemList.Remove(itemID); } if (IsDone) { Professionbuddy.Log("Done sending {0} via mail", UseCategory ? string.Format("Items that belong to category {0} and subcategory {1}", Category, SubCategory) : string.Format("Items that match Id of {0}", ItemID)); } else { return(RunStatus.Success); } } return(RunStatus.Failure); }
protected override RunStatus Run(object context) { if (!IsDone) { if (MerchantFrame.Instance == null || !MerchantFrame.Instance.IsVisible) { WoWPoint movetoPoint = _loc; WoWUnit unit = ObjectManager.GetObjectsOfType <WoWUnit>().Where(o => o.Entry == NpcEntry). OrderBy(o => o.Distance).FirstOrDefault(); if (unit != null) { movetoPoint = WoWMathHelper.CalculatePointFrom(Me.Location, unit.Location, 3); } else if (movetoPoint == WoWPoint.Zero) { movetoPoint = MoveToAction.GetLocationFromDB(MoveToAction.MoveToType.NpcByID, NpcEntry); } if (movetoPoint != WoWPoint.Zero && ObjectManager.Me.Location.Distance(movetoPoint) > 4.5) { Util.MoveTo(movetoPoint); } else if (unit != null) { unit.Target(); unit.Interact(); } if (GossipFrame.Instance != null && GossipFrame.Instance.IsVisible && GossipFrame.Instance.GossipOptionEntries != null) { foreach (GossipEntry ge in GossipFrame.Instance.GossipOptionEntries) { if (ge.Type == GossipEntry.GossipEntryType.Vendor) { GossipFrame.Instance.SelectGossipOption(ge.Index); break; } } } } else { // check if we have merchant frame open at correct NPC if (NpcEntry > 0 && Me.GotTarget && Me.CurrentTarget.Entry != NpcEntry) { MerchantFrame.Instance.Close(); return(RunStatus.Success); } if (!_concludingSw.IsRunning) { if (BuyItemType == BuyItemActionType.SpecificItem) { var idList = new List <uint>(); string[] entries = ItemID.Split(','); if (entries.Length > 0) { foreach (string entry in entries) { uint temp; uint.TryParse(entry.Trim(), out temp); idList.Add(temp); } } else { Professionbuddy.Err(Pb.Strings["Error_NoItemEntries"]); IsDone = true; return(RunStatus.Failure); } foreach (uint id in idList) { int count = !BuyAdditively ? Count - Util.GetCarriedItemCount(id) : Count; if (count > 0) { BuyItem(id, (uint)count); } } } else if (BuyItemType == BuyItemActionType.Material) { foreach (var kv in Pb.MaterialList) { // only buy items if we don't have enough in bags... int amount = kv.Value - (int)Ingredient.GetInBagItemCount(kv.Key); if (amount > 0) { BuyItem(kv.Key, (uint)amount); } } } _concludingSw.Start(); } if (_concludingSw.ElapsedMilliseconds >= 2000) { Professionbuddy.Log("BuyItemAction Completed"); IsDone = true; } } if (!IsDone) { return(RunStatus.Success); } } return(RunStatus.Failure); }
protected override RunStatus Run(object context) { if (!IsDone) { if ((Bank == BankType.Guild && !IsGbankFrameVisible) || (Bank == BankType.Personal && !Util.IsBankFrameOpen)) { MoveToBanker(); } else { if (_itemsSW == null) { _itemsSW = new Stopwatch(); _itemsSW.Start(); } else if (_itemsSW.ElapsedMilliseconds < Professionbuddy.Ping * 1.5) { return(RunStatus.Running); } if (ItemList == null) { ItemList = BuildItemList(); } // no bag space... if (ItemList.Count == 0) { IsDone = true; } else { KeyValuePair <uint, int> kv = ItemList.FirstOrDefault(); bool done = false; if (Bank == BankType.Personal) { done = PutItemInBank(kv.Key, kv.Value); } else { done = PutItemInGBank(kv.Key, kv.Value, GuildTab); } if (done) { Professionbuddy.Debug("Done Depositing Item:{0} to bank", kv.Key); ItemList.Remove(kv.Key); } _itemsSW.Reset(); _itemsSW.Start(); } } if (IsDone) { Professionbuddy.Log("Deposited Items:[{0}] to {1} Bank", ItemID, Bank); } else { return(RunStatus.Running); } } return(RunStatus.Failure); }
public bool PutItemInGBank(uint id, int amount, uint tab) { if (queueServerSW == null) { queueServerSW = new Stopwatch(); queueServerSW.Start(); Lua.DoString("for i=GetNumGuildBankTabs(), 1, -1 do QueryGuildBankTab(i) end "); Professionbuddy.Log("Queuing server for gbank info"); return(false); } else if (queueServerSW.ElapsedMilliseconds < 2000) { return(false); } string lua = string.Format( "local tabnum = GetNumGuildBankTabs() " + "local bagged = 0 " + "local tabInfo = {{0}} " + "local tab = 0 " + "local i = 1 " + "local _,_,_,_,_,_,_,maxStack = GetItemInfo({0}) " + "while tab <= tabnum do " + "local_,_,v,d =GetGuildBankTabInfo(tab) " + "if v == 1 and d == 1 then " + "SetCurrentGuildBankTab(tab) " + "for slot=1, 98 do " + "local _,c,l=GetGuildBankItemInfo(tab, slot) " + "if c > 0 and l == nil then " + "local id = tonumber(string.match(GetGuildBankItemLink(tab,slot), 'Hitem:(%d+)')) " + "if id == {0} and c < maxStack then " + "tabInfo[i] = {{tab,slot,maxStack-c}} " + "i = i +1 " + "end " + "elseif c == 0 then " + "tabInfo[i] = {{tab,slot,maxStack}} " + "i = i +1 " + "end " + "end " + "end " + "tab = tab + 1 " + "end " + "i = 1 " + "for bag = 0,4 do " + "for slot=1,GetContainerNumSlots(bag) do " + "if i > #tabInfo then return end " + "local id = GetContainerItemID(bag,slot) " + "local _,c,l = GetContainerItemInfo(bag, slot) " + "if id == {0} and l == nil then " + "if c + bagged <= {1} and c <= tabInfo[i][3]then " + "PickupContainerItem(bag,slot) " + "PickupGuildBankItem(tabInfo[i][1] ,tabInfo[i][2]) " + "bagged = bagged + c " + "i=i+1 " + "else " + "local cnt = {1}-bagged " + "if cnt > tabInfo[i][3] then cnt = tabInfo[i][3] end " + "SplitContainerItem(bag,slot, cnt) " + "PickupGuildBankItem(tabInfo[i][1] ,tabInfo[i][2]) " + "bagged = bagged + cnt " + "i=i+1 " + "end " + "end " + "if bagged >= {1} then return end " + "end " + "end " + "return " , id, amount <= 0 ? int.MaxValue : amount, tab, _currentBag, _currentSlot); List <string> retVals = Lua.GetReturnValues(lua); //if (retVals != null) //{ // int.TryParse(retVals[0], out _currentBag); // int.TryParse(retVals[1], out _currentSlot); // _currentBag = -1; // _currentSlot = 1; return(true); //} //return false; }
protected override RunStatus Run(object context) { if (!IsDone) { if (!TimeoutSW.IsRunning) { TimeoutSW.Start(); } if (TimeoutSW.ElapsedMilliseconds > 300000) { IsDone = true; } WoWPoint movetoPoint = loc; if (MailFrame.Instance == null || !MailFrame.Instance.IsVisible) { if (AutoFindMailBox || movetoPoint == WoWPoint.Zero) { mailbox = ObjectManager.GetObjectsOfType <WoWGameObject>().Where(o => o.SubType == WoWGameObjectType.Mailbox) .OrderBy(o => o.Distance).FirstOrDefault(); } else { mailbox = ObjectManager.GetObjectsOfType <WoWGameObject>().Where(o => o.SubType == WoWGameObjectType.Mailbox && o.Location.Distance(loc) < 10) .OrderBy(o => o.Distance).FirstOrDefault(); } if (mailbox != null) { movetoPoint = WoWMathHelper.CalculatePointFrom(me.Location, mailbox.Location, 3); } if (movetoPoint == WoWPoint.Zero) { return(RunStatus.Failure); } if (movetoPoint.Distance(ObjectManager.Me.Location) > 4.5) { Util.MoveTo(movetoPoint); } else if (mailbox != null) { mailbox.Interact(); } return(RunStatus.Running); } else { if (_idList == null) { _idList = BuildItemList(); } if (!_refreshInboxSW.IsRunning) { _refreshInboxSW.Start(); } if (!WaitForContentToShowSW.IsRunning) { WaitForContentToShowSW.Start(); } if (WaitForContentToShowSW.ElapsedMilliseconds < 3000) { return(RunStatus.Running); } uint freeslots = ObjectManager.Me.FreeNormalBagSlots; if (!ConcludingSW.IsRunning) { if (_refreshInboxSW.ElapsedMilliseconds < 61000) { if (GetMailType == GetMailActionType.AllItems) { string lua = string.Format("local totalItems,numItems = GetInboxNumItems() local foundMail=0 for index=1,numItems do local _,_,sender,subj,gold,cod,_,itemCnt,_,_,hasText=GetInboxHeaderInfo(index) if sender ~= nil and cod == 0 and itemCnt == nil and gold == 0 and hasText == nil then DeleteInboxItem(index) end if cod == 0 and ((itemCnt and itemCnt >0) or (gold and gold > 0)) then AutoLootMailItem(index) foundMail = foundMail + 1 break end end local beans = BeanCounterMail and BeanCounterMail:IsVisible() if foundMail == 0 {0}and totalItems == numItems and beans ~= 1 then return 1 else return 0 end ", CheckNewMail ? "and HasNewMail() == nil " : ""); //freeslots / 2 >= MinFreeBagSlots ? (freeslots - MinFreeBagSlots) / 2 : 1); if (Lua.GetReturnValues(lua)[0] == "1" || ObjectManager.Me.FreeNormalBagSlots <= MinFreeBagSlots) { ConcludingSW.Start(); } } else { for (int i = 0; i < _idList.Count; i++) { string lua = string.Format("local totalItems,numItems = GetInboxNumItems() local foundMail=0 for index=1,numItems do local _,_,sender,subj,gold,cod,_,itemCnt,_,_,hasText=GetInboxHeaderInfo(index) if sender ~= nil and cod == 0 and itemCnt == nil and gold == 0 and hasText == nil then DeleteInboxItem(index) end if cod == 0 and itemCnt and itemCnt >0 then for i2=1, ATTACHMENTS_MAX_RECEIVE do local itemlink = GetInboxItemLink(index, i2) if itemlink ~= nil and string.find(itemlink,'{0}') then foundMail = foundMail + 1 TakeInboxItem(index, i2) break end end end end if (foundMail == 0 {1}) or (foundMail == 0 and (numItems == 50 and totalItems >= 50)) then return 1 else return 0 end ", //, Entry, freeslots / 2 >= MinFreeBagSlots ? (freeslots - MinFreeBagSlots) / 2 : 1); _idList[i], CheckNewMail ? "and HasNewMail() == nil " : ""); if (Lua.GetReturnValues(lua)[0] == "1" || ObjectManager.Me.FreeNormalBagSlots <= MinFreeBagSlots) { _idList.RemoveAt(i); } } if (_idList.Count == 0) { ConcludingSW.Start(); } } } else { _refreshInboxSW.Reset(); MailFrame.Instance.Close(); } } if (ConcludingSW.ElapsedMilliseconds > 2000) { IsDone = true; } if (IsDone) { Professionbuddy.Log("Mail retrieval of items:{0} finished", GetMailType); } else { return(RunStatus.Running); } } } return(RunStatus.Failure); }
/// <summary> /// Switches to a different character on same account /// </summary> /// <param name="character"></param> /// <param name="server"></param> /// <param name="botName">Name of bot to use on that character</param> public static void SwitchCharacter(string character, string server, string botName) { if (_isSwitchingToons) { Professionbuddy.Log("Already switching characters"); return; } string loginLua = string.Format(LoginLua, character, server); _isSwitchingToons = true; // reset all actions Professionbuddy.Instance.IsRunning = false; Professionbuddy.Instance.PbBehavior.Reset(); Application.Current.Dispatcher.Invoke( new Action(() => { TreeRoot.Stop(); BotBase bot = BotManager.Instance.Bots.FirstOrDefault( b => b.Key.IndexOf(botName, StringComparison.OrdinalIgnoreCase) >= 0).Value; if (bot != null) { if (Professionbuddy.Instance.SecondaryBot.Name != bot.Name) { Professionbuddy.Instance.SecondaryBot = bot; } if (!bot.Initialized) { bot.Initialize(); } if (ProfessionBuddySettings.Instance.LastBotBase != bot.Name) { ProfessionBuddySettings.Instance.LastBotBase = bot.Name; ProfessionBuddySettings.Instance.Save(); } } else { Professionbuddy.Err("Could not find bot with name {0}", botName); } Lua.DoString("Logout()"); new Thread(() => { while (ObjectManager.IsInGame) { Thread.Sleep(2000); } while (!ObjectManager.IsInGame) { Lua.DoString(loginLua); Thread.Sleep(2000); } TreeRoot.Start(); Professionbuddy.Instance.OnTradeSkillsLoaded += Professionbuddy.Instance.Professionbuddy_OnTradeSkillsLoaded; Professionbuddy.Instance.LoadTradeSkills(); _isSwitchingToons = false; Professionbuddy.Instance.IsRunning = true; }) { IsBackground = true }.Start(); })); }
protected override RunStatus Run(object context) { if (!IsDone) { WoWPoint movetoPoint = loc; if (MailFrame.Instance == null || !MailFrame.Instance.IsVisible) { if (AutoFindMailBox || movetoPoint == WoWPoint.Zero) { _mailbox = ObjectManager.GetObjectsOfType <WoWGameObject>().Where(o => o.SubType == WoWGameObjectType.Mailbox) .OrderBy(o => o.Distance).FirstOrDefault(); } else { _mailbox = ObjectManager.GetObjectsOfType <WoWGameObject>().Where(o => o.SubType == WoWGameObjectType.Mailbox && o.Location.Distance(loc) < 10) .OrderBy(o => o.Distance).FirstOrDefault(); } if (_mailbox != null) { movetoPoint = WoWMathHelper.CalculatePointFrom(me.Location, _mailbox.Location, 3); } if (movetoPoint == WoWPoint.Zero) { return(RunStatus.Failure); } if (movetoPoint.Distance(ObjectManager.Me.Location) > 4.5) { Util.MoveTo(movetoPoint); } else if (_mailbox != null) { _mailbox.Interact(); } return(RunStatus.Running); } else { List <WoWItem> ItemList = BuildItemList(); if (ItemList == null || ItemList.Count == 0) { IsDone = true; return(RunStatus.Failure); } using (new FrameLock()) { MailFrame.Instance.SwitchToSendMailTab(); foreach (WoWItem item in ItemList) { item.UseContainerItem(); } Lua.DoString(string.Format("SendMail ('{0}',' ','');SendMailMailButton:Click();", CharacterSettings.Instance.MailRecipient.ToFormatedUTF8())); } if (IsDone) { Professionbuddy.Log("Done sending {0} via mail", UseCategory ? string.Format("Items that belong to category {0} and subcategory {1}", Category, SubCategory) : string.Format("Items that match Id of {0}", ItemID)); } else { return(RunStatus.Running); } } } return(RunStatus.Failure); }
protected override RunStatus Run(object context) { if (!IsDone) { if (Me.IsFlying) { return(RunStatus.Failure); } if (_lootSw.IsRunning && _lootSw.ElapsedMilliseconds < 1000) { return(RunStatus.Success); } if (LootFrame.Instance != null && LootFrame.Instance.IsVisible) { LootFrame.Instance.LootAll(); _lootSw.Reset(); _lootSw.Start(); return(RunStatus.Success); } uint timeToWait = ((uint)ActionType * 1000) + 2500; if (!Me.IsCasting && (!_castTimer.IsRunning || _castTimer.ElapsedMilliseconds >= timeToWait)) { List <WoWItem> itemList = BuildItemList(); if (itemList == null || itemList.Count == 0) { IsDone = true; Professionbuddy.Log("Done {0}ing", ActionType); } else { // skip 'locked' items int index = 0; for (; index <= itemList.Count; index++) { if (!itemList[index].IsDisabled) { break; } } if (index < itemList.Count) { if (itemList[index].Guid == _lastItemGuid && _lastStackSize == itemList[index].StackCount) { if (++_tries >= 3) { Professionbuddy.Log("Unable to {0} {1}, BlackListing", Name, itemList[index].Name); if (!_blacklistedItems.Contains(_lastItemGuid)) { _blacklistedItems.Add(_lastItemGuid); } return(RunStatus.Success); } } else { _tries = 0; } WoWSpell spell = WoWSpell.FromId(SpellId); if (spell != null) { TreeRoot.GoalText = string.Format("{0}ing {1}", ActionType, itemList[index].Name); Professionbuddy.Log(TreeRoot.GoalText); //Lua.DoString("CastSpellByID({0}) UseContainerItem({1}, {2})", // spellId, ItemList[index].BagIndex + 1, ItemList[index].BagSlot + 1); spell.CastOnItem(itemList[index]); _lastItemGuid = itemList[index].Guid; _lastStackSize = itemList[index].StackCount; _castTimer.Reset(); _castTimer.Start(); } else { IsDone = true; } } } } if (!IsDone) { return(RunStatus.Success); } } return(RunStatus.Failure); }
protected override RunStatus Run(object context) { if (!IsDone) { if (Lua.GetReturnVal <int>("if AuctionFrame and AuctionFrame:IsVisible() then return 1 else return 0 end ", 0) == 0) { MoveToAh(); } else { if (ToScanItemList == null) { ToScanItemList = BuildScanItemList(); ToSellItemList = new List <AuctionEntry>(); } if (ToScanItemList.Count == 0 && ToSellItemList.Count == 0) { ToScanItemList = null; IsDone = true; return(RunStatus.Failure); } if (ToScanItemList.Count > 0) { AuctionEntry ae = ToScanItemList[0]; bool scanDone = ScanAh(ref ae); ToScanItemList[0] = ae; // update if (scanDone) { uint lowestBo = ae.LowestBo; if (lowestBo > MaxBuyout.TotalCopper) { ae.Buyout = MaxBuyout.TotalCopper; } else if (lowestBo < MinBuyout.TotalCopper) { ae.Buyout = MinBuyout.TotalCopper; } else { ae.Buyout = lowestBo - (uint)Math.Ceiling(((double)(lowestBo * UndercutPrecent) / 100d)); } ae.Bid = (uint)((double)(ae.Buyout * BidPrecent) / 100d); bool enoughItemsPosted = AmountType == AmountBasedType.Amount && ae.myAuctions >= Amount; bool tooLowBuyout = !PostIfBelowMinBuyout && lowestBo < MinBuyout.TotalCopper; Professionbuddy.Debug("PB: PostIfBelowMinBuyout:{0} ", PostIfBelowMinBuyout, MinBuyout.TotalCopper); Professionbuddy.Debug("PB: lowestBo:{0} MinBuyout.TotalCopper: {1}", lowestBo, MinBuyout.TotalCopper); Professionbuddy.Debug("PB: tooLowBuyout:{0} enoughItemsPosted: {1}", enoughItemsPosted, enoughItemsPosted); if (!enoughItemsPosted && !tooLowBuyout) { ToSellItemList.Add(ae); } else { Professionbuddy.Log("Skipping {0} since {1}", ae.Name, tooLowBuyout ? string.Format("lowest buyout:{0} is below MinBuyout:{1}", AuctionEntry.GoldString(lowestBo), MinBuyout) : string.Format("{0} items from me are already posted. Max amount is {1}", ae.myAuctions, Amount)); } ToScanItemList.RemoveAt(0); } if (ToScanItemList.Count == 0) { Professionbuddy.Debug("Finished scanning for items"); } } if (ToSellItemList.Count > 0) { if (SellOnAh(ToSellItemList[0])) { Professionbuddy.Log("Selling {0}", ToSellItemList[0]); ToSellItemList.RemoveAt(0); } } } return(RunStatus.Running); } return(RunStatus.Failure); }
const long GbankItemThrottle = 800; // 8 times per sec. protected override RunStatus Run(object context) { if (!IsDone) { if ((Bank == BankType.Guild && !IsGbankFrameVisible) || (Bank == BankType.Personal && !Util.IsBankFrameOpen)) { MoveToBanker(); } else { if (_itemsSW == null) { _itemsSW = new Stopwatch(); _itemsSW.Start(); } else if (_itemsSW.ElapsedMilliseconds < Util.WoWPing * 3) { return(RunStatus.Success); } if (_itemList == null) { _itemList = BuildItemList(); } // no bag space... if (_itemList.Count == 0) { IsDone = true; } else { uint itemID = _itemList.Keys.FirstOrDefault(); bool done; if (Bank == BankType.Personal) { done = PutItemInBank(itemID, _itemList[itemID]); } else { // throttle the amount of items being withdrawn from gbank per sec if (!_gbankItemThrottleSW.IsRunning) { _gbankItemThrottleSW.Start(); } if (_gbankItemThrottleSW.ElapsedMilliseconds < GbankItemThrottle) { return(RunStatus.Success); } _gbankItemThrottleSW.Reset(); _gbankItemThrottleSW.Start(); int ret = PutItemInGBank(itemID, _itemList[itemID], GuildTab); _itemList[itemID] = ret == -1 ? 0 : _itemList[itemID] - ret; done = _itemList[itemID] <= 0; } if (done) { Professionbuddy.Debug("Done Depositing Item:{0} to bank", itemID); _itemList.Remove(itemID); } _itemsSW.Reset(); _itemsSW.Start(); } } if (IsDone) { Professionbuddy.Log("Deposited Items:[{0}] to {1} Bank", ItemID, Bank); } else { return(RunStatus.Success); } } return(RunStatus.Failure); }