Q00143_FallenAngelRequestOfDusk.java 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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.Q00143_FallenAngelRequestOfDusk;
  20. import com.l2jserver.gameserver.model.actor.L2Npc;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.quest.Quest;
  23. import com.l2jserver.gameserver.model.quest.QuestState;
  24. import com.l2jserver.gameserver.model.quest.State;
  25. /**
  26. * Fallen Angel - Request of Dusk (143)
  27. * @author Nono
  28. */
  29. public class Q00143_FallenAngelRequestOfDusk extends Quest
  30. {
  31. // NPCs
  32. private static final int TOBIAS = 30297;
  33. private static final int CASIAN = 30612;
  34. private static final int NATOOLS = 30894;
  35. private static final int ROCK = 32368;
  36. private static final int ANGEL = 32369;
  37. // Items
  38. private static final int SEALED_PROPHECY_PATH_OF_THE_GOD = 10354;
  39. private static final int PROPHECY_PATH_OF_THE_GOD = 10355;
  40. private static final int EMPTY_SOUND_CRYSTAL = 10356;
  41. private static final int ANGEL_MEDICINE = 10357;
  42. private static final int ANGELS_MESSAGE = 10358;
  43. // Misc
  44. private static final int MAX_REWARD_LEVEL = 43;
  45. private boolean isAngelSpawned = false;
  46. public Q00143_FallenAngelRequestOfDusk()
  47. {
  48. super(143, Q00143_FallenAngelRequestOfDusk.class.getSimpleName(), "Fallen Angel - Request of Dusk");
  49. addTalkId(NATOOLS, TOBIAS, CASIAN, ROCK, ANGEL);
  50. registerQuestItems(SEALED_PROPHECY_PATH_OF_THE_GOD, PROPHECY_PATH_OF_THE_GOD, EMPTY_SOUND_CRYSTAL, ANGEL_MEDICINE, ANGELS_MESSAGE);
  51. }
  52. @Override
  53. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  54. {
  55. final QuestState st = getQuestState(player, false);
  56. if (st == null)
  57. {
  58. return null;
  59. }
  60. String htmltext = event;
  61. switch (event)
  62. {
  63. case "30894-02.html":
  64. case "30297-04.html":
  65. case "30612-05.html":
  66. case "30612-06.html":
  67. case "30612-07.html":
  68. case "30612-08.html":
  69. case "32369-04.html":
  70. case "32369-05.html":
  71. case "32369-07.html":
  72. case "32369-08.html":
  73. case "32369-09.html":
  74. case "32369-10.html":
  75. break;
  76. case "30894-01.html":
  77. st.startQuest();
  78. break;
  79. case "30894-03.html":
  80. st.setCond(2, true);
  81. st.giveItems(SEALED_PROPHECY_PATH_OF_THE_GOD, 1);
  82. break;
  83. case "30297-03.html":
  84. st.takeItems(SEALED_PROPHECY_PATH_OF_THE_GOD, -1);
  85. st.set("talk", "1");
  86. break;
  87. case "30297-05.html":
  88. st.unset("talk");
  89. st.setCond(3, true);
  90. st.giveItems(PROPHECY_PATH_OF_THE_GOD, 1);
  91. st.giveItems(EMPTY_SOUND_CRYSTAL, 1);
  92. break;
  93. case "30612-03.html":
  94. st.takeItems(PROPHECY_PATH_OF_THE_GOD, -1);
  95. st.set("talk", "1");
  96. break;
  97. case "30612-09.html":
  98. st.unset("talk");
  99. st.setCond(4, true);
  100. st.giveItems(ANGEL_MEDICINE, 1);
  101. break;
  102. case "32368-04.html":
  103. if (isAngelSpawned)
  104. {
  105. return "32368-03.html";
  106. }
  107. addSpawn(ANGEL, npc.getX() + 100, npc.getY() + 100, npc.getZ(), 0, false, 120000);
  108. startQuestTimer("despawn", 120000, null, player);
  109. isAngelSpawned = true;
  110. break;
  111. case "32369-03.html":
  112. st.takeItems(ANGEL_MEDICINE, -1);
  113. st.set("talk", "1");
  114. break;
  115. case "32369-06.html":
  116. st.set("talk", "2");
  117. break;
  118. case "32369-11.html":
  119. st.unset("talk");
  120. st.takeItems(EMPTY_SOUND_CRYSTAL, -1);
  121. st.giveItems(ANGELS_MESSAGE, 1);
  122. st.setCond(5, true);
  123. npc.deleteMe();
  124. isAngelSpawned = false;
  125. break;
  126. case "despawn":
  127. if (isAngelSpawned)
  128. {
  129. isAngelSpawned = false;
  130. }
  131. default:
  132. htmltext = null;
  133. break;
  134. }
  135. return htmltext;
  136. }
  137. @Override
  138. public String onTalk(L2Npc npc, L2PcInstance player)
  139. {
  140. String htmltext = getNoQuestMsg(player);
  141. final QuestState st = getQuestState(player, true);
  142. if (st == null)
  143. {
  144. return htmltext;
  145. }
  146. switch (npc.getId())
  147. {
  148. case NATOOLS:
  149. switch (st.getState())
  150. {
  151. case State.STARTED:
  152. switch (st.getCond())
  153. {
  154. case 1:
  155. htmltext = "30894-01.html";
  156. break;
  157. default:
  158. htmltext = "30894-04.html";
  159. break;
  160. }
  161. break;
  162. case State.COMPLETED:
  163. htmltext = getAlreadyCompletedMsg(player);
  164. break;
  165. }
  166. break;
  167. case TOBIAS:
  168. if (st.isStarted())
  169. {
  170. switch (st.getCond())
  171. {
  172. case 1:
  173. htmltext = "30297-01.html";
  174. break;
  175. case 2:
  176. htmltext = (st.isSet("talk")) ? "30297-04.html" : "30297-02.html";
  177. break;
  178. case 3:
  179. case 4:
  180. htmltext = "30297-06.html";
  181. break;
  182. case 5:
  183. st.giveAdena(89046, true);
  184. if (player.getLevel() <= MAX_REWARD_LEVEL)
  185. {
  186. st.addExpAndSp(223036, 13901);
  187. }
  188. st.exitQuest(false, true);
  189. htmltext = "30297-07.html";
  190. break;
  191. }
  192. }
  193. break;
  194. case CASIAN:
  195. if (st.isStarted())
  196. {
  197. switch (st.getCond())
  198. {
  199. case 1:
  200. case 2:
  201. htmltext = "30612-01.html";
  202. break;
  203. case 3:
  204. htmltext = (st.isSet("talk")) ? "30612-04.html" : "30612-02.html";
  205. break;
  206. default:
  207. htmltext = "30612-10.html";
  208. break;
  209. }
  210. }
  211. break;
  212. case ROCK:
  213. if (st.isStarted())
  214. {
  215. switch (st.getCond())
  216. {
  217. case 1:
  218. case 2:
  219. case 3:
  220. htmltext = "32368-01.html";
  221. break;
  222. case 4:
  223. htmltext = "32368-02.html";
  224. break;
  225. case 5:
  226. htmltext = "32368-05.html";
  227. break;
  228. }
  229. }
  230. break;
  231. case ANGEL:
  232. if (st.isStarted())
  233. {
  234. switch (st.getCond())
  235. {
  236. case 1:
  237. case 2:
  238. case 3:
  239. htmltext = "32369-01.html";
  240. break;
  241. case 4:
  242. if (st.getInt("talk") == 1)
  243. {
  244. htmltext = "32369-04.html";
  245. }
  246. else if (st.getInt("talk") == 2)
  247. {
  248. htmltext = "32369-07.html";
  249. }
  250. else
  251. {
  252. htmltext = "32369-02.html";
  253. }
  254. break;
  255. }
  256. }
  257. break;
  258. }
  259. return htmltext;
  260. }
  261. }