public override void Handle(GameSession session, PacketReader packet) { long boxUid = packet.ReadLong(); if (!session.Player.Inventory.Items.ContainsKey(boxUid)) { return; } // Get the box item Item box = session.Player.Inventory.Items[boxUid]; // Remove box if amount is 1 or less if (box.Amount <= 1) { session.Player.Inventory.Remove(boxUid, out Item removed); session.Send(ItemInventoryPacket.Remove(boxUid)); } // Decrement box amount to otherwise else { box.Amount -= 1; session.Send(ItemInventoryPacket.Update(boxUid, box.Amount)); } // Normally would look up which item to create, instead always add poisonous mushroom Item item = new Item(30001001); InventoryController.Add(session, item); }
private void HandleCollect(GameSession session, PacketReader packet) { int id = packet.ReadInt(); packet.ReadInt(); // Get items and add to inventory List <Item> items = session.Player.Mailbox.Collect(id); if (items == null) { return; } foreach (Item item in items) { session.Player.Inventory.Remove(item.Uid, out Item removed); session.Player.Inventory.Add(item); // Item packet, not sure if this is only used for mail, it also doesn't seem to do anything session.Send(ItemPacket.ItemData(item)); // Inventory packets session.Send(ItemInventoryPacket.Add(item)); session.Send(ItemInventoryPacket.MarkItemNew(item, item.Amount)); // TODO remove these inventory packets } session.Send(MailPacket.CollectedAmount(id, DateTimeOffset.UtcNow.ToUnixTimeSeconds())); session.Send(MailPacket.CollectResponse(id, DateTimeOffset.UtcNow.ToUnixTimeSeconds())); }
private static void HandleAddItemToTrade(GameSession session, PacketReader packet) { long itemUid = packet.ReadLong(); int amount = packet.ReadInt(); if (!session.Player.Inventory.HasItem(itemUid) || session.Player.TradeInventory.IsLocked) { return; } Item item = session.Player.Inventory.GetByUid(itemUid); if (item.IsBound()) { return; } // Split item if (item.Amount > amount) { item.TrySplit(amount, out Item splitItem); session.Send(ItemInventoryPacket.UpdateAmount(itemUid, item.Amount)); item = splitItem; } else { session.Player.Inventory.RemoveItem(session, itemUid, out Item removedItem); item = removedItem; } session.Player.TradeInventory.AddItem(session, item); }
public override void Handle(GameSession session, PacketReader packet) { long itemUid = packet.ReadLong(); Item item = session.Player.Inventory.GetByUid(itemUid); if (item is null) { return; } ItemEnchantTransferMetadata metadata = ItemEnchantTransferMetadataStorage.GetMetadata(item.Rarity, item.Id, item.EnchantLevel); if (metadata is null) { return; } // Remove Enchant item.EnchantLevel = 0; item.Stats.Enchants = new(); Item scroll = new(metadata.OutputItemId, metadata.OutputAmount, metadata.OutputRarity); session.Player.Inventory.AddItem(session, scroll, true); session.Send(ItemInventoryPacket.UpdateItem(item)); session.Send(ItemEnchantTransferPacket.Transfer()); }
// Drops item with option to drop bound items public static void DropItem(GameSession session, long uid, int amount, bool isbound) { if (!isbound) // Drops Item { int remaining = session.Player.Inventory.Remove(uid, out Item droppedItem, amount); // Returns remaining amount of item if (remaining < 0) { return; // Removal failed } else if (remaining > 0) // Updates item { session.Send(ItemInventoryPacket.Update(uid, remaining)); } else // Removes item { session.Send(ItemInventoryPacket.Remove(uid)); } session.FieldManager.AddItem(session, droppedItem); // Drops item onto floor } else // Drops bound item. { if (session.Player.Inventory.Remove(uid, out Item droppedItem) != 0) { return; // Removal from inventory failed } session.Send(ItemInventoryPacket.Remove(uid)); // Allow dropping bound items for now session.FieldManager.AddItem(session, droppedItem); } }
// Drops item with option to drop bound items public static void DropItem(GameSession session, long uid, int amount, bool isbound) { if (!isbound) // Drops Item { int remaining = session.Player.Inventory.Remove(uid, out Item droppedItem, amount); // Returns remaining amount of item if (remaining < 0) { return; // Removal failed } else if (remaining > 0) // Updates item { session.Send(ItemInventoryPacket.Update(uid, remaining)); DatabaseManager.Items.Update(session.Player.Inventory.Items.Values.First(x => x.Uid == uid)); } else // Removes item { session.Send(ItemInventoryPacket.Remove(uid)); DatabaseManager.Items.Delete(droppedItem.Uid); } session.FieldManager.AddItem(session, droppedItem); // Drops item onto floor } else // Drops bound item. { if (session.Player.Inventory.Remove(uid, out Item droppedItem) != 0) { return; // Removal from inventory failed } session.Send(ItemInventoryPacket.Remove(uid)); DatabaseManager.Items.Delete(droppedItem.Uid); Remove(session, uid, out droppedItem); } }
// Loads a Inventory Tab public static void LoadInventoryTab(GameSession session, InventoryTab tab) { Inventory inventory = session.Player.Inventory; session.Send(ItemInventoryPacket.ResetTab(tab)); session.Send(ItemInventoryPacket.LoadTab(tab, inventory.ExtraSize[tab])); session.Send(ItemInventoryPacket.LoadItem(inventory.Items.Values.Where(x => x.InventoryTab == tab).ToList())); }
// Picks up item public static void PickUp(GameSession session, Item item) { if (!session.Player.Inventory.Add(item)) // Adds item into internal database { return; } session.Send(ItemInventoryPacket.Add(item)); // Sends packet to add item clientside }
// Adds item public static void Add(GameSession session, Item item, bool isNew) { // Checks if item is stackable or not if (item.StackLimit > 1) { foreach (Item i in session.Player.Inventory.Items.Values) { // Checks to see if item exists in database (dictionary) if (i.Id != item.Id || i.Amount >= i.StackLimit) { continue; } // Updates inventory for item amount overflow if ((i.Amount + item.Amount) > i.StackLimit) { int added = i.StackLimit - i.Amount; item.Amount -= added; i.Amount = i.StackLimit; session.Send(ItemInventoryPacket.Update(i.Uid, i.Amount)); session.Send(ItemInventoryPacket.MarkItemNew(i, added)); } // Updates item amount else { i.Amount += item.Amount; session.Send(ItemInventoryPacket.Update(i.Uid, i.Amount)); session.Send(ItemInventoryPacket.MarkItemNew(i, item.Amount)); return; } } session.Player.Inventory.Add(item); // Adds item into internal database session.Send(ItemInventoryPacket.Add(item)); // Sends packet to add item clientside if (isNew) { session.Send(ItemInventoryPacket.MarkItemNew(item, item.Amount)); // Marks Item as New } } else { for (int i = 0; i < item.Amount; i++) { Item newItem = new Item(item) { Amount = 1, Slot = session.Player.Inventory.SlotTaken(item, item.Slot) ? -1 : item.Slot, Uid = GuidGenerator.Long() }; session.Player.Inventory.Add(newItem); session.Send(ItemInventoryPacket.Add(newItem)); if (isNew) { session.Send(ItemInventoryPacket.MarkItemNew(newItem, newItem.Amount)); } } } }
private void HandleSort(GameSession session, PacketReader packet, Inventory inventory) { var tab = (InventoryTab)packet.ReadShort(); inventory.Sort(tab); session.Send(ItemInventoryPacket.ResetTab(tab)); session.Send(ItemInventoryPacket.LoadItemsToTab(tab, inventory.GetItems(tab))); }
public void Add(GameSession session, long uid, int amount, short slot) { Item item = session.Player.Inventory.GetByUid(uid); if (amount < item.Amount) { item.TrySplit(amount, out Item splitItem); session.Send(ItemInventoryPacket.UpdateAmount(uid, item.Amount)); item = splitItem; } else { session.Player.Inventory.RemoveItem(session, uid, out Item removedItem); item = removedItem; } // If slot is free, add item to it if (Items[slot] is null) { item.Slot = slot; Items[slot] = item; session.Send(StorageInventoryPacket.Add(item)); return; } // Find first item with the same id, if true update the amount Item existingItem = Items.FirstOrDefault(x => x is not null && x.Id == item.Id && x.Rarity == item.Rarity); if (existingItem is not null) { if (existingItem.Amount + item.Amount <= existingItem.StackLimit) { existingItem.Amount += item.Amount; session.Send(StorageInventoryPacket.UpdateItem(existingItem)); return; } existingItem.Amount = existingItem.StackLimit; item.Amount = existingItem.Amount + item.Amount - existingItem.StackLimit; session.Send(StorageInventoryPacket.UpdateItem(existingItem)); } // Find first free slot for (short i = 0; i < Items.Length; i++) { if (Items[i] is not null) { continue; } item.Slot = i; Items[i] = item; session.Send(StorageInventoryPacket.Add(item)); return; } }
// Updates item information public static void Update(GameSession session, long uid, int amount) { if ((GetItemAmount(session, uid) + amount) >= GetItemMax(session, uid)) { session.Player.Inventory.Items[uid].Amount = session.Player.Inventory.Items[uid].SlotMax; session.Send(ItemInventoryPacket.Update(uid, session.Player.Inventory.Items[uid].SlotMax)); } session.Player.Inventory.Items[uid].Amount = amount; session.Send(ItemInventoryPacket.Update(uid, amount)); }
// Moves Item to destination slot public static void MoveItem(GameSession session, long uid, short dstSlot) { Tuple <long, short> srcSlot = session.Player.Inventory.Move(uid, dstSlot); if (srcSlot == null) { return; } session.Send(ItemInventoryPacket.Move(srcSlot.Item1, srcSlot.Item2, uid, dstSlot)); }
// Removes Item from inventory by reference public static bool Remove(GameSession session, long uid, out Item item) { int amountRemoved = session.Player.Inventory.Remove(uid, out item); if (amountRemoved == -1) { return(false); } session.Send(ItemInventoryPacket.Remove(uid)); return(true); }
public static void ExpandInventory(GameSession session, InventoryTab tab) { Inventory inventory = session.Player.Inventory; long meretPrice = 390; short expansionAmount = 6; if (session.Player.Account.RemoveMerets(meretPrice)) { inventory.ExtraSize[tab] += expansionAmount; session.Send(ItemInventoryPacket.LoadTab(tab, inventory.ExtraSize[tab])); session.Send(ItemInventoryPacket.Expand()); } }
private void HandleMove(GameSession session, PacketReader packet, Inventory inventory) { long uid = packet.ReadLong(); short dstSlot = packet.ReadShort(); Tuple <long, short> result = inventory.Move(uid, dstSlot); if (result == null) { return; } session.Send(ItemInventoryPacket.Move(result.Item1, result.Item2, uid, dstSlot)); }
private void HandleDropBound(GameSession session, PacketReader packet, Inventory inventory) { long uid = packet.ReadLong(); if (inventory.Remove(uid, out Item droppedItem) != 0) { return; // Removal from inventory failed } session.Send(ItemInventoryPacket.Remove(uid)); // Allow dropping bound items for now session.FieldManager.AddItem(session, droppedItem); }
// Updates item information public static void Update(GameSession session, long uid, int amount) { Item item = session.Player.Inventory.Items[uid]; if ((item.Amount + amount) >= item.StackLimit) { item.Amount = item.StackLimit; } else { item.Amount = amount; } session.Send(ItemInventoryPacket.Update(uid, amount)); }
public override void Handle(GameSession session, PacketReader packet) { int boxId = packet.ReadInt(); packet.ReadShort(); // Unknown int amount = packet.ReadInt(); short opened = 0; // Amount of opened boxes List <Item> items = new List <Item> (session.Player.Inventory.Items.Values); // Make copy of items in-case new item is added foreach (Item item in items) { // Continue over non-matching item ids if (item.Id != boxId) { continue; } for (int i = opened; i < amount; i++) { // Create new item from opening box Item newItem = new Item(30001001); // Remove box if there is only 1 left if (item.Amount <= 1) { session.Player.Inventory.Remove(item.Uid, out Item removed); session.Send(ItemInventoryPacket.Remove(item.Uid)); InventoryController.Add(session, newItem); opened++; break; // Break out of the amount loop because this stack of boxes is empty, look for next stack } // Update box amount if there is more than 1 item.Amount -= 1; session.Send(ItemInventoryPacket.Update(item.Uid, item.Amount)); InventoryController.Add(session, newItem); opened++; } } session.Send(ItemUsePacket.Use(boxId, amount)); // Need to handle opening boxes, probably serialize the item xml }
public override void Handle(GameSession session, PacketReader packet) { int objectId = packet.ReadInt(); packet.ReadByte(); // TODO: This will be bugged when you have a full inventory, check inventory before looting // Remove objectId from Field, make sure item still exists (multiple looters) if (!session.FieldManager.RemoveItem(objectId, out Item item)) { return; } session.Player.Inventory.Add(item); session.Send(ItemInventoryPacket.Add(item)); session.Send(ItemInventoryPacket.MarkItemNew(item, item.Amount)); }
public void Add(GameSession session, long uid, int amount, short slot) { Item item = session.Player.Inventory.Items[uid]; if (amount < item.Amount) { item.TrySplit(amount, out Item splitItem); session.Send(ItemInventoryPacket.Update(uid, item.Amount)); item = splitItem; } else { InventoryController.Remove(session, uid, out Item removedItem); item = removedItem; } if (slot >= 0) { if (Items[slot] == null) { item.Slot = slot; Items[slot] = item; session.Send(StorageInventoryPacket.Add(item)); return; } else { slot = -1; } } if (slot == -1) { for (slot = 0; slot < Items.Length; slot++) { if (Items[slot] != null) { continue; } item.Slot = slot; Items[slot] = item; session.Send(StorageInventoryPacket.Add(item)); return; } } }
private static void HandleCreateListing(GameSession session, PacketReader packet) { long itemUid = packet.ReadLong(); long price = packet.ReadLong(); int quantity = packet.ReadInt(); if (!session.Player.Inventory.HasItem(itemUid)) { session.Send(BlackMarketPacket.Error((int)BlackMarketError.ItemNotInInventory)); return; } Item item = session.Player.Inventory.GetByUid(itemUid); if (item.Amount < quantity || item.IsBound()) { return; } double depositRate = 0.01; // 1% deposit rate int maxDeposit = 100000; int calculatedDeposit = (int)(depositRate * (price * quantity)); int deposit = Math.Min(calculatedDeposit, maxDeposit); if (!session.Player.Wallet.Meso.Modify(-deposit)) { return; } if (item.Amount > quantity) { item.TrySplit(quantity, out Item newStack); session.Send(ItemInventoryPacket.UpdateAmount(item.Uid, item.Amount)); item = newStack; } else { session.Player.Inventory.ConsumeItem(session, item.Uid, quantity); } BlackMarketListing listing = new(session.Player, item, quantity, price, deposit); session.Send(BlackMarketPacket.CreateListing(listing)); }
// Removes item based on quantity public static void Consume(GameSession session, long uid, int amount) { Item item = session.Player.Inventory.Items[uid]; if (amount > item.Amount) { return; } if (amount == item.Amount) { Remove(session, uid, out Item _); return; } item.Amount -= amount; session.Send(ItemInventoryPacket.Update(uid, item.Amount)); return; }
private void HandleUnequipItem(GameSession session, PacketReader packet) { long itemUid = packet.ReadLong(); foreach ((ItemSlot slot, Item item) in session.Player.Equips) { if (itemUid != item.Uid) { continue; } if (session.Player.Equips.Remove(slot, out Item unequipItem)) { session.Player.Inventory.Add(unequipItem); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, unequipItem)); session.Send(ItemInventoryPacket.Add(unequipItem)); break; } } }
public override void Handle(GameSession session, PacketReader packet) { // No data passed in // TODO - Determine item from player's job Item tutorialBow = Item.TutorialBow(session.Player); // Add the item to the inventory session.Inventory.Add(tutorialBow); // Send to client session.Send(ItemInventoryPacket.Add(tutorialBow)); session.Send(ItemInventoryPacket.MarkItemNew(tutorialBow)); // The below packet is sent with the inventory packets, but doesn't seem to be needed //session.Send(PacketWriter.Of(0x0105).WriteHexString("3F A6 36 E2 94 98 9B 2F 01 00 00 00 00 00 00 00 FF FF FF FF 89 18 84 5E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B3 BC BC FF 3D DA C3 FF BA B4 B0 FF 13 00 00 00 05 00 00 00 00 03 00 11 00 0C 00 00 00 00 00 00 00 1B 00 0F 00 00 00 00 00 00 00 1C 00 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0E 00 00 00 01 00 00 00 00 00 00 00 00 00 01 01 66 66 66 66 66 66 66 66 08 00 61 00 73 00 61 00 73 00 61 00 73 00 31 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")); // The below two are kept for future reference in regards to the above //session.Send(PacketWriter.Of(0x16).WriteHexString("00 38 69 E6 00 3F A6 36 E2 94 98 9B 2F 00 00 01 00 00 00 00 00 01 00 00 00 00 00 00 00 FF FF FF FF 89 18 84 5E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B3 BC BC FF 3D DA C3 FF BA B4 B0 FF 13 00 00 00 05 00 00 00 00 03 00 11 00 0C 00 00 00 00 00 00 00 1B 00 0F 00 00 00 00 00 00 00 1C 00 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0E 00 00 00 01 00 00 00 00 00 00 00 00 00 01 01 66 66 66 66 66 66 66 66 08 00 61 00 73 00 61 00 73 00 61 00 73 00 31 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")); //session.Send(PacketWriter.Of(0x16).WriteHexString("08 3F A6 36 E2 94 98 9B 2F 01 00 00 00 00 00")); }
// Example: "item id:20000027" private static void ProcessItemCommand(GameSession session, string command) { Dictionary <string, string> config = command.ToMap(); int.TryParse(config.GetValueOrDefault("id", "20000027"), out int itemId); if (!ItemMetadataStorage.IsValid(itemId)) { session.SendNotice("Invalid item: " + itemId); return; } // Add some bonus attributes to equips and pets var stats = new ItemStats(); if (ItemMetadataStorage.GetTab(itemId) == InventoryType.Gear || ItemMetadataStorage.GetTab(itemId) == InventoryType.Pets) { var rng = new Random(); stats.BonusAttributes.Add(ItemStat.Of((ItemAttribute)rng.Next(35), 0.01f)); stats.BonusAttributes.Add(ItemStat.Of((ItemAttribute)rng.Next(35), 0.01f)); } var item = new Item(itemId) { Uid = Environment.TickCount64, CreationTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds(), Transfer = TransferFlag.Splitable | TransferFlag.Tradeable, Stats = stats }; int.TryParse(config.GetValueOrDefault("rarity", "5"), out item.Rarity); int.TryParse(config.GetValueOrDefault("amount", "1"), out item.Amount); // Simulate looting item if (session.Inventory.Add(item)) { session.Send(ItemInventoryPacket.Add(item)); session.Send(ItemInventoryPacket.MarkItemNew(item)); } }
private void HandleEquipItem(GameSession session, PacketReader packet) { long itemUid = packet.ReadLong(); string equipSlotStr = packet.ReadUnicodeString(); if (!Enum.TryParse(equipSlotStr, out ItemSlot equipSlot)) { logger.Warning("Unknown equip slot: " + equipSlotStr); return; } // Remove the item from the users inventory session.Player.Inventory.Remove(itemUid, out Item item); session.Send(ItemInventoryPacket.Remove(itemUid)); // TODO: Move unequipped item into the correct slot // Move previously equipped item back to inventory if (session.Player.Equips.Remove(equipSlot, out Item prevItem)) { session.Player.Inventory.Add(prevItem); session.Send(ItemInventoryPacket.Add(prevItem)); session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, prevItem)); } // Equip new item session.Player.Equips[equipSlot] = item; session.FieldManager.BroadcastPacket(EquipmentPacket.EquipItem(session.FieldPlayer, item, equipSlot)); // TODO - Increase stats based on the item stats itself session.Player.Stats.CritRate.Max += 12; session.Player.Stats.CritRate.Total += 12; session.Player.Stats.MinAtk.Max += 15; session.Player.Stats.MinAtk.Total += 15; session.Player.Stats.MaxAtk.Max += 17; session.Player.Stats.MaxAtk.Total += 17; session.Send(FieldObjectPacket.SetStats(session.FieldPlayer)); }
// Adds item public static void Add(GameSession session, Item item, bool isNew) { // Checks if item is stackable or not if (item.SlotMax > 1) { foreach (Item i in session.Player.Inventory.Items.Values) { // Checks to see if item exists in database (dictionary) if (i.Id != item.Id || i.Amount >= i.SlotMax) { continue; } // Updates inventory for item amount overflow if ((i.Amount + item.Amount) > i.SlotMax) { int added = i.SlotMax - i.Amount; item.Amount -= added; i.Amount = i.SlotMax; session.Send(ItemInventoryPacket.Update(i.Uid, i.Amount)); session.Send(ItemInventoryPacket.MarkItemNew(i, added)); } // Updates item amount else { i.Amount += item.Amount; session.Send(ItemInventoryPacket.Update(i.Uid, i.Amount)); session.Send(ItemInventoryPacket.MarkItemNew(i, item.Amount)); return; } } } session.Player.Inventory.Add(item); // Adds item into internal database session.Send(ItemInventoryPacket.Add(item)); // Sends packet to add item clientside if (isNew) { session.Send(ItemInventoryPacket.MarkItemNew(item, item.Amount)); // Marks Item as New } }
public override void Handle(GameSession session, PacketReader packet) { packet.ReadInt(); // ? // Liftable: 00 00 00 00 00 // SendBreakable // Self session.EnterField(session.Player.MapId); session.Send(FieldObjectPacket.SetStats(session.FieldPlayer)); session.Send(EmotePacket.LoadEmotes()); // Normally skill layout would be loaded from a database QuickSlot arrowStream = QuickSlot.From(10500001); QuickSlot arrowBarrage = QuickSlot.From(10500011); QuickSlot eagleGlide = QuickSlot.From(10500151); QuickSlot testSkill = QuickSlot.From(10500153); if (session.Player.GameOptions.TryGetHotbar(0, out Hotbar mainHotbar)) { mainHotbar.MoveQuickSlot(4, arrowStream); mainHotbar.MoveQuickSlot(5, arrowBarrage); mainHotbar.MoveQuickSlot(6, eagleGlide); mainHotbar.MoveQuickSlot(7, testSkill); session.Send(KeyTablePacket.SendHotbars(session.Player.GameOptions)); } // Add catalysts for testing int[] catalysts = { 40100001, 40100002, 40100003, 40100021, 40100023, 40100024, 40100026 }; foreach (int catalyst in catalysts) { var item = new Item(catalyst) { Amount = 99999, Uid = catalyst }; session.Inventory.Add(item); session.Send(ItemInventoryPacket.Add(item)); } }
private void HandleDrop(GameSession session, PacketReader packet, Inventory inventory) { // TODO: Make sure items are tradable? long uid = packet.ReadLong(); int amount = packet.ReadInt(); int remaining = inventory.Remove(uid, out Item droppedItem, amount); if (remaining < 0) { return; // Removal failed } if (remaining > 0) { session.Send(ItemInventoryPacket.Update(uid, remaining)); } else { session.Send(ItemInventoryPacket.Remove(uid)); } session.FieldManager.AddItem(session, droppedItem); }