BoatGludinRune.java 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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. * @author DS
  28. */
  29. public class BoatGludinRune implements Runnable
  30. {
  31. private static final Logger _log = Logger.getLogger(BoatGludinRune.class.getName());
  32. // Time: 1151s
  33. private static final VehiclePathPoint[] GLUDIN_TO_RUNE =
  34. {
  35. new VehiclePathPoint(-95686, 155514, -3610, 150, 800),
  36. new VehiclePathPoint(-98112, 159040, -3610, 150, 800),
  37. new VehiclePathPoint(-104192, 160608, -3610, 200, 1800),
  38. new VehiclePathPoint(-109952, 159616, -3610, 250, 1800),
  39. new VehiclePathPoint(-112768, 154784, -3610, 290, 1800),
  40. new VehiclePathPoint(-114688, 139040, -3610, 290, 1800),
  41. new VehiclePathPoint(-115232, 134368, -3610, 290, 1800),
  42. new VehiclePathPoint(-113888, 121696, -3610, 290, 1800),
  43. new VehiclePathPoint(-107808, 104928, -3610, 290, 1800),
  44. new VehiclePathPoint(-97152, 75520, -3610, 290, 800),
  45. new VehiclePathPoint(-85536, 67264, -3610, 290, 1800),
  46. new VehiclePathPoint(-64640, 55840, -3610, 290, 1800),
  47. new VehiclePathPoint(-60096, 44672, -3610, 290, 1800),
  48. new VehiclePathPoint(-52672, 37440, -3610, 290, 1800),
  49. new VehiclePathPoint(-46144, 33184, -3610, 290, 1800),
  50. new VehiclePathPoint(-36096, 24928, -3610, 290, 1800),
  51. new VehiclePathPoint(-33792, 8448, -3610, 290, 1800),
  52. new VehiclePathPoint(-23776, 3424, -3610, 290, 1000),
  53. new VehiclePathPoint(-12000, -1760, -3610, 290, 1000),
  54. new VehiclePathPoint(672, 480, -3610, 290, 1800),
  55. new VehiclePathPoint(15488, 200, -3610, 290, 1000),
  56. new VehiclePathPoint(24736, 164, -3610, 290, 1000),
  57. new VehiclePathPoint(32192, -1156, -3610, 290, 1000),
  58. new VehiclePathPoint(39200, -8032, -3610, 270, 1000),
  59. new VehiclePathPoint(44320, -25152, -3610, 270, 1000),
  60. new VehiclePathPoint(40576, -31616, -3610, 250, 800),
  61. new VehiclePathPoint(36819, -35315, -3610, 220, 800)
  62. };
  63. private static final VehiclePathPoint[] RUNE_DOCK =
  64. {
  65. new VehiclePathPoint(34381, -37680, -3610, 200, 800)
  66. };
  67. // Time: 967s
  68. private static final VehiclePathPoint[] RUNE_TO_GLUDIN =
  69. {
  70. new VehiclePathPoint(32750, -39300, -3610, 150, 800),
  71. new VehiclePathPoint(27440, -39328, -3610, 180, 1000),
  72. new VehiclePathPoint(21456, -34272, -3610, 200, 1000),
  73. new VehiclePathPoint(6608, -29520, -3610, 250, 800),
  74. new VehiclePathPoint(4160, -27828, -3610, 270, 800),
  75. new VehiclePathPoint(2432, -25472, -3610, 270, 1000),
  76. new VehiclePathPoint(-8000, -16272, -3610, 220, 1000),
  77. new VehiclePathPoint(-18976, -9760, -3610, 290, 800),
  78. new VehiclePathPoint(-23776, 3408, -3610, 290, 800),
  79. new VehiclePathPoint(-33792, 8432, -3610, 290, 800),
  80. new VehiclePathPoint(-36096, 24912, -3610, 290, 800),
  81. new VehiclePathPoint(-46144, 33184, -3610, 290, 800),
  82. new VehiclePathPoint(-52688, 37440, -3610, 290, 800),
  83. new VehiclePathPoint(-60096, 44672, -3610, 290, 800),
  84. new VehiclePathPoint(-64640, 55840, -3610, 290, 800),
  85. new VehiclePathPoint(-85552, 67248, -3610, 290, 800),
  86. new VehiclePathPoint(-97168, 85264, -3610, 290, 800),
  87. new VehiclePathPoint(-107824, 104912, -3610, 290, 800),
  88. new VehiclePathPoint(-102151, 135704, -3610, 290, 800),
  89. new VehiclePathPoint(-96686, 140595, -3610, 290, 800),
  90. new VehiclePathPoint(-95686, 147717, -3610, 250, 800),
  91. new VehiclePathPoint(-95686, 148218, -3610, 200, 800)
  92. };
  93. private static final VehiclePathPoint[] GLUDIN_DOCK =
  94. {
  95. new VehiclePathPoint(-95686, 150514, -3610, 150, 800)
  96. };
  97. private final L2BoatInstance _boat;
  98. private int _cycle = 0;
  99. private int _shoutCount = 0;
  100. private final CreatureSay ARRIVED_AT_GLUDIN;
  101. private final CreatureSay ARRIVED_AT_GLUDIN_2;
  102. private final CreatureSay LEAVE_GLUDIN5;
  103. private final CreatureSay LEAVE_GLUDIN1;
  104. private final CreatureSay LEAVE_GLUDIN0;
  105. private final CreatureSay LEAVING_GLUDIN;
  106. private final CreatureSay ARRIVED_AT_RUNE;
  107. private final CreatureSay ARRIVED_AT_RUNE_2;
  108. private final CreatureSay LEAVE_RUNE5;
  109. private final CreatureSay LEAVE_RUNE1;
  110. private final CreatureSay LEAVE_RUNE0;
  111. private final CreatureSay LEAVING_RUNE;
  112. private final CreatureSay BUSY_GLUDIN;
  113. private final CreatureSay BUSY_RUNE;
  114. private final CreatureSay ARRIVAL_RUNE15;
  115. private final CreatureSay ARRIVAL_RUNE10;
  116. private final CreatureSay ARRIVAL_RUNE5;
  117. private final CreatureSay ARRIVAL_RUNE1;
  118. private final CreatureSay ARRIVAL_GLUDIN15;
  119. private final CreatureSay ARRIVAL_GLUDIN10;
  120. private final CreatureSay ARRIVAL_GLUDIN5;
  121. private final CreatureSay ARRIVAL_GLUDIN1;
  122. private final PlaySound GLUDIN_SOUND;
  123. private final PlaySound RUNE_SOUND;
  124. public BoatGludinRune(L2BoatInstance boat)
  125. {
  126. _boat = boat;
  127. ARRIVED_AT_GLUDIN = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.FERRY_ARRIVED_AT_GLUDIN);
  128. ARRIVED_AT_GLUDIN_2 = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.DEPARTURE_FOR_RUNE_10_MINUTES);
  129. LEAVE_GLUDIN5 = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.DEPARTURE_FOR_RUNE_5_MINUTES);
  130. LEAVE_GLUDIN1 = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.DEPARTURE_FOR_RUNE_1_MINUTE);
  131. LEAVE_GLUDIN0 = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.DEPARTURE_FOR_GLUDIN_SHORTLY2);
  132. LEAVING_GLUDIN = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.DEPARTURE_FOR_GLUDIN_NOW);
  133. ARRIVED_AT_RUNE = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.ARRIVED_AT_RUNE);
  134. ARRIVED_AT_RUNE_2 = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.FERRY_LEAVE_FOR_GLUDIN_AFTER_10_MINUTES);
  135. LEAVE_RUNE5 = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.DEPARTURE_FOR_GLUDIN_5_MINUTES);
  136. LEAVE_RUNE1 = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.DEPARTURE_FOR_GLUDIN_1_MINUTE);
  137. LEAVE_RUNE0 = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.DEPARTURE_FOR_GLUDIN_SHORTLY);
  138. LEAVING_RUNE = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.DEPARTURE_FOR_GLUDIN_NOW);
  139. BUSY_GLUDIN = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.FERRY_RUNE_GLUDIN_DELAYED);
  140. BUSY_RUNE = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.FERRY_GLUDIN_RUNE_DELAYED);
  141. ARRIVAL_RUNE15 = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.FERRY_FROM_GLUDIN_AT_RUNE_15_MINUTES);
  142. ARRIVAL_RUNE10 = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.FERRY_FROM_GLUDIN_AT_RUNE_10_MINUTES);
  143. ARRIVAL_RUNE5 = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.FERRY_FROM_GLUDIN_AT_RUNE_5_MINUTES);
  144. ARRIVAL_RUNE1 = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.FERRY_FROM_GLUDIN_AT_RUNE_1_MINUTE);
  145. ARRIVAL_GLUDIN15 = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.FERRY_FROM_RUNE_AT_GLUDIN_15_MINUTES);
  146. ARRIVAL_GLUDIN10 = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.FERRY_FROM_RUNE_AT_GLUDIN_10_MINUTES);
  147. ARRIVAL_GLUDIN5 = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.FERRY_FROM_RUNE_AT_GLUDIN_5_MINUTES);
  148. ARRIVAL_GLUDIN1 = new CreatureSay(0, Say2.BOAT, 801, SystemMessageId.FERRY_FROM_RUNE_AT_GLUDIN_1_MINUTE);
  149. GLUDIN_SOUND = new PlaySound(0, "itemsound.ship_arrival_departure", 1, _boat.getObjectId(), GLUDIN_DOCK[0].x, GLUDIN_DOCK[0].y, GLUDIN_DOCK[0].z);
  150. RUNE_SOUND = new PlaySound(0, "itemsound.ship_arrival_departure", 1, _boat.getObjectId(), RUNE_DOCK[0].x, RUNE_DOCK[0].y, RUNE_DOCK[0].z);
  151. }
  152. @Override
  153. public void run()
  154. {
  155. try
  156. {
  157. switch (_cycle)
  158. {
  159. case 0:
  160. BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], LEAVE_GLUDIN5);
  161. ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
  162. break;
  163. case 1:
  164. BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], LEAVE_GLUDIN1);
  165. ThreadPoolManager.getInstance().scheduleGeneral(this, 40000);
  166. break;
  167. case 2:
  168. BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], LEAVE_GLUDIN0);
  169. ThreadPoolManager.getInstance().scheduleGeneral(this, 20000);
  170. break;
  171. case 3:
  172. BoatManager.getInstance().dockShip(BoatManager.GLUDIN_HARBOR, false);
  173. BoatManager.getInstance().broadcastPackets(GLUDIN_DOCK[0], RUNE_DOCK[0], LEAVING_GLUDIN);
  174. _boat.broadcastPacket(GLUDIN_SOUND);
  175. _boat.payForRide(7905, 1, -90015, 150422, -3610);
  176. _boat.executePath(GLUDIN_TO_RUNE);
  177. ThreadPoolManager.getInstance().scheduleGeneral(this, 250000);
  178. break;
  179. case 4:
  180. BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], ARRIVAL_RUNE15);
  181. ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
  182. break;
  183. case 5:
  184. BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], ARRIVAL_RUNE10);
  185. ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
  186. break;
  187. case 6:
  188. BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], ARRIVAL_RUNE5);
  189. ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
  190. break;
  191. case 7:
  192. BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], ARRIVAL_RUNE1);
  193. break;
  194. case 8:
  195. if (BoatManager.getInstance().dockBusy(BoatManager.RUNE_HARBOR))
  196. {
  197. if (_shoutCount == 0)
  198. BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], BUSY_RUNE);
  199. _shoutCount++;
  200. if (_shoutCount > 35)
  201. _shoutCount = 0;
  202. ThreadPoolManager.getInstance().scheduleGeneral(this, 5000);
  203. return;
  204. }
  205. _boat.executePath(RUNE_DOCK);
  206. break;
  207. case 9:
  208. BoatManager.getInstance().dockShip(BoatManager.RUNE_HARBOR, true);
  209. BoatManager.getInstance().broadcastPackets(RUNE_DOCK[0], GLUDIN_DOCK[0], ARRIVED_AT_RUNE, ARRIVED_AT_RUNE_2);
  210. _boat.broadcastPacket(RUNE_SOUND);
  211. ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
  212. break;
  213. case 10:
  214. BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], LEAVE_RUNE5);
  215. ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
  216. break;
  217. case 11:
  218. BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], LEAVE_RUNE1);
  219. ThreadPoolManager.getInstance().scheduleGeneral(this, 40000);
  220. break;
  221. case 12:
  222. BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], LEAVE_RUNE0);
  223. ThreadPoolManager.getInstance().scheduleGeneral(this, 20000);
  224. break;
  225. case 13:
  226. BoatManager.getInstance().dockShip(BoatManager.RUNE_HARBOR, false);
  227. BoatManager.getInstance().broadcastPackets(RUNE_DOCK[0], GLUDIN_DOCK[0], LEAVING_RUNE);
  228. _boat.broadcastPacket(RUNE_SOUND);
  229. _boat.payForRide(7904, 1, 34513, -38009, -3640);
  230. _boat.executePath(RUNE_TO_GLUDIN);
  231. ThreadPoolManager.getInstance().scheduleGeneral(this, 60000);
  232. break;
  233. case 14:
  234. BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], ARRIVAL_GLUDIN15);
  235. ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
  236. break;
  237. case 15:
  238. BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], ARRIVAL_GLUDIN10);
  239. ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
  240. break;
  241. case 16:
  242. BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], ARRIVAL_GLUDIN5);
  243. ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
  244. break;
  245. case 17:
  246. BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], ARRIVAL_GLUDIN1);
  247. break;
  248. case 18:
  249. if (BoatManager.getInstance().dockBusy(BoatManager.GLUDIN_HARBOR))
  250. {
  251. if (_shoutCount == 0)
  252. BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], BUSY_GLUDIN);
  253. _shoutCount++;
  254. if (_shoutCount > 35)
  255. _shoutCount = 0;
  256. ThreadPoolManager.getInstance().scheduleGeneral(this, 5000);
  257. return;
  258. }
  259. _boat.executePath(GLUDIN_DOCK);
  260. break;
  261. case 19:
  262. BoatManager.getInstance().dockShip(BoatManager.GLUDIN_HARBOR, true);
  263. BoatManager.getInstance().broadcastPackets(GLUDIN_DOCK[0], RUNE_DOCK[0], ARRIVED_AT_GLUDIN, ARRIVED_AT_GLUDIN_2);
  264. _boat.broadcastPacket(GLUDIN_SOUND);
  265. ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
  266. break;
  267. }
  268. _shoutCount = 0;
  269. _cycle++;
  270. if (_cycle > 19)
  271. _cycle = 0;
  272. }
  273. catch (Exception e)
  274. {
  275. _log.log(Level.WARNING, e.getMessage());
  276. }
  277. }
  278. public static void main(String[] args)
  279. {
  280. final L2BoatInstance boat = BoatManager.getInstance().getNewBoat(3, -95686, 150514, -3610, 16723);
  281. if (boat != null)
  282. {
  283. boat.registerEngine(new BoatGludinRune(boat));
  284. boat.runEngine(180000);
  285. BoatManager.getInstance().dockShip(BoatManager.GLUDIN_HARBOR, true);
  286. }
  287. }
  288. }