BoatRunePrimeval.java 6.5 KB

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