Q00643_RiseAndFallOfTheElrokiTribe.java 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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.Q00643_RiseAndFallOfTheElrokiTribe;
  20. import com.l2jserver.Config;
  21. import com.l2jserver.gameserver.enums.QuestSound;
  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. import com.l2jserver.gameserver.model.quest.State;
  27. import com.l2jserver.gameserver.util.Util;
  28. /**
  29. * Rise and Fall of the Elroki Tribe (643)
  30. * @author Adry_85
  31. */
  32. public class Q00643_RiseAndFallOfTheElrokiTribe extends Quest
  33. {
  34. // NPCs
  35. private static final int SINGSING = 32106;
  36. private static final int KARAKAWEI = 32117;
  37. // Item
  38. private static final int BONES_OF_A_PLAINS_DINOSAUR = 8776;
  39. // Misc
  40. private static final int MIN_LEVEL = 75;
  41. private static final int CHANCE_MOBS1 = 116;
  42. private static final int CHANCE_MOBS2 = 360;
  43. private static final int CHANCE_DEINO = 558;
  44. private boolean isFirstTalk = true;
  45. // Rewards
  46. private static final int[] PIECE =
  47. {
  48. 8712, // Sirra's Blade Edge
  49. 8713, // Sword of Ipos Blade
  50. 8714, // Barakiel's Axe Piece
  51. 8715, // Behemoth's Tuning Fork Piece
  52. 8716, // Naga Storm Piece
  53. 8717, // Tiphon's Spear Edge
  54. 8718, // Shyeed's Bow Shaft
  55. 8719, // Sobekk's Hurricane Edge
  56. 8720, // Themis' Tongue Piece
  57. 8721, // Cabrio's Hand Head
  58. 8722, // Daimon Crystal Fragment
  59. };
  60. // Mobs
  61. private static final int[] MOBS1 =
  62. {
  63. 22200, // Ornithomimus
  64. 22201, // Ornithomimus
  65. 22202, // Ornithomimus
  66. 22204, // Deinonychus
  67. 22205, // Deinonychus
  68. 22208, // Pachycephalosaurus
  69. 22209, // Pachycephalosaurus
  70. 22210, // Pachycephalosaurus
  71. 22211, // Wild Strider
  72. 22212, // Wild Strider
  73. 22213, // Wild Strider
  74. 22219, // Ornithomimus
  75. 22220, // Deinonychus
  76. 22221, // Pachycephalosaurus
  77. 22222, // Wild Strider
  78. 22224, // Ornithomimus
  79. 22225, // Deinonychus
  80. 22226, // Pachycephalosaurus
  81. 22227, // Wild Strider
  82. };
  83. private static final int[] MOBS2 =
  84. {
  85. 22742, // Ornithomimus
  86. 22743, // Deinonychus
  87. 22744, // Ornithomimus
  88. 22745, // Deinonychus
  89. };
  90. private static final int DEINONYCHUS = 22203;
  91. public Q00643_RiseAndFallOfTheElrokiTribe()
  92. {
  93. super(643, Q00643_RiseAndFallOfTheElrokiTribe.class.getSimpleName(), "Rise and Fall of the Elroki Tribe");
  94. addStartNpc(SINGSING);
  95. addTalkId(SINGSING, KARAKAWEI);
  96. addKillId(MOBS1);
  97. addKillId(MOBS2);
  98. addKillId(DEINONYCHUS);
  99. registerQuestItems(BONES_OF_A_PLAINS_DINOSAUR);
  100. }
  101. @Override
  102. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  103. {
  104. final QuestState st = getQuestState(player, false);
  105. if (st == null)
  106. {
  107. return null;
  108. }
  109. String htmltext = null;
  110. switch (event)
  111. {
  112. case "32106-02.htm":
  113. case "32106-04.htm":
  114. case "32106-05.html":
  115. case "32106-10.html":
  116. case "32106-13.html":
  117. case "32117-02.html":
  118. case "32117-06.html":
  119. case "32117-07.html":
  120. {
  121. htmltext = event;
  122. break;
  123. }
  124. case "quest_accept":
  125. {
  126. if (player.getLevel() >= MIN_LEVEL)
  127. {
  128. st.startQuest();
  129. htmltext = "32106-03.html";
  130. }
  131. else
  132. {
  133. htmltext = "32106-07.html";
  134. }
  135. break;
  136. }
  137. case "32106-09.html":
  138. {
  139. st.giveAdena(1374 * st.getQuestItemsCount(BONES_OF_A_PLAINS_DINOSAUR), true);
  140. st.takeItems(BONES_OF_A_PLAINS_DINOSAUR, -1);
  141. htmltext = event;
  142. break;
  143. }
  144. case "exit":
  145. {
  146. if (!st.hasQuestItems(BONES_OF_A_PLAINS_DINOSAUR))
  147. {
  148. htmltext = "32106-11.html";
  149. }
  150. else
  151. {
  152. st.giveAdena(1374 * st.getQuestItemsCount(BONES_OF_A_PLAINS_DINOSAUR), true);
  153. htmltext = "32106-12.html";
  154. }
  155. st.exitQuest(true, true);
  156. break;
  157. }
  158. case "exchange":
  159. {
  160. if (st.getQuestItemsCount(BONES_OF_A_PLAINS_DINOSAUR) < 300)
  161. {
  162. htmltext = "32117-04.html";
  163. }
  164. else
  165. {
  166. st.rewardItems(PIECE[getRandom(PIECE.length)], 5);
  167. st.takeItems(BONES_OF_A_PLAINS_DINOSAUR, 300);
  168. st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
  169. htmltext = "32117-05.html";
  170. }
  171. break;
  172. }
  173. }
  174. return htmltext;
  175. }
  176. @Override
  177. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  178. {
  179. final L2PcInstance partyMember = getRandomPartyMember(player, 1);
  180. if (partyMember == null)
  181. {
  182. return super.onKill(npc, player, isSummon);
  183. }
  184. final QuestState st = getQuestState(partyMember, false);
  185. int npcId = npc.getId();
  186. if (Util.contains(MOBS1, npcId))
  187. {
  188. float chance = (CHANCE_MOBS1 * Config.RATE_QUEST_DROP);
  189. if (getRandom(1000) < chance)
  190. {
  191. st.rewardItems(BONES_OF_A_PLAINS_DINOSAUR, 2);
  192. }
  193. else
  194. {
  195. st.rewardItems(BONES_OF_A_PLAINS_DINOSAUR, 1);
  196. }
  197. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  198. }
  199. if (Util.contains(MOBS2, npcId))
  200. {
  201. float chance = (CHANCE_MOBS2 * Config.RATE_QUEST_DROP);
  202. if (getRandom(1000) < chance)
  203. {
  204. st.rewardItems(BONES_OF_A_PLAINS_DINOSAUR, 1);
  205. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  206. }
  207. }
  208. if (npcId == DEINONYCHUS)
  209. {
  210. float chance = (CHANCE_DEINO * Config.RATE_QUEST_DROP);
  211. if (getRandom(1000) < chance)
  212. {
  213. st.rewardItems(BONES_OF_A_PLAINS_DINOSAUR, 1);
  214. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  215. }
  216. }
  217. return super.onKill(npc, player, isSummon);
  218. }
  219. @Override
  220. public String onTalk(L2Npc npc, L2PcInstance player)
  221. {
  222. final QuestState st = getQuestState(player, true);
  223. String htmltext = getNoQuestMsg(player);
  224. if (st == null)
  225. {
  226. return htmltext;
  227. }
  228. switch (st.getState())
  229. {
  230. case State.CREATED:
  231. {
  232. htmltext = (player.getLevel() >= MIN_LEVEL) ? "32106-01.htm" : "32106-06.html";
  233. break;
  234. }
  235. case State.STARTED:
  236. {
  237. if (npc.getId() == SINGSING)
  238. {
  239. htmltext = (st.hasQuestItems(BONES_OF_A_PLAINS_DINOSAUR)) ? "32106-08.html" : "32106-14.html";
  240. }
  241. else if (npc.getId() == KARAKAWEI)
  242. {
  243. if (isFirstTalk)
  244. {
  245. isFirstTalk = false;
  246. htmltext = "32117-01.html";
  247. }
  248. else
  249. {
  250. htmltext = "32117-03.html";
  251. }
  252. }
  253. break;
  254. }
  255. }
  256. return htmltext;
  257. }
  258. }