RequestMoveToLocationInVehicle.java 2.9 KB

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