Q00412_PathOfTheDarkWizard.java 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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.Q00412_PathOfTheDarkWizard;
  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 Dark Wizard (412)
  30. * @author ivantotov
  31. */
  32. public final class Q00412_PathOfTheDarkWizard extends Quest
  33. {
  34. // NPCs
  35. private static final int CHARKEREN = 30415;
  36. private static final int ANNIKA = 30418;
  37. private static final int ARKENIA = 30419;
  38. private static final int VARIKA = 30421;
  39. // Items
  40. private static final int SEEDS_OF_ANGER = 1253;
  41. private static final int SEEDS_OF_DESPAIR = 1254;
  42. private static final int SEEDS_OF_HORROR = 1255;
  43. private static final int SEEDS_OF_LUNACY = 1256;
  44. private static final int FAMILYS_REMAINS = 1257;
  45. private static final int KNEE_BONE = 1259;
  46. private static final int HEART_OF_LUNACY = 1260;
  47. private static final int LUCKY_KEY = 1277;
  48. private static final int CANDLE = 1278;
  49. private static final int HUB_SCENT = 1279;
  50. // Reward
  51. private static final int JEWEL_OF_DARKNESS = 1261;
  52. // Monster
  53. private static final int MARSH_ZOMBIE = 20015;
  54. private static final int MISERY_SKELETON = 20022;
  55. private static final int SKELETON_SCOUT = 20045;
  56. private static final int SKELETON_HUNTER = 20517;
  57. private static final int SKELETON_HUNTER_ARCHER = 20518;
  58. // Misc
  59. private static final int MIN_LEVEL = 18;
  60. public Q00412_PathOfTheDarkWizard()
  61. {
  62. super(412, Q00412_PathOfTheDarkWizard.class.getSimpleName(), "Path Of The Dark Wizard");
  63. addStartNpc(VARIKA);
  64. addTalkId(VARIKA, CHARKEREN, ANNIKA, ARKENIA);
  65. addKillId(MARSH_ZOMBIE, MISERY_SKELETON, SKELETON_SCOUT, SKELETON_HUNTER, SKELETON_HUNTER_ARCHER);
  66. registerQuestItems(SEEDS_OF_ANGER, SEEDS_OF_DESPAIR, SEEDS_OF_HORROR, SEEDS_OF_LUNACY, FAMILYS_REMAINS, KNEE_BONE, HEART_OF_LUNACY, LUCKY_KEY, CANDLE, HUB_SCENT);
  67. }
  68. @Override
  69. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  70. {
  71. final QuestState qs = getQuestState(player, false);
  72. if (qs == null)
  73. {
  74. return null;
  75. }
  76. String htmltext = null;
  77. switch (event)
  78. {
  79. case "ACCEPT":
  80. {
  81. if (player.getClassId() == ClassId.darkMage)
  82. {
  83. if (player.getLevel() >= MIN_LEVEL)
  84. {
  85. if (hasQuestItems(player, JEWEL_OF_DARKNESS))
  86. {
  87. htmltext = "30421-04.htm";
  88. }
  89. else
  90. {
  91. qs.startQuest();
  92. giveItems(player, SEEDS_OF_DESPAIR, 1);
  93. htmltext = "30421-05.htm";
  94. }
  95. }
  96. else
  97. {
  98. htmltext = "30421-02.htm";
  99. }
  100. }
  101. else if (player.getClassId() == ClassId.darkWizard)
  102. {
  103. htmltext = "30421-02a.htm";
  104. }
  105. else
  106. {
  107. htmltext = "30421-03.htm";
  108. }
  109. break;
  110. }
  111. case "30421-06.html":
  112. {
  113. if (hasQuestItems(player, SEEDS_OF_ANGER))
  114. {
  115. htmltext = event;
  116. }
  117. else
  118. {
  119. htmltext = "30421-07.html";
  120. }
  121. break;
  122. }
  123. case "30421-09.html":
  124. {
  125. if (hasQuestItems(player, SEEDS_OF_HORROR))
  126. {
  127. htmltext = event;
  128. }
  129. else
  130. {
  131. htmltext = "30421-10.html";
  132. }
  133. break;
  134. }
  135. case "30421-11.html":
  136. {
  137. if (hasQuestItems(player, SEEDS_OF_LUNACY))
  138. {
  139. htmltext = event;
  140. }
  141. else if (!hasQuestItems(player, SEEDS_OF_LUNACY) && hasQuestItems(player, SEEDS_OF_DESPAIR))
  142. {
  143. htmltext = "30421-12.html";
  144. }
  145. break;
  146. }
  147. case "30421-08.html":
  148. case "30415-02.html":
  149. {
  150. htmltext = event;
  151. break;
  152. }
  153. case "30415-03.html":
  154. {
  155. giveItems(player, LUCKY_KEY, 1);
  156. htmltext = event;
  157. break;
  158. }
  159. case "30418-02.html":
  160. {
  161. giveItems(player, CANDLE, 1);
  162. htmltext = event;
  163. break;
  164. }
  165. }
  166. return htmltext;
  167. }
  168. @Override
  169. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  170. {
  171. final QuestState qs = getQuestState(killer, false);
  172. if ((qs != null) && qs.isStarted() && Util.checkIfInRange(1500, npc, killer, true))
  173. {
  174. switch (npc.getId())
  175. {
  176. case MARSH_ZOMBIE:
  177. {
  178. if (hasQuestItems(killer, LUCKY_KEY) && (getQuestItemsCount(killer, FAMILYS_REMAINS) < 3))
  179. {
  180. if (getRandom(2) == 0)
  181. {
  182. giveItems(killer, FAMILYS_REMAINS, 1);
  183. if (getQuestItemsCount(killer, FAMILYS_REMAINS) == 3)
  184. {
  185. playSound(killer, QuestSound.ITEMSOUND_QUEST_MIDDLE);
  186. }
  187. else
  188. {
  189. playSound(killer, QuestSound.ITEMSOUND_QUEST_ITEMGET);
  190. }
  191. }
  192. }
  193. break;
  194. }
  195. case MISERY_SKELETON:
  196. case SKELETON_HUNTER:
  197. case SKELETON_HUNTER_ARCHER:
  198. {
  199. if (hasQuestItems(killer, CANDLE) && (getQuestItemsCount(killer, KNEE_BONE) < 2))
  200. {
  201. if (getRandom(2) == 0)
  202. {
  203. giveItems(killer, KNEE_BONE, 1);
  204. if (getQuestItemsCount(killer, KNEE_BONE) == 2)
  205. {
  206. playSound(killer, QuestSound.ITEMSOUND_QUEST_MIDDLE);
  207. }
  208. else
  209. {
  210. playSound(killer, QuestSound.ITEMSOUND_QUEST_ITEMGET);
  211. }
  212. }
  213. }
  214. break;
  215. }
  216. case SKELETON_SCOUT:
  217. {
  218. if (hasQuestItems(killer, HUB_SCENT) && (getQuestItemsCount(killer, HEART_OF_LUNACY) < 3))
  219. {
  220. if (getRandom(2) == 0)
  221. {
  222. giveItems(killer, HEART_OF_LUNACY, 1);
  223. if (getQuestItemsCount(killer, HEART_OF_LUNACY) == 3)
  224. {
  225. playSound(killer, QuestSound.ITEMSOUND_QUEST_MIDDLE);
  226. }
  227. else
  228. {
  229. playSound(killer, QuestSound.ITEMSOUND_QUEST_ITEMGET);
  230. }
  231. }
  232. }
  233. break;
  234. }
  235. }
  236. }
  237. return super.onKill(npc, killer, isSummon);
  238. }
  239. @Override
  240. public String onTalk(L2Npc npc, L2PcInstance player)
  241. {
  242. final QuestState qs = getQuestState(player, true);
  243. String htmltext = getNoQuestMsg(player);
  244. if (qs.isCreated() || qs.isCompleted())
  245. {
  246. if (npc.getId() == VARIKA)
  247. {
  248. if (!hasQuestItems(player, JEWEL_OF_DARKNESS))
  249. {
  250. htmltext = "30421-01.htm";
  251. }
  252. else
  253. {
  254. htmltext = "30421-04.htm";
  255. }
  256. }
  257. }
  258. else if (qs.isStarted())
  259. {
  260. switch (npc.getId())
  261. {
  262. case VARIKA:
  263. {
  264. if (hasQuestItems(player, SEEDS_OF_DESPAIR, SEEDS_OF_HORROR, SEEDS_OF_LUNACY, SEEDS_OF_ANGER))
  265. {
  266. giveAdena(player, 163800, true);
  267. giveItems(player, JEWEL_OF_DARKNESS, 1);
  268. final int level = player.getLevel();
  269. if (level >= 20)
  270. {
  271. addExpAndSp(player, 320534, 28630);
  272. }
  273. else if (level == 19)
  274. {
  275. addExpAndSp(player, 456128, 28630);
  276. }
  277. else
  278. {
  279. addExpAndSp(player, 591724, 35328);
  280. }
  281. qs.exitQuest(false, true);
  282. player.sendPacket(new SocialAction(player.getObjectId(), 3));
  283. qs.saveGlobalQuestVar("1ClassQuestFinished", "1");
  284. htmltext = "30421-13.html";
  285. }
  286. else if (hasQuestItems(player, SEEDS_OF_DESPAIR))
  287. {
  288. if (!hasAtLeastOneQuestItem(player, FAMILYS_REMAINS, LUCKY_KEY, CANDLE, HUB_SCENT, KNEE_BONE, HEART_OF_LUNACY))
  289. {
  290. htmltext = "30421-14.html";
  291. }
  292. else if (!hasQuestItems(player, SEEDS_OF_ANGER))
  293. {
  294. htmltext = "30421-08.html";
  295. }
  296. else if (!hasQuestItems(player, SEEDS_OF_HORROR))
  297. {
  298. htmltext = "30421-15.html";
  299. }
  300. else if (!hasQuestItems(player, SEEDS_OF_LUNACY))
  301. {
  302. htmltext = "30421-12.html";
  303. }
  304. }
  305. break;
  306. }
  307. case CHARKEREN:
  308. {
  309. if (!hasQuestItems(player, SEEDS_OF_ANGER) && hasQuestItems(player, SEEDS_OF_DESPAIR))
  310. {
  311. if (!hasAtLeastOneQuestItem(player, FAMILYS_REMAINS, LUCKY_KEY))
  312. {
  313. htmltext = "30415-01.html";
  314. }
  315. else if (hasQuestItems(player, LUCKY_KEY) && (getQuestItemsCount(player, FAMILYS_REMAINS) < 3))
  316. {
  317. htmltext = "30415-04.html";
  318. }
  319. else
  320. {
  321. giveItems(player, SEEDS_OF_ANGER, 1);
  322. takeItems(player, FAMILYS_REMAINS, -1);
  323. takeItems(player, LUCKY_KEY, 1);
  324. htmltext = "30415-05.html";
  325. }
  326. }
  327. else
  328. {
  329. htmltext = "30415-06.html";
  330. }
  331. break;
  332. }
  333. case ANNIKA:
  334. {
  335. if (!hasQuestItems(player, SEEDS_OF_HORROR) && hasQuestItems(player, SEEDS_OF_DESPAIR))
  336. {
  337. if (!hasAtLeastOneQuestItem(player, CANDLE, KNEE_BONE))
  338. {
  339. htmltext = "30418-01.html";
  340. }
  341. else if (hasQuestItems(player, CANDLE) && (getQuestItemsCount(player, KNEE_BONE) < 2))
  342. {
  343. htmltext = "30418-03.html";
  344. }
  345. else
  346. {
  347. giveItems(player, SEEDS_OF_HORROR, 1);
  348. takeItems(player, KNEE_BONE, -1);
  349. takeItems(player, CANDLE, 1);
  350. htmltext = "30418-04.html";
  351. }
  352. }
  353. break;
  354. }
  355. case ARKENIA:
  356. {
  357. if (!hasQuestItems(player, SEEDS_OF_LUNACY))
  358. {
  359. if (!hasAtLeastOneQuestItem(player, HUB_SCENT, HEART_OF_LUNACY))
  360. {
  361. giveItems(player, HUB_SCENT, 1);
  362. htmltext = "30419-01.html";
  363. }
  364. else if (hasQuestItems(player, HUB_SCENT) && (getQuestItemsCount(player, HEART_OF_LUNACY) < 3))
  365. {
  366. htmltext = "30419-02.html";
  367. }
  368. else
  369. {
  370. giveItems(player, SEEDS_OF_LUNACY, 1);
  371. takeItems(player, HEART_OF_LUNACY, -1);
  372. takeItems(player, HUB_SCENT, 1);
  373. htmltext = "30419-03.html";
  374. }
  375. }
  376. break;
  377. }
  378. }
  379. }
  380. return htmltext;
  381. }
  382. }