Q00631_DeliciousTopChoiceMeat.java 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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.Q00631_DeliciousTopChoiceMeat;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.quest.Quest;
  25. import com.l2jserver.gameserver.model.quest.QuestState;
  26. /**
  27. * Delicious Top Choice Meat (631)
  28. * @author Adry_85
  29. */
  30. public class Q00631_DeliciousTopChoiceMeat extends Quest
  31. {
  32. // NPC
  33. private static final int TUNATUN = 31537;
  34. // Items
  35. private static final int TOP_QUALITY_MEAT = 7546;
  36. private static final int PRIME_MEAT = 15534;
  37. // Misc
  38. private static final int MIN_LEVEL = 82;
  39. private static final int PRIME_MEAT_COUNT = 120;
  40. // Rewards
  41. private static final int[] RECIPE =
  42. {
  43. 10373, // Recipe - Icarus Sawsword (60%)
  44. 10374, // Recipe - Icarus Disperser (60%)
  45. 10375, // Recipe - Icarus Spirit (60%)
  46. 10376, // Recipe - Icarus Heavy Arms (60%)
  47. 10377, // Recipe - Icarus Trident (60%)
  48. 10378, // Recipe - Icarus Hammer (60%)
  49. 10379, // Recipe - Icarus Hand (60%)
  50. 10380, // Recipe - Icarus Hall (60%)
  51. 10381, // Recipe - Icarus Spitter (60%)
  52. };
  53. private static final int[] PIECE =
  54. {
  55. 10397, // Icarus Sawsword Piece
  56. 10398, // Icarus Disperser Piece
  57. 10399, // Icarus Spirit Piece
  58. 10400, // Icarus Heavy Arms Piece
  59. 10401, // Icarus Trident Piece
  60. 10402, // Icarus Hammer Piece
  61. 10403, // Icarus Hand Piece
  62. 10404, // Icarus Hall Piece
  63. 10405, // Icarus Spitter Piece
  64. };
  65. private static final int GOLDEN_SPICE_CRATE = 15482;
  66. private static final int CRYSTAL_SPICE_COMPRESSED_PACK = 15483;
  67. private static final Map<Integer, Double> MOBS_MEAT = new HashMap<>();
  68. static
  69. {
  70. MOBS_MEAT.put(18878, 0.172); // Full Grown Kookaburra
  71. MOBS_MEAT.put(18879, 0.334); // Full Grown Kookaburra
  72. MOBS_MEAT.put(18885, 0.172); // Full Grown Cougar
  73. MOBS_MEAT.put(18886, 0.334); // Full Grown Cougar
  74. MOBS_MEAT.put(18892, 0.182); // Full Grown Buffalo
  75. MOBS_MEAT.put(18893, 0.349); // Full Grown Buffalo
  76. MOBS_MEAT.put(18899, 0.182); // Full Grown Grendel
  77. MOBS_MEAT.put(18900, 0.349); // Full Grown Grendel
  78. }
  79. public Q00631_DeliciousTopChoiceMeat()
  80. {
  81. super(631, Q00631_DeliciousTopChoiceMeat.class.getSimpleName(), "Delicious Top Choice Meat");
  82. addStartNpc(TUNATUN);
  83. addTalkId(TUNATUN);
  84. addKillId(MOBS_MEAT.keySet());
  85. registerQuestItems(TOP_QUALITY_MEAT, PRIME_MEAT);
  86. }
  87. @Override
  88. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  89. {
  90. final QuestState st = getQuestState(player, false);
  91. if (st == null)
  92. {
  93. return null;
  94. }
  95. String htmltext = null;
  96. switch (event)
  97. {
  98. case "quest_accept":
  99. {
  100. if (player.getLevel() >= MIN_LEVEL)
  101. {
  102. st.startQuest();
  103. htmltext = "31537-02.html";
  104. }
  105. else
  106. {
  107. htmltext = "31537-03.html";
  108. }
  109. break;
  110. }
  111. case "31537-06.html":
  112. {
  113. if (st.isCond(2) && (getQuestItemsCount(player, PRIME_MEAT) >= PRIME_MEAT_COUNT))
  114. {
  115. switch (getRandom(10))
  116. {
  117. case 0:
  118. {
  119. st.rewardItems(RECIPE[getRandom(RECIPE.length)], 1);
  120. break;
  121. }
  122. case 1:
  123. {
  124. st.rewardItems(PIECE[getRandom(PIECE.length)], 1);
  125. break;
  126. }
  127. case 2:
  128. {
  129. st.rewardItems(PIECE[getRandom(PIECE.length)], 2);
  130. break;
  131. }
  132. case 3:
  133. {
  134. st.rewardItems(PIECE[getRandom(PIECE.length)], 3);
  135. break;
  136. }
  137. case 4:
  138. {
  139. st.rewardItems(PIECE[getRandom(PIECE.length)], getRandom(5) + 2);
  140. break;
  141. }
  142. case 5:
  143. {
  144. st.rewardItems(PIECE[getRandom(PIECE.length)], getRandom(7) + 2);
  145. break;
  146. }
  147. case 6:
  148. {
  149. st.rewardItems(GOLDEN_SPICE_CRATE, 1);
  150. break;
  151. }
  152. case 7:
  153. {
  154. st.rewardItems(GOLDEN_SPICE_CRATE, 2);
  155. break;
  156. }
  157. case 8:
  158. {
  159. st.rewardItems(CRYSTAL_SPICE_COMPRESSED_PACK, 1);
  160. break;
  161. }
  162. case 9:
  163. {
  164. st.rewardItems(CRYSTAL_SPICE_COMPRESSED_PACK, 2);
  165. break;
  166. }
  167. }
  168. st.exitQuest(true, true);
  169. htmltext = event;
  170. }
  171. break;
  172. }
  173. }
  174. return htmltext;
  175. }
  176. @Override
  177. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  178. {
  179. final QuestState st = getRandomPartyMemberState(player, 1, 3, npc);
  180. if (st != null)
  181. {
  182. if (st.giveItemRandomly(npc, PRIME_MEAT, 1, PRIME_MEAT_COUNT, MOBS_MEAT.get(npc.getId()), true))
  183. {
  184. st.setCond(2, true);
  185. }
  186. }
  187. return super.onKill(npc, player, isSummon);
  188. }
  189. @Override
  190. public String onTalk(L2Npc npc, L2PcInstance player)
  191. {
  192. final QuestState st = getQuestState(player, true);
  193. String htmltext = getNoQuestMsg(player);
  194. if (st == null)
  195. {
  196. return htmltext;
  197. }
  198. if (st.isCreated())
  199. {
  200. htmltext = "31537-01.htm";
  201. }
  202. else if (st.isStarted())
  203. {
  204. if (st.isCond(1))
  205. {
  206. if (st.getQuestItemsCount(PRIME_MEAT) < PRIME_MEAT_COUNT)
  207. {
  208. htmltext = "31537-04.html";
  209. }
  210. }
  211. else if (st.isCond(2))
  212. {
  213. if (st.getQuestItemsCount(PRIME_MEAT) >= PRIME_MEAT_COUNT)
  214. {
  215. htmltext = "31537-05.html";
  216. }
  217. }
  218. }
  219. return htmltext;
  220. }
  221. }