Q00117_TheOceanOfDistantStars.java 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. /*
  2. * Copyright (C) 2004-2015 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 quests.Q00117_TheOceanOfDistantStars;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.quest.Quest;
  25. import com.l2jserver.gameserver.model.quest.QuestState;
  26. import com.l2jserver.gameserver.util.Util;
  27. /**
  28. * The Ocean of Distant Stars (117)
  29. * @author Adry_85
  30. */
  31. public final class Q00117_TheOceanOfDistantStars extends Quest
  32. {
  33. // NPCs
  34. private static final int OBI = 32052;
  35. private static final int ABEY = 32053;
  36. private static final int GHOST_OF_A_RAILROAD_ENGINEER = 32054;
  37. private static final int GHOST_OF_AN_ANCIENT_RAILROAD_ENGINEER = 32055;
  38. private static final int BOX = 32076;
  39. // Items
  40. private static final int ENGRAVED_HAMMER = 8488;
  41. private static final int BOOK_OF_GREY_STAR = 8495;
  42. // Misc
  43. private static final int MIN_LEVEL = 39;
  44. // Monsters
  45. private static final int BANDIT_WARRIOR = 22023;
  46. private static final int BANDIT_INSPECTOR = 22024;
  47. private static final Map<Integer, Double> MONSTER_DROP_CHANCES = new HashMap<>();
  48. static
  49. {
  50. MONSTER_DROP_CHANCES.put(BANDIT_WARRIOR, 0.179);
  51. MONSTER_DROP_CHANCES.put(BANDIT_INSPECTOR, 0.1);
  52. }
  53. public Q00117_TheOceanOfDistantStars()
  54. {
  55. super(117, Q00117_TheOceanOfDistantStars.class.getSimpleName(), "The Ocean of Distant Stars");
  56. addStartNpc(ABEY);
  57. addTalkId(ABEY, GHOST_OF_A_RAILROAD_ENGINEER, GHOST_OF_AN_ANCIENT_RAILROAD_ENGINEER, BOX, OBI);
  58. addKillId(BANDIT_WARRIOR, BANDIT_INSPECTOR);
  59. registerQuestItems(ENGRAVED_HAMMER, BOOK_OF_GREY_STAR);
  60. }
  61. @Override
  62. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  63. {
  64. final QuestState qs = getQuestState(player, false);
  65. if (qs == null)
  66. {
  67. return null;
  68. }
  69. String htmltext = null;
  70. switch (event)
  71. {
  72. case "32053-02.htm":
  73. {
  74. qs.setMemoState(1);
  75. qs.startQuest();
  76. htmltext = event;
  77. break;
  78. }
  79. case "32053-06.html":
  80. {
  81. if (qs.isMemoState(3))
  82. {
  83. qs.setMemoState(4);
  84. qs.setCond(4, true);
  85. htmltext = event;
  86. }
  87. break;
  88. }
  89. case "32053-09.html":
  90. {
  91. if (qs.isMemoState(5) && hasQuestItems(player, ENGRAVED_HAMMER))
  92. {
  93. qs.setMemoState(6);
  94. qs.setCond(6, true);
  95. htmltext = event;
  96. }
  97. break;
  98. }
  99. case "32054-02.html":
  100. {
  101. if (qs.isMemoState(9))
  102. {
  103. htmltext = event;
  104. }
  105. break;
  106. }
  107. case "32054-03.html":
  108. {
  109. if (qs.isMemoState(9))
  110. {
  111. giveAdena(player, 17647, true);
  112. addExpAndSp(player, 107387, 7369);
  113. qs.exitQuest(false, true);
  114. htmltext = event;
  115. }
  116. break;
  117. }
  118. case "32055-02.html":
  119. {
  120. if (qs.isMemoState(1))
  121. {
  122. qs.setMemoState(2);
  123. qs.setCond(2, true);
  124. htmltext = event;
  125. }
  126. break;
  127. }
  128. case "32055-05.html":
  129. {
  130. if (qs.isMemoState(8))
  131. {
  132. if (hasQuestItems(player, ENGRAVED_HAMMER))
  133. {
  134. qs.setMemoState(9);
  135. qs.setCond(10, true);
  136. takeItems(player, ENGRAVED_HAMMER, -1);
  137. htmltext = event;
  138. }
  139. else
  140. {
  141. htmltext = "32055-06.html";
  142. }
  143. }
  144. break;
  145. }
  146. case "32076-02.html":
  147. {
  148. if (qs.isMemoState(4))
  149. {
  150. qs.setMemoState(5);
  151. qs.setCond(5, true);
  152. giveItems(player, ENGRAVED_HAMMER, 1);
  153. htmltext = event;
  154. }
  155. break;
  156. }
  157. case "32052-02.html":
  158. {
  159. if (qs.isMemoState(2))
  160. {
  161. qs.setMemoState(3);
  162. qs.setCond(3, true);
  163. htmltext = event;
  164. }
  165. break;
  166. }
  167. case "32052-05.html":
  168. {
  169. if (qs.isMemoState(6))
  170. {
  171. qs.setMemoState(7);
  172. qs.setCond(7, true);
  173. htmltext = event;
  174. }
  175. break;
  176. }
  177. case "32052-07.html":
  178. {
  179. if (qs.isMemoState(7) && hasQuestItems(player, BOOK_OF_GREY_STAR))
  180. {
  181. qs.setMemoState(8);
  182. qs.setCond(9, true);
  183. takeItems(player, BOOK_OF_GREY_STAR, -1);
  184. htmltext = event;
  185. }
  186. break;
  187. }
  188. }
  189. return htmltext;
  190. }
  191. @Override
  192. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  193. {
  194. final QuestState qs = getRandomPartyMemberState(killer, 7, 3, npc);
  195. if ((qs == null) || !Util.checkIfInRange(1500, npc, killer, true))
  196. {
  197. return null;
  198. }
  199. if (giveItemRandomly(killer, npc, BOOK_OF_GREY_STAR, 1, 1, MONSTER_DROP_CHANCES.get(npc.getId()), true))
  200. {
  201. qs.setCond(8);
  202. }
  203. return super.onKill(npc, killer, isSummon);
  204. }
  205. @Override
  206. public String onTalk(L2Npc npc, L2PcInstance player)
  207. {
  208. QuestState qs = getQuestState(player, true);
  209. String htmltext = getNoQuestMsg(player);
  210. if (qs.isCompleted())
  211. {
  212. if (npc.getId() == ABEY)
  213. {
  214. htmltext = getAlreadyCompletedMsg(player);
  215. }
  216. }
  217. else if (qs.isCreated())
  218. {
  219. htmltext = (player.getLevel() >= MIN_LEVEL) ? "32053-01.htm" : "32053-03.htm";
  220. }
  221. else if (qs.isStarted())
  222. {
  223. switch (npc.getId())
  224. {
  225. case ABEY:
  226. {
  227. switch (qs.getMemoState())
  228. {
  229. case 1:
  230. {
  231. htmltext = "32053-04.html";
  232. break;
  233. }
  234. case 3:
  235. {
  236. htmltext = "32053-05.html";
  237. break;
  238. }
  239. case 4:
  240. {
  241. htmltext = "32053-07.html";
  242. break;
  243. }
  244. case 5:
  245. {
  246. if (hasQuestItems(player, ENGRAVED_HAMMER))
  247. {
  248. htmltext = "32053-08.html";
  249. }
  250. break;
  251. }
  252. case 6:
  253. {
  254. htmltext = "32053-10.html";
  255. break;
  256. }
  257. }
  258. break;
  259. }
  260. case GHOST_OF_A_RAILROAD_ENGINEER:
  261. {
  262. if (qs.isMemoState(9))
  263. {
  264. htmltext = "32054-01.html";
  265. }
  266. break;
  267. }
  268. case GHOST_OF_AN_ANCIENT_RAILROAD_ENGINEER:
  269. {
  270. switch (qs.getMemoState())
  271. {
  272. case 1:
  273. {
  274. htmltext = "32055-01.html";
  275. break;
  276. }
  277. case 2:
  278. {
  279. htmltext = "32055-03.html";
  280. break;
  281. }
  282. case 8:
  283. {
  284. htmltext = "32055-04.html";
  285. break;
  286. }
  287. case 9:
  288. {
  289. htmltext = "32055-07.html";
  290. break;
  291. }
  292. }
  293. break;
  294. }
  295. case BOX:
  296. {
  297. if (qs.isMemoState(4))
  298. {
  299. htmltext = "32076-01.html";
  300. }
  301. else if (qs.isMemoState(5))
  302. {
  303. htmltext = "32076-03.html";
  304. }
  305. break;
  306. }
  307. case OBI:
  308. {
  309. switch (qs.getMemoState())
  310. {
  311. case 2:
  312. {
  313. htmltext = "32052-01.html";
  314. break;
  315. }
  316. case 3:
  317. {
  318. htmltext = "32052-03.html";
  319. break;
  320. }
  321. case 6:
  322. {
  323. htmltext = "32052-04.html";
  324. break;
  325. }
  326. case 7:
  327. {
  328. if (hasQuestItems(player, BOOK_OF_GREY_STAR))
  329. {
  330. htmltext = "32052-06.html";
  331. }
  332. else
  333. {
  334. htmltext = "32052-08.html";
  335. }
  336. break;
  337. }
  338. case 8:
  339. {
  340. htmltext = "32052-09.html";
  341. break;
  342. }
  343. }
  344. break;
  345. }
  346. }
  347. }
  348. return htmltext;
  349. }
  350. }