TradeStart.java 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package net.sf.l2j.gameserver.serverpackets;
  16. import net.sf.l2j.gameserver.model.L2ItemInstance;
  17. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  18. /**
  19. * This class ...
  20. *
  21. * @version $Revision: 1.4.2.1.2.3 $ $Date: 2005/03/27 15:29:39 $
  22. */
  23. public final class TradeStart extends L2GameServerPacket
  24. {
  25. private static final String _S__2E_TRADESTART = "[S] 14 TradeStart";
  26. private L2PcInstance _activeChar;
  27. private L2ItemInstance[] _itemList;
  28. public TradeStart (L2PcInstance player)
  29. {
  30. _activeChar = player;
  31. _itemList = _activeChar.getInventory().getAvailableItems(true);
  32. }
  33. @Override
  34. protected final void writeImpl()
  35. {//0x2e TradeStart d h (h dddhh dhhh)
  36. if (_activeChar.getActiveTradeList() == null || _activeChar.getActiveTradeList().getPartner() == null)
  37. return;
  38. writeC(0x14);
  39. writeD(_activeChar.getActiveTradeList().getPartner().getObjectId());
  40. //writeD((_activeChar != null || _activeChar.getTransactionRequester() != null)? _activeChar.getTransactionRequester().getObjectId() : 0);
  41. writeH(_itemList.length);
  42. for (L2ItemInstance item : _itemList)//int i = 0; i < count; i++)
  43. {
  44. writeH(item.getItem().getType1()); // item type1
  45. writeD(item.getObjectId());
  46. writeD(item.getItemId());
  47. writeD(item.getCount());
  48. writeH(item.getItem().getType2()); // item type2
  49. writeH(0x00); // ?
  50. writeD(item.getItem().getBodyPart()); // rev 415 slot 0006-lr.ear 0008-neck 0030-lr.finger 0040-head 0080-?? 0100-l.hand 0200-gloves 0400-chest 0800-pants 1000-feet 2000-?? 4000-r.hand 8000-r.hand
  51. writeH(item.getEnchantLevel()); // enchant level
  52. writeH(0x00); // ?
  53. writeH(0x00);
  54. // T1
  55. writeD(item.getAttackAttrElement());
  56. writeD(item.getAttackAttrElementVal());
  57. writeD(item.getDefAttrFire());
  58. writeD(item.getDefAttrWater());
  59. writeD(item.getDefAttrWind());
  60. writeD(item.getDefAttrEarth());
  61. writeD(item.getDefAttrHoly());
  62. writeD(item.getDefAttrUnholy());
  63. }
  64. }
  65. /* (non-Javadoc)
  66. * @see net.sf.l2j.gameserver.serverpackets.ServerBasePacket#getType()
  67. */
  68. @Override
  69. public String getType()
  70. {
  71. return _S__2E_TRADESTART;
  72. }
  73. }