Q00373_SupplierOfReagents.java 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  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.Q00373_SupplierOfReagents;
  20. import java.util.HashMap;
  21. import quests.Q00235_MimirsElixir.Q00235_MimirsElixir;
  22. import com.l2jserver.gameserver.enums.QuestSound;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.model.holders.ItemHolder;
  26. import com.l2jserver.gameserver.model.quest.Quest;
  27. import com.l2jserver.gameserver.model.quest.QuestState;
  28. /**
  29. * Supplier of Reagents (373)
  30. * @author Joxit
  31. */
  32. public final class Q00373_SupplierOfReagents extends Quest
  33. {
  34. // NPCs
  35. private static final int WESLEY = 30166;
  36. private static final int ALCHEMIST_MIXING_URN = 31149;
  37. // Mobs
  38. private static final int HALLATE_MAID = 20822;
  39. private static final int HALLATE_GUARDIAN = 21061;
  40. private static final int HAMES_ORC_SHAMAN = 21115;
  41. private static final int LAVA_WYRM = 21111;
  42. private static final int CRENDION = 20813;
  43. private static final int PLATINUM_TRIBE_SHAMAN = 20828;
  44. private static final int PLATINUM_GUARDIAN_SHAMAN = 21066;
  45. // Items
  46. private static final int REAGENT_POUNCH1 = 6007;
  47. private static final int REAGENT_POUNCH2 = 6008;
  48. private static final int REAGENT_POUNCH3 = 6009;
  49. private static final int REAGENT_BOX = 6010;
  50. private static final int WYRM_BLOOD = 6011;
  51. private static final int LAVA_STONE = 6012;
  52. private static final int MOONSTONE_SHARD = 6013;
  53. private static final int ROTTEN_BONE = 6014;
  54. private static final int DEMONS_BLOOD = 6015;
  55. private static final int INFERNIUM_ORE = 6016;
  56. private static final int BLOOD_ROOT = 6017;
  57. private static final int VOLCANIC_ASH = 6018;
  58. private static final int QUICKSILVER = 6019;
  59. private static final int SULFUR = 6020;
  60. private static final int DRACOPLASM = 6021;
  61. private static final int MAGMA_DUST = 6022;
  62. private static final int MOON_DUST = 6023;
  63. private static final int NECROPLASM = 6024;
  64. private static final int DEMONPLASM = 6025;
  65. private static final int INFERNO_DUST = 6026;
  66. private static final int DRACONIC_ESSENCE = 6027;
  67. private static final int FIRE_ESSENCE = 6028;
  68. private static final int LUNARGENT = 6029;
  69. private static final int MIDNIGHT_OIL = 6030;
  70. private static final int DEMONIC_ESSENCE = 6031;
  71. private static final int ABYSS_OIL = 6032;
  72. private static final int HELLFIRE_OIL = 6033;
  73. private static final int NIGHTMARE_OIL = 6034;
  74. private static final int PURE_SILVER = 6320;
  75. private static final int MIXING_MANUAL = 6317;
  76. private static final int WESLEYS_MIXING_STONE = 5904;
  77. // Misc
  78. private static final int MIN_LVL = 57;
  79. private static final HashMap<String, Integer> HTML_TO_MEMO_STATE = new HashMap<>(20);
  80. private static final HashMap<Integer, ItemHolder> MEMO_STATE_TO_ITEM = new HashMap<>(20);
  81. private static final HashMap<Integer, Entry> MEMO_STATE_TO_REWARD = new HashMap<>(15);
  82. static
  83. {
  84. // List of ingredients to mix
  85. HTML_TO_MEMO_STATE.put("31149-03.html", 11);
  86. HTML_TO_MEMO_STATE.put("31149-04.html", 12);
  87. HTML_TO_MEMO_STATE.put("31149-05.html", 13);
  88. HTML_TO_MEMO_STATE.put("31149-06.html", 14);
  89. HTML_TO_MEMO_STATE.put("31149-07.html", 15);
  90. HTML_TO_MEMO_STATE.put("31149-08.html", 16);
  91. HTML_TO_MEMO_STATE.put("31149-09.html", 17);
  92. HTML_TO_MEMO_STATE.put("31149-10.html", 18);
  93. HTML_TO_MEMO_STATE.put("31149-11.html", 19);
  94. HTML_TO_MEMO_STATE.put("31149-12.html", 20);
  95. HTML_TO_MEMO_STATE.put("31149-13.html", 21);
  96. HTML_TO_MEMO_STATE.put("31149-14.html", 22);
  97. HTML_TO_MEMO_STATE.put("31149-15.html", 23);
  98. HTML_TO_MEMO_STATE.put("31149-16.html", 24);
  99. MEMO_STATE_TO_ITEM.put(11, new ItemHolder(WYRM_BLOOD, 10));
  100. MEMO_STATE_TO_ITEM.put(12, new ItemHolder(LAVA_STONE, 10));
  101. MEMO_STATE_TO_ITEM.put(13, new ItemHolder(MOONSTONE_SHARD, 10));
  102. MEMO_STATE_TO_ITEM.put(14, new ItemHolder(ROTTEN_BONE, 10));
  103. MEMO_STATE_TO_ITEM.put(15, new ItemHolder(DEMONS_BLOOD, 10));
  104. MEMO_STATE_TO_ITEM.put(16, new ItemHolder(INFERNIUM_ORE, 10));
  105. MEMO_STATE_TO_ITEM.put(17, new ItemHolder(DRACOPLASM, 10));
  106. MEMO_STATE_TO_ITEM.put(18, new ItemHolder(MAGMA_DUST, 10));
  107. MEMO_STATE_TO_ITEM.put(19, new ItemHolder(MOON_DUST, 10));
  108. MEMO_STATE_TO_ITEM.put(20, new ItemHolder(NECROPLASM, 10));
  109. MEMO_STATE_TO_ITEM.put(21, new ItemHolder(DEMONPLASM, 10));
  110. MEMO_STATE_TO_ITEM.put(22, new ItemHolder(INFERNO_DUST, 10));
  111. MEMO_STATE_TO_ITEM.put(23, new ItemHolder(FIRE_ESSENCE, 1));
  112. MEMO_STATE_TO_ITEM.put(24, new ItemHolder(LUNARGENT, 1));
  113. // List of catalysts to mix
  114. HTML_TO_MEMO_STATE.put("31149-19.html", 1100);
  115. HTML_TO_MEMO_STATE.put("31149-20.html", 1200);
  116. HTML_TO_MEMO_STATE.put("31149-21.html", 1300);
  117. HTML_TO_MEMO_STATE.put("31149-22.html", 1400);
  118. HTML_TO_MEMO_STATE.put("31149-23.html", 1500);
  119. HTML_TO_MEMO_STATE.put("31149-24.html", 1600);
  120. MEMO_STATE_TO_ITEM.put(1100, new ItemHolder(BLOOD_ROOT, 1));
  121. MEMO_STATE_TO_ITEM.put(1200, new ItemHolder(VOLCANIC_ASH, 1));
  122. MEMO_STATE_TO_ITEM.put(1300, new ItemHolder(QUICKSILVER, 1));
  123. MEMO_STATE_TO_ITEM.put(1400, new ItemHolder(SULFUR, 1));
  124. MEMO_STATE_TO_ITEM.put(1500, new ItemHolder(DEMONIC_ESSENCE, 1));
  125. MEMO_STATE_TO_ITEM.put(1600, new ItemHolder(MIDNIGHT_OIL, 1));
  126. // The reward is the sum of ingredient and catalyst
  127. MEMO_STATE_TO_REWARD.put(1111, new Entry(DRACOPLASM, "31149-30.html"));
  128. MEMO_STATE_TO_REWARD.put(1212, new Entry(MAGMA_DUST, "31149-31.html"));
  129. MEMO_STATE_TO_REWARD.put(1213, new Entry(MOON_DUST, "31149-32.html"));
  130. MEMO_STATE_TO_REWARD.put(1114, new Entry(NECROPLASM, "31149-33.html"));
  131. MEMO_STATE_TO_REWARD.put(1115, new Entry(DEMONPLASM, "31149-34.html"));
  132. MEMO_STATE_TO_REWARD.put(1216, new Entry(INFERNO_DUST, "31149-35.html"));
  133. MEMO_STATE_TO_REWARD.put(1317, new Entry(DRACONIC_ESSENCE, "31149-36.html"));
  134. MEMO_STATE_TO_REWARD.put(1418, new Entry(FIRE_ESSENCE, "31149-37.html"));
  135. MEMO_STATE_TO_REWARD.put(1319, new Entry(LUNARGENT, "31149-38.html"));
  136. MEMO_STATE_TO_REWARD.put(1320, new Entry(MIDNIGHT_OIL, "31149-39.html"));
  137. MEMO_STATE_TO_REWARD.put(1421, new Entry(DEMONIC_ESSENCE, "31149-40.html"));
  138. MEMO_STATE_TO_REWARD.put(1422, new Entry(ABYSS_OIL, "31149-41.html"));
  139. MEMO_STATE_TO_REWARD.put(1523, new Entry(HELLFIRE_OIL, "31149-42.html"));
  140. MEMO_STATE_TO_REWARD.put(1624, new Entry(NIGHTMARE_OIL, "31149-43.html"));
  141. MEMO_STATE_TO_REWARD.put(1324, new Entry(PURE_SILVER, "31149-46.html"));
  142. }
  143. public Q00373_SupplierOfReagents()
  144. {
  145. super(373, Q00373_SupplierOfReagents.class.getSimpleName(), "Supplier of Reagents");
  146. addStartNpc(WESLEY);
  147. addKillId(HALLATE_GUARDIAN, HALLATE_MAID, HAMES_ORC_SHAMAN, LAVA_WYRM, CRENDION, PLATINUM_GUARDIAN_SHAMAN, PLATINUM_TRIBE_SHAMAN);
  148. addTalkId(WESLEY, ALCHEMIST_MIXING_URN);
  149. registerQuestItems(WESLEYS_MIXING_STONE, MIXING_MANUAL);
  150. }
  151. @Override
  152. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  153. {
  154. final QuestState qs = getQuestState(player, false);
  155. String htmltext = null;
  156. if (qs == null)
  157. {
  158. return htmltext;
  159. }
  160. switch (event)
  161. {
  162. case "30166-03.htm":
  163. case "30166-06.html":
  164. case "30166-04a.html":
  165. case "30166-04b.html":
  166. case "30166-04c.html":
  167. case "30166-04d.html":
  168. case "31149-18.html":
  169. {
  170. htmltext = event;
  171. break;
  172. }
  173. case "30166-04.html":
  174. {
  175. if ((player.getLevel() >= MIN_LVL) && qs.isCreated())
  176. {
  177. giveItems(player, WESLEYS_MIXING_STONE, 1);
  178. giveItems(player, MIXING_MANUAL, 1);
  179. qs.startQuest();
  180. htmltext = event;
  181. }
  182. break;
  183. }
  184. case "30166-07.html":
  185. {
  186. qs.exitQuest(true, true);
  187. htmltext = event;
  188. break;
  189. }
  190. case "31149-02.html":
  191. {
  192. qs.setMemoState(0);
  193. qs.setMemoStateEx(1, 0);
  194. htmltext = event;
  195. break;
  196. }
  197. case "31149-03.html":
  198. case "31149-04.html":
  199. case "31149-05.html":
  200. case "31149-06.html":
  201. case "31149-07.html":
  202. case "31149-08.html":
  203. case "31149-09.html":
  204. case "31149-10.html":
  205. case "31149-11.html":
  206. case "31149-12.html":
  207. case "31149-13.html":
  208. case "31149-14.html":
  209. case "31149-15.html":
  210. case "31149-16.html":
  211. case "31149-19.html":
  212. case "31149-20.html":
  213. case "31149-21.html":
  214. case "31149-22.html":
  215. case "31149-23.html":
  216. case "31149-24.html":
  217. {
  218. final int memoState = HTML_TO_MEMO_STATE.get(event);
  219. if (hasItem(player, MEMO_STATE_TO_ITEM.get(memoState)))
  220. {
  221. // If the player has the chosen item (ingredient or catalyst), we save it (for the catalyst or the reward)
  222. qs.setMemoState(qs.getMemoState() + memoState);
  223. htmltext = event;
  224. playSound(player, QuestSound.SKILLSOUND_LIQUID_MIX);
  225. }
  226. else
  227. {
  228. // If the player has not the chosen catalyst, we take the ingredient previously saved (if not null)
  229. takeItem(player, MEMO_STATE_TO_ITEM.get(qs.getMemoState()));
  230. if (event.equals("31149-19.html"))
  231. {
  232. htmltext = "31149-25.html";
  233. }
  234. else
  235. {
  236. htmltext = "31149-17.html";
  237. }
  238. }
  239. break;
  240. }
  241. case "31149-26.html":
  242. {
  243. if (qs.isMemoState(1324))
  244. {
  245. htmltext = "31149-26a.html";
  246. }
  247. else
  248. {
  249. htmltext = event;
  250. }
  251. break;
  252. }
  253. case "31149-27.html":
  254. {
  255. qs.setMemoStateEx(1, 1); // Temperature Salamander
  256. htmltext = event;
  257. break;
  258. }
  259. case "31149-28a.html":
  260. {
  261. if (getRandom(100) < 33)
  262. {
  263. qs.setMemoStateEx(1, 3); // Temperature Ifrit
  264. }
  265. else
  266. {
  267. qs.setMemoStateEx(1, 0);
  268. }
  269. htmltext = event;
  270. break;
  271. }
  272. case "31149-29a.html":
  273. {
  274. if (getRandom(100) < 20)
  275. {
  276. qs.setMemoStateEx(1, 5); // Temperature Phoenix
  277. }
  278. else
  279. {
  280. qs.setMemoStateEx(1, 0);
  281. }
  282. htmltext = event;
  283. break;
  284. }
  285. case "mixitems":
  286. {
  287. final int memoState = qs.getMemoState();
  288. final ItemHolder item1 = MEMO_STATE_TO_ITEM.get(memoState % 100);
  289. final ItemHolder item2 = MEMO_STATE_TO_ITEM.get((memoState / 100) * 100);
  290. final Entry reward = MEMO_STATE_TO_REWARD.get(memoState);
  291. final QuestState q235 = player.getQuestState(Q00235_MimirsElixir.class.getSimpleName());
  292. if ((reward == null) || qs.isMemoStateEx(1, 0))
  293. {
  294. takeItem(player, item1);
  295. takeItem(player, item2);
  296. htmltext = (reward == null) ? "31149-44.html" : "31149-45.html";
  297. playSound(player, QuestSound.SKILLSOUND_LIQUID_FAIL);
  298. }
  299. else if ((memoState != 1324) || ((memoState == 1324) && (q235 != null) && q235.isStarted() && !hasQuestItems(player, reward.getItem())))
  300. {
  301. if ((item1 != null) && (item2 != null) && hasItem(player, item1) && hasItem(player, item2))
  302. {
  303. takeItem(player, item1);
  304. takeItem(player, item2);
  305. giveItems(player, reward.getItem(), (memoState == 1324) ? 1 : qs.getMemoStateEx(1));
  306. qs.setMemoState(0);
  307. qs.setMemoStateEx(1, 0);
  308. htmltext = reward.getHtml();
  309. playSound(player, QuestSound.SKILLSOUND_LIQUID_SUCCESS);
  310. }
  311. else
  312. {
  313. htmltext = "31149-44.html";
  314. playSound(player, QuestSound.SKILLSOUND_LIQUID_FAIL);
  315. }
  316. }
  317. else
  318. {
  319. htmltext = "31149-44.html";
  320. }
  321. break;
  322. }
  323. }
  324. return htmltext;
  325. }
  326. @Override
  327. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  328. {
  329. final QuestState qs = getRandomPartyMemberState(killer, -1, 3, npc);
  330. if (qs != null)
  331. {
  332. switch (npc.getId())
  333. {
  334. case HALLATE_GUARDIAN:
  335. {
  336. final int chance = getRandom(1000);
  337. if (chance < 766)
  338. {
  339. giveItemRandomly(qs.getPlayer(), npc, DEMONS_BLOOD, 3, 0, 1, true);
  340. }
  341. else if (chance < 876)
  342. {
  343. giveItemRandomly(qs.getPlayer(), npc, MOONSTONE_SHARD, 1, 0, 1, true);
  344. }
  345. break;
  346. }
  347. case HALLATE_MAID:
  348. {
  349. final int chance = getRandom(100);
  350. if (chance < 45)
  351. {
  352. giveItemRandomly(qs.getPlayer(), npc, REAGENT_POUNCH1, 1, 0, 1, true);
  353. }
  354. else if (chance < 65)
  355. {
  356. giveItemRandomly(qs.getPlayer(), npc, VOLCANIC_ASH, 1, 0, 1, true);
  357. }
  358. break;
  359. }
  360. case HAMES_ORC_SHAMAN:
  361. {
  362. if (getRandom(1000) < 616)
  363. {
  364. giveItemRandomly(qs.getPlayer(), npc, REAGENT_POUNCH3, 1, 0, 1, true);
  365. }
  366. break;
  367. }
  368. case LAVA_WYRM:
  369. {
  370. final int chance = getRandom(1000);
  371. if (chance < 666)
  372. {
  373. giveItemRandomly(qs.getPlayer(), npc, WYRM_BLOOD, 1, 0, 1, true);
  374. }
  375. else if (chance < 989)
  376. {
  377. giveItemRandomly(qs.getPlayer(), npc, LAVA_STONE, 1, 0, 1, true);
  378. }
  379. break;
  380. }
  381. case CRENDION:
  382. {
  383. if (getRandom(1000) < 618)
  384. {
  385. giveItemRandomly(qs.getPlayer(), npc, ROTTEN_BONE, 1, 0, 1, true);
  386. }
  387. else
  388. {
  389. giveItemRandomly(qs.getPlayer(), npc, QUICKSILVER, 1, 0, 1, true);
  390. }
  391. break;
  392. }
  393. case PLATINUM_GUARDIAN_SHAMAN:
  394. {
  395. if (getRandom(1000) < 444)
  396. {
  397. giveItemRandomly(qs.getPlayer(), npc, REAGENT_BOX, 1, 0, 1, true);
  398. }
  399. break;
  400. }
  401. case PLATINUM_TRIBE_SHAMAN:
  402. {
  403. if (getRandom(1000) < 658)
  404. {
  405. giveItemRandomly(qs.getPlayer(), npc, REAGENT_POUNCH2, 1, 0, 1, true);
  406. }
  407. else
  408. {
  409. giveItemRandomly(qs.getPlayer(), npc, QUICKSILVER, 2, 0, 1, true);
  410. }
  411. break;
  412. }
  413. }
  414. }
  415. return super.onKill(npc, killer, isSummon);
  416. }
  417. @Override
  418. public String onTalk(L2Npc npc, L2PcInstance talker)
  419. {
  420. final QuestState qs = getQuestState(talker, true);
  421. String htmltext = getNoQuestMsg(talker);
  422. if (qs.isCreated())
  423. {
  424. if (talker.getLevel() < MIN_LVL)
  425. {
  426. htmltext = "30166-01.html";
  427. }
  428. else
  429. {
  430. htmltext = "30166-02.htm";
  431. }
  432. }
  433. else if (qs.isStarted())
  434. {
  435. if (npc.getId() == WESLEY)
  436. {
  437. htmltext = "30166-05.html";
  438. }
  439. else
  440. {
  441. htmltext = "31149-01.html";
  442. }
  443. }
  444. return htmltext;
  445. }
  446. private static final class Entry
  447. {
  448. private final int item;
  449. private final String html;
  450. public Entry(int item, String html)
  451. {
  452. this.item = item;
  453. this.html = html;
  454. }
  455. public int getItem()
  456. {
  457. return item;
  458. }
  459. public String getHtml()
  460. {
  461. return html;
  462. }
  463. }
  464. }