Q00618_IntoTheFlame.java 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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.Q00618_IntoTheFlame;
  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. /**
  28. * Into The Flame (618)
  29. * @author St3eT
  30. */
  31. public class Q00618_IntoTheFlame extends Quest
  32. {
  33. // NPCs
  34. private static final int KLEIN = 31540;
  35. private static final int HILDA = 31271;
  36. // Monsters
  37. private static final Map<Integer, Integer> MONSTERS = new HashMap<>();
  38. // Items
  39. private static final int VACUALITE_ORE = 7265;
  40. private static final int VACUALITE = 7266;
  41. private static final int VACUALITE_FLOATING_STONE = 7267;
  42. // Misc
  43. private static final int MIN_LEVEL = 60;
  44. private static final int REQUIRED_COUNT = 50;
  45. static
  46. {
  47. MONSTERS.put(21274, 630);
  48. MONSTERS.put(21276, 630);
  49. MONSTERS.put(21282, 670);
  50. MONSTERS.put(21283, 670);
  51. MONSTERS.put(21284, 670);
  52. MONSTERS.put(21290, 710);
  53. MONSTERS.put(21291, 710);
  54. MONSTERS.put(21292, 710);
  55. }
  56. public Q00618_IntoTheFlame()
  57. {
  58. super(618, Q00618_IntoTheFlame.class.getSimpleName(), "Into the Flame");
  59. addStartNpc(KLEIN);
  60. addTalkId(HILDA, KLEIN);
  61. addKillId(MONSTERS.keySet());
  62. registerQuestItems(VACUALITE_ORE, VACUALITE);
  63. }
  64. @Override
  65. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  66. {
  67. final QuestState st = getQuestState(player, false);
  68. if (st == null)
  69. {
  70. return null;
  71. }
  72. String htmltext = null;
  73. switch (event)
  74. {
  75. case "31540-03.htm":
  76. st.startQuest();
  77. htmltext = event;
  78. break;
  79. case "31540-05.html":
  80. if (!st.hasQuestItems(VACUALITE))
  81. {
  82. htmltext = "31540-03.htm";
  83. }
  84. else
  85. {
  86. st.giveItems(VACUALITE_FLOATING_STONE, 1);
  87. st.exitQuest(true, true);
  88. htmltext = event;
  89. }
  90. break;
  91. case "31271-02.html":
  92. if (st.isCond(1))
  93. {
  94. st.setCond(2, true);
  95. htmltext = event;
  96. }
  97. break;
  98. case "31271-05.html":
  99. if ((st.getQuestItemsCount(VACUALITE_ORE) == REQUIRED_COUNT) && st.isCond(3))
  100. {
  101. st.takeItems(VACUALITE_ORE, -1);
  102. st.giveItems(VACUALITE, 1);
  103. st.setCond(4, true);
  104. htmltext = event;
  105. }
  106. else
  107. {
  108. htmltext = "31271-03.html";
  109. }
  110. break;
  111. }
  112. return htmltext;
  113. }
  114. @Override
  115. public String onKill(L2Npc npc, L2PcInstance player, boolean isPet)
  116. {
  117. final L2PcInstance member = getRandomPartyMember(player, 2);
  118. if (member != null)
  119. {
  120. final QuestState qs = getQuestState(member, false);
  121. if ((qs.getQuestItemsCount(VACUALITE_ORE) < REQUIRED_COUNT) && (getRandom(1000) < MONSTERS.get(npc.getId())))
  122. {
  123. qs.giveItems(VACUALITE_ORE, 1);
  124. if (qs.getQuestItemsCount(VACUALITE_ORE) >= REQUIRED_COUNT)
  125. {
  126. qs.setCond(3, true);
  127. }
  128. else
  129. {
  130. qs.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  131. }
  132. }
  133. }
  134. return super.onKill(npc, player, isPet);
  135. }
  136. @Override
  137. public String onTalk(L2Npc npc, L2PcInstance player)
  138. {
  139. String htmltext = getNoQuestMsg(player);
  140. final QuestState st = getQuestState(player, true);
  141. if (st == null)
  142. {
  143. return htmltext;
  144. }
  145. switch (npc.getId())
  146. {
  147. case KLEIN:
  148. {
  149. if (st.isCreated())
  150. {
  151. htmltext = (player.getLevel() < MIN_LEVEL) ? "31540-01.html" : "31540-02.htm";
  152. }
  153. else if (st.isStarted())
  154. {
  155. htmltext = st.isCond(4) ? "31540-04.html" : "31540-03.htm";
  156. }
  157. break;
  158. }
  159. case HILDA:
  160. {
  161. switch (st.getCond())
  162. {
  163. case 1:
  164. htmltext = "31271-01.html";
  165. break;
  166. case 2:
  167. htmltext = "31271-03.html";
  168. break;
  169. case 3:
  170. htmltext = "31271-04.html";
  171. break;
  172. case 4:
  173. htmltext = "31271-06.html";
  174. break;
  175. }
  176. break;
  177. }
  178. }
  179. return htmltext;
  180. }
  181. }