Q00142_FallenAngelRequestOfDawn.java 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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.Q00142_FallenAngelRequestOfDawn;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import com.l2jserver.gameserver.enums.QuestSound;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.model.quest.Quest;
  26. import com.l2jserver.gameserver.model.quest.QuestState;
  27. import com.l2jserver.gameserver.model.quest.State;
  28. /**
  29. * Fallen Angel - Request of Dawn (142)
  30. * @author Nono
  31. */
  32. public class Q00142_FallenAngelRequestOfDawn extends Quest
  33. {
  34. // NPCs
  35. private static final int RAYMOND = 30289;
  36. private static final int CASIAN = 30612;
  37. private static final int NATOOLS = 30894;
  38. private static final int ROCK = 32368;
  39. // Monsters
  40. private static final int FALLEN_ANGEL = 27338;
  41. private static final Map<Integer, Integer> MOBS = new HashMap<>();
  42. static
  43. {
  44. MOBS.put(20079, 338); // Ant
  45. MOBS.put(20080, 363); // Ant Captain
  46. MOBS.put(20081, 611); // Ant Overseer
  47. MOBS.put(20082, 371); // Ant Recruit
  48. MOBS.put(20084, 421); // Ant Patrol
  49. MOBS.put(20086, 371); // Ant Guard
  50. MOBS.put(20087, 900); // Ant Soldier
  51. MOBS.put(20088, 1000);// Ant Warrior Captain
  52. MOBS.put(20089, 431); // Noble Ant
  53. MOBS.put(20090, 917); // Noble Ant Leader
  54. }
  55. // Items
  56. private static final int CRYPTOGRAM_OF_THE_ANGEL_SEARCH = 10351;
  57. private static final int PROPHECY_FRAGMENT = 10352;
  58. private static final int FALLEN_ANGEL_BLOOD = 10353;
  59. // Misc
  60. private static final int MAX_REWARD_LEVEL = 43;
  61. private static final int FRAGMENT_COUNT = 30;
  62. private boolean isAngelSpawned = false;
  63. public Q00142_FallenAngelRequestOfDawn()
  64. {
  65. super(142, Q00142_FallenAngelRequestOfDawn.class.getSimpleName(), "Fallen Angel - Request of Dawn");
  66. addTalkId(NATOOLS, RAYMOND, CASIAN, ROCK);
  67. addKillId(MOBS.keySet());
  68. addKillId(FALLEN_ANGEL);
  69. registerQuestItems(CRYPTOGRAM_OF_THE_ANGEL_SEARCH, PROPHECY_FRAGMENT, FALLEN_ANGEL_BLOOD);
  70. }
  71. @Override
  72. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  73. {
  74. final QuestState st = getQuestState(player, false);
  75. if (st == null)
  76. {
  77. return null;
  78. }
  79. String htmltext = event;
  80. switch (event)
  81. {
  82. case "30894-02.html":
  83. case "30289-03.html":
  84. case "30289-04.html":
  85. case "30612-03.html":
  86. case "30612-04.html":
  87. case "30612-06.html":
  88. case "30612-07.html":
  89. break;
  90. case "30894-01.html":
  91. st.startQuest();
  92. break;
  93. case "30894-03.html":
  94. st.giveItems(CRYPTOGRAM_OF_THE_ANGEL_SEARCH, 1);
  95. st.setCond(2, true);
  96. break;
  97. case "30289-05.html":
  98. st.unset("talk");
  99. st.setCond(3, true);
  100. break;
  101. case "30612-05.html":
  102. st.set("talk", "2");
  103. break;
  104. case "30612-08.html":
  105. st.unset("talk");
  106. st.setCond(4, true);
  107. break;
  108. case "32368-04.html":
  109. if (isAngelSpawned)
  110. {
  111. return "32368-03.html";
  112. }
  113. addSpawn(FALLEN_ANGEL, npc.getX() + 100, npc.getY() + 100, npc.getZ(), 0, false, 120000);
  114. isAngelSpawned = true;
  115. startQuestTimer("despawn", 120000, null, player);
  116. break;
  117. case "despawn":
  118. if (isAngelSpawned)
  119. {
  120. isAngelSpawned = false;
  121. }
  122. default:
  123. htmltext = null;
  124. break;
  125. }
  126. return htmltext;
  127. }
  128. @Override
  129. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  130. {
  131. final QuestState st;
  132. if ((npc.getId() == FALLEN_ANGEL))
  133. {
  134. st = player.getQuestState(getName());
  135. if (st.isCond(5))
  136. {
  137. st.giveItems(FALLEN_ANGEL_BLOOD, 1);
  138. st.setCond(6, true);
  139. isAngelSpawned = false;
  140. }
  141. }
  142. else
  143. {
  144. final L2PcInstance member = getRandomPartyMember(player, 4);
  145. if (member != null)
  146. {
  147. st = getQuestState(member, false);
  148. if (getRandom(1000) < MOBS.get(npc.getId()))
  149. {
  150. st.giveItems(PROPHECY_FRAGMENT, 1);
  151. if (st.getQuestItemsCount(PROPHECY_FRAGMENT) >= FRAGMENT_COUNT)
  152. {
  153. st.takeItems(PROPHECY_FRAGMENT, -1);
  154. st.setCond(5, true);
  155. }
  156. else
  157. {
  158. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  159. }
  160. }
  161. }
  162. }
  163. return super.onKill(npc, player, isSummon);
  164. }
  165. @Override
  166. public String onTalk(L2Npc npc, L2PcInstance player)
  167. {
  168. String htmltext = getNoQuestMsg(player);
  169. final QuestState st = getQuestState(player, true);
  170. if (st == null)
  171. {
  172. return htmltext;
  173. }
  174. switch (npc.getId())
  175. {
  176. case NATOOLS:
  177. switch (st.getState())
  178. {
  179. case State.STARTED:
  180. switch (st.getCond())
  181. {
  182. case 1:
  183. htmltext = "30894-01.html";
  184. break;
  185. default:
  186. htmltext = "30894-04.html";
  187. break;
  188. }
  189. break;
  190. case State.COMPLETED:
  191. htmltext = getAlreadyCompletedMsg(player);
  192. break;
  193. }
  194. break;
  195. case RAYMOND:
  196. if (st.isStarted())
  197. {
  198. switch (st.getCond())
  199. {
  200. case 1:
  201. htmltext = "30289-01.html";
  202. break;
  203. case 2:
  204. if (st.isSet("talk"))
  205. {
  206. htmltext = "30289-03.html";
  207. }
  208. else
  209. {
  210. st.takeItems(CRYPTOGRAM_OF_THE_ANGEL_SEARCH, -1);
  211. st.set("talk", "1");
  212. htmltext = "30289-02.html";
  213. }
  214. break;
  215. case 3:
  216. case 4:
  217. case 5:
  218. htmltext = "30289-06.html";
  219. break;
  220. case 6:
  221. st.giveAdena(92676, true);
  222. if (player.getLevel() <= MAX_REWARD_LEVEL)
  223. {
  224. st.addExpAndSp(223036, 13091);
  225. }
  226. st.exitQuest(false, true);
  227. htmltext = "30289-07.html";
  228. break;
  229. }
  230. }
  231. break;
  232. case CASIAN:
  233. if (st.isStarted())
  234. {
  235. switch (st.getCond())
  236. {
  237. case 1:
  238. case 2:
  239. htmltext = "30612-01.html";
  240. break;
  241. case 3:
  242. if (st.getInt("talk") == 1)
  243. {
  244. htmltext = "30612-03.html";
  245. }
  246. else if (st.getInt("talk") == 2)
  247. {
  248. htmltext = "30612-06.html";
  249. }
  250. else
  251. {
  252. htmltext = "30612-02.html";
  253. st.set("talk", "1");
  254. }
  255. break;
  256. case 4:
  257. case 5:
  258. case 6:
  259. htmltext = "30612-09.html";
  260. break;
  261. }
  262. }
  263. break;
  264. case ROCK:
  265. if (st.isStarted())
  266. {
  267. switch (st.getCond())
  268. {
  269. case 5:
  270. htmltext = "32368-02.html";
  271. break;
  272. case 6:
  273. htmltext = "32368-05.html";
  274. break;
  275. default:
  276. htmltext = "32368-01.html";
  277. break;
  278. }
  279. }
  280. break;
  281. }
  282. return htmltext;
  283. }
  284. }