MoveToLocationInAirShip.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.network.clientpackets;
  20. import com.l2jserver.gameserver.model.Location;
  21. import com.l2jserver.gameserver.model.actor.instance.L2AirShipInstance;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.model.items.type.WeaponType;
  24. import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  25. import com.l2jserver.gameserver.network.serverpackets.ExMoveToLocationInAirShip;
  26. import com.l2jserver.gameserver.network.serverpackets.StopMoveInVehicle;
  27. /**
  28. * format: ddddddd X:%d Y:%d Z:%d OriginX:%d OriginY:%d OriginZ:%d
  29. * @author GodKratos
  30. */
  31. public class MoveToLocationInAirShip extends L2GameClientPacket
  32. {
  33. private static final String _C__D0_20_MOVETOLOCATIONINAIRSHIP = "[C] D0:20 MoveToLocationInAirShip";
  34. private int _shipId;
  35. private int _targetX;
  36. private int _targetY;
  37. private int _targetZ;
  38. private int _originX;
  39. private int _originY;
  40. private int _originZ;
  41. @Override
  42. protected void readImpl()
  43. {
  44. _shipId = readD();
  45. _targetX = readD();
  46. _targetY = readD();
  47. _targetZ = readD();
  48. _originX = readD();
  49. _originY = readD();
  50. _originZ = readD();
  51. }
  52. @Override
  53. protected void runImpl()
  54. {
  55. final L2PcInstance activeChar = getClient().getActiveChar();
  56. if (activeChar == null)
  57. {
  58. return;
  59. }
  60. if ((_targetX == _originX) && (_targetY == _originY) && (_targetZ == _originZ))
  61. {
  62. activeChar.sendPacket(new StopMoveInVehicle(activeChar, _shipId));
  63. return;
  64. }
  65. if (activeChar.isAttackingNow() && (activeChar.getActiveWeaponItem() != null) && (activeChar.getActiveWeaponItem().getItemType() == WeaponType.BOW))
  66. {
  67. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  68. return;
  69. }
  70. if (activeChar.isSitting() || activeChar.isMovementDisabled())
  71. {
  72. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  73. return;
  74. }
  75. if (!activeChar.isInAirShip())
  76. {
  77. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  78. return;
  79. }
  80. final L2AirShipInstance airShip = activeChar.getAirShip();
  81. if (airShip.getObjectId() != _shipId)
  82. {
  83. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  84. return;
  85. }
  86. activeChar.setInVehiclePosition(new Location(_targetX, _targetY, _targetZ));
  87. activeChar.broadcastPacket(new ExMoveToLocationInAirShip(activeChar));
  88. }
  89. @Override
  90. public String getType()
  91. {
  92. return _C__D0_20_MOVETOLOCATIONINAIRSHIP;
  93. }
  94. }