BoatGludinRune.java 14 KB

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