Q00031_SecretBuriedInTheSwamp.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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.Q00031_SecretBuriedInTheSwamp;
  20. import java.util.Arrays;
  21. import java.util.List;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.quest.Quest;
  25. import com.l2jserver.gameserver.model.quest.QuestState;
  26. import com.l2jserver.gameserver.model.quest.State;
  27. /**
  28. * Secret Buried in the Swamp (31)
  29. * @author janiko
  30. */
  31. public final class Q00031_SecretBuriedInTheSwamp extends Quest
  32. {
  33. // NPCs
  34. private static final int ABERCROMBIE = 31555;
  35. private static final int FORGOTTEN_MONUMENT_1 = 31661;
  36. private static final int FORGOTTEN_MONUMENT_2 = 31662;
  37. private static final int FORGOTTEN_MONUMENT_3 = 31663;
  38. private static final int FORGOTTEN_MONUMENT_4 = 31664;
  39. private static final int CORPSE_OF_DWARF = 31665;
  40. // Items
  41. private static final int KRORINS_JOURNAL = 7252;
  42. // Misc
  43. private static final int MIN_LVL = 66;
  44. // Monuments
  45. private static final List<Integer> MONUMENTS = Arrays.asList(FORGOTTEN_MONUMENT_1, FORGOTTEN_MONUMENT_2, FORGOTTEN_MONUMENT_3, FORGOTTEN_MONUMENT_4);
  46. public Q00031_SecretBuriedInTheSwamp()
  47. {
  48. super(31, Q00031_SecretBuriedInTheSwamp.class.getSimpleName(), "Secret Buried in the Swamp");
  49. addStartNpc(ABERCROMBIE);
  50. addTalkId(ABERCROMBIE, CORPSE_OF_DWARF);
  51. addTalkId(MONUMENTS);
  52. registerQuestItems(KRORINS_JOURNAL);
  53. }
  54. @Override
  55. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  56. {
  57. final QuestState st = getQuestState(player, false);
  58. String htmltext = null;
  59. if (st == null)
  60. {
  61. return htmltext;
  62. }
  63. switch (event)
  64. {
  65. case "31555-02.html":
  66. {
  67. if (st.isCreated())
  68. {
  69. st.startQuest();
  70. htmltext = event;
  71. }
  72. break;
  73. }
  74. case "31665-02.html":
  75. {
  76. if (st.isCond(1))
  77. {
  78. st.setCond(2, true);
  79. st.giveItems(KRORINS_JOURNAL, 1);
  80. htmltext = event;
  81. }
  82. break;
  83. }
  84. case "31555-05.html":
  85. {
  86. if (st.isCond(2) && st.hasQuestItems(KRORINS_JOURNAL))
  87. {
  88. st.takeItems(KRORINS_JOURNAL, -1);
  89. st.setCond(3, true);
  90. htmltext = event;
  91. }
  92. break;
  93. }
  94. case "31661-02.html":
  95. case "31662-02.html":
  96. case "31663-02.html":
  97. case "31664-02.html":
  98. {
  99. if (MONUMENTS.contains(npc.getId()) && st.isCond(MONUMENTS.indexOf(npc.getId()) + 3))
  100. {
  101. st.setCond(st.getCond() + 1, true);
  102. htmltext = event;
  103. }
  104. break;
  105. }
  106. case "31555-08.html":
  107. {
  108. if (st.isCond(7))
  109. {
  110. st.addExpAndSp(490000, 45880);
  111. st.giveAdena(120000, true);
  112. st.exitQuest(false, true);
  113. htmltext = event;
  114. }
  115. break;
  116. }
  117. }
  118. return htmltext;
  119. }
  120. @Override
  121. public String onTalk(L2Npc npc, L2PcInstance player)
  122. {
  123. final QuestState st = getQuestState(player, true);
  124. String htmltext = getNoQuestMsg(player);
  125. if (st == null)
  126. {
  127. return htmltext;
  128. }
  129. switch (npc.getId())
  130. {
  131. case ABERCROMBIE:
  132. {
  133. switch (st.getState())
  134. {
  135. case State.CREATED:
  136. {
  137. htmltext = (player.getLevel() >= MIN_LVL) ? "31555-01.htm" : "31555-03.htm";
  138. break;
  139. }
  140. case State.STARTED:
  141. {
  142. switch (st.getCond())
  143. {
  144. case 1:
  145. {
  146. htmltext = "31555-02.html";
  147. break;
  148. }
  149. case 2:
  150. {
  151. if (st.hasQuestItems(KRORINS_JOURNAL))
  152. {
  153. htmltext = "31555-04.html";
  154. }
  155. break;
  156. }
  157. case 3:
  158. {
  159. htmltext = "31555-06.html";
  160. break;
  161. }
  162. case 7:
  163. {
  164. htmltext = "31555-07.html";
  165. break;
  166. }
  167. }
  168. break;
  169. }
  170. case State.COMPLETED:
  171. {
  172. htmltext = getAlreadyCompletedMsg(player);
  173. break;
  174. }
  175. }
  176. break;
  177. }
  178. case CORPSE_OF_DWARF:
  179. {
  180. switch (st.getCond())
  181. {
  182. case 1:
  183. {
  184. htmltext = "31665-01.html";
  185. break;
  186. }
  187. case 2:
  188. {
  189. htmltext = "31665-03.html";
  190. break;
  191. }
  192. }
  193. break;
  194. }
  195. case FORGOTTEN_MONUMENT_1:
  196. case FORGOTTEN_MONUMENT_2:
  197. case FORGOTTEN_MONUMENT_3:
  198. case FORGOTTEN_MONUMENT_4:
  199. {
  200. final int loc = MONUMENTS.indexOf(npc.getId()) + 3;
  201. if (st.isCond(loc))
  202. {
  203. htmltext = npc.getId() + "-01.html";
  204. }
  205. else if (st.isCond(loc + 1))
  206. {
  207. htmltext = npc.getId() + "-03.html";
  208. }
  209. break;
  210. }
  211. }
  212. return htmltext;
  213. }
  214. }