Q00231_TestOfTheMaestro.java 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  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.Q00231_TestOfTheMaestro;
  20. import com.l2jserver.gameserver.enums.QuestSound;
  21. import com.l2jserver.gameserver.model.actor.L2Npc;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.model.base.ClassId;
  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. * Test Of The Maestro (231)
  30. * @author ivantotov
  31. */
  32. public final class Q00231_TestOfTheMaestro extends Quest
  33. {
  34. // NPCs
  35. private static final int IRON_GATES_LOCKIRIN = 30531;
  36. private static final int GOLDEN_WHEELS_SPIRON = 30532;
  37. private static final int SILVER_SCALES_BALANKI = 30533;
  38. private static final int BRONZE_KEYS_KEEF = 30534;
  39. private static final int GRAY_PILLAR_MEMBER_FILAUR = 30535;
  40. private static final int BLACK_ANVILS_ARIN = 30536;
  41. private static final int MASTER_TOMA = 30556;
  42. private static final int CHIEF_CROTO = 30671;
  43. private static final int JAILER_DUBABAH = 30672;
  44. private static final int RESEARCHER_LORAIN = 30673;
  45. // Items
  46. private static final int RECOMMENDATION_OF_BALANKI = 2864;
  47. private static final int RECOMMENDATION_OF_FILAUR = 2865;
  48. private static final int RECOMMENDATION_OF_ARIN = 2866;
  49. private static final int LETTER_OF_SOLDER_DERACHMENT = 2868;
  50. private static final int PAINT_OF_KAMURU = 2869;
  51. private static final int NECKLACE_OF_KAMUTU = 2870;
  52. private static final int PAINT_OF_TELEPORT_DEVICE = 2871;
  53. private static final int TELEPORT_DEVICE = 2872;
  54. private static final int ARCHITECTURE_OF_CRUMA = 2873;
  55. private static final int REPORT_OF_CRUMA = 2874;
  56. private static final int INGREDIENTS_OF_ANTIDOTE = 2875;
  57. private static final int STINGER_WASP_NEEDLE = 2876;
  58. private static final int MARSH_SPIDERS_WEB = 2877;
  59. private static final int BLOOD_OF_LEECH = 2878;
  60. private static final int BROKEN_TELEPORT_DEVICE = 2916;
  61. // Reward
  62. private static final int MARK_OF_MAESTRO = 2867;
  63. private static final int DIMENSIONAL_DIAMOND = 7562;
  64. // Monster
  65. private static final int KING_BUGBEAR = 20150;
  66. private static final int GIANT_MIST_LEECH = 20225;
  67. private static final int STINGER_WASP = 20229;
  68. private static final int MARSH_SPIDER = 20233;
  69. // Quest Monster
  70. private static final int EVIL_EYE_LORD = 27133;
  71. // Misc
  72. private static final int MIN_LEVEL = 39;
  73. public Q00231_TestOfTheMaestro()
  74. {
  75. super(231, Q00231_TestOfTheMaestro.class.getSimpleName(), "Test Of The Maestro");
  76. addStartNpc(IRON_GATES_LOCKIRIN);
  77. addTalkId(IRON_GATES_LOCKIRIN, GOLDEN_WHEELS_SPIRON, SILVER_SCALES_BALANKI, BRONZE_KEYS_KEEF, GRAY_PILLAR_MEMBER_FILAUR, BLACK_ANVILS_ARIN, MASTER_TOMA, CHIEF_CROTO, JAILER_DUBABAH, RESEARCHER_LORAIN);
  78. addKillId(KING_BUGBEAR, GIANT_MIST_LEECH, STINGER_WASP, MARSH_SPIDER, EVIL_EYE_LORD);
  79. registerQuestItems(RECOMMENDATION_OF_BALANKI, RECOMMENDATION_OF_FILAUR, RECOMMENDATION_OF_ARIN, LETTER_OF_SOLDER_DERACHMENT, PAINT_OF_KAMURU, NECKLACE_OF_KAMUTU, PAINT_OF_TELEPORT_DEVICE, TELEPORT_DEVICE, ARCHITECTURE_OF_CRUMA, REPORT_OF_CRUMA, INGREDIENTS_OF_ANTIDOTE, STINGER_WASP_NEEDLE, MARSH_SPIDERS_WEB, BLOOD_OF_LEECH, BROKEN_TELEPORT_DEVICE);
  80. }
  81. @Override
  82. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  83. {
  84. final QuestState qs = getQuestState(player, false);
  85. if (qs == null)
  86. {
  87. return null;
  88. }
  89. String htmltext = null;
  90. switch (event)
  91. {
  92. case "ACCEPT":
  93. {
  94. if (qs.isCreated())
  95. {
  96. qs.startQuest();
  97. qs.setMemoState(1);
  98. playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
  99. if (player.getVariables().getInt("2ND_CLASS_DIAMOND_REWARD", 0) == 0)
  100. {
  101. giveItems(player, DIMENSIONAL_DIAMOND, 23);
  102. player.getVariables().set("2ND_CLASS_DIAMOND_REWARD", 1);
  103. htmltext = "30531-04a.htm";
  104. }
  105. else
  106. {
  107. htmltext = "30531-04.htm";
  108. }
  109. }
  110. break;
  111. }
  112. case "30533-02.html":
  113. {
  114. qs.setMemoState(2);
  115. htmltext = event;
  116. break;
  117. }
  118. case "30556-02.html":
  119. case "30556-03.html":
  120. case "30556-04.html":
  121. {
  122. htmltext = event;
  123. break;
  124. }
  125. case "30556-05.html":
  126. {
  127. if (hasQuestItems(player, PAINT_OF_TELEPORT_DEVICE))
  128. {
  129. giveItems(player, BROKEN_TELEPORT_DEVICE, 1);
  130. takeItems(player, PAINT_OF_TELEPORT_DEVICE, 1);
  131. player.teleToLocation(140352, -194133, -3146);
  132. startQuestTimer("SPAWN_KING_BUGBEAR", 5000, npc, player);
  133. htmltext = event;
  134. }
  135. break;
  136. }
  137. case "30671-02.html":
  138. {
  139. giveItems(player, PAINT_OF_KAMURU, 1);
  140. htmltext = event;
  141. break;
  142. }
  143. case "30673-04.html":
  144. {
  145. if (hasQuestItems(player, INGREDIENTS_OF_ANTIDOTE) && (getQuestItemsCount(player, STINGER_WASP_NEEDLE) >= 10) && (getQuestItemsCount(player, MARSH_SPIDERS_WEB) >= 10) && (getQuestItemsCount(player, BLOOD_OF_LEECH) >= 10))
  146. {
  147. giveItems(player, REPORT_OF_CRUMA, 1);
  148. takeItems(player, STINGER_WASP_NEEDLE, -1);
  149. takeItems(player, MARSH_SPIDERS_WEB, -1);
  150. takeItems(player, BLOOD_OF_LEECH, -1);
  151. takeItems(player, INGREDIENTS_OF_ANTIDOTE, 1);
  152. htmltext = event;
  153. }
  154. break;
  155. }
  156. case "SPAWN_KING_BUGBEAR":
  157. {
  158. addAttackPlayerDesire(addSpawn(KING_BUGBEAR, 140395, -194147, -3146, 0, false, 200000, false), player);
  159. addAttackPlayerDesire(addSpawn(KING_BUGBEAR, 140395, -194147, -3146, 0, false, 200000, false), player);
  160. addAttackPlayerDesire(addSpawn(KING_BUGBEAR, 140395, -194147, -3146, 0, false, 200000, false), player);
  161. break;
  162. }
  163. }
  164. return htmltext;
  165. }
  166. @Override
  167. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  168. {
  169. final QuestState qs = getQuestState(killer, false);
  170. if ((qs != null) && qs.isStarted() && Util.checkIfInRange(1500, npc, killer, true))
  171. {
  172. switch (npc.getId())
  173. {
  174. case GIANT_MIST_LEECH:
  175. {
  176. if (qs.isMemoState(4) && hasQuestItems(killer, INGREDIENTS_OF_ANTIDOTE) && (getQuestItemsCount(killer, BLOOD_OF_LEECH) < 10))
  177. {
  178. giveItems(killer, BLOOD_OF_LEECH, 1);
  179. if (getQuestItemsCount(killer, BLOOD_OF_LEECH) >= 10)
  180. {
  181. playSound(killer, QuestSound.ITEMSOUND_QUEST_MIDDLE);
  182. }
  183. else
  184. {
  185. playSound(killer, QuestSound.ITEMSOUND_QUEST_ITEMGET);
  186. }
  187. }
  188. break;
  189. }
  190. case STINGER_WASP:
  191. {
  192. if (qs.isMemoState(4) && hasQuestItems(killer, INGREDIENTS_OF_ANTIDOTE) && (getQuestItemsCount(killer, STINGER_WASP_NEEDLE) < 10))
  193. {
  194. giveItems(killer, STINGER_WASP_NEEDLE, 1);
  195. if (getQuestItemsCount(killer, STINGER_WASP_NEEDLE) >= 10)
  196. {
  197. playSound(killer, QuestSound.ITEMSOUND_QUEST_MIDDLE);
  198. }
  199. else
  200. {
  201. playSound(killer, QuestSound.ITEMSOUND_QUEST_ITEMGET);
  202. }
  203. }
  204. break;
  205. }
  206. case MARSH_SPIDER:
  207. {
  208. if (qs.isMemoState(4) && hasQuestItems(killer, INGREDIENTS_OF_ANTIDOTE) && (getQuestItemsCount(killer, MARSH_SPIDERS_WEB) < 10))
  209. {
  210. giveItems(killer, MARSH_SPIDERS_WEB, 1);
  211. if (getQuestItemsCount(killer, MARSH_SPIDERS_WEB) >= 10)
  212. {
  213. playSound(killer, QuestSound.ITEMSOUND_QUEST_MIDDLE);
  214. }
  215. else
  216. {
  217. playSound(killer, QuestSound.ITEMSOUND_QUEST_ITEMGET);
  218. }
  219. }
  220. break;
  221. }
  222. case EVIL_EYE_LORD:
  223. {
  224. if (qs.isMemoState(2) && hasQuestItems(killer, PAINT_OF_KAMURU) && !hasQuestItems(killer, NECKLACE_OF_KAMUTU))
  225. {
  226. giveItems(killer, NECKLACE_OF_KAMUTU, 1);
  227. playSound(killer, QuestSound.ITEMSOUND_QUEST_MIDDLE);
  228. }
  229. break;
  230. }
  231. }
  232. }
  233. return super.onKill(npc, killer, isSummon);
  234. }
  235. @Override
  236. public String onTalk(L2Npc npc, L2PcInstance player)
  237. {
  238. final QuestState qs = getQuestState(player, true);
  239. final int memoState = qs.getMemoState();
  240. String htmltext = getNoQuestMsg(player);
  241. if (qs.isCreated())
  242. {
  243. if (npc.getId() == IRON_GATES_LOCKIRIN)
  244. {
  245. if (player.getClassId() == ClassId.artisan)
  246. {
  247. if (player.getLevel() >= MIN_LEVEL)
  248. {
  249. htmltext = "30531-03.htm";
  250. }
  251. else
  252. {
  253. htmltext = "30531-01.html";
  254. }
  255. }
  256. else
  257. {
  258. htmltext = "30531-02.html";
  259. }
  260. }
  261. }
  262. else if (qs.isStarted())
  263. {
  264. switch (npc.getId())
  265. {
  266. case IRON_GATES_LOCKIRIN:
  267. {
  268. if ((memoState >= 1) && !hasQuestItems(player, RECOMMENDATION_OF_BALANKI, RECOMMENDATION_OF_FILAUR, RECOMMENDATION_OF_ARIN))
  269. {
  270. htmltext = "30531-05.html";
  271. }
  272. else if (hasQuestItems(player, RECOMMENDATION_OF_BALANKI, RECOMMENDATION_OF_FILAUR, RECOMMENDATION_OF_ARIN))
  273. {
  274. giveAdena(player, 372154, true);
  275. giveItems(player, MARK_OF_MAESTRO, 1);
  276. addExpAndSp(player, 2085244, 141240);
  277. qs.exitQuest(false, true);
  278. player.sendPacket(new SocialAction(player.getObjectId(), 3));
  279. htmltext = "30531-06.html";
  280. }
  281. break;
  282. }
  283. case GOLDEN_WHEELS_SPIRON:
  284. {
  285. htmltext = "30532-01.html";
  286. break;
  287. }
  288. case SILVER_SCALES_BALANKI:
  289. {
  290. if ((memoState == 1) && !hasQuestItems(player, RECOMMENDATION_OF_BALANKI))
  291. {
  292. htmltext = "30533-01.html";
  293. }
  294. else if (memoState == 2)
  295. {
  296. if (!hasQuestItems(player, LETTER_OF_SOLDER_DERACHMENT))
  297. {
  298. htmltext = "30533-03.html";
  299. }
  300. else
  301. {
  302. giveItems(player, RECOMMENDATION_OF_BALANKI, 1);
  303. takeItems(player, LETTER_OF_SOLDER_DERACHMENT, 1);
  304. qs.setMemoState(1);
  305. if (hasQuestItems(player, RECOMMENDATION_OF_ARIN, RECOMMENDATION_OF_FILAUR))
  306. {
  307. qs.setCond(2, true);
  308. }
  309. htmltext = "30533-04.html";
  310. }
  311. }
  312. else if (hasQuestItems(player, RECOMMENDATION_OF_BALANKI))
  313. {
  314. htmltext = "30533-05.html";
  315. }
  316. break;
  317. }
  318. case BRONZE_KEYS_KEEF:
  319. {
  320. htmltext = "30534-01.html";
  321. break;
  322. }
  323. case GRAY_PILLAR_MEMBER_FILAUR:
  324. {
  325. if ((memoState == 1) && !hasQuestItems(player, RECOMMENDATION_OF_FILAUR))
  326. {
  327. giveItems(player, ARCHITECTURE_OF_CRUMA, 1);
  328. qs.setMemoState(4);
  329. htmltext = "30535-01.html";
  330. }
  331. else if (memoState == 4)
  332. {
  333. if (hasQuestItems(player, ARCHITECTURE_OF_CRUMA) && !hasQuestItems(player, REPORT_OF_CRUMA))
  334. {
  335. htmltext = "30535-02.html";
  336. }
  337. else if (hasQuestItems(player, REPORT_OF_CRUMA) && !hasQuestItems(player, ARCHITECTURE_OF_CRUMA))
  338. {
  339. giveItems(player, RECOMMENDATION_OF_FILAUR, 1);
  340. takeItems(player, REPORT_OF_CRUMA, 1);
  341. qs.setMemoState(1);
  342. if (hasQuestItems(player, RECOMMENDATION_OF_BALANKI, RECOMMENDATION_OF_ARIN))
  343. {
  344. qs.setCond(2, true);
  345. }
  346. htmltext = "30535-03.html";
  347. }
  348. }
  349. else if (hasQuestItems(player, RECOMMENDATION_OF_FILAUR))
  350. {
  351. htmltext = "30535-04.html";
  352. }
  353. break;
  354. }
  355. case BLACK_ANVILS_ARIN:
  356. {
  357. if ((memoState == 1) && !hasQuestItems(player, RECOMMENDATION_OF_ARIN))
  358. {
  359. giveItems(player, PAINT_OF_TELEPORT_DEVICE, 1);
  360. qs.setMemoState(3);
  361. htmltext = "30536-01.html";
  362. }
  363. else if (memoState == 3)
  364. {
  365. if (hasQuestItems(player, PAINT_OF_TELEPORT_DEVICE) && !hasQuestItems(player, TELEPORT_DEVICE))
  366. {
  367. htmltext = "30536-02.html";
  368. }
  369. else if (getQuestItemsCount(player, TELEPORT_DEVICE) >= 5)
  370. {
  371. giveItems(player, RECOMMENDATION_OF_ARIN, 1);
  372. takeItems(player, TELEPORT_DEVICE, -1);
  373. qs.setMemoState(1);
  374. if (hasQuestItems(player, RECOMMENDATION_OF_BALANKI, RECOMMENDATION_OF_FILAUR))
  375. {
  376. qs.setCond(2, true);
  377. }
  378. htmltext = "30536-03.html";
  379. }
  380. }
  381. else if (hasQuestItems(player, RECOMMENDATION_OF_ARIN))
  382. {
  383. htmltext = "30536-04.html";
  384. }
  385. break;
  386. }
  387. case MASTER_TOMA:
  388. {
  389. if (memoState == 3)
  390. {
  391. if (hasQuestItems(player, PAINT_OF_TELEPORT_DEVICE))
  392. {
  393. htmltext = "30556-01.html";
  394. }
  395. else if (hasQuestItems(player, BROKEN_TELEPORT_DEVICE))
  396. {
  397. giveItems(player, TELEPORT_DEVICE, 5);
  398. takeItems(player, BROKEN_TELEPORT_DEVICE, 1);
  399. htmltext = "30556-06.html";
  400. }
  401. else if (getQuestItemsCount(player, TELEPORT_DEVICE) == 5)
  402. {
  403. htmltext = "30556-07.html";
  404. }
  405. }
  406. break;
  407. }
  408. case CHIEF_CROTO:
  409. {
  410. if ((memoState == 2) && !hasAtLeastOneQuestItem(player, PAINT_OF_KAMURU, NECKLACE_OF_KAMUTU, LETTER_OF_SOLDER_DERACHMENT))
  411. {
  412. htmltext = "30671-01.html";
  413. }
  414. else if (hasQuestItems(player, PAINT_OF_KAMURU) && !hasQuestItems(player, NECKLACE_OF_KAMUTU))
  415. {
  416. htmltext = "30671-03.html";
  417. }
  418. else if (hasQuestItems(player, NECKLACE_OF_KAMUTU))
  419. {
  420. giveItems(player, LETTER_OF_SOLDER_DERACHMENT, 1);
  421. takeItems(player, NECKLACE_OF_KAMUTU, 1);
  422. takeItems(player, PAINT_OF_KAMURU, 1);
  423. htmltext = "30671-04.html";
  424. }
  425. else if (hasQuestItems(player, LETTER_OF_SOLDER_DERACHMENT))
  426. {
  427. htmltext = "30671-05.html";
  428. }
  429. break;
  430. }
  431. case JAILER_DUBABAH:
  432. {
  433. if (hasQuestItems(player, PAINT_OF_KAMURU))
  434. {
  435. htmltext = "30672-01.html";
  436. }
  437. break;
  438. }
  439. case RESEARCHER_LORAIN:
  440. {
  441. if (memoState == 4)
  442. {
  443. if (hasQuestItems(player, ARCHITECTURE_OF_CRUMA) && !hasAtLeastOneQuestItem(player, INGREDIENTS_OF_ANTIDOTE, REPORT_OF_CRUMA))
  444. {
  445. giveItems(player, INGREDIENTS_OF_ANTIDOTE, 1);
  446. takeItems(player, ARCHITECTURE_OF_CRUMA, 1);
  447. htmltext = "30673-01.html";
  448. }
  449. else if (hasQuestItems(player, INGREDIENTS_OF_ANTIDOTE) && !hasQuestItems(player, REPORT_OF_CRUMA))
  450. {
  451. if ((getQuestItemsCount(player, STINGER_WASP_NEEDLE) >= 10) && (getQuestItemsCount(player, MARSH_SPIDERS_WEB) >= 10) && (getQuestItemsCount(player, BLOOD_OF_LEECH) >= 10))
  452. {
  453. htmltext = "30673-03.html";
  454. }
  455. else
  456. {
  457. htmltext = "30673-02.html";
  458. }
  459. }
  460. else if (hasQuestItems(player, REPORT_OF_CRUMA))
  461. {
  462. htmltext = "30673-05.html";
  463. }
  464. }
  465. break;
  466. }
  467. }
  468. }
  469. else if (qs.isCompleted())
  470. {
  471. if (npc.getId() == IRON_GATES_LOCKIRIN)
  472. {
  473. htmltext = getAlreadyCompletedMsg(player);
  474. }
  475. }
  476. return htmltext;
  477. }
  478. }