BoatRunePrimeval.java 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. * Copyright (C) 2004-2014 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack 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 DataPack 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 vehicles;
  20. import java.util.logging.Level;
  21. import java.util.logging.Logger;
  22. import com.l2jserver.gameserver.ThreadPoolManager;
  23. import com.l2jserver.gameserver.instancemanager.BoatManager;
  24. import com.l2jserver.gameserver.model.VehiclePathPoint;
  25. import com.l2jserver.gameserver.model.actor.instance.L2BoatInstance;
  26. import com.l2jserver.gameserver.network.SystemMessageId;
  27. import com.l2jserver.gameserver.network.clientpackets.Say2;
  28. import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
  29. import com.l2jserver.gameserver.network.serverpackets.PlaySound;
  30. /**
  31. * @author DS
  32. */
  33. public class BoatRunePrimeval implements Runnable
  34. {
  35. private static final Logger _log = Logger.getLogger(BoatRunePrimeval.class.getName());
  36. // Time: 239s
  37. private static final VehiclePathPoint[] RUNE_TO_PRIMEVAL =
  38. {
  39. new VehiclePathPoint(32750, -39300, -3610, 180, 800),
  40. new VehiclePathPoint(27440, -39328, -3610, 250, 1000),
  41. new VehiclePathPoint(19616, -39360, -3610, 270, 1000),
  42. new VehiclePathPoint(3840, -38528, -3610, 270, 1000),
  43. new VehiclePathPoint(1664, -37120, -3610, 270, 1000),
  44. new VehiclePathPoint(896, -34560, -3610, 180, 1800),
  45. new VehiclePathPoint(832, -31104, -3610, 180, 180),
  46. new VehiclePathPoint(2240, -29132, -3610, 150, 1800),
  47. new VehiclePathPoint(4160, -27828, -3610, 150, 1800),
  48. new VehiclePathPoint(5888, -27279, -3610, 150, 1800),
  49. new VehiclePathPoint(7000, -27279, -3610, 150, 1800),
  50. new VehiclePathPoint(10342, -27279, -3610, 150, 1800)
  51. };
  52. // Time: 221s
  53. private static final VehiclePathPoint[] PRIMEVAL_TO_RUNE =
  54. {
  55. new VehiclePathPoint(15528, -27279, -3610, 180, 800),
  56. new VehiclePathPoint(22304, -29664, -3610, 290, 800),
  57. new VehiclePathPoint(33824, -26880, -3610, 290, 800),
  58. new VehiclePathPoint(38848, -21792, -3610, 240, 1200),
  59. new VehiclePathPoint(43424, -22080, -3610, 180, 1800),
  60. new VehiclePathPoint(44320, -25152, -3610, 180, 1800),
  61. new VehiclePathPoint(40576, -31616, -3610, 250, 800),
  62. new VehiclePathPoint(36819, -35315, -3610, 220, 800)
  63. };
  64. private static final VehiclePathPoint[] RUNE_DOCK =
  65. {
  66. new VehiclePathPoint(34381, -37680, -3610, 220, 800)
  67. };
  68. private static final VehiclePathPoint PRIMEVAL_DOCK = RUNE_TO_PRIMEVAL[RUNE_TO_PRIMEVAL.length - 1];
  69. private final L2BoatInstance _boat;
  70. private int _cycle = 0;
  71. private int _shoutCount = 0;
  72. private final CreatureSay ARRIVED_AT_RUNE;
  73. private final CreatureSay ARRIVED_AT_RUNE_2;
  74. private final CreatureSay LEAVING_RUNE;
  75. private final CreatureSay ARRIVED_AT_PRIMEVAL;
  76. private final CreatureSay ARRIVED_AT_PRIMEVAL_2;
  77. private final CreatureSay LEAVING_PRIMEVAL;
  78. private final CreatureSay BUSY_RUNE;
  79. private final PlaySound RUNE_SOUND;
  80. private final PlaySound PRIMEVAL_SOUND;
  81. public BoatRunePrimeval(L2BoatInstance boat)
  82. {
  83. _boat = boat;
  84. ARRIVED_AT_RUNE = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.ARRIVED_AT_RUNE);
  85. ARRIVED_AT_RUNE_2 = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.FERRY_LEAVING_FOR_PRIMEVAL_3_MINUTES);
  86. LEAVING_RUNE = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.FERRY_LEAVING_RUNE_FOR_PRIMEVAL_NOW);
  87. ARRIVED_AT_PRIMEVAL = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.FERRY_ARRIVED_AT_PRIMEVAL);
  88. ARRIVED_AT_PRIMEVAL_2 = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.FERRY_LEAVING_FOR_RUNE_3_MINUTES);
  89. LEAVING_PRIMEVAL = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.FERRY_LEAVING_PRIMEVAL_FOR_RUNE_NOW);
  90. BUSY_RUNE = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.FERRY_FROM_PRIMEVAL_TO_RUNE_DELAYED);
  91. RUNE_SOUND = new PlaySound(0, "itemsound.ship_arrival_departure", 1, _boat.getObjectId(), RUNE_DOCK[0].getX(), RUNE_DOCK[0].getY(), RUNE_DOCK[0].getZ());
  92. PRIMEVAL_SOUND = new PlaySound(0, "itemsound.ship_arrival_departure", 1, _boat.getObjectId(), PRIMEVAL_DOCK.getX(), PRIMEVAL_DOCK.getY(), PRIMEVAL_DOCK.getZ());
  93. }
  94. @Override
  95. public void run()
  96. {
  97. try
  98. {
  99. switch (_cycle)
  100. {
  101. case 0:
  102. BoatManager.getInstance().dockShip(BoatManager.RUNE_HARBOR, false);
  103. BoatManager.getInstance().broadcastPackets(RUNE_DOCK[0], PRIMEVAL_DOCK, LEAVING_RUNE, RUNE_SOUND);
  104. _boat.payForRide(8925, 1, 34513, -38009, -3640);
  105. _boat.executePath(RUNE_TO_PRIMEVAL);
  106. break;
  107. case 1:
  108. BoatManager.getInstance().broadcastPackets(PRIMEVAL_DOCK, RUNE_DOCK[0], ARRIVED_AT_PRIMEVAL, ARRIVED_AT_PRIMEVAL_2, PRIMEVAL_SOUND);
  109. ThreadPoolManager.getInstance().scheduleGeneral(this, 180000);
  110. break;
  111. case 2:
  112. BoatManager.getInstance().broadcastPackets(PRIMEVAL_DOCK, RUNE_DOCK[0], LEAVING_PRIMEVAL, PRIMEVAL_SOUND);
  113. _boat.payForRide(8924, 1, 10447, -24982, -3664);
  114. _boat.executePath(PRIMEVAL_TO_RUNE);
  115. break;
  116. case 3:
  117. if (BoatManager.getInstance().dockBusy(BoatManager.RUNE_HARBOR))
  118. {
  119. if (_shoutCount == 0)
  120. {
  121. BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], PRIMEVAL_DOCK, BUSY_RUNE);
  122. }
  123. _shoutCount++;
  124. if (_shoutCount > 35)
  125. {
  126. _shoutCount = 0;
  127. }
  128. ThreadPoolManager.getInstance().scheduleGeneral(this, 5000);
  129. return;
  130. }
  131. _boat.executePath(RUNE_DOCK);
  132. break;
  133. case 4:
  134. BoatManager.getInstance().dockShip(BoatManager.RUNE_HARBOR, true);
  135. BoatManager.getInstance().broadcastPackets(RUNE_DOCK[0], PRIMEVAL_DOCK, ARRIVED_AT_RUNE, ARRIVED_AT_RUNE_2, RUNE_SOUND);
  136. ThreadPoolManager.getInstance().scheduleGeneral(this, 180000);
  137. break;
  138. }
  139. _shoutCount = 0;
  140. _cycle++;
  141. if (_cycle > 4)
  142. {
  143. _cycle = 0;
  144. }
  145. }
  146. catch (Exception e)
  147. {
  148. _log.log(Level.WARNING, e.getMessage());
  149. }
  150. }
  151. public static void main(String[] args)
  152. {
  153. final L2BoatInstance boat = BoatManager.getInstance().getNewBoat(5, 34381, -37680, -3610, 40785);
  154. if (boat != null)
  155. {
  156. boat.registerEngine(new BoatRunePrimeval(boat));
  157. boat.runEngine(180000);
  158. BoatManager.getInstance().dockShip(BoatManager.RUNE_HARBOR, true);
  159. }
  160. }
  161. }