Q00464_Oath.java 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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.Q00464_Oath;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import com.l2jserver.gameserver.enums.QuestType;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  26. import com.l2jserver.gameserver.model.quest.Quest;
  27. import com.l2jserver.gameserver.model.quest.QuestState;
  28. import com.l2jserver.gameserver.model.quest.State;
  29. /**
  30. * Oath (464)
  31. * @author malyelfik
  32. */
  33. public class Q00464_Oath extends Quest
  34. {
  35. // NPCs @formatter:off
  36. private static final int[][] NPC =
  37. {
  38. // NPC id, EXP, SP, Adena
  39. {32596, 0, 0, 0},
  40. {30657, 15449, 17696, 42910},
  41. {30839, 189377, 21692, 52599},
  42. {30899, 249180, 28542, 69210},
  43. {31350, 249180, 28542, 69210},
  44. {30539, 19408, 47062, 169442},
  45. {30297, 24146, 58551, 210806},
  46. {31960, 15449, 17696, 42910},
  47. {31588, 15449, 17696, 42910}
  48. };
  49. // @formatter:on
  50. // Items
  51. private static final int STRONGBOX = 15537;
  52. private static final int BOOK = 15538;
  53. private static final int BOOK2 = 15539;
  54. // Misc
  55. private static final int MIN_LEVEL = 82;
  56. // Monsters
  57. private static final Map<Integer, Integer> MOBS = new HashMap<>();
  58. static
  59. {
  60. MOBS.put(22799, 9);
  61. MOBS.put(22794, 6);
  62. MOBS.put(22800, 10);
  63. MOBS.put(22796, 9);
  64. MOBS.put(22798, 9);
  65. MOBS.put(22795, 8);
  66. MOBS.put(22797, 7);
  67. MOBS.put(22789, 5);
  68. MOBS.put(22791, 4);
  69. MOBS.put(22790, 5);
  70. MOBS.put(22792, 4);
  71. MOBS.put(22793, 5);
  72. }
  73. public Q00464_Oath()
  74. {
  75. super(464, Q00464_Oath.class.getSimpleName(), "Oath");
  76. for (int[] npc : NPC)
  77. {
  78. addTalkId(npc[0]);
  79. }
  80. addKillId(MOBS.keySet());
  81. addItemTalkId(STRONGBOX);
  82. registerQuestItems(BOOK, BOOK2);
  83. }
  84. @Override
  85. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  86. {
  87. final QuestState st = getQuestState(player, false);
  88. if (st == null)
  89. {
  90. return null;
  91. }
  92. String htmltext = event;
  93. switch (event)
  94. {
  95. case "32596-04.html":
  96. if (!st.hasQuestItems(BOOK))
  97. {
  98. return getNoQuestMsg(player);
  99. }
  100. int cond = getRandom(2, 9);
  101. st.set("npc", String.valueOf(NPC[cond - 1][0]));
  102. st.setCond(cond, true);
  103. st.takeItems(BOOK, 1);
  104. st.giveItems(BOOK2, 1);
  105. switch (cond)
  106. {
  107. case 2:
  108. htmltext = "32596-04.html";
  109. break;
  110. case 3:
  111. htmltext = "32596-04a.html";
  112. break;
  113. case 4:
  114. htmltext = "32596-04b.html";
  115. break;
  116. case 5:
  117. htmltext = "32596-04c.html";
  118. break;
  119. case 6:
  120. htmltext = "32596-04d.html";
  121. break;
  122. case 7:
  123. htmltext = "32596-04e.html";
  124. break;
  125. case 8:
  126. htmltext = "32596-04f.html";
  127. break;
  128. case 9:
  129. htmltext = "32596-04g.html";
  130. break;
  131. }
  132. break;
  133. case "end_quest":
  134. if (!st.hasQuestItems(BOOK2))
  135. {
  136. return getNoQuestMsg(player);
  137. }
  138. int i = st.getCond() - 1;
  139. st.addExpAndSp(NPC[i][1], NPC[i][2]);
  140. st.giveAdena(NPC[i][3], true);
  141. st.exitQuest(QuestType.DAILY, true);
  142. htmltext = npc.getId() + "-02.html";
  143. break;
  144. case "32596-02.html":
  145. case "32596-03.html":
  146. break;
  147. default:
  148. htmltext = null;
  149. break;
  150. }
  151. return htmltext;
  152. }
  153. @Override
  154. public String onItemTalk(L2ItemInstance item, L2PcInstance player)
  155. {
  156. String htmltext = getNoQuestMsg(player);
  157. final QuestState st = getQuestState(player, true);
  158. boolean startQuest = false;
  159. switch (st.getState())
  160. {
  161. case State.CREATED:
  162. startQuest = true;
  163. break;
  164. case State.STARTED:
  165. htmltext = "strongbox-02.html";
  166. break;
  167. case State.COMPLETED:
  168. if (st.isNowAvailable())
  169. {
  170. st.setState(State.CREATED);
  171. startQuest = true;
  172. }
  173. else
  174. {
  175. htmltext = "strongbox-03.html";
  176. }
  177. break;
  178. }
  179. if (startQuest)
  180. {
  181. if (player.getLevel() >= MIN_LEVEL)
  182. {
  183. st.startQuest();
  184. st.takeItems(STRONGBOX, 1);
  185. st.giveItems(BOOK, 1);
  186. htmltext = "strongbox-01.htm";
  187. }
  188. else
  189. {
  190. htmltext = "strongbox-00.htm";
  191. }
  192. }
  193. return htmltext;
  194. }
  195. @Override
  196. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  197. {
  198. if (getRandom(1000) < MOBS.get(npc.getId()))
  199. {
  200. npc.dropItem(killer, STRONGBOX, 1);
  201. }
  202. return super.onKill(npc, killer, isSummon);
  203. }
  204. @Override
  205. public String onTalk(L2Npc npc, L2PcInstance player)
  206. {
  207. String htmltext = getNoQuestMsg(player);
  208. final QuestState st = getQuestState(player, true);
  209. if ((st != null) && st.isStarted())
  210. {
  211. int npcId = npc.getId();
  212. if (npcId == NPC[0][0])
  213. {
  214. switch (st.getCond())
  215. {
  216. case 1:
  217. htmltext = "32596-01.html";
  218. break;
  219. case 2:
  220. htmltext = "32596-05.html";
  221. break;
  222. case 3:
  223. htmltext = "32596-05a.html";
  224. break;
  225. case 4:
  226. htmltext = "32596-05b.html";
  227. break;
  228. case 5:
  229. htmltext = "32596-05c.html";
  230. break;
  231. case 6:
  232. htmltext = "32596-05d.html";
  233. break;
  234. case 7:
  235. htmltext = "32596-05e.html";
  236. break;
  237. case 8:
  238. htmltext = "32596-05f.html";
  239. break;
  240. case 9:
  241. htmltext = "32596-05g.html";
  242. break;
  243. }
  244. }
  245. else if ((st.getCond() > 1) && (st.getInt("npc") == npcId))
  246. {
  247. htmltext = npcId + "-01.html";
  248. }
  249. }
  250. return htmltext;
  251. }
  252. }