Wow thank you pro! I can't believe how simple the solution was. It took some thinking though. I was thinking that when I send this packet I would also have to do something in code to be able to see it in game. But I had to stop and think "what is the role of the client?". The client spawns the item when it receives the packet. Not the server spawning the item. Here is my code:
Code:
case "@drop":
{
IConquerItem itm = new ItemDataPacket(true);
itm.ID = 480339;
itm.Plus = 12;
itm.UID = ItemDataPacket.NextItemUID;
byte[] packet = new byte[20];
PacketBuilder.WriteUInt16(20, packet, 0);
PacketBuilder.WriteUInt16(1101, packet, 2);
PacketBuilder.WriteUInt32(itm.UID, packet, 4);
PacketBuilder.WriteUInt32(itm.ID, packet, 8);
PacketBuilder.WriteUInt16(Client.Entity.X, packet, 12);
PacketBuilder.WriteUInt16(Client.Entity.Y, packet, 14);
PacketBuilder.WriteUInt32(0x1, packet, 16);
Kernel.ToLocal(packet, Client.Entity.X, Client.Entity.Y, Client.Entity.MapID, 0, 0);
break;
}
Edit: Ok, I've fixed the drop method like so:
Code:
static public void DropItem(GameClient Client, ItemUsagePacket Packet)
{
IConquerItem thisItem = Client.GetInventoryItem(Packet.UID);
Client.RemoveInventory(thisItem.UID);
byte[] packet = new byte[20];
PacketBuilder.WriteUInt16(20, packet, 0);
PacketBuilder.WriteUInt16(1101, packet, 2);
PacketBuilder.WriteUInt32(thisItem.UID, packet, 4);
PacketBuilder.WriteUInt32(thisItem.ID, packet, 8);
PacketBuilder.WriteUInt16(Client.Entity.X, packet, 12);
PacketBuilder.WriteUInt16(Client.Entity.Y, packet, 14);
PacketBuilder.WriteUInt32(0x1, packet, 16);
Item item = new Item();
item.UID = thisItem.UID;
item.ID = thisItem.ID;
item.MapID = Client.Entity.MapID;
item.Plus = thisItem.Plus;
item.Position = thisItem.Position;
item.SocketOne = thisItem.SocketOne;
item.SocketTwo = thisItem.SocketTwo;
item.X = Client.Entity.X;
item.Y = Client.Entity.Y;
item.Enchant = thisItem.Enchant;
item.Bless = thisItem.Bless;
Kernel.ItemsOnTheFloor.Add(item.UID, item);
Kernel.ToLocal(packet, Client.Entity.X, Client.Entity.Y, Client.Entity.MapID, 0, 0);
}
And I thought it would be a good idea to update the client every time it jumps so it will be able to see items throughout the map--but one problem. The client keeps playing the item drop sound whenever I jump. Am I sending the wrong subtype or does the wiki not have all the subtypes? Is this a good idea to begin with?
In the jump method:
Code:
foreach (KeyValuePair<uint, Item> itm in Kernel.ItemsOnTheFloor)
{
if (itm.Value.MapID == Client.Entity.MapID && Kernel.CanSee(itm.Value.X, itm.Value.Y, Client.Entity.X, Client.Entity.Y))
{
byte[] packet = new byte[20];
PacketBuilder.WriteUInt16(20, packet, 0);
PacketBuilder.WriteUInt16(1101, packet, 2);
PacketBuilder.WriteUInt32(itm.Value.UID, packet, 4);
PacketBuilder.WriteUInt32(itm.Value.ID, packet, 8);
PacketBuilder.WriteUInt16(itm.Value.X, packet, 12);
PacketBuilder.WriteUInt16(itm.Value.Y, packet, 14);
PacketBuilder.WriteUInt32(0x1, packet, 16);
Client.Send(packet);
}
}