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 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; } }
public static bool ContainsEntry(NpcResult npcResult) { return (npcResult != null) && ContainsEntry(npcResult.Entry); }
public static void AddEntry(NpcResult npcResult, TimeSpan timeSpan) { if(npcResult != null) { AddEntry(npcResult.Entry, timeSpan); } }
public override void Pulse() { if (!_pulseTimer.IsFinished) { return; } _pulseTimer.Reset(); if (LogoutAtCap && WoWCurrency.GetCurrencyByType(WoWCurrencyType.HonorPoints).Amount > 3750 && WoWCurrency.GetCurrencyByType(WoWCurrencyType.JusticePoints).Amount > 3750) { Slog("HonorPoints and Justice Points are Capped! Logging out!"); InactivityDetector.ForceLogout(true); } // We should avoid overriding any poi set by the core if (BotPoi.Current.Type != PoiType.None) { return; } // There are no vendors in battlegrounds or dungeons ! if (Styx.Logic.Battlegrounds.IsInsideBattleground || Me.IsInInstance) { return; } // First item in the list. We should check item by item so we don't end up buying the last item in the list with lower cost. var firstItem = BuyItemList.FirstOrDefault(); // BuyItemList looks to be empty. Wait for user to populate the list if (firstItem == null) { return; } // Should check if we have enough currency. var currencyType = Enum.Parse(typeof(WoWCurrencyType), firstItem.ItemCostType); // Something went wrong with parsing. We should avoid buying that item. if (!(currencyType is WoWCurrencyType)) { Slog("Couldn't parse item's cost type ({0}). Please consult to the plugin writer", firstItem.ItemCostType); BuyItemList.Remove(firstItem); return; } // Actually checking if we have enough of that currency now. var currency = WoWCurrency.GetCurrencyByType((WoWCurrencyType)currencyType); var currencyJp = WoWCurrency.GetCurrencyByType(WoWCurrencyType.JusticePoints); var currencyHp = WoWCurrency.GetCurrencyByType(WoWCurrencyType.HonorPoints); if (currency == null) { return; } if (currency.Amount < firstItem.ItemCost) { // Don't ever buy justice points to buy honor points and vice versa. Otherwise we will enter in an endless loop which will drop // the total of our points. if (firstItem.ItemId != 392 && firstItem.ItemId != 395 && BuyOppositePointToBuildUp) { if (currency.CurrencyType == WoWCurrencyType.JusticePoints && currencyHp.Amount >= 375) { // We set this to true here. So we don't end up spending all our honor points if the Only remove hp/jp points when capped is true _forceAddedPoints = true; if (Me.IsAlliance) { var buyJusticePoint = new BuyItemInfo { ItemCost = 375, ItemName = "Justice Points", ItemSupplierId = 52029, ItemId = 395, ItemCostType = WoWCurrencyType.HonorPoints.ToString() }; Slog( "Adding Justice Point to the Buy List so we can build up Justice Points to buy {0}.", firstItem.ItemName); BuyItemList.Insert(0, buyJusticePoint); } if (Me.IsHorde) { var buyJusticePoint = new BuyItemInfo { ItemCost = 375, ItemName = "Justice Points", ItemSupplierId = 52033, ItemId = 395, ItemCostType = WoWCurrencyType.HonorPoints.ToString() }; Slog( "Adding Justice Point to the Buy List so we can build up Justice Points to buy {0}.", firstItem.ItemName); BuyItemList.Insert(0, buyJusticePoint); } } if (currency.CurrencyType == WoWCurrencyType.HonorPoints && currencyJp.Amount >= 375) { // We set this to true here. So we don't end up spending all our justice points if the Only remove hp/jp points when capped is true _forceAddedPoints = true; if (Me.IsAlliance) { var buyHonorPoint = new BuyItemInfo { ItemCost = 375, ItemName = "Honor Points", ItemSupplierId = 52028, ItemId = 392, ItemCostType = WoWCurrencyType.JusticePoints.ToString() }; Slog("Adding HonorPoint to the Buy List so we can build up HonorPoints to buy {0}.", firstItem.ItemName); BuyItemList.Insert(0, buyHonorPoint); } if (Me.IsHorde) { var buyHonorPoint = new BuyItemInfo { ItemCost = 375, ItemName = "Honor Points", ItemSupplierId = 52034, ItemId = 392, ItemCostType = WoWCurrencyType.JusticePoints.ToString() }; Slog("Adding HonorPoint to the Buy List so we can build up HonorPoints to buy {0}.", firstItem.ItemName); BuyItemList.Insert(0, buyHonorPoint); } } } return; } // We need to find the vendor var vendorAsUnit = ObjectManager.GetObjectsOfType <WoWUnit>(false, false).FirstOrDefault( u => u.Entry == firstItem.ItemSupplierId); Vendor vendor; // Vendor is not around. This won't work if (vendorAsUnit == null) { // Check the database for the vendor as a second hope NpcResult npc = NpcQueries.GetNpcById(firstItem.ItemSupplierId); if (npc != null) { vendor = new Vendor(npc.Entry, npc.Name, Vendor.VendorType.Unknown, npc.Location); } else { Slog("Please move your toon close to the vendor. Otherwise HonorCap won't be able to buy items."); return; } } else { vendor = new Vendor(vendorAsUnit, Vendor.VendorType.Unknown); } // Setting ItemToBuy here so VendorBehavior knows which item we want. ItemToBuy = firstItem; //We need to make sure vender is usable, so removing blacklist. if (Blacklist.Contains(vendorAsUnit)) { Slog("For whatever reason vender is blacklisted, Clearing Blacklist."); Blacklist.Flush(); } // Finally setting the poi BotPoi.Current = new BotPoi(vendor, PoiType.Buy); }