RequestMoveToLocationInVehicle.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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.clientpackets;
  16. import com.l2jserver.gameserver.TaskPriority;
  17. import com.l2jserver.gameserver.instancemanager.BoatManager;
  18. import com.l2jserver.gameserver.model.actor.instance.L2BoatInstance;
  19. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  20. import com.l2jserver.gameserver.network.SystemMessageId;
  21. import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  22. import com.l2jserver.gameserver.network.serverpackets.MoveToLocationInVehicle;
  23. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  24. import com.l2jserver.gameserver.templates.item.L2WeaponType;
  25. import com.l2jserver.util.Point3D;
  26. public final class RequestMoveToLocationInVehicle extends L2GameClientPacket
  27. {
  28. private static final String _C__75_MOVETOLOCATIONINVEHICLE = "[C] 75 RequestMoveToLocationInVehicle";
  29. private int _boatId;
  30. private Point3D _pos;
  31. private Point3D _origin_pos;
  32. public TaskPriority getPriority() { return TaskPriority.PR_HIGH; }
  33. @Override
  34. protected void readImpl()
  35. {
  36. int _x, _y, _z;
  37. _boatId = readD(); //objectId of boat
  38. _x = readD();
  39. _y = readD();
  40. _z = readD();
  41. _pos = new Point3D(_x, _y, _z);
  42. _x = readD();
  43. _y = readD();
  44. _z = readD();
  45. _origin_pos = new Point3D(_x, _y, _z);
  46. }
  47. /* (non-Javadoc)
  48. * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#runImpl()
  49. */
  50. @Override
  51. protected
  52. void runImpl()
  53. {
  54. final L2PcInstance activeChar = getClient().getActiveChar();
  55. if (activeChar == null)
  56. return;
  57. if (activeChar.isAttackingNow()
  58. && activeChar.getActiveWeaponItem() != null
  59. && (activeChar.getActiveWeaponItem().getItemType() == L2WeaponType.BOW))
  60. {
  61. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  62. return;
  63. }
  64. if (activeChar.isSitting() || activeChar.isMovementDisabled())
  65. {
  66. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  67. return;
  68. }
  69. if (activeChar.getPet() != null)
  70. {
  71. activeChar.sendPacket(new SystemMessage(SystemMessageId.RELEASE_PET_ON_BOAT));
  72. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  73. return;
  74. }
  75. if (activeChar.isTransformed())
  76. {
  77. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANT_POLYMORPH_ON_BOAT));
  78. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  79. return;
  80. }
  81. final L2BoatInstance boat;
  82. if (activeChar.isInBoat())
  83. {
  84. boat = activeChar.getBoat();
  85. if (boat.getObjectId() != _boatId)
  86. {
  87. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  88. return;
  89. }
  90. }
  91. else
  92. {
  93. boat = BoatManager.getInstance().getBoat(_boatId);
  94. if (boat == null)
  95. {
  96. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  97. return;
  98. }
  99. activeChar.setVehicle(boat);
  100. }
  101. activeChar.setInVehiclePosition(_pos);
  102. activeChar.broadcastPacket(new MoveToLocationInVehicle(activeChar, _pos, _origin_pos));
  103. }
  104. /* (non-Javadoc)
  105. * @see com.l2jserver.gameserver.BasePacket#getType()
  106. */
  107. @Override
  108. public String getType()
  109. {
  110. return _C__75_MOVETOLOCATIONINVEHICLE;
  111. }
  112. }