MoveToLocationInAirShip.java 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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.AirShipManager;
  19. import com.l2jserver.gameserver.model.L2CharPosition;
  20. import com.l2jserver.gameserver.model.actor.instance.L2AirShipInstance;
  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. /**
  26. * format: ddddddd
  27. * X:%d Y:%d Z:%d OriginX:%d OriginY:%d OriginZ:%d
  28. * @author GodKratos
  29. */
  30. public class MoveToLocationInAirShip extends L2GameClientPacket
  31. {
  32. private static final String _C__D0_20_MOVETOLOCATIONINAIRSHIP = "[C] D0:20 MoveToLocationInAirShip";
  33. private int _shipId;
  34. private final Point3D _pos = new Point3D(0,0,0);
  35. private final Point3D _origin_pos = new Point3D(0,0,0);
  36. public TaskPriority getPriority() { return TaskPriority.PR_HIGH; }
  37. @Override
  38. protected void readImpl()
  39. {
  40. _shipId = readD();
  41. int _x, _y, _z;
  42. _x = readD();
  43. _y = readD();
  44. _z = readD();
  45. _pos.setXYZ(_x, _y, _z);
  46. _x = readD();
  47. _y = readD();
  48. _z = readD();
  49. _origin_pos.setXYZ(_x, _y, _z);
  50. }
  51. @Override
  52. protected void runImpl()
  53. {
  54. L2PcInstance activeChar = getClient().getActiveChar();
  55. if (activeChar == null)
  56. return;
  57. else if (activeChar.isAttackingNow() && activeChar.getActiveWeaponItem() != null && (activeChar.getActiveWeaponItem().getItemType() == L2WeaponType.BOW))
  58. {
  59. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  60. }
  61. else
  62. {
  63. L2AirShipInstance airShip = AirShipManager.getInstance().getAirShip();
  64. if (airShip == null || airShip.getObjectId() != _shipId)
  65. return;
  66. activeChar.setAirShip(airShip);
  67. activeChar.setInAirShip(true);
  68. activeChar.setInAirShipPosition(_pos);
  69. activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO_IN_AIR_SHIP, new L2CharPosition(_pos.getX(),_pos.getY(), _pos.getZ(), 0), new L2CharPosition(_origin_pos.getX(),_origin_pos.getY(),_origin_pos.getZ(), 0));
  70. }
  71. }
  72. /* (non-Javadoc)
  73. * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
  74. */
  75. @Override
  76. public String getType()
  77. {
  78. return _C__D0_20_MOVETOLOCATIONINAIRSHIP;
  79. }
  80. }