Q00626_ADarkTwilight.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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.Q00626_ADarkTwilight;
  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. * A Dark Twilight (626)<br>
  31. * Original Jython script by disKret.
  32. * @author Citizen
  33. */
  34. public class Q00626_ADarkTwilight extends Quest
  35. {
  36. // NPCs
  37. private static final int HIERARCH = 31517;
  38. // Items
  39. private static final int BLOOD_OF_SAINT = 7169;
  40. // Monsters
  41. private static final Map<Integer, Integer> MONSTERS = new HashMap<>();
  42. static
  43. {
  44. MONSTERS.put(21520, 641); // Eye of Splendor
  45. MONSTERS.put(21523, 648); // Flash of Splendor
  46. MONSTERS.put(21524, 692); // Blade of Splendor
  47. MONSTERS.put(21525, 710); // Blade of Splendor
  48. MONSTERS.put(21526, 772); // Wisdom of Splendor
  49. MONSTERS.put(21529, 639); // Soul of Splendor
  50. MONSTERS.put(21530, 683); // Victory of Splendor
  51. MONSTERS.put(21531, 767); // Punishment of Splendor
  52. MONSTERS.put(21532, 795); // Shout of Splendor
  53. MONSTERS.put(21535, 802); // Signet of Splendor
  54. MONSTERS.put(21536, 774); // Crown of Splendor
  55. MONSTERS.put(21539, 848); // Wailing of Splendor
  56. MONSTERS.put(21540, 880); // Wailing of Splendor
  57. MONSTERS.put(21658, 790); // Punishment of Splendor
  58. }
  59. // Misc
  60. private static final int MIN_LEVEL_REQUIRED = 60;
  61. private static final int ITEMS_COUNT_REQUIRED = 300;
  62. // Rewards
  63. private static final int ADENA_COUNT = 100000;
  64. private static final int XP_COUNT = 162773;
  65. private static final int SP_COUNT = 12500;
  66. public Q00626_ADarkTwilight()
  67. {
  68. super(626, Q00626_ADarkTwilight.class.getSimpleName(), "A Dark Twilight");
  69. addStartNpc(HIERARCH);
  70. addTalkId(HIERARCH);
  71. addKillId(MONSTERS.keySet());
  72. registerQuestItems(BLOOD_OF_SAINT);
  73. }
  74. @Override
  75. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  76. {
  77. final QuestState st = getQuestState(player, false);
  78. if (st == null)
  79. {
  80. return null;
  81. }
  82. String htmltext = event;
  83. switch (event)
  84. {
  85. case "31517-05.html":
  86. break;
  87. case "31517-02.htm":
  88. st.startQuest();
  89. break;
  90. case "Exp":
  91. if (st.getQuestItemsCount(BLOOD_OF_SAINT) < ITEMS_COUNT_REQUIRED)
  92. {
  93. return "31517-06.html";
  94. }
  95. st.addExpAndSp(XP_COUNT, SP_COUNT);
  96. st.exitQuest(true, true);
  97. htmltext = "31517-07.html";
  98. break;
  99. case "Adena":
  100. if (st.getQuestItemsCount(BLOOD_OF_SAINT) < ITEMS_COUNT_REQUIRED)
  101. {
  102. return "31517-06.html";
  103. }
  104. st.giveAdena(ADENA_COUNT, true);
  105. st.exitQuest(true, true);
  106. htmltext = "31517-07.html";
  107. break;
  108. default:
  109. htmltext = null;
  110. break;
  111. }
  112. return htmltext;
  113. }
  114. @Override
  115. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  116. {
  117. final L2PcInstance partyMember = getRandomPartyMember(killer, 1);
  118. if (partyMember != null)
  119. {
  120. final QuestState st = getQuestState(partyMember, false);
  121. final float chance = (MONSTERS.get(npc.getId()) * Config.RATE_QUEST_DROP);
  122. if (getRandom(1000) < chance)
  123. {
  124. st.giveItems(BLOOD_OF_SAINT, 1);
  125. if (st.getQuestItemsCount(BLOOD_OF_SAINT) < ITEMS_COUNT_REQUIRED)
  126. {
  127. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  128. }
  129. else
  130. {
  131. st.setCond(2, true);
  132. }
  133. }
  134. }
  135. return super.onKill(npc, killer, isSummon);
  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 (st.getState())
  147. {
  148. case State.CREATED:
  149. htmltext = (player.getLevel() >= MIN_LEVEL_REQUIRED) ? "31517-01.htm" : "31517-00.htm";
  150. break;
  151. case State.STARTED:
  152. switch (st.getCond())
  153. {
  154. case 1:
  155. htmltext = "31517-03.html";
  156. break;
  157. case 2:
  158. htmltext = "31517-04.html";
  159. break;
  160. }
  161. break;
  162. }
  163. return htmltext;
  164. }
  165. }