Example #1
0
		public void WriteItemCardData(Packet p) {
			// Blank data
			if (Cards == null) {
				for (int i = 0; i < Global.MAX_SLOTS; i++) {
					p.Write((short)0);
				}
				return;
			}

			// Pet eggs
			if (Cards[0] == Item.Card0Pet) {
				p.Write((short)0);
				p.Write((short)0);
				p.Write((short)0);
				p.Write((short)Cards[3]); // Pet renamed flag.
				return;
			}

			// Forged/created items
			if (Cards[0] == Item.Card0Create || Cards[0] == Item.Card0Forge) {
				for (int i = 0; i < Global.MAX_SLOTS; i++) {
					p.Write((short)Cards[i]);
				}
				return;
			}

			// Normal items
			for (int i = 0; i < Global.MAX_SLOTS; i++) {
				// Write viewID of cards
				ItemDatabaseData item = (Cards[i] > 0 ? (ItemDatabaseData)World.Database[EDatabaseType.Item, Cards[i]] : null);
				p.Write((ushort)(item != null && item.ViewID != EWeaponType.Fist ? (ushort)item.ViewID : Cards[i]));
			}

		}
Example #2
0
		/// <summary>
		/// Simplifies inventory/cart/storage packets by handling the packet section relevant to items
		/// </summary>
		/// <param name="p"></param>
		public void WriteItemData(Packet p, int equip) {
			if (Data.ViewID > 0) {
				p.Write((short)Data.ViewID);
			} else {
				p.Write((short)NameID);
			}
			p.Write((byte)(Data.Type == EItemType.PetEgg ? EItemType.Weapon : Data.Type));
			p.Write((byte)(Identify == true ? 1 : 0));
			if (equip >= 0) {
				// Equippable item 
				p.Write((short)equip);
				p.Write((short)Equip);
				p.Write((byte)Attribute);
				p.Write((byte)Refine);
			} else {
				// Stackable item.
				p.Write((short)Amount);
				if (equip == -2 && Equip == EItemEquipLocation.Ammo) {
					p.Write((ushort)EItemEquipLocation.Ammo);
				} else {
					p.Write((short)0);
				}
			}
		}