TradeStart.java 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 com.l2jserver.gameserver.network.serverpackets;
  16. import com.l2jserver.Config;
  17. import com.l2jserver.gameserver.model.L2ItemInstance;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. /**
  20. * This class ...
  21. *
  22. * @version $Revision: 1.4.2.1.2.3 $ $Date: 2005/03/27 15:29:39 $
  23. */
  24. public final class TradeStart extends L2GameServerPacket
  25. {
  26. private static final String _S__2E_TRADESTART = "[S] 14 TradeStart";
  27. private L2PcInstance _activeChar;
  28. private L2ItemInstance[] _itemList;
  29. public TradeStart(L2PcInstance player)
  30. {
  31. _activeChar = player;
  32. _itemList = _activeChar.getInventory().getAvailableItems(true, (_activeChar.isGM() && Config.GM_TRADE_RESTRICTED_ITEMS));
  33. }
  34. @Override
  35. protected final void writeImpl()
  36. {//0x2e TradeStart d h (h dddhh dhhh)
  37. if (_activeChar.getActiveTradeList() == null || _activeChar.getActiveTradeList().getPartner() == null)
  38. return;
  39. writeC(0x14);
  40. writeD(_activeChar.getActiveTradeList().getPartner().getObjectId());
  41. //writeD((_activeChar != null || _activeChar.getTransactionRequester() != null)? _activeChar.getTransactionRequester().getObjectId() : 0);
  42. writeH(_itemList.length);
  43. for (L2ItemInstance item : _itemList)
  44. {
  45. writeH(item.getItem().getType1()); // item type1
  46. writeD(item.getObjectId());
  47. writeD(item.getItemId());
  48. writeQ(item.getCount());
  49. writeH(item.getItem().getType2()); // item type2
  50. writeH(0x00); // ?
  51. 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
  52. writeH(item.getEnchantLevel()); // enchant level
  53. writeH(0x00);
  54. writeH(item.getCustomType2());
  55. // T1
  56. writeH(item.getAttackElementType());
  57. writeH(item.getAttackElementPower());
  58. for (byte i = 0; i < 6; i++)
  59. writeH(item.getElementDefAttr(i));
  60. writeH(0x00); // Enchant effect 1
  61. writeH(0x00); // Enchant effect 2
  62. writeH(0x00); // Enchant effect 3
  63. }
  64. }
  65. /* (non-Javadoc)
  66. * @see com.l2jserver.gameserver.serverpackets.ServerBasePacket#getType()
  67. */
  68. @Override
  69. public String getType()
  70. {
  71. return _S__2E_TRADESTART;
  72. }
  73. }