Q00617_GatherTheFlames.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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.Q00617_GatherTheFlames;
  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. * Gather the Flames (617)
  29. * @author malyelfik
  30. */
  31. public class Q00617_GatherTheFlames extends Quest
  32. {
  33. // NPCs
  34. private static final int HILDA = 31271;
  35. private static final int VULCAN = 31539;
  36. private static final int ROONEY = 32049;
  37. // Item
  38. private static final int TORCH = 7264;
  39. // Reward
  40. private static final int[] REWARD =
  41. {
  42. 6881,
  43. 6883,
  44. 6885,
  45. 6887,
  46. 6891,
  47. 6893,
  48. 6895,
  49. 6897,
  50. 6899,
  51. 7580
  52. };
  53. // Monsters
  54. private static final Map<Integer, Integer> MOBS = new HashMap<>();
  55. static
  56. {
  57. MOBS.put(22634, 639);
  58. MOBS.put(22635, 611);
  59. MOBS.put(22636, 649);
  60. MOBS.put(22637, 639);
  61. MOBS.put(22638, 639);
  62. MOBS.put(22639, 645);
  63. MOBS.put(22640, 559);
  64. MOBS.put(22641, 588);
  65. MOBS.put(22642, 537);
  66. MOBS.put(22643, 618);
  67. MOBS.put(22644, 633);
  68. MOBS.put(22645, 550);
  69. MOBS.put(22646, 593);
  70. MOBS.put(22647, 688);
  71. MOBS.put(22648, 632);
  72. MOBS.put(22649, 685);
  73. }
  74. public Q00617_GatherTheFlames()
  75. {
  76. super(617, Q00617_GatherTheFlames.class.getSimpleName(), "Gather the Flames");
  77. addStartNpc(HILDA, VULCAN);
  78. addTalkId(ROONEY, HILDA, VULCAN);
  79. addKillId(MOBS.keySet());
  80. registerQuestItems(TORCH);
  81. }
  82. @Override
  83. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  84. {
  85. final QuestState st = getQuestState(player, false);
  86. if (st == null)
  87. {
  88. return getNoQuestMsg(player);
  89. }
  90. String htmltext = event;
  91. switch (event)
  92. {
  93. case "31539-03.htm":
  94. case "31271-03.htm":
  95. st.startQuest();
  96. break;
  97. case "32049-02.html":
  98. case "31539-04.html":
  99. case "31539-06.html":
  100. break;
  101. case "31539-07.html":
  102. if ((st.getQuestItemsCount(TORCH) < 1000) || !st.isStarted())
  103. {
  104. return getNoQuestMsg(player);
  105. }
  106. st.giveItems(REWARD[getRandom(REWARD.length)], 1);
  107. st.takeItems(TORCH, 1000);
  108. break;
  109. case "31539-08.html":
  110. st.exitQuest(true, true);
  111. break;
  112. case "6883":
  113. case "6885":
  114. case "7580":
  115. case "6891":
  116. case "6893":
  117. case "6895":
  118. case "6897":
  119. case "6899":
  120. if ((st.getQuestItemsCount(TORCH) < 1200) || !st.isStarted())
  121. {
  122. return getNoQuestMsg(player);
  123. }
  124. st.giveItems(Integer.valueOf(event), 1);
  125. st.takeItems(TORCH, 1200);
  126. htmltext = "32049-04.html";
  127. break;
  128. case "6887":
  129. case "6881":
  130. if ((st.getQuestItemsCount(TORCH) < 1200) || !st.isStarted())
  131. {
  132. return getNoQuestMsg(player);
  133. }
  134. st.giveItems(Integer.valueOf(event), 1);
  135. st.takeItems(TORCH, 1200);
  136. htmltext = "32049-03.html";
  137. break;
  138. default:
  139. htmltext = null;
  140. break;
  141. }
  142. return htmltext;
  143. }
  144. @Override
  145. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  146. {
  147. final L2PcInstance partyMember = getRandomPartyMember(player, 1);
  148. if (partyMember == null)
  149. {
  150. return super.onKill(npc, player, isSummon);
  151. }
  152. final QuestState st = getQuestState(partyMember, false);
  153. if (getRandom(1000) < MOBS.get(npc.getId()))
  154. {
  155. st.giveItems(TORCH, 2);
  156. }
  157. else
  158. {
  159. st.giveItems(TORCH, 1);
  160. }
  161. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  162. return super.onKill(npc, player, isSummon);
  163. }
  164. @Override
  165. public String onTalk(L2Npc npc, L2PcInstance player)
  166. {
  167. String htmltext = getNoQuestMsg(player);
  168. final QuestState st = getQuestState(player, true);
  169. if (st == null)
  170. {
  171. return htmltext;
  172. }
  173. switch (npc.getId())
  174. {
  175. case ROONEY:
  176. if (st.isStarted())
  177. {
  178. htmltext = (st.getQuestItemsCount(TORCH) >= 1200) ? "32049-02.html" : "32049-01.html";
  179. }
  180. break;
  181. case VULCAN:
  182. if (st.isCreated())
  183. {
  184. htmltext = (player.getLevel() >= 74) ? "31539-01.htm" : "31539-02.htm";
  185. }
  186. else
  187. {
  188. htmltext = (st.getQuestItemsCount(TORCH) >= 1000) ? "31539-04.html" : "31539-05.html";
  189. }
  190. break;
  191. case HILDA:
  192. if (st.isCreated())
  193. {
  194. htmltext = (player.getLevel() >= 74) ? "31271-01.htm" : "31271-02.htm";
  195. }
  196. else
  197. {
  198. htmltext = "31271-04.html";
  199. }
  200. break;
  201. }
  202. return htmltext;
  203. }
  204. }