MoveToLocationInAirShip.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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.model.actor.instance.L2AirShipInstance;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  20. import com.l2jserver.gameserver.network.serverpackets.ExMoveToLocationInAirShip;
  21. import com.l2jserver.gameserver.templates.item.L2WeaponType;
  22. import com.l2jserver.util.Point3D;
  23. /**
  24. * format: ddddddd
  25. * X:%d Y:%d Z:%d OriginX:%d OriginY:%d OriginZ:%d
  26. * @author GodKratos
  27. */
  28. public class MoveToLocationInAirShip extends L2GameClientPacket
  29. {
  30. private static final String _C__D0_20_MOVETOLOCATIONINAIRSHIP = "[C] D0:20 MoveToLocationInAirShip";
  31. private int _shipId;
  32. private final Point3D _pos = new Point3D(0,0,0);
  33. private final Point3D _origin_pos = new Point3D(0,0,0);
  34. public TaskPriority getPriority() { return TaskPriority.PR_HIGH; }
  35. @Override
  36. protected void readImpl()
  37. {
  38. _shipId = readD();
  39. int _x, _y, _z;
  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. @Override
  50. protected void runImpl()
  51. {
  52. final L2PcInstance activeChar = getClient().getActiveChar();
  53. if (activeChar == null)
  54. return;
  55. if (activeChar.isAttackingNow()
  56. && activeChar.getActiveWeaponItem() != null
  57. && (activeChar.getActiveWeaponItem().getItemType() == L2WeaponType.BOW))
  58. {
  59. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  60. return;
  61. }
  62. if (activeChar.isSitting() || activeChar.isMovementDisabled())
  63. {
  64. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  65. return;
  66. }
  67. if (!activeChar.isInAirShip())
  68. {
  69. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  70. return;
  71. }
  72. final L2AirShipInstance airShip = activeChar.getAirShip();
  73. if (airShip.getObjectId() != _shipId)
  74. {
  75. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  76. return;
  77. }
  78. activeChar.setVehicle(airShip);
  79. activeChar.setInVehiclePosition(_pos);
  80. activeChar.broadcastPacket(new ExMoveToLocationInAirShip(activeChar));
  81. }
  82. /* (non-Javadoc)
  83. * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
  84. */
  85. @Override
  86. public String getType()
  87. {
  88. return _C__D0_20_MOVETOLOCATIONINAIRSHIP;
  89. }
  90. }