static public WoWPoint GetLocationFromDB(MoveToType type, uint entry) { NpcResult npcResults = null; switch (type) { case MoveToType.NearestRepair: npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId, ObjectManager.Me.Location, UnitNPCFlags.Repair); break; case MoveToType.NearestVendor: npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId, ObjectManager.Me.Location, UnitNPCFlags.Vendor); break; case MoveToType.NpcByID: npcResults = NpcQueries.GetNpcById(entry); break; } if (npcResults != null) { return(npcResults.Location); } else { return(WoWPoint.Zero); } }
public static WoWPoint GetLocationFromDB(MoveToType type, uint entry) { NpcResult npcResults = null; switch (type) { case MoveToType.NearestAH: npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId, ObjectManager.Me.Location, UnitNPCFlags.Auctioneer); break; case MoveToType.NearestBanker: npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId, ObjectManager.Me.Location, UnitNPCFlags.Banker); break; case MoveToType.NearestFlight: npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId, ObjectManager.Me.Location, UnitNPCFlags.Flightmaster); break; case MoveToType.NearestGB: npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId, ObjectManager.Me.Location, UnitNPCFlags.GuildBanker); break; case MoveToType.NearestReagentVendor: npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId, ObjectManager.Me.Location, UnitNPCFlags.ReagentVendor); break; case MoveToType.NearestRepair: npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId, ObjectManager.Me.Location, UnitNPCFlags.Repair); break; case MoveToType.NearestVendor: npcResults = NpcQueries.GetNearestNpc(ObjectManager.Me.FactionTemplate, ObjectManager.Me.MapId, ObjectManager.Me.Location, UnitNPCFlags.Vendor); break; case MoveToType.NpcByID: npcResults = NpcQueries.GetNpcById(entry); break; } if (npcResults != null) { return(npcResults.Location); } return(WoWPoint.Zero); }
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); }
protected override async Task Run() { if (MerchantFrame.Instance == null || !MerchantFrame.Instance.IsVisible) { WoWPoint movetoPoint = _loc; if (_entry == 0) { _entry = NpcEntry; } if (_entry == 0) { MoveToAction.GetLocationFromDB(MoveToAction.MoveToType.NearestVendor, 0); NpcResult npcResults = NpcQueries.GetNearestNpc( StyxWoW.Me.MapId, StyxWoW.Me.Location, UnitNPCFlags.Vendor); _entry = (uint)npcResults.Entry; movetoPoint = npcResults.Location; } WoWUnit 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 && StyxWoW.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; } } } } else { if (SellItemType == SellItemActionType.Specific) { var idList = new List <uint>(); string[] entries = ItemID.Split(','); if (entries.Length > 0) { foreach (string entry in entries) { uint itemID; if (!uint.TryParse(entry.Trim(), out itemID)) { PBLog.Warn(Strings["Error_NotAValidItemEntry"], entry.Trim()); continue; } idList.Add(itemID); } } else { PBLog.Warn(Strings["Error_NoItemEntries"]); IsDone = true; return; } List <WoWItem> itemList = StyxWoW.Me.BagItems.Where(u => idList.Contains(u.Entry)). Take(Sell == DepositWithdrawAmount.All ? int.MaxValue : Count).ToList(); using (StyxWoW.Memory.AcquireFrame()) { foreach (WoWItem item in itemList) { item.UseContainerItem(); } } } else { List <WoWItem> itemList = null; IEnumerable <WoWItem> itemQuery = from item in Me.BagItems where !ProtectedItemsManager.Contains(item.Entry) && !ProfessionbuddyBot.Instance.TradeskillTools.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; case SellItemActionType.Blues: itemList = itemQuery.Where(i => i.Quality == WoWItemQuality.Rare).ToList(); break; } if (itemList != null) { using (StyxWoW.Memory.AcquireFrame()) { foreach (WoWItem item in itemList) { item.UseContainerItem(); } } } } PBLog.Log("SellItemAction Completed for {0}", ItemID); IsDone = true; } }