Q00627_HeartInSearchOfPower.java 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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.Q00627_HeartInSearchOfPower;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import com.l2jserver.Config;
  23. import com.l2jserver.gameserver.enums.QuestSound;
  24. import com.l2jserver.gameserver.model.actor.L2Npc;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  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. * Heart in Search of Power (627)
  31. * @author Citizen
  32. */
  33. public class Q00627_HeartInSearchOfPower extends Quest
  34. {
  35. // NPCs
  36. private static final int MYSTERIOUS_NECROMANCER = 31518;
  37. private static final int ENFEUX = 31519;
  38. // Items
  39. private static final int SEAL_OF_LIGHT = 7170;
  40. private static final int BEAD_OF_OBEDIENCE = 7171;
  41. private static final int GEM_OF_SAINTS = 7172;
  42. // Monsters
  43. private static final Map<Integer, Integer> MONSTERS = new HashMap<>();
  44. static
  45. {
  46. MONSTERS.put(21520, 661); // Eye of Splendor
  47. MONSTERS.put(21523, 668); // Flash of Splendor
  48. MONSTERS.put(21524, 714); // Blade of Splendor
  49. MONSTERS.put(21525, 714); // Blade of Splendor
  50. MONSTERS.put(21526, 796); // Wisdom of Splendor
  51. MONSTERS.put(21529, 659); // Soul of Splendor
  52. MONSTERS.put(21530, 704); // Victory of Splendor
  53. MONSTERS.put(21531, 791); // Punishment of Splendor
  54. MONSTERS.put(21532, 820); // Shout of Splendor
  55. MONSTERS.put(21535, 827); // Signet of Splendor
  56. MONSTERS.put(21536, 798); // Crown of Splendor
  57. MONSTERS.put(21539, 875); // Wailing of Splendor
  58. MONSTERS.put(21540, 875); // Wailing of Splendor
  59. MONSTERS.put(21658, 791); // Punishment of Splendor
  60. }
  61. // Misc
  62. private static final int MIN_LEVEL_REQUIRED = 60;
  63. private static final int BEAD_OF_OBEDIENCE_COUNT_REQUIRED = 300;
  64. // Rewards ID's
  65. private static final int ASOFE = 4043;
  66. private static final int THONS = 4044;
  67. private static final int ENRIA = 4042;
  68. private static final int MOLD_HARDENER = 4041;
  69. public Q00627_HeartInSearchOfPower()
  70. {
  71. super(627, Q00627_HeartInSearchOfPower.class.getSimpleName(), "Heart in Search of Power");
  72. addStartNpc(MYSTERIOUS_NECROMANCER);
  73. addTalkId(MYSTERIOUS_NECROMANCER, ENFEUX);
  74. addKillId(MONSTERS.keySet());
  75. registerQuestItems(SEAL_OF_LIGHT, BEAD_OF_OBEDIENCE, GEM_OF_SAINTS);
  76. }
  77. @Override
  78. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  79. {
  80. final QuestState st = getQuestState(player, false);
  81. if (st == null)
  82. {
  83. return null;
  84. }
  85. String htmltext = event;
  86. switch (event)
  87. {
  88. case "31518-02.htm":
  89. st.startQuest();
  90. break;
  91. case "31518-06.html":
  92. if (st.getQuestItemsCount(BEAD_OF_OBEDIENCE) < BEAD_OF_OBEDIENCE_COUNT_REQUIRED)
  93. {
  94. return "31518-05.html";
  95. }
  96. st.giveItems(SEAL_OF_LIGHT, 1);
  97. st.takeItems(BEAD_OF_OBEDIENCE, -1);
  98. st.setCond(3);
  99. break;
  100. case "Adena":
  101. case "Asofes":
  102. case "Thons":
  103. case "Enrias":
  104. case "Mold_Hardener":
  105. if (!st.hasQuestItems(GEM_OF_SAINTS))
  106. {
  107. return "31518-11.html";
  108. }
  109. switch (event)
  110. {
  111. case "Adena":
  112. st.giveAdena(100000, true);
  113. break;
  114. case "Asofes":
  115. st.rewardItems(ASOFE, 13);
  116. st.giveAdena(6400, true);
  117. break;
  118. case "Thons":
  119. st.rewardItems(THONS, 13);
  120. st.giveAdena(6400, true);
  121. break;
  122. case "Enrias":
  123. st.rewardItems(ENRIA, 6);
  124. st.giveAdena(13600, true);
  125. break;
  126. case "Mold_Hardener":
  127. st.rewardItems(MOLD_HARDENER, 3);
  128. st.giveAdena(17200, true);
  129. break;
  130. }
  131. htmltext = "31518-10.html";
  132. st.exitQuest(true);
  133. break;
  134. case "31519-02.html":
  135. if (st.hasQuestItems(SEAL_OF_LIGHT) && st.isCond(3))
  136. {
  137. st.giveItems(GEM_OF_SAINTS, 1);
  138. st.takeItems(SEAL_OF_LIGHT, -1);
  139. st.setCond(4);
  140. }
  141. else
  142. {
  143. htmltext = getNoQuestMsg(player);
  144. }
  145. break;
  146. case "31518-09.html":
  147. break;
  148. default:
  149. htmltext = null;
  150. break;
  151. }
  152. return htmltext;
  153. }
  154. @Override
  155. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  156. {
  157. final L2PcInstance partyMember = getRandomPartyMember(killer, 1);
  158. if (partyMember != null)
  159. {
  160. final QuestState st = getQuestState(partyMember, false);
  161. final float chance = (MONSTERS.get(npc.getId()) * Config.RATE_QUEST_DROP);
  162. if (getRandom(1000) < chance)
  163. {
  164. st.giveItems(BEAD_OF_OBEDIENCE, 1);
  165. if (st.getQuestItemsCount(BEAD_OF_OBEDIENCE) < BEAD_OF_OBEDIENCE_COUNT_REQUIRED)
  166. {
  167. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  168. }
  169. else
  170. {
  171. st.setCond(2, true);
  172. }
  173. }
  174. }
  175. return super.onKill(npc, killer, isSummon);
  176. }
  177. @Override
  178. public String onTalk(L2Npc npc, L2PcInstance player)
  179. {
  180. String htmltext = getNoQuestMsg(player);
  181. final QuestState st = getQuestState(player, true);
  182. if (st == null)
  183. {
  184. return htmltext;
  185. }
  186. switch (st.getState())
  187. {
  188. case State.CREATED:
  189. if (npc.getId() == MYSTERIOUS_NECROMANCER)
  190. {
  191. htmltext = (player.getLevel() >= MIN_LEVEL_REQUIRED) ? "31518-01.htm" : "31518-00.htm";
  192. }
  193. break;
  194. case State.STARTED:
  195. switch (npc.getId())
  196. {
  197. case MYSTERIOUS_NECROMANCER:
  198. switch (st.getCond())
  199. {
  200. case 1:
  201. htmltext = "31518-03.html";
  202. break;
  203. case 2:
  204. htmltext = "31518-04.html";
  205. break;
  206. case 3:
  207. htmltext = "31518-07.html";
  208. break;
  209. case 4:
  210. htmltext = "31518-08.html";
  211. break;
  212. }
  213. break;
  214. case ENFEUX:
  215. switch (st.getCond())
  216. {
  217. case 3:
  218. htmltext = "31519-01.html";
  219. break;
  220. case 4:
  221. htmltext = "31519-03.html";
  222. break;
  223. }
  224. break;
  225. }
  226. break;
  227. }
  228. return htmltext;
  229. }
  230. }