BoatRunePrimeval.java 6.2 KB

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