Q00269_InventionAmbition.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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.Q00269_InventionAmbition;
  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. * Invention Ambition (269)
  30. * @author xban1x
  31. */
  32. public final class Q00269_InventionAmbition extends Quest
  33. {
  34. // NPC
  35. private static final int INVENTOR_MARU = 32486;
  36. // Items
  37. private static final int ENERGY_ORE = 10866;
  38. // Monsters
  39. private static final Map<Integer, Integer> MONSTERS = new HashMap<>();
  40. static
  41. {
  42. MONSTERS.put(21124, 46); // Red Eye Barbed Bat
  43. MONSTERS.put(21125, 48); // Northern Trimden
  44. MONSTERS.put(21126, 50); // Kerope Werewolf
  45. MONSTERS.put(21127, 64); // Northern Goblin
  46. MONSTERS.put(21128, 66); // Spine Golem
  47. MONSTERS.put(21129, 68); // Kerope Werewolf Chief
  48. MONSTERS.put(21130, 76); // Northern Goblin Leader
  49. MONSTERS.put(21131, 78); // Enchanted Spine Golem
  50. }
  51. // Misc
  52. private static final int MIN_LVL = 18;
  53. public Q00269_InventionAmbition()
  54. {
  55. super(269, Q00269_InventionAmbition.class.getSimpleName(), "Invention Ambition");
  56. addStartNpc(INVENTOR_MARU);
  57. addTalkId(INVENTOR_MARU);
  58. addKillId(MONSTERS.keySet());
  59. registerQuestItems(ENERGY_ORE);
  60. }
  61. @Override
  62. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  63. {
  64. final QuestState st = getQuestState(player, false);
  65. String htmltext = null;
  66. if (st != null)
  67. {
  68. switch (event)
  69. {
  70. case "32486-03.htm":
  71. {
  72. htmltext = (player.getLevel() >= MIN_LVL) ? event : null;
  73. break;
  74. }
  75. case "32486-04.htm":
  76. {
  77. st.startQuest();
  78. htmltext = event;
  79. break;
  80. }
  81. case "32486-07.html":
  82. {
  83. st.exitQuest(true, true);
  84. htmltext = event;
  85. break;
  86. }
  87. case "32486-08.html":
  88. {
  89. htmltext = event;
  90. break;
  91. }
  92. }
  93. }
  94. return htmltext;
  95. }
  96. @Override
  97. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  98. {
  99. final QuestState st = getQuestState(killer, false);
  100. if ((st != null) && (getRandom(100) < MONSTERS.get(npc.getId())))
  101. {
  102. st.giveItems(ENERGY_ORE, 1);
  103. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  104. }
  105. return super.onKill(npc, killer, isSummon);
  106. }
  107. @Override
  108. public String onTalk(L2Npc npc, L2PcInstance player)
  109. {
  110. final QuestState st = getQuestState(player, true);
  111. String htmltext = getNoQuestMsg(player);
  112. if (st != null)
  113. {
  114. switch (st.getState())
  115. {
  116. case State.CREATED:
  117. {
  118. htmltext = (player.getLevel() >= MIN_LVL) ? "32486-01.htm" : "32486-02.html";
  119. break;
  120. }
  121. case State.STARTED:
  122. {
  123. if (st.hasQuestItems(ENERGY_ORE))
  124. {
  125. final long count = st.getQuestItemsCount(ENERGY_ORE);
  126. st.giveAdena((count * 50) + (count >= 10 ? 2044 : null), true);
  127. st.takeItems(ENERGY_ORE, -1);
  128. htmltext = "32486-06.html";
  129. }
  130. else
  131. {
  132. htmltext = "32486-05.html";
  133. }
  134. break;
  135. }
  136. }
  137. }
  138. return htmltext;
  139. }
  140. }