Q00405_PathOfTheCleric.java 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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.Q00405_PathOfTheCleric;
  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 Cleric (405)
  30. * @author ivantotov
  31. */
  32. public final class Q00405_PathOfTheCleric extends Quest
  33. {
  34. // NPCs
  35. private static final int GALLINT = 30017;
  36. private static final int ZIGAUNT = 30022;
  37. private static final int VIVYAN = 30030;
  38. private static final int TRADER_SIMPLON = 30253;
  39. private static final int GUARD_PRAGA = 30333;
  40. private static final int LIONEL = 30408;
  41. // Items
  42. private static final int LETTER_OF_ORDER_1ST = 1191;
  43. private static final int LETTER_OF_ORDER_2ND = 1192;
  44. private static final int LIONELS_BOOK = 1193;
  45. private static final int BOOK_OF_VIVYAN = 1194;
  46. private static final int BOOK_OF_SIMPLON = 1195;
  47. private static final int BOOK_OF_PRAGA = 1196;
  48. private static final int CERTIFICATE_OF_GALLINT = 1197;
  49. private static final int PENDANT_OF_MOTHER = 1198;
  50. private static final int NECKLACE_OF_MOTHER = 1199;
  51. private static final int LEMONIELLS_COVENANT = 1200;
  52. // Reward
  53. private static final int MARK_OF_FAITH = 1201;
  54. // Monster
  55. private static final int RUIN_ZOMBIE = 20026;
  56. private static final int RUIN_ZOMBIE_LEADER = 20029;
  57. // Misc
  58. private static final int MIN_LEVEL = 18;
  59. public Q00405_PathOfTheCleric()
  60. {
  61. super(405, Q00405_PathOfTheCleric.class.getSimpleName(), "Path Of The Cleric");
  62. addStartNpc(ZIGAUNT);
  63. addTalkId(ZIGAUNT, GALLINT, VIVYAN, TRADER_SIMPLON, GUARD_PRAGA, LIONEL);
  64. addKillId(RUIN_ZOMBIE, RUIN_ZOMBIE_LEADER);
  65. registerQuestItems(LETTER_OF_ORDER_1ST, LETTER_OF_ORDER_2ND, LIONELS_BOOK, BOOK_OF_VIVYAN, BOOK_OF_SIMPLON, BOOK_OF_PRAGA, CERTIFICATE_OF_GALLINT, PENDANT_OF_MOTHER, NECKLACE_OF_MOTHER, LEMONIELLS_COVENANT);
  66. }
  67. @Override
  68. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  69. {
  70. final QuestState qs = getQuestState(player, false);
  71. if (qs == null)
  72. {
  73. return null;
  74. }
  75. String htmltext = null;
  76. switch (event)
  77. {
  78. case "ACCEPT":
  79. {
  80. if (player.getClassId() == ClassId.mage)
  81. {
  82. if (player.getLevel() >= MIN_LEVEL)
  83. {
  84. if (hasQuestItems(player, MARK_OF_FAITH))
  85. {
  86. htmltext = "30022-04.htm";
  87. }
  88. else
  89. {
  90. qs.startQuest();
  91. giveItems(player, LETTER_OF_ORDER_1ST, 1);
  92. htmltext = "30022-05.htm";
  93. }
  94. }
  95. else
  96. {
  97. htmltext = "30022-03.htm";
  98. }
  99. }
  100. else if (player.getClassId() == ClassId.cleric)
  101. {
  102. htmltext = "30022-02a.htm";
  103. }
  104. else
  105. {
  106. htmltext = "30022-02.htm";
  107. }
  108. break;
  109. }
  110. }
  111. return htmltext;
  112. }
  113. @Override
  114. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  115. {
  116. final QuestState qs = getQuestState(killer, false);
  117. if ((qs != null) && qs.isStarted() && Util.checkIfInRange(1500, npc, killer, true))
  118. {
  119. if (hasQuestItems(killer, NECKLACE_OF_MOTHER) && !hasQuestItems(killer, PENDANT_OF_MOTHER))
  120. {
  121. giveItems(killer, PENDANT_OF_MOTHER, 1);
  122. playSound(qs.getPlayer(), QuestSound.ITEMSOUND_QUEST_MIDDLE);
  123. }
  124. }
  125. return super.onKill(npc, killer, isSummon);
  126. }
  127. @Override
  128. public String onTalk(L2Npc npc, L2PcInstance player)
  129. {
  130. final QuestState qs = getQuestState(player, true);
  131. String htmltext = getNoQuestMsg(player);
  132. if (qs.isCreated() || qs.isCompleted())
  133. {
  134. if (npc.getId() == ZIGAUNT)
  135. {
  136. if (!hasQuestItems(player, MARK_OF_FAITH))
  137. {
  138. htmltext = "30022-01.htm";
  139. }
  140. else
  141. {
  142. htmltext = "30022-04.htm";
  143. }
  144. }
  145. }
  146. else if (qs.isStarted())
  147. {
  148. switch (npc.getId())
  149. {
  150. case ZIGAUNT:
  151. {
  152. if (!hasQuestItems(player, LEMONIELLS_COVENANT) && hasQuestItems(player, LETTER_OF_ORDER_2ND))
  153. {
  154. htmltext = "30022-07.html";
  155. }
  156. else if (hasQuestItems(player, LETTER_OF_ORDER_2ND, LEMONIELLS_COVENANT))
  157. {
  158. giveAdena(player, 163800, true);
  159. takeItems(player, LETTER_OF_ORDER_2ND, 1);
  160. takeItems(player, LEMONIELLS_COVENANT, 1);
  161. giveItems(player, MARK_OF_FAITH, 1);
  162. final int level = player.getLevel();
  163. if (level >= 20)
  164. {
  165. addExpAndSp(player, 320534, 23152);
  166. }
  167. else if (level == 19)
  168. {
  169. addExpAndSp(player, 456128, 28630);
  170. }
  171. else
  172. {
  173. addExpAndSp(player, 591724, 35328);
  174. }
  175. qs.exitQuest(false, true);
  176. player.sendPacket(new SocialAction(player.getObjectId(), 3));
  177. qs.saveGlobalQuestVar("1ClassQuestFinished", "1");
  178. htmltext = "30022-09.html";
  179. }
  180. else if (hasQuestItems(player, LETTER_OF_ORDER_1ST))
  181. {
  182. if (hasQuestItems(player, BOOK_OF_VIVYAN, BOOK_OF_SIMPLON, BOOK_OF_PRAGA))
  183. {
  184. takeItems(player, LETTER_OF_ORDER_1ST, 1);
  185. giveItems(player, LETTER_OF_ORDER_2ND, 1);
  186. takeItems(player, BOOK_OF_VIVYAN, 1);
  187. takeItems(player, BOOK_OF_SIMPLON, -1);
  188. takeItems(player, BOOK_OF_PRAGA, 1);
  189. qs.setCond(3, true);
  190. htmltext = "30022-08.html";
  191. }
  192. else
  193. {
  194. htmltext = "30022-06.html";
  195. }
  196. }
  197. break;
  198. }
  199. case GALLINT:
  200. {
  201. if (!hasQuestItems(player, LEMONIELLS_COVENANT) && hasQuestItems(player, LETTER_OF_ORDER_2ND))
  202. {
  203. if (!hasQuestItems(player, CERTIFICATE_OF_GALLINT) && hasQuestItems(player, LIONELS_BOOK))
  204. {
  205. takeItems(player, LIONELS_BOOK, 1);
  206. giveItems(player, CERTIFICATE_OF_GALLINT, 1);
  207. qs.setCond(5, true);
  208. htmltext = "30017-01.html";
  209. }
  210. else
  211. {
  212. htmltext = "30017-02.html";
  213. }
  214. }
  215. break;
  216. }
  217. case VIVYAN:
  218. {
  219. if (hasQuestItems(player, LETTER_OF_ORDER_1ST))
  220. {
  221. if (!hasQuestItems(player, BOOK_OF_VIVYAN))
  222. {
  223. giveItems(player, BOOK_OF_VIVYAN, 1);
  224. if ((getQuestItemsCount(player, BOOK_OF_SIMPLON) >= 3) && (getQuestItemsCount(player, BOOK_OF_VIVYAN) >= 0) && (getQuestItemsCount(player, BOOK_OF_PRAGA) >= 1))
  225. {
  226. qs.setCond(2, true);
  227. }
  228. htmltext = "30030-01.html";
  229. }
  230. else
  231. {
  232. htmltext = "30030-02.html";
  233. }
  234. }
  235. break;
  236. }
  237. case TRADER_SIMPLON:
  238. {
  239. if (hasQuestItems(player, LETTER_OF_ORDER_1ST))
  240. {
  241. if (!hasQuestItems(player, BOOK_OF_SIMPLON))
  242. {
  243. giveItems(player, BOOK_OF_SIMPLON, 3);
  244. if ((getQuestItemsCount(player, BOOK_OF_SIMPLON) >= 0) && (getQuestItemsCount(player, BOOK_OF_VIVYAN) >= 1) && (getQuestItemsCount(player, BOOK_OF_PRAGA) >= 1))
  245. {
  246. qs.setCond(2, true);
  247. }
  248. htmltext = "30253-01.html";
  249. }
  250. else
  251. {
  252. htmltext = "30253-02.html";
  253. }
  254. }
  255. break;
  256. }
  257. case GUARD_PRAGA:
  258. {
  259. if (hasQuestItems(player, LETTER_OF_ORDER_1ST))
  260. {
  261. if (!hasAtLeastOneQuestItem(player, BOOK_OF_PRAGA, NECKLACE_OF_MOTHER))
  262. {
  263. giveItems(player, NECKLACE_OF_MOTHER, 1);
  264. htmltext = "30333-01.html";
  265. }
  266. else if (!hasAtLeastOneQuestItem(player, BOOK_OF_PRAGA, PENDANT_OF_MOTHER) && hasQuestItems(player, NECKLACE_OF_MOTHER))
  267. {
  268. htmltext = "30333-02.html";
  269. }
  270. else if (!hasQuestItems(player, BOOK_OF_PRAGA) && hasQuestItems(player, NECKLACE_OF_MOTHER, PENDANT_OF_MOTHER))
  271. {
  272. giveItems(player, BOOK_OF_PRAGA, 1);
  273. takeItems(player, PENDANT_OF_MOTHER, 1);
  274. takeItems(player, NECKLACE_OF_MOTHER, 1);
  275. if ((getQuestItemsCount(player, BOOK_OF_SIMPLON) >= 3) && (getQuestItemsCount(player, BOOK_OF_VIVYAN) >= 1) && (getQuestItemsCount(player, BOOK_OF_PRAGA) >= 0))
  276. {
  277. qs.setCond(2, true);
  278. }
  279. htmltext = "30333-03.html";
  280. }
  281. else if (hasQuestItems(player, BOOK_OF_PRAGA))
  282. {
  283. htmltext = "30333-04.html";
  284. }
  285. }
  286. break;
  287. }
  288. case LIONEL:
  289. {
  290. if (!hasQuestItems(player, LETTER_OF_ORDER_2ND))
  291. {
  292. htmltext = "30408-02.html";
  293. }
  294. else if (!hasAtLeastOneQuestItem(player, LIONELS_BOOK, LEMONIELLS_COVENANT, CERTIFICATE_OF_GALLINT) && hasQuestItems(player, LETTER_OF_ORDER_2ND))
  295. {
  296. giveItems(player, LIONELS_BOOK, 1);
  297. qs.setCond(4, true);
  298. htmltext = "30408-01.html";
  299. }
  300. else if (!hasAtLeastOneQuestItem(player, LEMONIELLS_COVENANT, CERTIFICATE_OF_GALLINT) && hasQuestItems(player, LETTER_OF_ORDER_2ND, LIONELS_BOOK))
  301. {
  302. htmltext = "30408-03.html";
  303. }
  304. else if (!hasAtLeastOneQuestItem(player, LIONELS_BOOK, LEMONIELLS_COVENANT) && hasQuestItems(player, LETTER_OF_ORDER_2ND, CERTIFICATE_OF_GALLINT))
  305. {
  306. takeItems(player, CERTIFICATE_OF_GALLINT, 1);
  307. giveItems(player, LEMONIELLS_COVENANT, 1);
  308. qs.setCond(6, true);
  309. htmltext = "30408-04.html";
  310. }
  311. else if (!hasAtLeastOneQuestItem(player, LIONELS_BOOK, CERTIFICATE_OF_GALLINT) && hasQuestItems(player, LETTER_OF_ORDER_2ND, LEMONIELLS_COVENANT))
  312. {
  313. htmltext = "30408-05.html";
  314. }
  315. break;
  316. }
  317. }
  318. }
  319. return htmltext;
  320. }
  321. }