Q00647_InfluxOfMachines.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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.Q00647_InfluxOfMachines;
  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. import com.l2jserver.gameserver.model.quest.State;
  28. /**
  29. * Influx of Machines (647)
  30. * @author malyelfik
  31. */
  32. public class Q00647_InfluxOfMachines extends Quest
  33. {
  34. // NPC
  35. private static final int GUTENHAGEN = 32069;
  36. // Monsters
  37. private static final Map<Integer, Integer> MOBS = new HashMap<>();
  38. static
  39. {
  40. MOBS.put(22801, 280); // Cruel Pincer Golem
  41. MOBS.put(22802, 227); // Cruel Pincer Golem
  42. MOBS.put(22803, 286); // Cruel Pincer Golem
  43. MOBS.put(22804, 288); // Horrifying Jackhammer Golem
  44. MOBS.put(22805, 235); // Horrifying Jackhammer Golem
  45. MOBS.put(22806, 295); // Horrifying Jackhammer Golem
  46. MOBS.put(22807, 273); // Scout-type Golem No. 28
  47. MOBS.put(22808, 143); // Scout-type Golem No. 2
  48. MOBS.put(22809, 629); // Guard Golem
  49. MOBS.put(22810, 465); // Micro Scout Golem
  50. MOBS.put(22811, 849); // Great Chaos Golem
  51. MOBS.put(22812, 463); // Boom Golem
  52. }
  53. // Item
  54. private static final int BROKEN_GOLEM_FRAGMENT = 15521;
  55. private static final int[] RECIPES =
  56. {
  57. 6881, // Recipe: Forgotten Blade (60%)
  58. 6883, // Recipe: Basalt Battlehammer (60%)
  59. 6885, // Recipe: Imperial Staff (60%)
  60. 6887, // Recipe: Angel Slayer (60%)
  61. 6891, // Recipe: Dragon Hunter Axe (60%)
  62. 6893, // Recipe: Saint Spear (60%)
  63. 6895, // Recipe: Demon Splinter (60%)
  64. 6897, // Recipe: Heavens Divider (60%)
  65. 6899, // Recipe: Arcana Mace (60%)
  66. 7580, // Recipe: Draconic Bow (60%)
  67. };
  68. // Misc
  69. private static final int MIN_LEVEL = 70;
  70. private static final int FRAGMENT_COUNT = 500;
  71. public Q00647_InfluxOfMachines()
  72. {
  73. super(647, Q00647_InfluxOfMachines.class.getSimpleName(), "Influx of Machines");
  74. addStartNpc(GUTENHAGEN);
  75. addTalkId(GUTENHAGEN);
  76. addKillId(MOBS.keySet());
  77. registerQuestItems(BROKEN_GOLEM_FRAGMENT);
  78. }
  79. @Override
  80. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  81. {
  82. final QuestState st = getQuestState(player, false);
  83. if (st == null)
  84. {
  85. return null;
  86. }
  87. String htmltext = null;
  88. switch (event)
  89. {
  90. case "32069-03.htm":
  91. st.startQuest();
  92. htmltext = event;
  93. break;
  94. case "32069-06.html":
  95. if (st.isCond(2) && (st.getQuestItemsCount(BROKEN_GOLEM_FRAGMENT) >= FRAGMENT_COUNT))
  96. {
  97. st.giveItems(RECIPES[getRandom(RECIPES.length)], 1);
  98. st.exitQuest(true, true);
  99. htmltext = event;
  100. }
  101. else
  102. {
  103. htmltext = "32069-07.html";
  104. }
  105. break;
  106. }
  107. return htmltext;
  108. }
  109. @Override
  110. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  111. {
  112. final L2PcInstance member = getRandomPartyMember(player, 1);
  113. if (member != null)
  114. {
  115. final QuestState st = getQuestState(member, false);
  116. if (st.isCond(1) && (getRandom(1000) < MOBS.get(npc.getId())))
  117. {
  118. st.giveItems(BROKEN_GOLEM_FRAGMENT, 1);
  119. if (st.getQuestItemsCount(BROKEN_GOLEM_FRAGMENT) >= FRAGMENT_COUNT)
  120. {
  121. st.setCond(2, true);
  122. }
  123. else
  124. {
  125. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  126. }
  127. }
  128. }
  129. return super.onKill(npc, player, isSummon);
  130. }
  131. @Override
  132. public String onTalk(L2Npc npc, L2PcInstance player)
  133. {
  134. String htmltext = getNoQuestMsg(player);
  135. final QuestState st = getQuestState(player, true);
  136. if (st == null)
  137. {
  138. return htmltext;
  139. }
  140. switch (st.getState())
  141. {
  142. case State.CREATED:
  143. htmltext = (player.getLevel() >= MIN_LEVEL) ? "32069-01.htm" : "32069-02.htm";
  144. break;
  145. case State.STARTED:
  146. if (st.isCond(1))
  147. {
  148. htmltext = "32069-04.html";
  149. }
  150. else if (st.isCond(2) && (st.getQuestItemsCount(BROKEN_GOLEM_FRAGMENT) >= FRAGMENT_COUNT))
  151. {
  152. htmltext = "32069-05.html";
  153. }
  154. break;
  155. }
  156. return htmltext;
  157. }
  158. }