RequestMoveToLocationInVehicle.java 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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.ai.CtrlIntention;
  18. import com.l2jserver.gameserver.instancemanager.BoatManager;
  19. import com.l2jserver.gameserver.model.L2CharPosition;
  20. import com.l2jserver.gameserver.model.actor.instance.L2BoatInstance;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  23. import com.l2jserver.gameserver.templates.item.L2WeaponType;
  24. import com.l2jserver.util.Point3D;
  25. public final class RequestMoveToLocationInVehicle extends L2GameClientPacket
  26. {
  27. private static final String _C__75_MOVETOLOCATIONINVEHICLE = "[C] 75 RequestMoveToLocationInVehicle";
  28. private final Point3D _pos = new Point3D(0,0,0);
  29. private final Point3D _origin_pos = new Point3D(0,0,0);
  30. private int _boatId;
  31. public TaskPriority getPriority() { return TaskPriority.PR_HIGH; }
  32. @Override
  33. protected void readImpl()
  34. {
  35. int _x, _y, _z;
  36. _boatId = readD(); //objectId of boat
  37. _x = readD();
  38. _y = readD();
  39. _z = readD();
  40. _pos.setXYZ(_x, _y, _z);
  41. _x = readD();
  42. _y = readD();
  43. _z = readD();
  44. _origin_pos.setXYZ(_x, _y, _z);
  45. }
  46. /* (non-Javadoc)
  47. * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#runImpl()
  48. */
  49. @Override
  50. protected
  51. void runImpl()
  52. {
  53. L2PcInstance activeChar = getClient().getActiveChar();
  54. if (activeChar == null)
  55. return;
  56. else if (activeChar.isAttackingNow() && activeChar.getActiveWeaponItem() != null && (activeChar.getActiveWeaponItem().getItemType() == L2WeaponType.BOW))
  57. {
  58. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  59. }
  60. else
  61. {
  62. L2BoatInstance boat = BoatManager.getInstance().getBoat(_boatId);
  63. if (boat == null) return;
  64. activeChar.setBoat(boat);
  65. activeChar.setInBoat(true);
  66. activeChar.setInBoatPosition(_pos);
  67. activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO_IN_A_BOAT, new L2CharPosition(_pos.getX(),_pos.getY(), _pos.getZ(), 0), new L2CharPosition(_origin_pos.getX(),_origin_pos.getY(),_origin_pos.getZ(), 0));
  68. }
  69. }
  70. /* (non-Javadoc)
  71. * @see com.l2jserver.gameserver.BasePacket#getType()
  72. */
  73. @Override
  74. public String getType()
  75. {
  76. return _C__75_MOVETOLOCATIONINVEHICLE;
  77. }
  78. }