Q00632_NecromancersRequest.java 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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.Q00632_NecromancersRequest;
  20. import java.util.HashMap;
  21. import java.util.Map;
  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. /**
  27. * Necromancer's Request (632)
  28. * @author Zoey76
  29. */
  30. public final class Q00632_NecromancersRequest extends Quest
  31. {
  32. // NPC
  33. private static final int MYSTERIOUS_WIZARD = 31522;
  34. // Items
  35. private static final int VAMPIRES_HEART = 7542;
  36. private static final int ZOMBIES_BRAIN = 7543;
  37. // Misc
  38. private static final int MIN_LEVEL = 63;
  39. private static final int REQUIRED_ITEM_COUNT = 200;
  40. private static final int ADENA_REWARD = 120000;
  41. // Monsters
  42. private static final Map<Integer, Double> BRAIN_MONSTERS = new HashMap<>();
  43. private static final Map<Integer, Double> HEART_MONSTERS = new HashMap<>();
  44. static
  45. {
  46. BRAIN_MONSTERS.put(21547, 0.565); // Corrupted Knight
  47. BRAIN_MONSTERS.put(21548, 0.484); // Resurrected Knight
  48. BRAIN_MONSTERS.put(21549, 0.585); // Corrupted Guard
  49. BRAIN_MONSTERS.put(21550, 0.597); // Corrupted Guard
  50. BRAIN_MONSTERS.put(21551, 0.673); // Resurrected Guard
  51. BRAIN_MONSTERS.put(21552, 0.637); // Resurrected Guard
  52. BRAIN_MONSTERS.put(21555, 0.575); // Slaughter Executioner
  53. BRAIN_MONSTERS.put(21556, 0.560); // Slaughter Executioner
  54. BRAIN_MONSTERS.put(21562, 0.631); // Guillotine's Ghost
  55. BRAIN_MONSTERS.put(21571, 0.758); // Ghost of Rebellion Soldier
  56. BRAIN_MONSTERS.put(21576, 0.647); // Ghost of Guillotine
  57. BRAIN_MONSTERS.put(21577, 0.625); // Ghost of Guillotine
  58. BRAIN_MONSTERS.put(21579, 0.766); // Ghost of Rebellion Leader
  59. HEART_MONSTERS.put(21568, 0.452); // Devil Bat
  60. HEART_MONSTERS.put(21569, 0.484); // Devil Bat
  61. HEART_MONSTERS.put(21573, 0.499); // Atrox
  62. HEART_MONSTERS.put(21582, 0.522); // Vampire Soldier
  63. HEART_MONSTERS.put(21585, 0.413); // Vampire Magician
  64. HEART_MONSTERS.put(21586, 0.496); // Vampire Adept
  65. HEART_MONSTERS.put(21587, 0.519); // Vampire Warrior
  66. HEART_MONSTERS.put(21588, 0.428); // Vampire Wizard
  67. HEART_MONSTERS.put(21589, 0.439); // Vampire Wizard
  68. HEART_MONSTERS.put(21590, 0.428); // Vampire Magister
  69. HEART_MONSTERS.put(21591, 0.502); // Vampire Magister
  70. HEART_MONSTERS.put(21592, 0.370); // Vampire Magister
  71. HEART_MONSTERS.put(21593, 0.592); // Vampire Warlord
  72. HEART_MONSTERS.put(21594, 0.554); // Vampire Warlord
  73. HEART_MONSTERS.put(21595, 0.392); // Vampire Warlord
  74. }
  75. public Q00632_NecromancersRequest()
  76. {
  77. super(632, Q00632_NecromancersRequest.class.getSimpleName(), "Necromancer's Request");
  78. addStartNpc(MYSTERIOUS_WIZARD);
  79. addTalkId(MYSTERIOUS_WIZARD);
  80. addKillId(BRAIN_MONSTERS.keySet());
  81. addKillId(HEART_MONSTERS.keySet());
  82. registerQuestItems(VAMPIRES_HEART, ZOMBIES_BRAIN);
  83. }
  84. @Override
  85. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  86. {
  87. final QuestState qs = getQuestState(player, false);
  88. if (qs == null)
  89. {
  90. return null;
  91. }
  92. String htmltext = null;
  93. switch (event)
  94. {
  95. case "31522-104.htm":
  96. {
  97. if (player.getLevel() >= MIN_LEVEL)
  98. {
  99. qs.startQuest();
  100. qs.setMemoState(11);
  101. htmltext = event;
  102. }
  103. break;
  104. }
  105. case "31522-201.html":
  106. {
  107. htmltext = event;
  108. break;
  109. }
  110. case "31522-202.html":
  111. {
  112. if (getQuestItemsCount(player, VAMPIRES_HEART) >= REQUIRED_ITEM_COUNT)
  113. {
  114. takeItems(player, VAMPIRES_HEART, -1);
  115. giveAdena(player, ADENA_REWARD, true);
  116. qs.setMemoState(11);
  117. htmltext = event;
  118. }
  119. else
  120. {
  121. htmltext = "31522-203.html";
  122. }
  123. break;
  124. }
  125. case "31522-204.html":
  126. {
  127. takeItems(player, VAMPIRES_HEART, -1);
  128. qs.exitQuest(true, true);
  129. htmltext = event;
  130. break;
  131. }
  132. }
  133. return htmltext;
  134. }
  135. @Override
  136. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  137. {
  138. final QuestState qs = getRandomPartyMemberState(player, -1, 3, npc);
  139. if (qs != null)
  140. {
  141. if (BRAIN_MONSTERS.containsKey(npc.getId()))
  142. {
  143. qs.giveItemRandomly(npc, ZOMBIES_BRAIN, 1, 0, BRAIN_MONSTERS.get(npc.getId()), true);
  144. }
  145. else
  146. {
  147. qs.giveItemRandomly(npc, VAMPIRES_HEART, 1, 0, HEART_MONSTERS.get(npc.getId()), true);
  148. if (getQuestItemsCount(player, VAMPIRES_HEART) >= REQUIRED_ITEM_COUNT)
  149. {
  150. qs.setCond(2);
  151. qs.setMemoState(12);
  152. }
  153. }
  154. }
  155. return super.onKill(npc, player, isSummon);
  156. }
  157. @Override
  158. public String onTalk(L2Npc npc, L2PcInstance player)
  159. {
  160. final QuestState qs = getQuestState(player, true);
  161. String htmltext = getNoQuestMsg(player);
  162. if (qs == null)
  163. {
  164. return htmltext;
  165. }
  166. if (qs.isCreated())
  167. {
  168. htmltext = player.getLevel() >= MIN_LEVEL ? "31522-101.htm" : "31522-103.htm";
  169. }
  170. else if (qs.isStarted())
  171. {
  172. if (qs.isMemoState(11))
  173. {
  174. htmltext = "31522-106.html";
  175. }
  176. else if (qs.isMemoState(12) && (getQuestItemsCount(player, VAMPIRES_HEART) >= REQUIRED_ITEM_COUNT))
  177. {
  178. htmltext = "31522-105.html";
  179. }
  180. }
  181. return htmltext;
  182. }
  183. }