Q00642_APowerfulPrimevalCreature.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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.Q00642_APowerfulPrimevalCreature;
  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. * A Powerful Primeval Creature (642)
  28. * @author Adry_85
  29. */
  30. public class Q00642_APowerfulPrimevalCreature extends Quest
  31. {
  32. // NPC
  33. private static final int DINN = 32105;
  34. // Items
  35. private static final int DINOSAUR_TISSUE = 8774;
  36. private static final int DINOSAUR_EGG = 8775;
  37. // Misc
  38. private static final int MIN_LEVEL = 75;
  39. // Mobs
  40. private static final int ANCIENT_EGG = 18344;
  41. private static final Map<Integer, Double> MOBS_TISSUE = new HashMap<>();
  42. static
  43. {
  44. MOBS_TISSUE.put(22196, 0.309); // Velociraptor
  45. MOBS_TISSUE.put(22197, 0.309); // Velociraptor
  46. MOBS_TISSUE.put(22198, 0.309); // Velociraptor
  47. MOBS_TISSUE.put(22199, 0.309); // Pterosaur
  48. MOBS_TISSUE.put(22215, 0.988); // Tyrannosaurus
  49. MOBS_TISSUE.put(22216, 0.988); // Tyrannosaurus
  50. MOBS_TISSUE.put(22217, 0.988); // Tyrannosaurus
  51. MOBS_TISSUE.put(22218, 0.309); // Velociraptor
  52. MOBS_TISSUE.put(22223, 0.309); // Velociraptor
  53. }
  54. public Q00642_APowerfulPrimevalCreature()
  55. {
  56. super(642, Q00642_APowerfulPrimevalCreature.class.getSimpleName(), "A Powerful Primeval Creature");
  57. addStartNpc(DINN);
  58. addTalkId(DINN);
  59. addKillId(ANCIENT_EGG);
  60. addKillId(MOBS_TISSUE.keySet());
  61. registerQuestItems(DINOSAUR_TISSUE, DINOSAUR_EGG);
  62. }
  63. @Override
  64. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  65. {
  66. final QuestState qs = getQuestState(player, false);
  67. if (qs == null)
  68. {
  69. return null;
  70. }
  71. String htmltext = event;
  72. switch (event)
  73. {
  74. case "32105-05.html":
  75. {
  76. qs.startQuest();
  77. break;
  78. }
  79. case "32105-06.htm":
  80. {
  81. qs.exitQuest(true);
  82. break;
  83. }
  84. case "32105-09.html":
  85. {
  86. if (hasQuestItems(player, DINOSAUR_TISSUE))
  87. {
  88. giveAdena(player, 5000 * getQuestItemsCount(player, DINOSAUR_TISSUE), true);
  89. takeItems(player, DINOSAUR_TISSUE, -1);
  90. }
  91. else
  92. {
  93. htmltext = "32105-14.html";
  94. }
  95. break;
  96. }
  97. case "exit":
  98. {
  99. if (hasQuestItems(player, DINOSAUR_TISSUE))
  100. {
  101. giveAdena(player, 5000 * getQuestItemsCount(player, DINOSAUR_TISSUE), true);
  102. qs.exitQuest(true, true);
  103. htmltext = "32105-12.html";
  104. }
  105. else
  106. {
  107. qs.exitQuest(true, true);
  108. htmltext = "32105-13.html";
  109. }
  110. break;
  111. }
  112. }
  113. return htmltext;
  114. }
  115. @Override
  116. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  117. {
  118. final QuestState qs = getRandomPartyMemberState(killer, -1, 3, npc);
  119. if (qs == null)
  120. {
  121. return null;
  122. }
  123. int npcId = npc.getId();
  124. if (MOBS_TISSUE.containsKey(npcId))
  125. {
  126. giveItemRandomly(qs.getPlayer(), npc, DINOSAUR_TISSUE, 1, 0, MOBS_TISSUE.get(npcId), true);
  127. }
  128. else
  129. {
  130. giveItemRandomly(qs.getPlayer(), npc, DINOSAUR_EGG, 1, 0, 1.0, true);
  131. }
  132. return super.onKill(npc, killer, isSummon);
  133. }
  134. @Override
  135. public String onTalk(L2Npc npc, L2PcInstance player)
  136. {
  137. QuestState qs = getQuestState(player, true);
  138. String htmltext = getNoQuestMsg(player);
  139. if (qs.isCreated())
  140. {
  141. htmltext = player.getLevel() < MIN_LEVEL ? "32105-01.htm" : "32105-02.htm";
  142. }
  143. else if (qs.isStarted())
  144. {
  145. htmltext = (hasAtLeastOneQuestItem(player, DINOSAUR_TISSUE, DINOSAUR_EGG)) ? "32105-08.html" : "32105-07.html";
  146. }
  147. return htmltext;
  148. }
  149. }