public override void OnResponse(Server.Network.NetState sender, RelayInfo info) { int index = info.ButtonID; switch (index) { case 0: // EXIT { break; } case 1: // Set Filter { this.m_From.SendGump(new BOBFilterGump(this.m_From, this.m_Book)); break; } case 2: // Previous page { if (this.m_Page > 0) { this.m_From.SendGump(new BOBGump(this.m_From, this.m_Book, this.m_Page - 1, this.m_List)); } return; } case 3: // Next page { if (this.GetIndexForPage(this.m_Page + 1) < this.m_List.Count) { this.m_From.SendGump(new BOBGump(this.m_From, this.m_Book, this.m_Page + 1, this.m_List)); } break; } case 4: // Price all { if (this.m_Book.IsChildOf(this.m_From.Backpack)) { this.m_From.Prompt = new SetPricePrompt(this.m_Book, null, this.m_Page, this.m_List); this.m_From.SendMessage("Type in a price for all deeds in the book:"); } break; } default: { bool canDrop = this.m_Book.IsChildOf(this.m_From.Backpack); bool canPrice = canDrop || (this.m_Book.RootParent is PlayerVendor); index -= 5; int type = index % 2; index /= 2; if (index < 0 || index >= this.m_List.Count) { break; } object obj = this.m_List[index]; if (!this.m_Book.Entries.Contains(obj)) { this.m_From.SendLocalizedMessage(1062382); // The deed selected is not available. break; } if (type == 0) // Drop { if (this.m_Book.IsChildOf(this.m_From.Backpack)) { Item item = this.Reconstruct(obj); if (item != null) { Container pack = this.m_From.Backpack; if ((pack == null) || ((pack != null) && (!pack.CheckHold(this.m_From, item, true, true, 0, item.PileWeight + item.TotalWeight)))) { this.m_From.SendLocalizedMessage(503204); // You do not have room in your backpack for this this.m_From.SendGump(new BOBGump(this.m_From, this.m_Book, this.m_Page, null)); } else { if (this.m_Book.IsChildOf(this.m_From.Backpack)) { int sizeOfDroppedBod; if (obj is BOBLargeEntry) { sizeOfDroppedBod = ((BOBLargeEntry)obj).Entries.Length; } else { sizeOfDroppedBod = 1; } this.m_From.AddToBackpack(item); this.m_From.SendLocalizedMessage(1045152); // The bulk order deed has been placed in your backpack. this.m_Book.Entries.Remove(obj); this.m_Book.InvalidateProperties(); if (this.m_Book.Entries.Count / 5 < this.m_Book.ItemCount) { this.m_Book.ItemCount--; this.m_Book.InvalidateItems(); } if (this.m_Book.Entries.Count > 0) { this.m_Page = this.GetPageForIndex(index, sizeOfDroppedBod); this.m_From.SendGump(new BOBGump(this.m_From, this.m_Book, this.m_Page, null)); } else { this.m_From.SendLocalizedMessage(1062381); // The book is empty. } } } } else { this.m_From.SendMessage("Internal error. The bulk order deed could not be reconstructed."); } } } else // Set Price | Buy { if (this.m_Book.IsChildOf(this.m_From.Backpack)) { this.m_From.Prompt = new SetPricePrompt(this.m_Book, obj, this.m_Page, this.m_List); this.m_From.SendLocalizedMessage(1062383); // Type in a price for the deed: } else if (this.m_Book.RootParent is PlayerVendor) { PlayerVendor pv = (PlayerVendor)this.m_Book.RootParent; VendorItem vi = pv.GetVendorItem(this.m_Book); if (vi != null && !vi.IsForSale) { int sizeOfDroppedBod; int price = 0; if (obj is BOBLargeEntry) { price = ((BOBLargeEntry)obj).Price; sizeOfDroppedBod = ((BOBLargeEntry)obj).Entries.Length; } else { price = ((BOBSmallEntry)obj).Price; sizeOfDroppedBod = 1; } if (price == 0) { this.m_From.SendLocalizedMessage(1062382); // The deed selected is not available. } else { if (this.m_Book.Entries.Count > 0) { this.m_Page = this.GetPageForIndex(index, sizeOfDroppedBod); this.m_From.SendGump(new BODBuyGump(this.m_From, this.m_Book, obj, this.m_Page, price)); } else { this.m_From.SendLocalizedMessage(1062381); // The book is emptz } } } } } break; } } }
public override void OnResponse(Network.NetState sender, RelayInfo info) { if (info.ButtonID == 2) { PlayerVendor pv = m_Book.RootParent as PlayerVendor; if (m_Book.Entries.Contains(m_Object) && pv != null) { int price = 0; VendorItem vi = pv.GetVendorItem(m_Book); if (vi != null && !vi.IsForSale) { if (m_Object is BOBLargeEntry) { price = ((BOBLargeEntry)m_Object).Price; } else if (m_Object is BOBSmallEntry) { price = ((BOBSmallEntry)m_Object).Price; } } if (price != m_Price) { pv.SayTo(m_From, "The price has been been changed. If you like, you may offer to purchase the item again."); } else if (price == 0) { pv.SayTo(m_From, 1062382); // The deed selected is not available. } else { Item item = null; if (m_Object is BOBLargeEntry) { item = ((BOBLargeEntry)m_Object).Reconstruct(); } else if (m_Object is BOBSmallEntry) { item = ((BOBSmallEntry)m_Object).Reconstruct(); } if (item == null) { m_From.SendMessage("Internal error. The bulk order deed could not be reconstructed."); } else { pv.Say(m_From.Name); Container pack = m_From.Backpack; if ((pack == null) || ((pack != null) && (!pack.CheckHold(m_From, item, true, true, 0, item.PileWeight + item.TotalWeight)))) { pv.SayTo(m_From, 503204); // You do not have room in your backpack for this m_From.SendGump(new BOBGump(m_From, m_Book, m_Page, null)); } else { if ((pack != null && pack.ConsumeTotal(typeof(Gold), price)) || Banker.Withdraw(m_From, price)) { m_Book.Entries.Remove(m_Object); m_Book.InvalidateProperties(); pv.HoldGold += price; m_From.AddToBackpack(item); m_From.SendLocalizedMessage(1045152); // The bulk order deed has been placed in your backpack. if (m_Book.Entries.Count / 5 < m_Book.ItemCount) { m_Book.ItemCount--; m_Book.InvalidateItems(); } if (m_Book.Entries.Count > 0) { m_From.SendGump(new BOBGump(m_From, m_Book, m_Page, null)); } else { m_From.SendLocalizedMessage(1062381); // The book is empty. } } else { pv.SayTo(m_From, 503205); // You cannot afford this item. item.Delete(); } } } } } else { if (pv == null) { m_From.SendLocalizedMessage(1062382); // The deed selected is not available. } else { pv.SayTo(m_From, 1062382); // The deed selected is not available. } } } else { m_From.SendLocalizedMessage(503207); // Cancelled purchase. } }
public VendorItem(VendorItem item) { this.Item = item.Item; this.Stock = item.Stock; }
public BOBGump(PlayerMobile from, BulkOrderBook book, int page = 0, List <IBOBEntry> list = null) : base(12, 24) { from.CloseGump <BOBGump>(); from.CloseGump <BOBFilterGump>(); m_From = from; m_Book = book; m_Page = page; if (list == null) { list = new List <IBOBEntry>(book.Entries.Count); for (int i = 0; i < book.Entries.Count; ++i) { IBOBEntry entry = book.Entries[i]; if (CheckFilter(entry)) { list.Add(entry); } } } m_List = list; int index = GetIndexForPage(page); int count = GetCountForIndex(index); int tableIndex = 0; PlayerVendor pv = book.RootParent as PlayerVendor; bool canDrop = book.IsChildOf(from.Backpack); bool canBuy = pv != null; bool canPrice = canDrop || canBuy; if (canBuy) { VendorItem vi = pv.GetVendorItem(book); canBuy = vi?.IsForSale == false; } int width = 600; if (!canPrice) { width = 516; } X = (624 - width) / 2; AddPage(0); AddBackground(10, 10, width, 439, 5054); AddImageTiled(18, 20, width - 17, 420, 2624); if (canPrice) { AddImageTiled(573, 64, 24, 352, 200); AddImageTiled(493, 64, 78, 352, 1416); } if (canDrop) { AddImageTiled(24, 64, 32, 352, 1416); } AddImageTiled(58, 64, 36, 352, 200); AddImageTiled(96, 64, 133, 352, 1416); AddImageTiled(231, 64, 80, 352, 200); AddImageTiled(313, 64, 100, 352, 1416); AddImageTiled(415, 64, 76, 352, 200); for (int i = index; i < index + count && i >= 0 && i < list.Count; ++i) { IBOBEntry entry = list[i]; if (!CheckFilter(entry)) { continue; } AddImageTiled(24, 94 + tableIndex * 32, canPrice ? 573 : 489, 2, 2624); tableIndex += entry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1; } AddAlphaRegion(18, 20, width - 17, 420); AddImage(5, 5, 10460); AddImage(width - 15, 5, 10460); AddImage(5, 424, 10460); AddImage(width - 15, 424, 10460); AddHtmlLocalized(canPrice ? 266 : 224, 32, 200, 32, 1062220, LabelColor); // Bulk Order Book AddHtmlLocalized(63, 64, 200, 32, 1062213, LabelColor); // Type AddHtmlLocalized(147, 64, 200, 32, 1062214, LabelColor); // Item AddHtmlLocalized(246, 64, 200, 32, 1062215, LabelColor); // Quality AddHtmlLocalized(336, 64, 200, 32, 1062216, LabelColor); // Material AddHtmlLocalized(429, 64, 200, 32, 1062217, LabelColor); // Amount AddButton(35, 32, 4005, 4007, 1); AddHtmlLocalized(70, 32, 200, 32, 1062476, LabelColor); // Set Filter BOBFilter f = from.UseOwnFilter ? from.BOBFilter : book.Filter; if (f.IsDefault) { AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062475, 16927); // Using No Filter } else if (from.UseOwnFilter) { AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062451, 16927); // Using Your Filter } else { AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062230, 16927); // Using Book Filter } AddButton(375, 416, 4017, 4018, 0); AddHtmlLocalized(410, 416, 120, 20, 1011441, LabelColor); // EXIT if (canDrop) { AddHtmlLocalized(26, 64, 50, 32, 1062212, LabelColor); // Drop } if (canPrice) { AddHtmlLocalized(516, 64, 200, 32, 1062218, LabelColor); // Price if (canBuy) { AddHtmlLocalized(576, 64, 200, 32, 1062219, LabelColor); // Buy } else { AddHtmlLocalized(576, 64, 200, 32, 1062227, LabelColor); // Set AddButton(450, 416, 4005, 4007, 4); AddHtml(485, 416, 120, 20, "<BASEFONT COLOR=#FFFFFF>Price all</FONT>"); } } tableIndex = 0; if (page > 0) { AddButton(75, 416, 4014, 4016, 2); AddHtmlLocalized(110, 416, 150, 20, 1011067, LabelColor); // Previous page } if (GetIndexForPage(page + 1) < list.Count) { AddButton(225, 416, 4005, 4007, 3); AddHtmlLocalized(260, 416, 150, 20, 1011066, LabelColor); // Next page } for (int i = index; i < index + count && i >= 0 && i < list.Count; ++i) { IBOBEntry entry = list[i]; if (!CheckFilter(entry)) { continue; } if (entry is BOBLargeEntry largeEntry) { int y = 96 + tableIndex * 32; if (canDrop) { AddButton(35, y + 2, 5602, 5606, 5 + i * 2); } if (canDrop || (canBuy && entry.Price > 0)) { AddButton(579, y + 2, 2117, 2118, 6 + i * 2); AddLabel(495, y, 1152, entry.Price.ToString()); } AddHtmlLocalized(61, y, 50, 32, 1062225, LabelColor); // Large for (int j = 0; j < largeEntry.Entries.Length; ++j) { BOBLargeSubEntry sub = largeEntry.Entries[j]; AddHtmlLocalized(103, y, 130, 32, sub.Number, LabelColor); if (entry.RequireExceptional) { AddHtmlLocalized(235, y, 80, 20, 1060636, LabelColor); // exceptional } else { AddHtmlLocalized(235, y, 80, 20, 1011542, LabelColor); // normal } TextDefinition name = GetMaterialName(entry.Material, entry.DeedType, sub.ItemType); if (name.Number > 0) { AddHtmlLocalized(316, y, 100, 20, name, LabelColor); } else { AddLabel(316, y, 1152, name); } AddLabel(421, y, 1152, $"{sub.AmountCur} / {entry.AmountMax}"); ++tableIndex; y += 32; } } else { BOBSmallEntry smallEntry = (BOBSmallEntry)entry; int y = 96 + tableIndex++ *32; if (canDrop) { AddButton(35, y + 2, 5602, 5606, 5 + i * 2); } if (canDrop || (canBuy && smallEntry.Price > 0)) { AddButton(579, y + 2, 2117, 2118, 6 + i * 2); AddLabel(495, y, 1152, smallEntry.Price.ToString()); } AddHtmlLocalized(61, y, 50, 32, 1062224, LabelColor); // Small AddHtmlLocalized(103, y, 130, 32, smallEntry.Number, LabelColor); if (smallEntry.RequireExceptional) { AddHtmlLocalized(235, y, 80, 20, 1060636, LabelColor); // exceptional } else { AddHtmlLocalized(235, y, 80, 20, 1011542, LabelColor); // normal } TextDefinition name = GetMaterialName(smallEntry.Material, smallEntry.DeedType, smallEntry.ItemType); if (name.Number > 0) { AddHtmlLocalized(316, y, 100, 20, name, LabelColor); } else { AddLabel(316, y, 1152, name); } AddLabel(421, y, 1152, $"{smallEntry.AmountCur} / {smallEntry.AmountMax}"); } } }
public static IVendorSearchItem CreateForContainedItem(VendorItem vi, Item item) { return(new VendorSearchItem(item, vi.Price, () => vi.Valid, vi.Vendor, vi.Item.Parent as Container, true)); }
public override void OnResponse(Server.Network.NetState sender, RelayInfo info) { int index = info.ButtonID; switch (index) { case 0: // EXIT { break; } case 1: // Set Filter { m_From.SendGump(new BOBFilterGump(m_From, m_Book)); break; } case 2: // Previous page { if (m_Page > 0) { m_From.SendGump(new BOBGump(m_From, m_Book, m_Page - 1, m_List)); } return; } case 3: // Next page { if (GetIndexForPage(m_Page + 1) < m_List.Count) { m_From.SendGump(new BOBGump(m_From, m_Book, m_Page + 1, m_List)); } break; } default: { bool canDrop = m_Book.IsChildOf(m_From.Backpack); bool canPrice = canDrop || (m_Book.RootParent is PlayerVendor); index -= 4; int type = index % 2; index /= 2; if (index < 0 || index >= m_List.Count) { break; } object obj = m_List[index]; if (!m_Book.Entries.Contains(obj)) { m_From.SendLocalizedMessage(1062382); // The deed selected is not available. break; } if (type == 0) // Drop { if (m_Book.IsChildOf(m_From.Backpack)) { Item item = Reconstruct(obj); if (item != null) { m_From.AddToBackpack(item); m_From.SendLocalizedMessage(1045152); // The bulk order deed has been placed in your backpack. m_Book.Entries.Remove(obj); m_Book.InvalidateProperties(); if (m_Book.Entries.Count > 0) { m_From.SendGump(new BOBGump(m_From, m_Book, 0, null)); } else { m_From.SendLocalizedMessage(1062381); // The book is empty. } } else { m_From.SendMessage("Internal error. The bulk order deed could not be reconstructed."); } } } else // Set Price | Buy { if (m_Book.IsChildOf(m_From.Backpack)) { m_From.Prompt = new SetPricePrompt(m_Book, obj, m_Page, m_List); m_From.SendLocalizedMessage(1062383); // Type in a price for the deed: } else if (m_Book.RootParent is PlayerVendor) { PlayerVendor pv = (PlayerVendor)m_Book.RootParent; VendorItem vi = pv.GetVendorItem(m_Book); int price = 0; if (vi != null && !vi.IsForSale) { if (obj is BOBLargeEntry) { price = ((BOBLargeEntry)obj).Price; } else if (obj is BOBSmallEntry) { price = ((BOBSmallEntry)obj).Price; } } if (price == 0) { m_From.SendLocalizedMessage(1062382); // The deed selected is not available. } else { m_From.SendGump(new BODBuyGump(m_From, m_Book, obj, price)); } } } break; } } }
public static void HandleVendorInventoryList(Packet packet) { var npcVendor = new NpcVendor(); var guid = new byte[8]; packet.StartBitStream(guid, 5, 4, 7, 1, 2, 3); var itemCount = packet.ReadBits("Item Count", 18); var hasExtendedCost = new bool[itemCount]; var hasCondition = new bool[itemCount]; for (int i = 0; i < itemCount; ++i) { hasCondition[i] = !packet.ReadBit(); hasExtendedCost[i] = !packet.ReadBit(); packet.ReadBit("Unk bit", i); } packet.StartBitStream(guid, 6, 0); packet.ResetBitReader(); packet.ReadXORBytes(guid, 3, 4); npcVendor.VendorItems = new List <VendorItem>((int)itemCount); for (int i = 0; i < itemCount; ++i) { var vendorItem = new VendorItem(); vendorItem.ItemId = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Item, "Item ID", i); vendorItem.Slot = packet.ReadUInt32("Item Position", i); packet.ReadInt32("Item Upgrade ID", i); packet.ReadInt32("Display ID", i); var maxCount = packet.ReadInt32("Max Count", i); var buyCount = packet.ReadUInt32("Buy Count", i); packet.ReadInt32("Price", i); if (hasCondition[i]) { packet.ReadInt32("Condition ID", i); } vendorItem.Type = packet.ReadUInt32("Type", i); // 1 - item, 2 - currency packet.ReadInt32("Max Durability", i); if (hasExtendedCost[i]) { vendorItem.ExtendedCostId = packet.ReadUInt32("Extended Cost", i); } vendorItem.MaxCount = maxCount == -1 ? 0 : maxCount; // TDB if (vendorItem.Type == 2) { vendorItem.MaxCount = (int)buyCount; } npcVendor.VendorItems.Add(vendorItem); } packet.ReadXORBytes(guid, 1, 2, 7); packet.ReadByte("Unk Byte"); packet.ReadXORBytes(guid, 6, 0, 5); packet.WriteGuid("GUID", guid); var GUID = new Guid(BitConverter.ToUInt64(guid, 0)); Storage.NpcVendors.Add(GUID.GetEntry(), npcVendor, packet.TimeSpan); }
/// <summary> /// Try spawn vending item and reduce items count in stock /// </summary> public void TryVendItem(VendorItem vendorItem, ConnectedPlayer player = null) { if (vendorItem == null) { return; } if (!CanSell(vendorItem, player)) { return; } // Spawn item on top of the vending machine Vector3 spawnPos = gameObject.RegisterTile().WorldPositionServer; var spawnedItem = Spawn.ServerPrefab(vendorItem.Item, spawnPos, transform.parent, scatterRadius: DispenseScatterRadius).GameObject; //something went wrong trying to spawn the item if (spawnedItem == null) { return; } vendorItem.Stock--; // State sucsess message to chat var itemNameStr = TextUtils.UppercaseFirst(spawnedItem.ExpensiveName()); Chat.AddLocalMsgToChat($"{itemNameStr} was dispensed from the vending machine", gameObject); // Play vending sound SoundManager.PlayNetworkedAtPos(VendingSound, gameObject.WorldPosServer(), Random.Range(.75f, 1.1f), sourceObj: gameObject); //Ejecting in direction if (EjectObjects && EjectDirection != EjectDirection.None && spawnedItem.TryGetComponent <CustomNetTransform>(out var cnt)) { Vector3 offset = Vector3.zero; switch (EjectDirection) { case EjectDirection.Up: offset = transform.rotation * Vector3.up / Random.Range(4, 12); break; case EjectDirection.Down: offset = transform.rotation * Vector3.down / Random.Range(4, 12); break; case EjectDirection.Random: offset = new Vector3(Random.Range(-0.15f, 0.15f), Random.Range(-0.15f, 0.15f), 0); break; } cnt.Throw(new ThrowInfo { ThrownBy = spawnedItem, Aim = BodyPartType.Chest, OriginWorldPos = spawnPos, WorldTrajectory = offset, SpinMode = (EjectDirection == EjectDirection.Random) ? SpinMode.Clockwise : SpinMode.None }); } OnItemVended.Invoke(vendorItem); }
public static void HandleVendorInventoryList434(Packet packet) { var npcVendor = new NpcVendor(); var guidBytes = new byte[8]; guidBytes[1] = packet.ReadBit(); guidBytes[0] = packet.ReadBit(); var itemCount = packet.ReadBits("Item Count", 21); guidBytes[3] = packet.ReadBit(); guidBytes[6] = packet.ReadBit(); guidBytes[5] = packet.ReadBit(); guidBytes[2] = packet.ReadBit(); guidBytes[7] = packet.ReadBit(); var hasExtendedCost = new bool[itemCount]; var hasCondition = new bool[itemCount]; for (int i = 0; i < itemCount; ++i) { hasExtendedCost[i] = !packet.ReadBit(); hasCondition[i] = !packet.ReadBit(); } guidBytes[4] = packet.ReadBit(); npcVendor.VendorItems = new List <VendorItem>((int)itemCount); for (int i = 0; i < itemCount; ++i) { var vendorItem = new VendorItem { Slot = packet.ReadUInt32("Item Position", i) }; packet.ReadInt32("Max Durability", i); if (hasExtendedCost[i]) { vendorItem.ExtendedCostId = packet.ReadUInt32("Extended Cost", i); } vendorItem.ItemId = (uint)packet.ReadInt32 <ItemId>("Item ID", i); vendorItem.Type = packet.ReadUInt32("Type", i); // 1 - item, 2 - currency packet.ReadInt32("Price", i); packet.ReadInt32("Display ID", i); if (hasCondition[i]) { packet.ReadInt32("Condition ID", i); } var maxCount = packet.ReadInt32("Max Count", i); vendorItem.MaxCount = maxCount == -1 ? 0 : maxCount; // TDB var buyCount = packet.ReadUInt32("Buy Count", i); if (vendorItem.Type == 2) { vendorItem.MaxCount = (int)buyCount; } npcVendor.VendorItems.Add(vendorItem); } packet.ReadXORByte(guidBytes, 5); packet.ReadXORByte(guidBytes, 4); packet.ReadXORByte(guidBytes, 1); packet.ReadXORByte(guidBytes, 0); packet.ReadXORByte(guidBytes, 6); packet.ReadByte("Unk Byte"); packet.ReadXORByte(guidBytes, 2); packet.ReadXORByte(guidBytes, 3); packet.ReadXORByte(guidBytes, 7); var guid = packet.WriteGuid("GUID", guidBytes); Storage.NpcVendors.Add(guid.GetEntry(), npcVendor, packet.TimeSpan); }
public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID == 2) { PlayerVendor pv = m_Book.RootParent as PlayerVendor; if (pv != null) { int price = 0; VendorItem vi = pv.GetVendorItem(m_Book); if (vi != null && !vi.IsForSale) { price = m_Recipe.Price; } if (price != m_Price) { pv.SayTo(m_From, 1150158); // The price of the selected item has been changed from the value you confirmed. You must select and confirm the purchase again at the new price in order to buy it. m_Book.Using = false; } else if (m_Recipe.Amount == 0 || price == 0) { pv.SayTo(m_From, 1158821); // The recipe selected is not available. m_Book.Using = false; } else { Item item = new RecipeScroll(m_Recipe.RecipeID); pv.Say(m_From.Name); Container pack = m_From.Backpack; if ((pack != null && pack.ConsumeTotal(typeof(Gold), price)) || Banker.Withdraw(m_From, price)) { m_Book.Recipes.ForEach(x => { if (x.RecipeID == m_Recipe.RecipeID) { x.Amount = x.Amount - 1; } }); m_Book.InvalidateProperties(); pv.HoldGold += price; if (m_From.AddToBackpack(item)) { m_From.SendLocalizedMessage(1158820); // The recipe has been placed in your backpack. } else { pv.SayTo(m_From, 503204); // You do not have room in your backpack for this. } m_From.SendGump(new RecipeBookGump(m_From, m_Book)); } else { pv.SayTo(m_From, 503205); // You cannot afford this item. item.Delete(); m_Book.Using = false; } } } else { m_Book.Using = false; if (pv == null) { m_From.SendLocalizedMessage(1158821); // The recipe selected is not available. } else { pv.SayTo(m_From, 1158821); // The recipe selected is not available. } } } else { m_Book.Using = false; m_From.SendLocalizedMessage(503207); // Cancelled purchase. } }
public static void HandleVendorInventoryList(Packet packet) { var npcVendor = new NpcVendor(); var guid = new byte[8]; var itemCount = (int)packet.ReadBits(18); guid[0] = packet.ReadBit(); var hasExtendedCost = new bool[itemCount]; var hasCondition = new bool[itemCount]; for (int i = 0; i < itemCount; ++i) { packet.ReadBit("Unk bit", i); hasExtendedCost[i] = !packet.ReadBit(); hasCondition[i] = !packet.ReadBit(); } guid[3] = packet.ReadBit(); guid[7] = packet.ReadBit(); guid[6] = packet.ReadBit(); guid[5] = packet.ReadBit(); guid[2] = packet.ReadBit(); guid[1] = packet.ReadBit(); guid[4] = packet.ReadBit(); packet.ReadXORByte(guid, 7); packet.ReadXORByte(guid, 6); npcVendor.VendorItems = new List <VendorItem>(itemCount); for (int i = 0; i < itemCount; ++i) { var vendorItem = new VendorItem(); vendorItem.Type = packet.ReadUInt32("Type", i); // 1 - item, 2 - currency var buyCount = packet.ReadUInt32("Buy Count", i); var maxCount = packet.ReadInt32("Max Count", i); packet.ReadInt32("Display ID", i); vendorItem.Slot = packet.ReadUInt32("Item Position", i); packet.ReadInt32("Max Durability", i); packet.ReadInt32("Price", i); if (hasExtendedCost[i]) { vendorItem.ExtendedCostId = packet.ReadUInt32("Extended Cost", i); } packet.ReadInt32("Item Upgrade ID", i); vendorItem.ItemId = (uint)packet.ReadInt32 <ItemId>("Item ID", i); if (hasCondition[i]) { packet.ReadInt32("Condition ID", i); } npcVendor.VendorItems.Add(vendorItem); } packet.ReadByte("Byte28"); packet.ReadXORByte(guid, 2); packet.ReadXORByte(guid, 3); packet.ReadXORByte(guid, 5); packet.ReadXORByte(guid, 1); packet.ReadXORByte(guid, 0); packet.ReadXORByte(guid, 4); packet.WriteGuid("Guid", guid); var vendorGUID = new WowGuid64(BitConverter.ToUInt64(guid, 0)); Storage.NpcVendors.Add(vendorGUID.GetEntry(), npcVendor, packet.TimeSpan); }
public VendorToolGump(Mobile from, PlayerVendor pv, int page) : base(50, 40) { // make sure we don't crash shit.. try { from.CloseGump(typeof(VendorToolGump)); m_Vendor = pv; m_Page = page; ArrayList values = new ArrayList(m_Vendor.SellItems.Values); AddPage(0); AddImageTiled(0, 0, 430, 508, 0xA40); AddAlphaRegion(1, 1, 428, 506); AddHtml(0, 0, 428, 22, "<basefont color=#FFFFFF><center>Vendor Inventory</center></basefont>", false, false); AddHtml(2, 22, 200, 16, "<basefont color=#ffffff>Description</basefont>", false, false); AddHtml(203, 22, 50, 16, "<basefont color=#ffffff>Price</basefont>", false, false); AddHtml(254, 22, 110, 16, "<basefont color=#ffffff>Item</basefont>", false, false); for (int i = page * 20; i < page * 20 + 20 && i < m_Vendor.SellItems.Count; i++) { VendorItem vi = values[i] as VendorItem; if (vi == null) { continue; } AddHtml(2, 44 + 22 * (i % 20), 200, 16, String.Format("<basefont color=#ffffff>{0}</basefont>", vi.Description), false, false); AddHtml(203, 44 + 22 * (i % 20), 50, 16, String.Format("<basefont color=#ffffff>{0}</basefont>", (vi.IsForSale ? vi.Price.ToString() : "NFS")), false, false); string typename; if (vi.Item == null) { typename = "null"; } else { typename = vi.Item.GetType().ToString(); typename = typename.Substring(typename.LastIndexOf(".") + 1); } AddHtml(254, 44 + 22 * (i % 20), 110, 16, String.Format("<basefont color=#ffffff>{0}</basefont>", typename), false, false); AddButton(369, 44 + 22 * (i % 20), 0xFB1, 0xFB3, 4 + 2 * i, GumpButtonType.Reply, 0); AddButton(399, 44 + 22 * (i % 20), 0xFA5, 0xFA7, 5 + 2 * i, GumpButtonType.Reply, 0); } AddButton(1, 485, 0xFB1, 0xFB3, 3, GumpButtonType.Reply, 0); AddHtml(35, 485, 100, 22, "<basefont color=#ffffff>Clear Vendor</basefont>", false, false); AddButton(200, 485, 0xFB7, 0xFB9, 0, GumpButtonType.Reply, 0); // ok if (m_Page > 0) { AddButton(339, 485, 0xFAE, 0xFB0, 1, GumpButtonType.Reply, 0); // back } if (m_Vendor.SellItems.Count >= 20 * m_Page) { AddButton(369, 485, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0); // next } } catch { from.SendMessage("An error occurred while listing the vendor contents."); } }
public static void HandleVendorInventoryList(Packet packet) { var npcVendor = new NpcVendor(); var guid = new byte[8]; guid[5] = packet.ReadBit(); guid[7] = packet.ReadBit(); guid[1] = packet.ReadBit(); guid[3] = packet.ReadBit(); guid[6] = packet.ReadBit(); var itemCount = packet.ReadBits(18); var unkBit = new uint[itemCount]; var hasExtendedCost = new bool[itemCount]; var hasCondition = new bool[itemCount]; for (var i = 0; i < itemCount; ++i) { unkBit[i] = packet.ReadBit(); hasExtendedCost[i] = !packet.ReadBit(); // +44 hasCondition[i] = !packet.ReadBit(); // +36 } guid[4] = packet.ReadBit(); guid[0] = packet.ReadBit(); guid[2] = packet.ReadBit(); packet.ReadByte("Byte10"); npcVendor.VendorItems = new List <VendorItem>((int)itemCount); for (var i = 0; i < itemCount; ++i) { var vendorItem = new VendorItem(); packet.AddValue("unkBit", unkBit[i], i); packet.ReadInt32("Max Durability", i); // +16 packet.ReadInt32("Price", i); // +20 vendorItem.Type = packet.ReadUInt32("Type", i); // +4 var maxCount = packet.ReadInt32("Max Count", i); // +24 packet.ReadInt32("Display ID", i); // +12 var buyCount = packet.ReadUInt32("Buy Count", i); // +28 vendorItem.ItemId = (uint)packet.ReadEntry <Int32>(StoreNameType.Item, "Item ID", i); // +8 if (hasExtendedCost[i]) { vendorItem.ExtendedCostId = packet.ReadUInt32("Extended Cost", i); // +36 } packet.ReadInt32("Item Upgrade ID", i); // +32 if (hasCondition[i]) { packet.ReadInt32("Condition ID", i); // +40 } vendorItem.Slot = packet.ReadUInt32("Item Position", i); // +0 npcVendor.VendorItems.Add(vendorItem); } packet.ParseBitStream(guid, 3, 7, 0, 6, 2, 1, 4, 5); packet.WriteGuid("Guid", guid); var vendorGUID = new WowGuid64(BitConverter.ToUInt64(guid, 0)); Storage.NpcVendors.Add(vendorGUID.GetEntry(), npcVendor, packet.TimeSpan); }
public static void HandleVendorInventoryList422(Packet packet) { var npcVendor = new NpcVendor(); var guidBytes = new byte[8]; guidBytes[5] = (byte)(packet.ReadBit() ? 1 : 0); guidBytes[6] = (byte)(packet.ReadBit() ? 1 : 0); guidBytes[1] = (byte)(packet.ReadBit() ? 1 : 0); guidBytes[2] = (byte)(packet.ReadBit() ? 1 : 0); guidBytes[3] = (byte)(packet.ReadBit() ? 1 : 0); guidBytes[0] = (byte)(packet.ReadBit() ? 1 : 0); guidBytes[7] = (byte)(packet.ReadBit() ? 1 : 0); guidBytes[4] = (byte)(packet.ReadBit() ? 1 : 0); if (guidBytes[2] != 0) { guidBytes[2] ^= packet.ReadByte(); } if (guidBytes[3] != 0) { guidBytes[3] ^= packet.ReadByte(); } var itemCount = packet.ReadUInt32("Item Count"); if (guidBytes[5] != 0) { guidBytes[5] ^= packet.ReadByte(); } if (guidBytes[0] != 0) { guidBytes[0] ^= packet.ReadByte(); } if (guidBytes[1] != 0) { guidBytes[1] ^= packet.ReadByte(); } packet.ReadByte("Unk Byte"); if (guidBytes[4] != 0) { guidBytes[4] ^= packet.ReadByte(); } if (guidBytes[7] != 0) { guidBytes[7] ^= packet.ReadByte(); } if (guidBytes[6] != 0) { guidBytes[6] ^= packet.ReadByte(); } var guid = new Guid(BitConverter.ToUInt64(guidBytes, 0)); packet.WriteLine("GUID: {0}", guid); npcVendor.VendorItems = new List <VendorItem>((int)itemCount); for (var i = 0; i < itemCount; i++) { var vendorItem = new VendorItem(); packet.ReadInt32("Max Durability", i); vendorItem.Slot = packet.ReadUInt32("Item Position", i); vendorItem.ItemId = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Item, "Item ID", i); packet.ReadInt32("Unk Int32 1", i); packet.ReadInt32("Display ID", i); vendorItem.MaxCount = packet.ReadInt32("Max Count", i); packet.ReadUInt32("Buy Count", i); vendorItem.ExtendedCostId = packet.ReadUInt32("Extended Cost", i); packet.ReadInt32("Unk Int32 2", i); packet.ReadInt32("Price", i); npcVendor.VendorItems.Add(vendorItem); } Storage.NpcVendors.TryAdd(guid.GetEntry(), npcVendor); }
public static void HandleVendorInventoryList(Packet packet) { var npcVendor = new NpcVendor(); var guid = packet.ReadPackedGuid128("VendorGUID"); packet.ReadByte("Reason"); var int9 = packet.ReadInt32("VendorItems"); npcVendor.VendorItems = new List <VendorItem>(int9); for (var i = 0; i < int9; ++i) { var vendorItem = new VendorItem(); vendorItem.Slot = (uint)packet.ReadInt32("Muid", i); vendorItem.Type = (uint)packet.ReadInt32("Type", i); // ItemInstance //if (ItemInstance) { vendorItem.ItemId = (uint)packet.ReadEntry <Int32>(StoreNameType.Item, "ItemID", i); packet.ReadUInt32("RandomPropertiesSeed", i); packet.ReadUInt32("RandomPropertiesID", i); packet.ResetBitReader(); var hasBonuses = packet.ReadBit("HasItemBonus", i); var hasModifications = packet.ReadBit("HasModifications", i); if (hasBonuses) { packet.ReadByte("Context", i); var bonusCount = packet.ReadUInt32(); for (var j = 0; j < bonusCount; ++j) { packet.ReadUInt32("BonusListID", i, j); } } if (hasModifications) { var modificationCount = packet.ReadUInt32() / 4; for (var j = 0; j < modificationCount; ++j) { packet.ReadUInt32("Modification", i, j); } } } var maxCount = packet.ReadInt32("Quantity", i); packet.ReadInt32("Price", i); packet.ReadInt32("Durability", i); var buyCount = packet.ReadInt32("StackCount", i); vendorItem.ExtendedCostId = (uint)packet.ReadInt32("ExtendedCostID", i); packet.ReadInt32("PlayerConditionFailed", i); packet.ResetBitReader(); packet.ReadBit("DoNotFilterOnVendor", i); vendorItem.MaxCount = maxCount == -1 ? 0 : maxCount; // TDB if (vendorItem.Type == 2) { vendorItem.MaxCount = (int)buyCount; } npcVendor.VendorItems.Add(vendorItem); } Storage.NpcVendors.Add(guid.GetEntry(), npcVendor, packet.TimeSpan); }
public void SendListInventory(ObjectGuid vendorGuid) { Creature vendor = GetPlayer().GetNPCIfCanInteractWith(vendorGuid, NPCFlags.Vendor); if (vendor == null) { Log.outDebug(LogFilter.Network, "WORLD: SendListInventory - {0} not found or you can not interact with him.", vendorGuid.ToString()); GetPlayer().SendSellError(SellResult.CantFindVendor, null, ObjectGuid.Empty); return; } // remove fake death if (GetPlayer().HasUnitState(UnitState.Died)) { GetPlayer().RemoveAurasByType(AuraType.FeignDeath); } // Stop the npc if moving if (vendor.HasUnitState(UnitState.Moving)) { vendor.StopMoving(); } VendorItemData vendorItems = vendor.GetVendorItems(); int rawItemCount = vendorItems != null?vendorItems.GetItemCount() : 0; VendorInventory packet = new VendorInventory(); packet.Vendor = vendor.GetGUID(); float discountMod = GetPlayer().GetReputationPriceDiscount(vendor); byte count = 0; for (uint slot = 0; slot < rawItemCount; ++slot) { VendorItem vendorItem = vendorItems.GetItem(slot); if (vendorItem == null) { continue; } VendorItemPkt item = new VendorItemPkt(); PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(vendorItem.PlayerConditionId); if (playerCondition != null) { if (!ConditionManager.IsPlayerMeetingCondition(_player, playerCondition)) { item.PlayerConditionFailed = (int)playerCondition.Id; } } if (vendorItem.Type == ItemVendorType.Item) { ItemTemplate itemTemplate = Global.ObjectMgr.GetItemTemplate(vendorItem.item); if (itemTemplate == null) { continue; } int leftInStock = vendorItem.maxcount == 0 ? -1 : (int)vendor.GetVendorItemCurrentCount(vendorItem); if (!GetPlayer().IsGameMaster()) { if (!Convert.ToBoolean(itemTemplate.GetAllowableClass() & GetPlayer().getClassMask()) && itemTemplate.GetBonding() == ItemBondingType.OnAcquire) { continue; } if ((itemTemplate.GetFlags2().HasAnyFlag(ItemFlags2.FactionHorde) && GetPlayer().GetTeam() == Team.Alliance) || (itemTemplate.GetFlags2().HasAnyFlag(ItemFlags2.FactionAlliance) && GetPlayer().GetTeam() == Team.Horde)) { continue; } if (leftInStock == 0) { continue; } } if (!Global.ConditionMgr.IsObjectMeetingVendorItemConditions(vendor.GetEntry(), vendorItem.item, _player, vendor)) { Log.outDebug(LogFilter.Condition, "SendListInventory: conditions not met for creature entry {0} item {1}", vendor.GetEntry(), vendorItem.item); continue; } int price = (int)(vendorItem.IsGoldRequired(itemTemplate) ? Math.Floor(itemTemplate.GetBuyPrice() * discountMod) : 0); int priceMod = GetPlayer().GetTotalAuraModifier(AuraType.ModVendorItemsPrices); if (priceMod != 0) { price -= MathFunctions.CalculatePct(price, priceMod); } item.MuID = (int)slot + 1; item.Durability = (int)itemTemplate.MaxDurability; item.ExtendedCostID = (int)vendorItem.ExtendedCost; item.Type = (int)vendorItem.Type; item.Quantity = leftInStock; item.StackCount = (int)itemTemplate.GetBuyCount(); item.Price = (ulong)price; item.DoNotFilterOnVendor = vendorItem.IgnoreFiltering; item.Item.ItemID = vendorItem.item; if (!vendorItem.BonusListIDs.Empty()) { item.Item.ItemBonus.HasValue = true; item.Item.ItemBonus.Value.BonusListIDs = vendorItem.BonusListIDs; } packet.Items.Add(item); } else if (vendorItem.Type == ItemVendorType.Currency) { CurrencyTypesRecord currencyTemplate = CliDB.CurrencyTypesStorage.LookupByKey(vendorItem.item); if (currencyTemplate == null) { continue; } if (vendorItem.ExtendedCost == 0) { continue; // there's no price defined for currencies, only extendedcost is used } item.MuID = (int)slot + 1; // client expects counting to start at 1 item.ExtendedCostID = (int)vendorItem.ExtendedCost; item.Item.ItemID = vendorItem.item; item.Type = (int)vendorItem.Type; item.StackCount = (int)vendorItem.maxcount; item.DoNotFilterOnVendor = vendorItem.IgnoreFiltering; packet.Items.Add(item); } else { continue; } if (++count >= SharedConst.MaxVendorItems) { break; } } SendPacket(packet); }
public static bool CheckMatch(VendorItem vitem, SearchCriteria searchCriteria) { if (vitem == null) { return(false); } Item item = vitem.Item; if (searchCriteria.MinPrice > -1 && vitem.Price < searchCriteria.MinPrice) { return(false); } if (searchCriteria.MaxPrice > -1 && vitem.Price > searchCriteria.MaxPrice) { return(false); } if (!String.IsNullOrEmpty(searchCriteria.SearchName)) { string name = GetItemName(item); if (name == null) { return(false); // TODO? REturn null names? } if (!CheckKeyword(searchCriteria.SearchName, item) && name.ToLower().IndexOf(searchCriteria.SearchName.ToLower()) < 0) { return(false); } } if (searchCriteria.SearchType != Layer.Invalid && searchCriteria.SearchType != item.Layer) { return(false); } if (searchCriteria.Details.Count == 0) { return(true); } foreach (SearchDetail detail in searchCriteria.Details) { object o = detail.Attribute; int value = detail.Value; if (value == 0) { value = 1; } if (o is AosAttribute) { AosAttributes attrs = RunicReforging.GetAosAttributes(item); if (attrs == null || attrs[(AosAttribute)o] < value) { return(false); } } else if (o is AosWeaponAttribute) { AosWeaponAttributes attrs = RunicReforging.GetAosWeaponAttributes(item); if ((AosWeaponAttribute)o == AosWeaponAttribute.MageWeapon) { if (attrs == null || attrs[(AosWeaponAttribute)o] == 0 || attrs[(AosWeaponAttribute)o] > Math.Max(0, 30 - value)) { return(false); } } else if (attrs == null || attrs[(AosWeaponAttribute)o] < value) { return(false); } } else if (o is SAAbsorptionAttribute) { SAAbsorptionAttributes attrs = RunicReforging.GetSAAbsorptionAttributes(item); if (attrs == null || attrs[(SAAbsorptionAttribute)o] < value) { return(false); } } else if (o is AosArmorAttribute) { AosArmorAttributes attrs = RunicReforging.GetAosArmorAttributes(item); if (attrs == null || attrs[(AosArmorAttribute)o] < value) { return(false); } } else if (o is SkillName) { if (detail.Category != Category.RequiredSkill) { AosSkillBonuses skillbonuses = RunicReforging.GetAosSkillBonuses(item); if (skillbonuses != null) { bool hasSkill = false; for (int i = 0; i < 5; i++) { SkillName check; double bonus; if (skillbonuses.GetValues(i, out check, out bonus) && check == (SkillName)o && bonus >= value) { hasSkill = true; break; } } if (!hasSkill) { return(false); } } else if (item is SpecialScroll && value >= 105) { if (((SpecialScroll)item).Skill != (SkillName)o || ((SpecialScroll)item).Value < value) { return(false); } } else { return(false); } } else if (!(item is BaseWeapon) || ((BaseWeapon)item).DefSkill != (SkillName)o) { return(false); } } else if (o is SlayerName && (!(item is ISlayer) || ((((ISlayer)item).Slayer != (SlayerName)o && ((ISlayer)item).Slayer2 != (SlayerName)o)))) { return(false); } else if (o is TalismanSlayerName && (!(item is BaseTalisman) || ((BaseTalisman)item).Slayer != (TalismanSlayerName)o)) { return(false); } else if (o is AosElementAttribute) { if (item is BaseWeapon) { BaseWeapon wep = item as BaseWeapon; if (detail.Category == Category.DamageType) { int phys, fire, cold, pois, nrgy, chaos, direct; wep.GetDamageTypes(null, out phys, out fire, out cold, out pois, out nrgy, out chaos, out direct); switch ((AosElementAttribute)o) { case AosElementAttribute.Physical: if (phys < value) { return(false); } break; case AosElementAttribute.Fire: if (fire < value) { return(false); } break; case AosElementAttribute.Cold: if (cold < value) { return(false); } break; case AosElementAttribute.Poison: if (pois < value) { return(false); } break; case AosElementAttribute.Energy: if (nrgy < value) { return(false); } break; case AosElementAttribute.Chaos: if (chaos < value) { return(false); } break; case AosElementAttribute.Direct: if (direct < value) { return(false); } break; } } else { switch ((AosElementAttribute)o) { case AosElementAttribute.Physical: if (wep.WeaponAttributes.ResistPhysicalBonus < value) { return(false); } break; case AosElementAttribute.Fire: if (wep.WeaponAttributes.ResistFireBonus < value) { return(false); } break; case AosElementAttribute.Cold: if (wep.WeaponAttributes.ResistColdBonus < value) { return(false); } break; case AosElementAttribute.Poison: if (wep.WeaponAttributes.ResistPoisonBonus < value) { return(false); } break; case AosElementAttribute.Energy: if (wep.WeaponAttributes.ResistEnergyBonus < value) { return(false); } break; } } } else if (item is BaseArmor && detail.Category == Category.Resists) { BaseArmor armor = item as BaseArmor; switch ((AosElementAttribute)o) { case AosElementAttribute.Physical: if (armor.PhysicalResistance < value) { return(false); } break; case AosElementAttribute.Fire: if (armor.FireResistance < value) { return(false); } break; case AosElementAttribute.Cold: if (armor.ColdResistance < value) { return(false); } break; case AosElementAttribute.Poison: if (armor.PoisonResistance < value) { return(false); } break; case AosElementAttribute.Energy: if (armor.EnergyResistance < value) { return(false); } break; } } else if (detail.Category != Category.DamageType) { AosElementAttributes attrs = RunicReforging.GetElementalAttributes(item); if (attrs == null || attrs[(AosElementAttribute)o] < value) { return(false); } } else { return(false); } } else if (o is Misc) { switch ((Misc)o) { case Misc.ExcludeFel: break; case Misc.GargoyleOnly: if (!IsGargoyle(item)) { return(false); } break; case Misc.NotGargoyleOnly: if (IsGargoyle(item)) { return(false); } break; case Misc.ElvesOnly: if (!IsElf(item)) { return(false); } break; case Misc.NotElvesOnly: if (IsElf(item)) { return(false); } break; case Misc.FactionItem: if (!(item is Server.Factions.IFactionItem)) { return(false); } break; case Misc.PromotionalToken: if (!(item is PromotionalToken)) { return(false); } break; case Misc.Cursed: if (item.LootType != LootType.Cursed) { return(false); } break; case Misc.NotCursed: if (item.LootType == LootType.Cursed) { return(false); } break; case Misc.CannotRepair: if (CheckCanRepair(item)) { return(false); } break; case Misc.NotCannotBeRepaired: if (!CheckCanRepair(item)) { return(false); } break; case Misc.Brittle: NegativeAttributes neg2 = RunicReforging.GetNegativeAttributes(item); if (neg2 == null || neg2.Brittle == 0) { return(false); } break; case Misc.NotBrittle: NegativeAttributes neg3 = RunicReforging.GetNegativeAttributes(item); if (neg3 != null && neg3.Brittle > 0) { return(false); } break; case Misc.Antique: NegativeAttributes neg4 = RunicReforging.GetNegativeAttributes(item); if (neg4 == null || neg4.Antique == 0) { return(false); } break; case Misc.NotAntique: NegativeAttributes neg5 = RunicReforging.GetNegativeAttributes(item); if (neg5 != null && neg5.Antique > 0) { return(false); } break; } } else if (o is string) { string str = o as string; if (str == "WeaponVelocity" && (!(item is BaseRanged) || ((BaseRanged)item).Velocity < value)) { return(false); } /*if (str == "BalancedWeapon" && (!(item is BaseRanged) || !((BaseRanged)item).Balanced)) * return false;*/ if (str == "SearingWeapon" && (!(item is BaseWeapon) || !((BaseWeapon)item).SearingWeapon)) { return(false); } if (str == "ArtifactRarity") { bool isarty = false; if (item is BaseWeapon && ((BaseWeapon)item).ArtifactRarity > value) { isarty = true; } else if (item is BaseArmor && ((BaseArmor)item).ArtifactRarity > value) { isarty = true; } else if (item is BaseClothing && ((BaseClothing)item).ArtifactRarity > value) { isarty = true; } else if (item is BaseJewel && ((BaseJewel)item).ArtifactRarity > value) { isarty = true; } else if (item is SimpleArtifact && ((SimpleArtifact)item).ArtifactRarity > value) { isarty = true; } else if (item is Artifact && ((Artifact)item).ArtifactRarity > value) { isarty = true; } if (!isarty) { return(false); } } } } return(true); }
public static IVendorSearchItem CreateForItem(VendorItem vi) { return(new VendorSearchItem(vi.Item, vi.Price, () => vi.Valid, vi.Vendor, vi.Item.Parent as Container, false)); }
public static void HandleBuyItemInSlotOpcode(ref PacketReader packet, ref WorldManager manager) { ulong vendor = packet.ReadUInt64(); uint item = packet.ReadUInt32(); ulong bag = packet.ReadUInt64(); byte bagslot = packet.ReadUInt8(); byte count = packet.ReadUInt8(); if (count < 1) { count = 1; } Player c = manager.Character; Creature npc = Database.Creatures.TryGet(vendor); if (npc == null || npc.IsEnemyTo(manager.Character) == true) { return; } ItemTemplate itm = Database.ItemTemplates.TryGet(item); VendorItem vitm = npc.Template.VendorItems.Where(vi => vi.Item == item).First(); uint cost = itm.BuyPrice * count; //Enough info to calc cost if (itm == null) //Item doesnt exist { c.SendBuyError(BuyResults.BUY_ERR_CANT_FIND_ITEM, npc, item); return; } Container container = c.Inventory.GetBag(bag); if (container == null || container.IsFull == true) { c.SendBuyError(BuyResults.BUY_ERR_CANT_CARRY_MORE, npc, item); return; } if (c.IsDead || npc.IsDead || vitm.Entry == 0) //Dead or doesnt sell that item { c.SendBuyError(BuyResults.BUY_ERR_CANT_FIND_ITEM, npc, item); return; } if (vitm.MaxCount > 0 && vitm.CurCount < count) //Vendor hasn't enough of them { c.SendBuyError(BuyResults.BUY_ERR_ITEM_SOLD_OUT, npc, item); return; } if (itm.LevelReq > c.Level) //Not high enough level { c.SendBuyError(BuyResults.BUY_ERR_RANK_REQUIRE, npc, item); return; } if (c.Money < cost) { c.SendBuyError(BuyResults.BUY_ERR_NOT_ENOUGHT_MONEY, npc, item); return; } if (c.AddItemInSlot(item, bagslot)) { c.SwapItem(0, 0, (byte)bag, bagslot); c.Money -= cost; manager.Character.Dirty = true; } else { c.SendBuyError(BuyResults.BUY_ERR_CANT_CARRY_MORE, npc, item); return; } }
public override void AddGumpLayout() { AddBackground(0, 0, 500, 550, 30536); AddHtmlLocalized(50, 50, 400, 18, 1114513, "#1154509", LabelColor, false, false); // Vendor Search Results AddHtmlLocalized(162, 70, 102, 18, 1114513, "#1062218", LabelColor, false, false); // Price AddHtmlLocalized(274, 70, 61, 18, 1114513, "#1154644", LabelColor, false, false); // Facet AddHtmlLocalized(345, 70, 102, 18, 1114513, "#1154642", LabelColor, false, false); // Create Map if (Index < 0) { Index = Items.Count - 1; } if (Index >= Items.Count) { Index = 0; } int start = Index; int index = 0; for (int i = start; i < start + PerPage && i < Items.Count; i++) { VendorItem item = Items[i]; Rectangle2D bounds = ItemBounds.Table[item.Item.ItemID]; int y = 101 + (index * 75); Map map = item.Item.Map; if (map == null && item.Item.RootParentEntity is Mobile) { map = ((Mobile)item.Item.RootParentEntity).Map; } AddImageTiledButton(50, y, 0x918, 0x918, 0x0, GumpButtonType.Page, 0, item.Item.ItemID, item.Item.Hue, 40 - bounds.Width / 2 - bounds.X, 30 - bounds.Height / 2 - bounds.Y); AddItemProperty(item.Item); AddHtmlLocalized(162, y, 102, 72, 1154645, String.Format("{0}", item.Price == -1 ? "0" : item.FormattedPrice), TextColor, false, false); // <center>~1_val~</center> if (map != null) { AddHtmlLocalized(274, y, 102, 72, 1060643, String.Format("{0}", map.ToString()), TextColor, false, false); } AddButton(386, y, 30533, 30533, 100 + i, GumpButtonType.Reply, 0); index++; } if (Index + PerPage < Items.Count) { AddButton(430, 480, 30533, 30533, 2, GumpButtonType.Reply, 0); AddHtmlLocalized(355, 480, 70, 20, 1114514, "#1044045", LabelColor, false, false); // NEXT PAGE } if (Index >= PerPage) { AddButton(50, 480, 30533, 30533, 3, GumpButtonType.Reply, 0); AddHtmlLocalized(90, 480, 255, 20, 1044044, "#1044044", LabelColor, false, false); // PREV PAGE } }
public VendorPricePrompt( PlayerVendor vendor, Item item, Item target, VendorItem vi ) { m_Vendor = vendor; m_Item = item; m_Cont = target; m_VI = vi; }
public void AddToBasket(VendorItem item) { InventoryScript.MyInstance.AddToSellBasket(item.item); total += item.item.MyPrice; item.stack--; }
public RecipeBookGump(Mobile from, RecipeBook book, int page, List <RecipeScrollDefinition> list) : base(12, 24) { from.CloseGump(typeof(RecipeBookGump)); from.CloseGump(typeof(RecipeScrollFilterGump)); m_Book = book; m_Page = page; if (list == null) { list = new List <RecipeScrollDefinition>(); m_Book.Recipes.ForEach(x => { if (CheckFilter(x)) { list.Add(x); } }); } m_List = list; int index = GetIndexForPage(page); int count = GetCountForIndex(index); int tableIndex = 0; PlayerVendor pv = book.RootParent as PlayerVendor; bool canLocked = book.IsLockedDown; bool canDrop = book.IsChildOf(from.Backpack); bool canBuy = (pv != null); bool canPrice = (canDrop || canBuy || canLocked); if (canBuy) { VendorItem vi = pv.GetVendorItem(book); canBuy = (vi != null && !vi.IsForSale); } int width = 600; if (!canPrice) { width = 516; } X = (624 - width) / 2; AddPage(0); AddBackground(10, 10, width, 439, 5054); AddImageTiled(18, 20, width - 17, 420, 2624); if (canPrice) { AddImageTiled(573, 64, 24, 352, 200); AddImageTiled(493, 64, 78, 352, 1416); } if (canDrop) { AddImageTiled(24, 64, 32, 352, 1416); } AddImageTiled(58, 64, 36, 352, 200); AddImageTiled(96, 64, 133, 352, 1416); AddImageTiled(231, 64, 80, 352, 200); AddImageTiled(313, 64, 100, 352, 1416); AddImageTiled(415, 64, 76, 352, 200); list = list.OrderBy(x => x.ID).ToList(); for (int i = index; i < (index + count) && i >= 0 && i < list.Count; ++i) { var recipe = list[i]; if (!CheckFilter(recipe)) { continue; } AddImageTiled(24, 94 + (tableIndex * 32), canPrice ? 573 : 489, 2, 2624); ++tableIndex; } AddAlphaRegion(18, 20, width - 17, 420); AddImage(0, 0, 10460); AddImage(width - 15, 5, 10460); AddImage(0, 429, 10460); AddImage(width - 15, 429, 10460); AddHtmlLocalized(266, 32, 200, 32, 1158810, LabelColor, false, false); // Recipe Book AddHtmlLocalized(147, 64, 200, 32, 1062214, LabelColor, false, false); // Item AddHtmlLocalized(246, 64, 200, 32, 1158814, LabelColor, false, false); // Expansion AddHtmlLocalized(336, 64, 200, 32, 1158816, LabelColor, false, false); // Crafting AddHtmlLocalized(429, 64, 100, 32, 1062217, LabelColor, false, false); // Amount AddHtmlLocalized(70, 32, 200, 32, 1062476, LabelColor, false, false); // Set Filter AddButton(35, 32, 4005, 4007, 1, GumpButtonType.Reply, 0); RecipeScrollFilter f = book.Filter; if (f.IsDefault) { AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062475, 16927, false, false); // Using No Filter } else if (((PlayerMobile)from).UseOwnFilter) { AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062451, 16927, false, false); // Using Your Filter } else { AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062230, 16927, false, false); // Using Book Filter } AddButton(375, 416, 4017, 4018, 0, GumpButtonType.Reply, 0); AddHtmlLocalized(410, 416, 120, 20, 1011441, LabelColor, false, false); // EXIT if (canDrop) { AddHtmlLocalized(26, 64, 50, 32, 1062212, LabelColor, false, false); // Drop } if (canPrice) { AddHtmlLocalized(516, 64, 200, 32, 1062218, LabelColor, false, false); // Price if (canBuy) { AddHtmlLocalized(576, 64, 200, 32, 1062219, LabelColor, false, false); // Buy } else { AddHtmlLocalized(576, 64, 200, 32, 1062227, LabelColor, false, false); // Set } } tableIndex = 0; if (page > 0) { AddButton(75, 416, 4014, 4016, 2, GumpButtonType.Reply, 0); AddHtmlLocalized(110, 416, 150, 20, 1011067, LabelColor, false, false); // Previous page } if (GetIndexForPage(page + 1) < list.Count) { AddButton(225, 416, 4005, 4007, 3, GumpButtonType.Reply, 0); AddHtmlLocalized(260, 416, 150, 20, 1011066, LabelColor, false, false); // Next page } for (int i = index; i < (index + count) && i >= 0 && i < list.Count; ++i) { var recipe = list[i]; if (!CheckFilter(recipe) || !Recipe.Recipes.ContainsKey(recipe.RecipeID)) { continue; } int y = 96 + (tableIndex++ *32); if (recipe.Amount > 0 && (canDrop || canLocked)) { AddButton(35, y + 2, 5602, 5606, 4 + (i * 2), GumpButtonType.Reply, 0); } AddLabel(61, y, 0x480, string.Format("{0}", recipe.ID)); AddHtmlLocalized(103, y, 130, 32, Recipe.Recipes[recipe.RecipeID].TextDefinition.Number, "#103221", 0xFFFFFF, false, false); // ~1_val~ AddLabel(235, y, 0x480, GetExpansion(recipe.Expansion)); AddHtmlLocalized(316, y, 100, 20, GetSkillName(recipe.Skill), "#104409", 0xFFFFFF, false, false); // ~1_val~ AddLabel(421, y, 0x480, recipe.Amount.ToString()); if (canDrop || (canBuy && recipe.Price > 0)) { AddButton(579, y + 2, 2117, 2118, 5 + (i * 2), GumpButtonType.Reply, 0); AddLabel(495, y, 1152, recipe.Price.ToString("N0")); } } }
public void AddGumpLayout() { AddBackground(0, 0, 500, 550, 30536); AddHtmlLocalized(0, 40, 500, 20, 1154645, "#1154509", TextColor, false, false); // Vendor Search Results AddHtmlLocalized(200, 70, 90, 20, 3000377, TextColor, false, false); // Price AddHtmlLocalized(290, 70, 100, 20, 3005088, TextColor, false, false); // Facet AddHtmlLocalized(360, 70, 100, 20, 1154642, TextColor, false, false); // Create Map if (Index < 0) { Index = Items.Count - 1; } if (Index >= Items.Count) { Index = 0; } int start = Index; int index = 0; for (int i = start; i < start + PerPage && i < Items.Count; i++) { VendorItem item = Items[i]; Rectangle2D bounds = ItemBounds.Table[item.Item.ItemID]; int y = 100 + (index * 75); AddImage(50, y, 2328); AddItem(90 - bounds.Width / 2 - bounds.X, (30 - bounds.Height / 2 - bounds.Y) + y, item.Item.ItemID, item.Item.Hue); ObjectPropertyList opl = new ObjectPropertyList(item.Item); item.Item.GetProperties(opl); if (User.NetState != null) { User.NetState.Send(opl); } AddImage(50, y, 2328); AddItemProperty(item.Item.Serial); AddItem(90 - bounds.Width / 2 - bounds.X, (30 - bounds.Height / 2 - bounds.Y) + y, item.Item.ItemID, item.Item.Hue); AddHtml(200, y + 5, 88, 20, String.Format("<basefont color=#F5DEB3>{0}", item.Price == -1 ? "0" : item.FormattedPrice), false, false); AddHtml(290, y + 5, 70, 20, String.Format("<basefont color=#F5DEB3>{0}", item.Item.Map.ToString()), false, false); AddButton(370, y + 5, 30533, 30533, 100 + i, GumpButtonType.Reply, 0); index++; } if (Index + PerPage < Items.Count) { AddButton(430, 480, 30533, 30533, 2, GumpButtonType.Reply, 0); AddHtmlLocalized(345, 480, 100, 20, 1044045, VendorSearchGump.C32216(VendorSearchGump.LabelColor), false, false); // NEXT PAGE } if (Index >= PerPage) { AddButton(50, 480, 30533, 30533, 3, GumpButtonType.Reply, 0); AddHtmlLocalized(90, 480, 100, 20, 1044044, VendorSearchGump.C32216(VendorSearchGump.LabelColor), false, false); // PREV PAGE } }
public TamingBOBGump(PlayerMobile from, TamingBulkOrderBook book, int page, ArrayList list) : base(12, 24) { from.CloseGump(typeof(TamingBOBGump)); from.CloseGump(typeof(TamingBOBFilterGump)); m_From = from; m_Book = book; m_Page = page; if (list == null) { list = new ArrayList(book.Entries.Count); for (int i = 0; i < book.Entries.Count; ++i) { object obj = book.Entries[i]; if (CheckFilter(obj)) { list.Add(obj); } } } m_List = list; int index = GetIndexForPage(page); int count = GetCountForIndex(index); int tableIndex = 0; PlayerVendor pv = book.RootParent as PlayerVendor; bool canDrop = book.IsChildOf(from.Backpack); bool canBuy = (pv != null); bool canPrice = (canDrop || canBuy); if (canBuy) { VendorItem vi = pv.GetVendorItem(book); canBuy = (vi != null && !vi.IsForSale); } int width = 600; if (!canPrice) { width = 516; } X = (624 - width) / 2; AddPage(0); AddBackground(10, 10, width, 439, 5054); AddImageTiled(18, 20, width - 17, 420, 2624); if (canPrice) { AddImageTiled(573, 64, 24, 352, 200); AddImageTiled(493, 64, 78, 352, 1416); } if (canDrop) { AddImageTiled(24, 64, 32, 352, 1416); } AddImageTiled(58, 64, 36, 352, 200); AddImageTiled(96, 64, 133, 352, 1416); //AddImage( 231, 100, 5549 ); AddImageTiled(415, 64, 76, 352, 200); for (int i = index; i < (index + count) && i >= 0 && i < list.Count; ++i) { object obj = list[i]; if (!CheckFilter(obj)) { continue; } AddImageTiled(24, 94 + (tableIndex * 32), canPrice ? 573 : 489, 2, 2624); if (obj is TamingBOBLargeEntry) { tableIndex += ((TamingBOBLargeEntry)obj).Entries.Length; } else if (obj is TamingBOBSmallEntry) { ++tableIndex; } } AddAlphaRegion(18, 20, width - 17, 420); AddImage(5, 5, 10460); AddImage(width - 15, 5, 10460); AddImage(5, 424, 10460); AddImage(width - 15, 424, 10460); AddHtmlLocalized(canPrice ? 266 : 224, 32, 200, 32, 1062220, LabelColor, false, false); // Bulk Order Book AddHtmlLocalized(63, 64, 200, 32, 1062213, LabelColor, false, false); // Type AddLabel(147, 64, 1149, @"Animal"); AddHtmlLocalized(429, 64, 200, 32, 1062217, LabelColor, false, false); // Amount AddButton(35, 32, 4005, 4007, 1, GumpButtonType.Reply, 0); AddHtmlLocalized(70, 32, 200, 32, 1062476, LabelColor, false, false); // Set Filter // TamingBOBFilter f = ( from.UseOwnFilter ? from.TamingBOBFilter : book.Filter ); // if ( f.IsDefault ) // AddHtmlLocalized( canPrice ? 470 : 386, 32, 120, 32, 1062475, 16927, false, false ); // Using No Filter // else if ( from.UseOwnFilter ) // AddHtmlLocalized( canPrice ? 470 : 386, 32, 120, 32, 1062451, 16927, false, false ); // Using Your Filter // else // AddHtmlLocalized( canPrice ? 470 : 386, 32, 120, 32, 1062230, 16927, false, false ); // Using Book Filter // AddButton( 375, 416, 4017, 4018, 0, GumpButtonType.Reply, 0 ); // AddHtmlLocalized( 410, 416, 120, 20, 1011441, LabelColor, false, false ); // EXIT // if ( canDrop ) // AddHtmlLocalized( 26, 64, 50, 32, 1062212, LabelColor, false, false ); // Drop // if ( canPrice ) // { // AddHtmlLocalized( 516, 64, 200, 32, 1062218, LabelColor, false, false ); // Price // if ( canBuy ) // AddHtmlLocalized( 576, 64, 200, 32, 1062219, LabelColor, false, false ); // Buy // else // AddHtmlLocalized( 576, 64, 200, 32, 1062227, LabelColor, false, false ); // Set // } // tableIndex = 0; // if ( page > 0 ) // { // AddButton( 75, 416, 4014, 4016, 2, GumpButtonType.Reply, 0 ); // AddHtmlLocalized( 110, 416, 150, 20, 1011067, LabelColor, false, false ); // Previous page // } // if ( GetIndexForPage( page + 1 ) < list.Count ) // { // AddButton( 225, 416, 4005, 4007, 3, GumpButtonType.Reply, 0 ); // AddHtmlLocalized( 260, 416, 150, 20, 1011066, LabelColor, false, false ); // Next page // } // for ( int i = index; i < (index + count) && i >= 0 && i < list.Count; ++i ) // { // object obj = list[i]; // if ( !CheckFilter( obj ) ) // continue; // if ( obj is TamingBOBLargeEntry ) // { // TamingBOBLargeEntry e = (TamingBOBLargeEntry)obj; // int y = 96 + (tableIndex * 32); // if ( canDrop ) // AddButton( 35, y + 2, 5602, 5606, 4 + (i * 2), GumpButtonType.Reply, 0 ); // if ( canDrop || (canBuy && e.Price > 0) ) // { // AddButton( 579, y + 2, 2117, 2118, 5 + (i * 2), GumpButtonType.Reply, 0 ); // AddLabel( 495, y, 1152, e.Price.ToString() ); // } // AddHtmlLocalized( 61, y, 50, 32, 1062225, LabelColor, false, false ); // Large // for ( int j = 0; j < e.Entries.Length; ++j ) // { // TamingBOBLargeSubEntry sub = e.Entries[j]; // string s = sub.AnimalName; // int capsbreak = s.IndexOfAny("ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray(),1); // if( capsbreak > -1 ) // { // string secondhalf = s.Substring( capsbreak ); // string firsthalf = s.Substring(0, capsbreak ); // string newname = firsthalf + " " + secondhalf; // AddLabel( 103, y, 1149, newname.ToString() ); // } // else // { // AddLabel( 103, y, 1149, sub.AnimalName.ToString() ); // } // object name = GetMaterialName( sub.Type ); // if ( name is int ) // AddHtmlLocalized( 316, y, 100, 20, (int)name, LabelColor, false, false ); // else if ( name is string ) // AddLabel( 316, y, 1152, (string)name ); // AddLabel( 421, y, 1152, String.Format( "{0} / {1}", sub.AmountCur, e.AmountMax ) ); // ++tableIndex; // y += 32; // } // } // else if ( obj is TamingBOBSmallEntry ) // { // TamingBOBSmallEntry e = (TamingBOBSmallEntry)obj; // int y = 96 + (tableIndex++ * 32); // if ( canDrop ) // AddButton( 35, y + 2, 5602, 5606, 4 + (i * 2), GumpButtonType.Reply, 0 ); // if ( canDrop || (canBuy && e.Price > 0) ) // { // AddButton( 579, y + 2, 2117, 2118, 5 + (i * 2), GumpButtonType.Reply, 0 ); // AddLabel( 495, y, 1152, e.Price.ToString() ); // } // AddHtmlLocalized( 61, y, 50, 32, 1062224, LabelColor, false, false ); // Small // string s = e.AnimalName; // int capsbreak = s.IndexOfAny("ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray(),1); // if( capsbreak > -1 ) // { // string secondhalf = s.Substring( capsbreak ); // string firsthalf = s.Substring(0, capsbreak ); // string newname = firsthalf + " " + secondhalf; // AddLabel( 103, y, 1149, newname.ToString() ); // } // else // { // AddLabel( 103, y, 1149, e.AnimalName.ToString() ); // } // object name = GetMaterialName( e.Type ); // if ( name is int ) // AddHtmlLocalized( 316, y, 100, 20, (int)name, LabelColor, false, false ); // else if ( name is string ) // AddLabel( 316, y, 1152, (string)name ); // AddLabel( 421, y, 1152, String.Format( "{0} / {1}", e.AmountCur, e.AmountMax ) ); // } // } }
public BOBGump(PlayerMobile from, BulkOrderBook book, int page, ArrayList list) : base(12, 24) { from.CloseGump(typeof(BOBGump)); from.CloseGump(typeof(BOBFilterGump)); this.m_From = from; this.m_Book = book; this.m_Page = page; if (list == null) { list = new ArrayList(book.Entries.Count); for (int i = 0; i < book.Entries.Count; ++i) { object obj = book.Entries[i]; if (this.CheckFilter(obj)) { list.Add(obj); } } } this.m_List = list; int index = this.GetIndexForPage(page); int count = this.GetCountForIndex(index); int tableIndex = 0; PlayerVendor pv = book.RootParent as PlayerVendor; bool canDrop = book.IsChildOf(from.Backpack); bool canBuy = (pv != null); bool canPrice = (canDrop || canBuy); if (canBuy) { VendorItem vi = pv.GetVendorItem(book); canBuy = (vi != null && !vi.IsForSale); } int width = 600; if (!canPrice) { width = 516; } this.X = (624 - width) / 2; this.AddPage(0); this.AddBackground(10, 10, width, 439, 5054); this.AddImageTiled(18, 20, width - 17, 420, 2624); if (canPrice) { this.AddImageTiled(573, 64, 24, 352, 200); this.AddImageTiled(493, 64, 78, 352, 1416); } if (canDrop) { this.AddImageTiled(24, 64, 32, 352, 1416); } this.AddImageTiled(58, 64, 36, 352, 200); this.AddImageTiled(96, 64, 133, 352, 1416); this.AddImageTiled(231, 64, 80, 352, 200); this.AddImageTiled(313, 64, 100, 352, 1416); this.AddImageTiled(415, 64, 76, 352, 200); for (int i = index; i < (index + count) && i >= 0 && i < list.Count; ++i) { object obj = list[i]; if (!this.CheckFilter(obj)) { continue; } this.AddImageTiled(24, 94 + (tableIndex * 32), canPrice ? 573 : 489, 2, 2624); if (obj is BOBLargeEntry) { tableIndex += ((BOBLargeEntry)obj).Entries.Length; } else if (obj is BOBSmallEntry) { ++tableIndex; } } this.AddAlphaRegion(18, 20, width - 17, 420); this.AddImage(5, 5, 10460); this.AddImage(width - 15, 5, 10460); this.AddImage(5, 424, 10460); this.AddImage(width - 15, 424, 10460); this.AddHtmlLocalized(canPrice ? 266 : 224, 32, 200, 32, 1062220, LabelColor, false, false); // Bulk Order Book this.AddHtmlLocalized(63, 64, 200, 32, 1062213, LabelColor, false, false); // Type this.AddHtmlLocalized(147, 64, 200, 32, 1062214, LabelColor, false, false); // Item this.AddHtmlLocalized(246, 64, 200, 32, 1062215, LabelColor, false, false); // Quality this.AddHtmlLocalized(336, 64, 200, 32, 1062216, LabelColor, false, false); // Material this.AddHtmlLocalized(429, 64, 200, 32, 1062217, LabelColor, false, false); // Amount this.AddButton(35, 32, 4005, 4007, 1, GumpButtonType.Reply, 0); this.AddHtmlLocalized(70, 32, 200, 32, 1062476, LabelColor, false, false); // Set Filter BOBFilter f = (from.UseOwnFilter ? from.BOBFilter : book.Filter); if (f.IsDefault) { this.AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062475, 16927, false, false); // Using No Filter } else if (from.UseOwnFilter) { this.AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062451, 16927, false, false); // Using Your Filter } else { this.AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062230, 16927, false, false); // Using Book Filter } this.AddButton(375, 416, 4017, 4018, 0, GumpButtonType.Reply, 0); this.AddHtmlLocalized(410, 416, 120, 20, 1011441, LabelColor, false, false); // EXIT if (canDrop) { this.AddHtmlLocalized(26, 64, 50, 32, 1062212, LabelColor, false, false); // Drop } if (canPrice) { this.AddHtmlLocalized(516, 64, 200, 32, 1062218, LabelColor, false, false); // Price if (canBuy) { this.AddHtmlLocalized(576, 64, 200, 32, 1062219, LabelColor, false, false); // Buy } else { this.AddHtmlLocalized(576, 64, 200, 32, 1062227, LabelColor, false, false); // Set this.AddButton(450, 416, 4005, 4007, 4, GumpButtonType.Reply, 0); this.AddHtml(485, 416, 120, 20, "<BASEFONT COLOR=#FFFFFF>Price all</FONT>", false, false); } } tableIndex = 0; if (page > 0) { this.AddButton(75, 416, 4014, 4016, 2, GumpButtonType.Reply, 0); this.AddHtmlLocalized(110, 416, 150, 20, 1011067, LabelColor, false, false); // Previous page } if (this.GetIndexForPage(page + 1) < list.Count) { this.AddButton(225, 416, 4005, 4007, 3, GumpButtonType.Reply, 0); this.AddHtmlLocalized(260, 416, 150, 20, 1011066, LabelColor, false, false); // Next page } for (int i = index; i < (index + count) && i >= 0 && i < list.Count; ++i) { object obj = list[i]; if (!this.CheckFilter(obj)) { continue; } if (obj is BOBLargeEntry) { BOBLargeEntry e = (BOBLargeEntry)obj; int y = 96 + (tableIndex * 32); if (canDrop) { this.AddButton(35, y + 2, 5602, 5606, 5 + (i * 2), GumpButtonType.Reply, 0); } if (canDrop || (canBuy && e.Price > 0)) { this.AddButton(579, y + 2, 2117, 2118, 6 + (i * 2), GumpButtonType.Reply, 0); this.AddLabel(495, y, 1152, e.Price.ToString()); } this.AddHtmlLocalized(61, y, 50, 32, 1062225, LabelColor, false, false); // Large for (int j = 0; j < e.Entries.Length; ++j) { BOBLargeSubEntry sub = e.Entries[j]; this.AddHtmlLocalized(103, y, 130, 32, sub.Number, LabelColor, false, false); if (e.RequireExceptional) { this.AddHtmlLocalized(235, y, 80, 20, 1060636, LabelColor, false, false); // exceptional } else { this.AddHtmlLocalized(235, y, 80, 20, 1011542, LabelColor, false, false); // normal } object name = this.GetMaterialName(e.Material, e.DeedType, sub.ItemType); if (name is int) { this.AddHtmlLocalized(316, y, 100, 20, (int)name, LabelColor, false, false); } else if (name is string) { this.AddLabel(316, y, 1152, (string)name); } this.AddLabel(421, y, 1152, String.Format("{0} / {1}", sub.AmountCur, e.AmountMax)); ++tableIndex; y += 32; } } else if (obj is BOBSmallEntry) { BOBSmallEntry e = (BOBSmallEntry)obj; int y = 96 + (tableIndex++ *32); if (canDrop) { this.AddButton(35, y + 2, 5602, 5606, 5 + (i * 2), GumpButtonType.Reply, 0); } if (canDrop || (canBuy && e.Price > 0)) { this.AddButton(579, y + 2, 2117, 2118, 6 + (i * 2), GumpButtonType.Reply, 0); this.AddLabel(495, y, 1152, e.Price.ToString()); } this.AddHtmlLocalized(61, y, 50, 32, 1062224, LabelColor, false, false); // Small this.AddHtmlLocalized(103, y, 130, 32, e.Number, LabelColor, false, false); if (e.RequireExceptional) { this.AddHtmlLocalized(235, y, 80, 20, 1060636, LabelColor, false, false); // exceptional } else { this.AddHtmlLocalized(235, y, 80, 20, 1011542, LabelColor, false, false); // normal } object name = this.GetMaterialName(e.Material, e.DeedType, e.ItemType); if (name is int) { this.AddHtmlLocalized(316, y, 100, 20, (int)name, LabelColor, false, false); } else if (name is string) { this.AddLabel(316, y, 1152, (string)name); } this.AddLabel(421, y, 1152, String.Format("{0} / {1}", e.AmountCur, e.AmountMax)); } } }
public override void OnResponse(Server.Network.NetState sender, RelayInfo info) { if (info.ButtonID == 2) { PlayerVendor pv = m_Book.RootParent as PlayerVendor; if (m_Book.Entries.Contains(m_Object) && pv != null) { int price = 0; VendorItem vi = pv.GetVendorItem(m_Book); if (vi != null && !vi.IsForSale) { if (m_Object is PowerScrollBookEntry) { price = ((PowerScrollBookEntry)m_Object).Price; } } if (price != m_Price) { pv.SayTo(m_From, "The price has been been changed. If you like, you may offer to purchase the item again."); } else if (price == 0) { pv.SayTo(m_From, 1062382); } else { Item item = null; if (m_Object is PowerScrollBookEntry) { item = ((PowerScrollBookEntry)m_Object).Reconstruct(); } if (item == null) { m_From.SendMessage("Internal error. The power scroll could not be reconstructed."); } else { pv.Say(m_From.Name); Container pack = m_From.Backpack; if ((pack != null && pack.ConsumeTotal(typeof(Gold), price)) || Banker.Withdraw(m_From, price)) { m_Book.Entries.Remove(m_Object); m_Book.InvalidateProperties(); pv.HoldGold += price; if (m_From.AddToBackpack(item)) { m_From.SendMessage("The power scroll has been placed in your backpack."); } else { pv.SayTo(m_From, 503204); } if (m_Book.Entries.Count > 0) { m_From.SendGump(new PowerScrollBookGump(m_From, m_Book)); } else { m_From.SendLocalizedMessage(1062381); } } else { pv.SayTo(m_From, 503205); item.Delete(); } } } } else { if (pv == null) { m_From.SendLocalizedMessage(1062382); } else { pv.SayTo(m_From, 1062382); } } } else { m_From.SendLocalizedMessage(503207); } }
public static void HandleVendorInventoryList(Packet packet) { var npcVendor = new NpcVendor(); var guidBytes = new byte[8]; guidBytes[4] = packet.ReadBit(); var itemCount = packet.ReadBits("Item Count", 18); var hasExtendedCost = new bool[itemCount]; var hasCondition = new bool[itemCount]; var hasCondition2 = new bool[itemCount]; for (int i = 0; i < itemCount; ++i) { hasCondition[i] = !packet.ReadBit(); hasCondition2[i] = !packet.ReadBit(); hasExtendedCost[i] = !packet.ReadBit(); } guidBytes[1] = packet.ReadBit(); guidBytes[6] = packet.ReadBit(); guidBytes[2] = packet.ReadBit(); guidBytes[5] = packet.ReadBit(); guidBytes[7] = packet.ReadBit(); guidBytes[0] = packet.ReadBit(); guidBytes[3] = packet.ReadBit(); packet.ReadXORByte(guidBytes, 3); npcVendor.VendorItems = new List <VendorItem>((int)itemCount); for (int i = 0; i < itemCount; ++i) { var vendorItem = new VendorItem(); //packet.ReadInt32("Max Durability", i); packet.ReadInt32("Unk1", i); vendorItem.Type = packet.ReadUInt32("Type", i); // 1 - item, 2 - currency var buyCount = packet.ReadUInt32("Buy Count", i); if (hasExtendedCost[i]) { vendorItem.ExtendedCostId = packet.ReadUInt32("Extended Cost", i); } packet.ReadInt32("Price", i); vendorItem.ItemId = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Item, "Item ID", i); vendorItem.Slot = packet.ReadUInt32("Item Position", i); packet.ReadInt32("LeftInStock", i); packet.ReadInt32("Unk2", i); packet.ReadInt32("Display ID", i); /*if (hasCondition[i]) * packet.ReadInt32("Condition ID", i); * var maxCount = packet.ReadInt32("Max Count", i); * vendorItem.MaxCount = maxCount == -1 ? 0 : maxCount; // TDB * * if (vendorItem.Type == 2) * vendorItem.MaxCount = (int)buyCount;*/ npcVendor.VendorItems.Add(vendorItem); } packet.ReadXORByte(guidBytes, 6); packet.ReadXORByte(guidBytes, 0); packet.ReadXORByte(guidBytes, 2); packet.ReadXORByte(guidBytes, 5); packet.ReadByte("rawItemCount"); packet.ReadXORByte(guidBytes, 1); packet.ReadXORByte(guidBytes, 4); packet.ReadXORByte(guidBytes, 7); var guid = new Guid(BitConverter.ToUInt64(guidBytes, 0)); packet.WriteLine("GUID: {0}", guid); Storage.NpcVendors.Add(guid.GetEntry(), npcVendor, packet.TimeSpan); }
public static void HandleVendorInventoryList(Packet packet) { var npcVendor = new NpcVendor(); var guid = new byte[8]; packet.ReadByte("Byte18"); guid[1] = packet.ReadBit(); guid[5] = packet.ReadBit(); guid[0] = packet.ReadBit(); guid[2] = packet.ReadBit(); var itemCount = packet.ReadBits("itemCount", 18); guid[4] = packet.ReadBit(); var hasExtendedCost = new bool[itemCount]; var hasCondition = new bool[itemCount]; for (int i = 0; i < itemCount; ++i) { hasExtendedCost[i] = !packet.ReadBit(); hasCondition[i] = !packet.ReadBit(); packet.ReadBit("Unk bit", i); } guid[3] = packet.ReadBit(); guid[6] = packet.ReadBit(); guid[7] = packet.ReadBit(); npcVendor.VendorItems = new List <VendorItem>((int)itemCount); for (int i = 0; i < itemCount; ++i) { var vendorItem = new VendorItem(); vendorItem.ItemId = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Item, "Item ID", i); if (hasCondition[i]) { packet.ReadInt32("Condition ID", i); } packet.ReadInt32("Price", i); if (hasExtendedCost[i]) { vendorItem.ExtendedCostId = packet.ReadUInt32("Extended Cost", i); } packet.ReadInt32("Display ID", i); var buyCount = packet.ReadUInt32("Buy Count", i); vendorItem.Slot = packet.ReadUInt32("Item Position", i); var maxCount = packet.ReadInt32("Max Count", i); vendorItem.Type = packet.ReadUInt32("Type", i); // 1 - item, 2 - currency packet.ReadInt32("Item Upgrade ID", i); packet.ReadInt32("Max Durability", i); npcVendor.VendorItems.Add(vendorItem); } packet.ParseBitStream(guid, 0, 2, 1, 3, 5, 7, 4, 6); packet.WriteGuid("Guid", guid); var vendorGUID = new Guid(BitConverter.ToUInt64(guid, 0)); Storage.NpcVendors.Add(vendorGUID.GetEntry(), npcVendor, packet.TimeSpan); }
public void VendItem(VendorItem item) { if (item == null || vendor == null) { return; } VendorItem itemToSpawn = null; foreach (var vendorItem in vendorContent) { if (vendorItem == item) { itemToSpawn = item; break; } } if (!CanSell(itemToSpawn)) { return; } Vector3 spawnPos = vendor.gameObject.RegisterTile().WorldPositionServer; var spawnedItem = Spawn.ServerPrefab(itemToSpawn.Item, spawnPos, vendor.transform.parent).GameObject; //something went wrong trying to spawn the item if (spawnedItem == null) { return; } itemToSpawn.Stock--; SendToChat($"{spawnedItem.ExpensiveName()} was dispensed from the vending machine"); //Ejecting in direction if (vendor.EjectObjects && vendor.EjectDirection != EjectDirection.None && spawnedItem.TryGetComponent <CustomNetTransform>(out var cnt)) { Vector3 offset = Vector3.zero; switch (vendor.EjectDirection) { case EjectDirection.Up: offset = vendor.transform.rotation * Vector3.up / Random.Range(4, 12); break; case EjectDirection.Down: offset = vendor.transform.rotation * Vector3.down / Random.Range(4, 12); break; case EjectDirection.Random: offset = new Vector3(Random.Range(-0.15f, 0.15f), Random.Range(-0.15f, 0.15f), 0); break; } cnt.Throw(new ThrowInfo { ThrownBy = spawnedItem, Aim = BodyPartType.Chest, OriginWorldPos = spawnPos, WorldTrajectory = offset, SpinMode = (vendor.EjectDirection == EjectDirection.Random) ? SpinMode.Clockwise : SpinMode.None }); } UpdateList(); allowSell = false; StartCoroutine(VendorInputCoolDown()); }
public VendorItem(VendorItem item) { this.Item = item.Item; this.Stock = item.Stock; this.ItemName = Item.name; }