MoveToLocationInAirShip.java 3.3 KB

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