L2BoatAI.java 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.ai;
  20. import com.l2jserver.gameserver.model.Location;
  21. import com.l2jserver.gameserver.model.actor.instance.L2BoatInstance;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.network.serverpackets.VehicleDeparture;
  24. import com.l2jserver.gameserver.network.serverpackets.VehicleInfo;
  25. import com.l2jserver.gameserver.network.serverpackets.VehicleStarted;
  26. /**
  27. * @author DS
  28. */
  29. public class L2BoatAI extends L2VehicleAI
  30. {
  31. public L2BoatAI(L2BoatInstance creature)
  32. {
  33. super(creature);
  34. }
  35. @Override
  36. protected void moveTo(int x, int y, int z)
  37. {
  38. if (!_actor.isMovementDisabled())
  39. {
  40. if (!_clientMoving)
  41. {
  42. _actor.broadcastPacket(new VehicleStarted(getActor(), 1));
  43. }
  44. _clientMoving = true;
  45. _actor.moveToLocation(x, y, z, 0);
  46. _actor.broadcastPacket(new VehicleDeparture(getActor()));
  47. }
  48. }
  49. @Override
  50. protected void clientStopMoving(Location loc)
  51. {
  52. if (_actor.isMoving())
  53. {
  54. _actor.stopMove(loc);
  55. }
  56. if (_clientMoving || (loc != null))
  57. {
  58. _clientMoving = false;
  59. _actor.broadcastPacket(new VehicleStarted(getActor(), 0));
  60. _actor.broadcastPacket(new VehicleInfo(getActor()));
  61. }
  62. }
  63. @Override
  64. public void describeStateToPlayer(L2PcInstance player)
  65. {
  66. if (_clientMoving)
  67. {
  68. player.sendPacket(new VehicleDeparture(getActor()));
  69. }
  70. }
  71. @Override
  72. public L2BoatInstance getActor()
  73. {
  74. return (L2BoatInstance) _actor;
  75. }
  76. }