Q00624_TheFinestIngredientsPart1.java 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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.Q00624_TheFinestIngredientsPart1;
  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. * The Finest Ingredients - Part 1.
  30. * @author Citizen, jurchiks, xban1x
  31. */
  32. public final class Q00624_TheFinestIngredientsPart1 extends Quest
  33. {
  34. // NPC
  35. private static final int JEREMY = 31521;
  36. // Items
  37. private static final int TRUNK_OF_NEPENTHES = 7202;
  38. private static final int FOOT_OF_BANDERSNATCHLING = 7203;
  39. private static final int SECRET_SPICE = 7204;
  40. // Rewards
  41. private static final int ICE_CRYSTAL = 7080;
  42. private static final int SOY_SAUCE_JAR = 7205;
  43. // Misc
  44. private static final int MIN_LVL = 73;
  45. private static final Map<Integer, Integer> MONSTER_DROPS = new HashMap<>();
  46. static
  47. {
  48. MONSTER_DROPS.put(21314, FOOT_OF_BANDERSNATCHLING); // Hot Springs Bandersnatchling
  49. MONSTER_DROPS.put(21317, SECRET_SPICE); // Hot Springs Atroxspawn
  50. MONSTER_DROPS.put(21319, TRUNK_OF_NEPENTHES); // Hot Springs Nepenthes
  51. MONSTER_DROPS.put(21321, SECRET_SPICE); // Hot Springs Atrox
  52. }
  53. public Q00624_TheFinestIngredientsPart1()
  54. {
  55. super(624, Q00624_TheFinestIngredientsPart1.class.getSimpleName(), "The Finest Ingredients - Part 1");
  56. addStartNpc(JEREMY);
  57. addTalkId(JEREMY);
  58. addKillId(MONSTER_DROPS.keySet());
  59. registerQuestItems(TRUNK_OF_NEPENTHES, FOOT_OF_BANDERSNATCHLING, SECRET_SPICE);
  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 "31521-02.htm":
  71. {
  72. st.startQuest();
  73. htmltext = event;
  74. break;
  75. }
  76. case "31521-05.html":
  77. {
  78. if (st.isCond(2) && (getQuestItemsCount(player, getRegisteredItemIds()) == 150))
  79. {
  80. st.giveItems(ICE_CRYSTAL, 1);
  81. st.giveItems(SOY_SAUCE_JAR, 1);
  82. st.exitQuest(true, true);
  83. htmltext = "31521-05.html";
  84. }
  85. else
  86. {
  87. htmltext = "31521-06.html";
  88. }
  89. break;
  90. }
  91. }
  92. }
  93. return htmltext;
  94. }
  95. @Override
  96. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  97. {
  98. final L2PcInstance partyMember = getRandomPartyMember(killer, 1);
  99. if ((partyMember != null) && partyMember.isInsideRadius(npc, 1500, true, false))
  100. {
  101. final int item = MONSTER_DROPS.get(npc.getId());
  102. final long count = getQuestItemsCount(partyMember, item);
  103. if ((count + 1) >= 50)
  104. {
  105. if (count < 50)
  106. {
  107. giveItems(partyMember, item, 50 - count);
  108. playSound(partyMember, QuestSound.ITEMSOUND_QUEST_FANFARE_MIDDLE);
  109. }
  110. if (getQuestItemsCount(partyMember, getRegisteredItemIds()) == 150)
  111. {
  112. getQuestState(partyMember, false).setCond(2, true);
  113. }
  114. }
  115. else
  116. {
  117. giveItems(partyMember, item, 1);
  118. playSound(partyMember, QuestSound.ITEMSOUND_QUEST_ITEMGET);
  119. }
  120. }
  121. return super.onKill(npc, killer, isSummon);
  122. }
  123. @Override
  124. public String onTalk(L2Npc npc, L2PcInstance player)
  125. {
  126. final QuestState st = getQuestState(player, true);
  127. String htmltext = getNoQuestMsg(player);
  128. if (st != null)
  129. {
  130. switch (st.getState())
  131. {
  132. case State.CREATED:
  133. {
  134. htmltext = (player.getLevel() >= MIN_LVL) ? "31521-01.htm" : "31521-00.htm";
  135. break;
  136. }
  137. case State.STARTED:
  138. {
  139. switch (st.getCond())
  140. {
  141. case 1:
  142. {
  143. htmltext = "31521-03.html";
  144. break;
  145. }
  146. case 2:
  147. {
  148. htmltext = "31521-04.html";
  149. break;
  150. }
  151. }
  152. break;
  153. }
  154. }
  155. }
  156. return htmltext;
  157. }
  158. }