BoatGludinRune.java 14 KB

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