Q00215_TrialOfThePilgrim.java 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  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.Q00215_TrialOfThePilgrim;
  20. import com.l2jserver.gameserver.enums.CategoryType;
  21. import com.l2jserver.gameserver.enums.QuestSound;
  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.network.serverpackets.SocialAction;
  27. import com.l2jserver.gameserver.util.Util;
  28. /**
  29. * Trial Of The Pilgrim (215)
  30. * @author ivantotov
  31. */
  32. public final class Q00215_TrialOfThePilgrim extends Quest
  33. {
  34. // NPCs
  35. private static final int PRIEST_PETRON = 30036;
  36. private static final int PRIEST_PRIMOS = 30117;
  37. private static final int ANDELLIA = 30362;
  38. private static final int GAURI_TWINKLEROCK = 30550;
  39. private static final int SEER_TANAPI = 30571;
  40. private static final int ELDER_CASIAN = 30612;
  41. private static final int HERMIT_SANTIAGO = 30648;
  42. private static final int ANCESTOR_MARTANKUS = 30649;
  43. private static final int PRIEST_OF_THE_EARTH_GERALD = 30650;
  44. private static final int WANDERER_DORF = 30651;
  45. private static final int URUHA = 30652;
  46. // Items
  47. private static final int ADENA = 57;
  48. private static final int BOOK_OF_SAGE = 2722;
  49. private static final int VOUCHER_OF_TRIAL = 2723;
  50. private static final int SPIRIT_OF_FLAME = 2724;
  51. private static final int ESSENSE_OF_FLAME = 2725;
  52. private static final int BOOK_OF_GERALD = 2726;
  53. private static final int GREY_BADGE = 2727;
  54. private static final int PICTURE_OF_NAHIR = 2728;
  55. private static final int HAIR_OF_NAHIR = 2729;
  56. private static final int STATUE_OF_EINHASAD = 2730;
  57. private static final int BOOK_OF_DARKNESS = 2731;
  58. private static final int DEBRIS_OF_WILLOW = 2732;
  59. private static final int TAG_OF_RUMOR = 2733;
  60. // Reward
  61. private static final int MARK_OF_PILGRIM = 2721;
  62. private static final int DIMENSIONAL_DIAMOND = 7562;
  63. // Quest Monster
  64. private static final int LAVA_SALAMANDER = 27116;
  65. private static final int NAHIR = 27117;
  66. private static final int BLACK_WILLOW = 27118;
  67. // Misc
  68. private static final int MIN_LVL = 35;
  69. public Q00215_TrialOfThePilgrim()
  70. {
  71. super(215, Q00215_TrialOfThePilgrim.class.getSimpleName(), "Trial Of The Pilgrim");
  72. addStartNpc(HERMIT_SANTIAGO);
  73. addTalkId(HERMIT_SANTIAGO, PRIEST_PETRON, PRIEST_PRIMOS, ANDELLIA, GAURI_TWINKLEROCK, SEER_TANAPI, ELDER_CASIAN, ANCESTOR_MARTANKUS, PRIEST_OF_THE_EARTH_GERALD, WANDERER_DORF, URUHA);
  74. addKillId(LAVA_SALAMANDER, NAHIR, BLACK_WILLOW);
  75. registerQuestItems(BOOK_OF_SAGE, VOUCHER_OF_TRIAL, SPIRIT_OF_FLAME, ESSENSE_OF_FLAME, BOOK_OF_GERALD, GREY_BADGE, PICTURE_OF_NAHIR, HAIR_OF_NAHIR, STATUE_OF_EINHASAD, BOOK_OF_DARKNESS, DEBRIS_OF_WILLOW, TAG_OF_RUMOR);
  76. }
  77. @Override
  78. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  79. {
  80. final QuestState qs = getQuestState(player, false);
  81. if (qs == null)
  82. {
  83. return null;
  84. }
  85. String htmltext = null;
  86. switch (event)
  87. {
  88. case "ACCEPT":
  89. {
  90. if (qs.isCreated())
  91. {
  92. qs.startQuest();
  93. qs.setMemoState(1);
  94. giveItems(player, VOUCHER_OF_TRIAL, 1);
  95. playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
  96. if (player.getVariables().getInt("2ND_CLASS_DIAMOND_REWARD", 0) == 0)
  97. {
  98. giveItems(player, DIMENSIONAL_DIAMOND, 49);
  99. player.getVariables().set("2ND_CLASS_DIAMOND_REWARD", 1);
  100. htmltext = "30648-04a.htm";
  101. }
  102. else
  103. {
  104. htmltext = "30648-04.htm";
  105. }
  106. }
  107. break;
  108. }
  109. case "30648-05.html":
  110. case "30648-06.html":
  111. case "30648-07.html":
  112. case "30648-08.html":
  113. {
  114. htmltext = event;
  115. break;
  116. }
  117. case "30362-05.html":
  118. {
  119. if (qs.isMemoState(15) && hasQuestItems(player, BOOK_OF_DARKNESS))
  120. {
  121. takeItems(player, BOOK_OF_DARKNESS, 1);
  122. qs.setMemoState(16);
  123. qs.setCond(16, true);
  124. htmltext = event;
  125. }
  126. break;
  127. }
  128. case "30362-04.html":
  129. {
  130. if (qs.isMemoState(15) && hasQuestItems(player, BOOK_OF_DARKNESS))
  131. {
  132. qs.setMemoState(16);
  133. qs.setCond(16, true);
  134. htmltext = event;
  135. }
  136. break;
  137. }
  138. case "30649-04.html":
  139. {
  140. if (qs.isMemoState(4) && hasQuestItems(player, ESSENSE_OF_FLAME))
  141. {
  142. giveItems(player, SPIRIT_OF_FLAME, 1);
  143. takeItems(player, ESSENSE_OF_FLAME, 1);
  144. qs.setMemoState(5);
  145. qs.setCond(5, true);
  146. htmltext = event;
  147. }
  148. break;
  149. }
  150. case "30650-02.html":
  151. {
  152. if (qs.isMemoState(6) && hasQuestItems(player, TAG_OF_RUMOR))
  153. {
  154. if (getQuestItemsCount(player, ADENA) >= 100000)
  155. {
  156. giveItems(player, BOOK_OF_GERALD, 1);
  157. takeItems(player, ADENA, 100000);
  158. qs.setMemoState(7);
  159. htmltext = event;
  160. }
  161. else
  162. {
  163. htmltext = "30650-03.html";
  164. }
  165. }
  166. break;
  167. }
  168. case "30650-03.html":
  169. {
  170. if (qs.isMemoState(6) && hasQuestItems(player, TAG_OF_RUMOR))
  171. {
  172. htmltext = event;
  173. }
  174. break;
  175. }
  176. case "30652-02.html":
  177. {
  178. if (qs.isMemoState(14) && hasQuestItems(player, DEBRIS_OF_WILLOW))
  179. {
  180. giveItems(player, BOOK_OF_DARKNESS, 1);
  181. takeItems(player, DEBRIS_OF_WILLOW, 1);
  182. qs.setMemoState(15);
  183. qs.setCond(15, true);
  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 = getQuestState(killer, false);
  195. if ((qs != null) && qs.isStarted() && Util.checkIfInRange(1500, npc, killer, true))
  196. {
  197. switch (npc.getId())
  198. {
  199. case LAVA_SALAMANDER:
  200. {
  201. if (qs.isMemoState(3) && !hasQuestItems(killer, ESSENSE_OF_FLAME))
  202. {
  203. qs.setMemoState(4);
  204. qs.setCond(4, true);
  205. giveItems(killer, ESSENSE_OF_FLAME, 1);
  206. }
  207. break;
  208. }
  209. case NAHIR:
  210. {
  211. if (qs.isMemoState(10) && !hasQuestItems(killer, HAIR_OF_NAHIR))
  212. {
  213. qs.setMemoState(11);
  214. qs.setCond(11, true);
  215. giveItems(killer, HAIR_OF_NAHIR, 1);
  216. }
  217. break;
  218. }
  219. case BLACK_WILLOW:
  220. {
  221. if (qs.isMemoState(13) && !hasQuestItems(killer, DEBRIS_OF_WILLOW))
  222. {
  223. qs.setMemoState(14);
  224. qs.setCond(14, true);
  225. giveItems(killer, DEBRIS_OF_WILLOW, 1);
  226. }
  227. break;
  228. }
  229. }
  230. }
  231. return super.onKill(npc, killer, isSummon);
  232. }
  233. @Override
  234. public String onTalk(L2Npc npc, L2PcInstance player)
  235. {
  236. final QuestState qs = getQuestState(player, true);
  237. final int memoState = qs.getMemoState();
  238. String htmltext = getNoQuestMsg(player);
  239. if (qs.isCreated())
  240. {
  241. if (npc.getId() == HERMIT_SANTIAGO)
  242. {
  243. if (!player.isInCategory(CategoryType.HEAL_GROUP))
  244. {
  245. htmltext = "30648-02.html";
  246. }
  247. else if (player.getLevel() < MIN_LVL)
  248. {
  249. htmltext = "30648-01.html";
  250. }
  251. else
  252. {
  253. htmltext = "30648-03.htm";
  254. }
  255. }
  256. }
  257. else if (qs.isStarted())
  258. {
  259. switch (npc.getId())
  260. {
  261. case HERMIT_SANTIAGO:
  262. {
  263. if (memoState >= 1)
  264. {
  265. if (!hasQuestItems(player, BOOK_OF_SAGE))
  266. {
  267. htmltext = "30648-09.html";
  268. }
  269. else
  270. {
  271. giveAdena(player, 229298, true);
  272. giveItems(player, MARK_OF_PILGRIM, 1);
  273. addExpAndSp(player, 1258250, 81606);
  274. qs.exitQuest(false, true);
  275. player.sendPacket(new SocialAction(player.getObjectId(), 3));
  276. htmltext = "30648-10.html";
  277. }
  278. }
  279. break;
  280. }
  281. case PRIEST_PETRON:
  282. {
  283. if (memoState == 9)
  284. {
  285. giveItems(player, PICTURE_OF_NAHIR, 1);
  286. qs.setMemoState(10);
  287. qs.setCond(10, true);
  288. htmltext = "30036-01.html";
  289. }
  290. else if (memoState == 10)
  291. {
  292. htmltext = "30036-02.html";
  293. }
  294. else if (memoState == 11)
  295. {
  296. takeItems(player, PICTURE_OF_NAHIR, 1);
  297. takeItems(player, HAIR_OF_NAHIR, 1);
  298. giveItems(player, STATUE_OF_EINHASAD, 1);
  299. qs.setMemoState(12);
  300. qs.setCond(12, true);
  301. htmltext = "30036-03.html";
  302. }
  303. else if (memoState == 12)
  304. {
  305. if (hasQuestItems(player, STATUE_OF_EINHASAD))
  306. {
  307. htmltext = "30036-04.html";
  308. }
  309. }
  310. break;
  311. }
  312. case PRIEST_PRIMOS:
  313. {
  314. if (memoState == 8)
  315. {
  316. qs.setMemoState(9);
  317. qs.setCond(9, true);
  318. htmltext = "30117-01.html";
  319. }
  320. else if (memoState == 9)
  321. {
  322. qs.setMemoState(9);
  323. qs.setCond(9, true);
  324. htmltext = "30117-02.html";
  325. }
  326. break;
  327. }
  328. case ANDELLIA:
  329. {
  330. if (memoState == 12)
  331. {
  332. if (player.getLevel() >= 0)
  333. {
  334. qs.setMemoState(13);
  335. qs.setCond(13, true);
  336. htmltext = "30362-01.html";
  337. }
  338. else
  339. {
  340. htmltext = "30362-01a.html";
  341. }
  342. }
  343. else if (memoState == 13)
  344. {
  345. htmltext = "30362-02.html";
  346. }
  347. else if (memoState == 14)
  348. {
  349. htmltext = "30362-02a.html";
  350. }
  351. else if (memoState == 15)
  352. {
  353. if (hasQuestItems(player, BOOK_OF_DARKNESS))
  354. {
  355. htmltext = "30362-03.html";
  356. }
  357. else
  358. {
  359. htmltext = "30362-07.html";
  360. }
  361. }
  362. else if (memoState == 16)
  363. {
  364. htmltext = "30362-06.html";
  365. }
  366. break;
  367. }
  368. case GAURI_TWINKLEROCK:
  369. {
  370. if (memoState == 5)
  371. {
  372. if (hasQuestItems(player, SPIRIT_OF_FLAME))
  373. {
  374. takeItems(player, SPIRIT_OF_FLAME, 1);
  375. giveItems(player, TAG_OF_RUMOR, 1);
  376. qs.setMemoState(6);
  377. qs.setCond(7, true);
  378. htmltext = "30550-01.html";
  379. }
  380. }
  381. else if (memoState == 6)
  382. {
  383. htmltext = "30550-02.html";
  384. }
  385. break;
  386. }
  387. case SEER_TANAPI:
  388. {
  389. if (memoState == 1)
  390. {
  391. if (hasQuestItems(player, VOUCHER_OF_TRIAL))
  392. {
  393. takeItems(player, VOUCHER_OF_TRIAL, 1);
  394. qs.setMemoState(2);
  395. qs.setCond(2, true);
  396. htmltext = "30571-01.html";
  397. }
  398. }
  399. else if (memoState == 2)
  400. {
  401. htmltext = "30571-02.html";
  402. }
  403. else if (memoState == 5)
  404. {
  405. if (hasQuestItems(player, SPIRIT_OF_FLAME))
  406. {
  407. qs.setCond(6, true);
  408. htmltext = "30571-03.html";
  409. }
  410. }
  411. break;
  412. }
  413. case ELDER_CASIAN:
  414. {
  415. if (memoState == 16)
  416. {
  417. qs.setMemoState(17);
  418. if (!hasQuestItems(player, BOOK_OF_SAGE))
  419. {
  420. giveItems(player, BOOK_OF_SAGE, 1);
  421. }
  422. takeItems(player, GREY_BADGE, 1);
  423. takeItems(player, SPIRIT_OF_FLAME, 1);
  424. takeItems(player, STATUE_OF_EINHASAD, 1);
  425. if (hasQuestItems(player, BOOK_OF_DARKNESS))
  426. {
  427. addExpAndSp(player, 5000, 500);
  428. takeItems(player, BOOK_OF_DARKNESS, 1);
  429. }
  430. htmltext = "30612-01.html";
  431. }
  432. else if (memoState == 17)
  433. {
  434. qs.setCond(17, true);
  435. htmltext = "30612-02.html";
  436. }
  437. break;
  438. }
  439. case ANCESTOR_MARTANKUS:
  440. {
  441. if (memoState == 2)
  442. {
  443. qs.setMemoState(3);
  444. qs.setCond(3, true);
  445. htmltext = "30649-01.html";
  446. }
  447. else if (memoState == 3)
  448. {
  449. htmltext = "30649-02.html";
  450. }
  451. else if (memoState == 4)
  452. {
  453. if (hasQuestItems(player, ESSENSE_OF_FLAME))
  454. {
  455. htmltext = "30649-03.html";
  456. }
  457. }
  458. break;
  459. }
  460. case PRIEST_OF_THE_EARTH_GERALD:
  461. {
  462. if (memoState == 6)
  463. {
  464. if (hasQuestItems(player, TAG_OF_RUMOR))
  465. {
  466. htmltext = "30650-01.html";
  467. }
  468. }
  469. else if (hasQuestItems(player, GREY_BADGE, BOOK_OF_GERALD))
  470. {
  471. giveAdena(player, 100000, true);
  472. takeItems(player, BOOK_OF_GERALD, 1);
  473. htmltext = "30650-04.html";
  474. }
  475. break;
  476. }
  477. case WANDERER_DORF:
  478. {
  479. if (memoState == 6)
  480. {
  481. if (hasQuestItems(player, TAG_OF_RUMOR))
  482. {
  483. giveItems(player, GREY_BADGE, 1);
  484. takeItems(player, TAG_OF_RUMOR, 1);
  485. qs.setMemoState(8);
  486. htmltext = "30651-01.html";
  487. }
  488. }
  489. else if (memoState == 7)
  490. {
  491. if (hasQuestItems(player, TAG_OF_RUMOR))
  492. {
  493. giveItems(player, GREY_BADGE, 1);
  494. takeItems(player, TAG_OF_RUMOR, 1);
  495. qs.setMemoState(8);
  496. htmltext = "30651-02.html";
  497. }
  498. }
  499. else if (memoState == 8)
  500. {
  501. qs.setCond(8, true);
  502. htmltext = "30651-03.html";
  503. }
  504. break;
  505. }
  506. case URUHA:
  507. {
  508. if (memoState == 14)
  509. {
  510. if (hasQuestItems(player, DEBRIS_OF_WILLOW))
  511. {
  512. htmltext = "30652-01.html";
  513. }
  514. }
  515. else if (memoState == 15)
  516. {
  517. if (hasQuestItems(player, BOOK_OF_DARKNESS))
  518. {
  519. htmltext = "30652-03.html";
  520. }
  521. }
  522. break;
  523. }
  524. }
  525. }
  526. else if (qs.isCompleted())
  527. {
  528. if (npc.getId() == HERMIT_SANTIAGO)
  529. {
  530. htmltext = getAlreadyCompletedMsg(player);
  531. }
  532. }
  533. return htmltext;
  534. }
  535. }