Q00408_PathOfTheElvenWizard.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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.Q00408_PathOfTheElvenWizard;
  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. * Path Of The Elven Wizard (408)
  30. * @author ivantotov
  31. */
  32. public final class Q00408_PathOfTheElvenWizard extends Quest
  33. {
  34. // NPCs
  35. private static final int ROSSELA = 30414;
  36. private static final int GREENIS = 30157;
  37. private static final int THALIA = 30371;
  38. private static final int NORTHWIND = 30423;
  39. // Items
  40. private static final int ROSELLAS_LETTER = 1218;
  41. private static final int RED_DOWN = 1219;
  42. private static final int MAGICAL_POWERS_RUBY = 1220;
  43. private static final int PURE_AQUAMARINE = 1221;
  44. private static final int APPETIZING_APPLE = 1222;
  45. private static final int GOLD_LEAVES = 1223;
  46. private static final int IMMORTAL_LOVE = 1224;
  47. private static final int AMETHYST = 1225;
  48. private static final int NOBILITY_AMETHYST = 1226;
  49. private static final int FERTILITY_PERIDOT = 1229;
  50. private static final int GREENISS_CHARM = 1272;
  51. private static final int SAP_OF_THE_MOTHER_TREE = 1273;
  52. private static final int LUCKY_POTPOURRI = 1274;
  53. // Reward
  54. private static final int ETERNITY_DIAMOND = 1230;
  55. // Monster
  56. private static final int DRYAD_ELDER = 20019;
  57. private static final int SUKAR_WERERAT_LEADER = 20047;
  58. private static final int PINCER_SPIDER = 20466;
  59. // Misc
  60. private static final int MIN_LEVEL = 18;
  61. public Q00408_PathOfTheElvenWizard()
  62. {
  63. super(408, Q00408_PathOfTheElvenWizard.class.getSimpleName(), "Path Of The Elven Wizard");
  64. addStartNpc(ROSSELA);
  65. addTalkId(ROSSELA, GREENIS, THALIA, NORTHWIND);
  66. addKillId(DRYAD_ELDER, SUKAR_WERERAT_LEADER, PINCER_SPIDER);
  67. registerQuestItems(ROSELLAS_LETTER, RED_DOWN, MAGICAL_POWERS_RUBY, PURE_AQUAMARINE, APPETIZING_APPLE, GOLD_LEAVES, IMMORTAL_LOVE, AMETHYST, NOBILITY_AMETHYST, FERTILITY_PERIDOT, GREENISS_CHARM, SAP_OF_THE_MOTHER_TREE, LUCKY_POTPOURRI);
  68. }
  69. @Override
  70. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  71. {
  72. final QuestState qs = getQuestState(player, false);
  73. if (qs == null)
  74. {
  75. return null;
  76. }
  77. String htmltext = null;
  78. switch (event)
  79. {
  80. case "ACCEPT":
  81. {
  82. if (player.getClassId() != ClassId.elvenMage)
  83. {
  84. if (player.getClassId() == ClassId.elvenWizard)
  85. {
  86. htmltext = "30414-02a.htm";
  87. }
  88. else
  89. {
  90. htmltext = "30414-03.htm";
  91. }
  92. }
  93. else if (player.getLevel() < MIN_LEVEL)
  94. {
  95. htmltext = "30414-04.htm";
  96. }
  97. else if (hasQuestItems(player, ETERNITY_DIAMOND))
  98. {
  99. htmltext = "30414-05.htm";
  100. }
  101. else
  102. {
  103. if (!hasQuestItems(player, FERTILITY_PERIDOT))
  104. {
  105. giveItems(player, FERTILITY_PERIDOT, 1);
  106. }
  107. qs.startQuest();
  108. htmltext = "30414-06.htm";
  109. }
  110. break;
  111. }
  112. case "30414-02.htm":
  113. {
  114. htmltext = event;
  115. break;
  116. }
  117. case "30414-10.html":
  118. {
  119. if (hasQuestItems(player, MAGICAL_POWERS_RUBY))
  120. {
  121. htmltext = event;
  122. }
  123. else if (!hasQuestItems(player, MAGICAL_POWERS_RUBY) && hasQuestItems(player, FERTILITY_PERIDOT))
  124. {
  125. if (!hasQuestItems(player, ROSELLAS_LETTER))
  126. {
  127. giveItems(player, ROSELLAS_LETTER, 1);
  128. }
  129. htmltext = "30414-07.html";
  130. }
  131. break;
  132. }
  133. case "30414-12.html":
  134. {
  135. if (hasQuestItems(player, PURE_AQUAMARINE))
  136. {
  137. htmltext = event;
  138. }
  139. else if (!hasQuestItems(player, PURE_AQUAMARINE) && hasQuestItems(player, FERTILITY_PERIDOT))
  140. {
  141. if (!hasQuestItems(player, APPETIZING_APPLE))
  142. {
  143. giveItems(player, APPETIZING_APPLE, 1);
  144. }
  145. htmltext = "30414-13.html";
  146. }
  147. break;
  148. }
  149. case "30414-16.html":
  150. {
  151. if (hasQuestItems(player, NOBILITY_AMETHYST))
  152. {
  153. htmltext = event;
  154. }
  155. else if (!hasQuestItems(player, NOBILITY_AMETHYST) && hasQuestItems(player, FERTILITY_PERIDOT))
  156. {
  157. if (!hasQuestItems(player, IMMORTAL_LOVE))
  158. {
  159. giveItems(player, IMMORTAL_LOVE, 1);
  160. }
  161. htmltext = "30414-17.html";
  162. }
  163. break;
  164. }
  165. case "30157-02.html":
  166. {
  167. if (hasQuestItems(player, ROSELLAS_LETTER))
  168. {
  169. takeItems(player, ROSELLAS_LETTER, 1);
  170. if (!hasQuestItems(player, GREENISS_CHARM))
  171. {
  172. giveItems(player, GREENISS_CHARM, 1);
  173. }
  174. }
  175. htmltext = event;
  176. break;
  177. }
  178. case "30371-02.html":
  179. {
  180. if (hasQuestItems(player, APPETIZING_APPLE))
  181. {
  182. takeItems(player, APPETIZING_APPLE, 1);
  183. if (!hasQuestItems(player, SAP_OF_THE_MOTHER_TREE))
  184. {
  185. giveItems(player, SAP_OF_THE_MOTHER_TREE, 1);
  186. }
  187. }
  188. htmltext = event;
  189. break;
  190. }
  191. }
  192. return htmltext;
  193. }
  194. @Override
  195. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  196. {
  197. final QuestState qs = getQuestState(killer, false);
  198. if ((qs != null) && qs.isStarted() && Util.checkIfInRange(1500, npc, killer, true))
  199. {
  200. switch (npc.getId())
  201. {
  202. case DRYAD_ELDER:
  203. {
  204. if (hasQuestItems(killer, SAP_OF_THE_MOTHER_TREE) && (getQuestItemsCount(killer, GOLD_LEAVES) < 5) && (getRandom(100) < 40))
  205. {
  206. giveItems(killer, GOLD_LEAVES, 1);
  207. if (getQuestItemsCount(killer, GOLD_LEAVES) == 5)
  208. {
  209. playSound(killer, QuestSound.ITEMSOUND_QUEST_MIDDLE);
  210. }
  211. else
  212. {
  213. playSound(killer, QuestSound.ITEMSOUND_QUEST_ITEMGET);
  214. }
  215. }
  216. break;
  217. }
  218. case SUKAR_WERERAT_LEADER:
  219. {
  220. if (hasQuestItems(killer, LUCKY_POTPOURRI) && (getQuestItemsCount(killer, AMETHYST) < 2) && (getRandom(100) < 40))
  221. {
  222. giveItems(killer, AMETHYST, 1);
  223. if (getQuestItemsCount(killer, AMETHYST) == 2)
  224. {
  225. playSound(killer, QuestSound.ITEMSOUND_QUEST_MIDDLE);
  226. }
  227. else
  228. {
  229. playSound(killer, QuestSound.ITEMSOUND_QUEST_ITEMGET);
  230. }
  231. }
  232. break;
  233. }
  234. case PINCER_SPIDER:
  235. {
  236. if (hasQuestItems(killer, GREENISS_CHARM) && (getQuestItemsCount(killer, RED_DOWN) < 5) && (getRandom(100) < 70))
  237. {
  238. giveItems(killer, RED_DOWN, 1);
  239. if (getQuestItemsCount(killer, RED_DOWN) == 5)
  240. {
  241. playSound(killer, QuestSound.ITEMSOUND_QUEST_MIDDLE);
  242. }
  243. else
  244. {
  245. playSound(killer, QuestSound.ITEMSOUND_QUEST_ITEMGET);
  246. }
  247. }
  248. break;
  249. }
  250. }
  251. }
  252. return super.onKill(npc, killer, isSummon);
  253. }
  254. @Override
  255. public String onTalk(L2Npc npc, L2PcInstance player)
  256. {
  257. final QuestState qs = getQuestState(player, true);
  258. String htmltext = getNoQuestMsg(player);
  259. if (qs.isCreated() || qs.isCompleted())
  260. {
  261. if (npc.getId() == ROSSELA)
  262. {
  263. htmltext = "30414-01.htm";
  264. }
  265. }
  266. else if (qs.isStarted())
  267. {
  268. switch (npc.getId())
  269. {
  270. case ROSSELA:
  271. {
  272. if (!hasAtLeastOneQuestItem(player, ROSELLAS_LETTER, APPETIZING_APPLE, IMMORTAL_LOVE, GREENISS_CHARM, SAP_OF_THE_MOTHER_TREE, LUCKY_POTPOURRI) && hasQuestItems(player, FERTILITY_PERIDOT) && !hasQuestItems(player, MAGICAL_POWERS_RUBY, NOBILITY_AMETHYST, PURE_AQUAMARINE))
  273. {
  274. htmltext = "30414-11.html";
  275. }
  276. else if (hasQuestItems(player, ROSELLAS_LETTER))
  277. {
  278. htmltext = "30414-08.html";
  279. }
  280. else if (hasQuestItems(player, GREENISS_CHARM))
  281. {
  282. if (getQuestItemsCount(player, RED_DOWN) < 5)
  283. {
  284. htmltext = "30414-09.html";
  285. }
  286. else
  287. {
  288. htmltext = "30414-21.html";
  289. }
  290. }
  291. else if (hasQuestItems(player, APPETIZING_APPLE))
  292. {
  293. htmltext = "30414-14.html";
  294. }
  295. else if (hasQuestItems(player, SAP_OF_THE_MOTHER_TREE))
  296. {
  297. if (getQuestItemsCount(player, GOLD_LEAVES) < 5)
  298. {
  299. htmltext = "30414-15.html";
  300. }
  301. else
  302. {
  303. htmltext = "30414-22.html";
  304. }
  305. }
  306. else if (hasQuestItems(player, IMMORTAL_LOVE))
  307. {
  308. htmltext = "30414-18.html";
  309. }
  310. else if (hasQuestItems(player, LUCKY_POTPOURRI))
  311. {
  312. if (getQuestItemsCount(player, AMETHYST) < 2)
  313. {
  314. htmltext = "30414-19.html";
  315. }
  316. else
  317. {
  318. htmltext = "30414-23.html";
  319. }
  320. }
  321. else
  322. {
  323. if (!hasAtLeastOneQuestItem(player, ROSELLAS_LETTER, APPETIZING_APPLE, IMMORTAL_LOVE, GREENISS_CHARM, SAP_OF_THE_MOTHER_TREE, LUCKY_POTPOURRI) && hasQuestItems(player, FERTILITY_PERIDOT, MAGICAL_POWERS_RUBY, NOBILITY_AMETHYST, PURE_AQUAMARINE))
  324. {
  325. giveAdena(player, 163800, true);
  326. if (!hasQuestItems(player, ETERNITY_DIAMOND))
  327. {
  328. giveItems(player, ETERNITY_DIAMOND, 1);
  329. }
  330. final int level = player.getLevel();
  331. if (level >= 20)
  332. {
  333. addExpAndSp(player, 320534, 22532);
  334. }
  335. else if (level == 19)
  336. {
  337. addExpAndSp(player, 456128, 29230);
  338. }
  339. else
  340. {
  341. addExpAndSp(player, 591724, 35928);
  342. }
  343. qs.exitQuest(false, true);
  344. player.sendPacket(new SocialAction(player.getObjectId(), 3));
  345. qs.saveGlobalQuestVar("1ClassQuestFinished", "1");
  346. htmltext = "30414-20.html";
  347. }
  348. }
  349. break;
  350. }
  351. case GREENIS:
  352. {
  353. if (hasQuestItems(player, ROSELLAS_LETTER))
  354. {
  355. htmltext = "30157-01.html";
  356. }
  357. else if (hasQuestItems(player, GREENISS_CHARM))
  358. {
  359. if (getQuestItemsCount(player, RED_DOWN) < 5)
  360. {
  361. htmltext = "30157-03.html";
  362. }
  363. else
  364. {
  365. takeItems(player, RED_DOWN, -1);
  366. if (!hasQuestItems(player, MAGICAL_POWERS_RUBY))
  367. {
  368. giveItems(player, MAGICAL_POWERS_RUBY, 1);
  369. }
  370. takeItems(player, GREENISS_CHARM, 1);
  371. htmltext = "30157-04.html";
  372. }
  373. }
  374. break;
  375. }
  376. case THALIA:
  377. {
  378. if (hasQuestItems(player, APPETIZING_APPLE))
  379. {
  380. htmltext = "30371-01.html";
  381. }
  382. else if (hasQuestItems(player, SAP_OF_THE_MOTHER_TREE))
  383. {
  384. if (getQuestItemsCount(player, GOLD_LEAVES) < 5)
  385. {
  386. htmltext = "30371-03.html";
  387. }
  388. else
  389. {
  390. if (!hasQuestItems(player, PURE_AQUAMARINE))
  391. {
  392. giveItems(player, PURE_AQUAMARINE, 1);
  393. }
  394. takeItems(player, GOLD_LEAVES, -1);
  395. takeItems(player, SAP_OF_THE_MOTHER_TREE, 1);
  396. htmltext = "30371-04.html";
  397. }
  398. }
  399. break;
  400. }
  401. case NORTHWIND:
  402. {
  403. if (hasQuestItems(player, IMMORTAL_LOVE))
  404. {
  405. takeItems(player, IMMORTAL_LOVE, 1);
  406. if (!hasQuestItems(player, LUCKY_POTPOURRI))
  407. {
  408. giveItems(player, LUCKY_POTPOURRI, 1);
  409. }
  410. htmltext = "30423-01.html";
  411. }
  412. else if (hasQuestItems(player, LUCKY_POTPOURRI))
  413. {
  414. if (getQuestItemsCount(player, AMETHYST) < 2)
  415. {
  416. htmltext = "30423-02.html";
  417. }
  418. else
  419. {
  420. takeItems(player, AMETHYST, -1);
  421. if (!hasQuestItems(player, NOBILITY_AMETHYST))
  422. {
  423. giveItems(player, NOBILITY_AMETHYST, 1);
  424. }
  425. takeItems(player, LUCKY_POTPOURRI, 1);
  426. htmltext = "30423-03.html";
  427. }
  428. }
  429. break;
  430. }
  431. }
  432. }
  433. return htmltext;
  434. }
  435. }