Q00661_MakingTheHarvestGroundsSafe.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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.Q00661_MakingTheHarvestGroundsSafe;
  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.holders.ItemChanceHolder;
  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. * Making the Harvest Grounds Safe (661)
  30. * @author Pandragon
  31. */
  32. public final class Q00661_MakingTheHarvestGroundsSafe extends Quest
  33. {
  34. // NPC
  35. private static final int NORMAN = 30210;
  36. // Items
  37. private static final int BIG_HORNET_STING = 8283;
  38. private static final int CLOUD_GEM = 8284;
  39. private static final int YOUNG_ARANEID_CLAW = 8285;
  40. // Monsters
  41. private final Map<Integer, ItemChanceHolder> MONSTER_CHANCES = new HashMap<>();
  42. {
  43. MONSTER_CHANCES.put(21095, new ItemChanceHolder(BIG_HORNET_STING, 0.508)); // Giant Poison Bee
  44. MONSTER_CHANCES.put(21096, new ItemChanceHolder(CLOUD_GEM, 0.5)); // Cloudy Beast
  45. MONSTER_CHANCES.put(21097, new ItemChanceHolder(YOUNG_ARANEID_CLAW, 0.516)); // Young Araneid
  46. }
  47. // Misc
  48. private static final int MIN_LVL = 21;
  49. public Q00661_MakingTheHarvestGroundsSafe()
  50. {
  51. super(661, Q00661_MakingTheHarvestGroundsSafe.class.getSimpleName(), "Making the Harvest Grounds Safe");
  52. addStartNpc(NORMAN);
  53. addTalkId(NORMAN);
  54. addKillId(MONSTER_CHANCES.keySet());
  55. registerQuestItems(BIG_HORNET_STING, CLOUD_GEM, YOUNG_ARANEID_CLAW);
  56. }
  57. @Override
  58. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  59. {
  60. final QuestState qs = getQuestState(player, false);
  61. String htmltext = null;
  62. if (qs == null)
  63. {
  64. return htmltext;
  65. }
  66. switch (event)
  67. {
  68. case "30210-01.htm":
  69. case "30210-02.htm":
  70. case "30210-04.html":
  71. case "30210-06.html":
  72. {
  73. htmltext = event;
  74. break;
  75. }
  76. case "30210-03.htm":
  77. {
  78. if (qs.isCreated())
  79. {
  80. qs.startQuest();
  81. htmltext = event;
  82. }
  83. break;
  84. }
  85. case "30210-08.html":
  86. {
  87. long stingCount = getQuestItemsCount(player, BIG_HORNET_STING);
  88. long gemCount = getQuestItemsCount(player, CLOUD_GEM);
  89. long clawCount = getQuestItemsCount(player, YOUNG_ARANEID_CLAW);
  90. long reward = (57 * stingCount) + (56 * gemCount) + (60 * clawCount);
  91. if ((stingCount + gemCount + clawCount) >= 10)
  92. {
  93. reward += 5773;
  94. }
  95. takeItems(player, BIG_HORNET_STING, -1);
  96. takeItems(player, CLOUD_GEM, -1);
  97. takeItems(player, YOUNG_ARANEID_CLAW, -1);
  98. giveAdena(player, reward, true);
  99. htmltext = event;
  100. break;
  101. }
  102. case "30210-09.html":
  103. {
  104. qs.exitQuest(true, true);
  105. htmltext = event;
  106. break;
  107. }
  108. }
  109. return htmltext;
  110. }
  111. @Override
  112. public String onTalk(L2Npc npc, L2PcInstance talker)
  113. {
  114. final QuestState qs = getQuestState(talker, true);
  115. String htmltext = getNoQuestMsg(talker);
  116. switch (qs.getState())
  117. {
  118. case State.CREATED:
  119. {
  120. htmltext = (talker.getLevel() >= MIN_LVL) ? "30210-01.htm" : "30210-02.htm";
  121. break;
  122. }
  123. case State.STARTED:
  124. {
  125. if (hasQuestItems(talker, BIG_HORNET_STING, CLOUD_GEM, YOUNG_ARANEID_CLAW))
  126. {
  127. htmltext = "30210-04.html";
  128. }
  129. else
  130. {
  131. htmltext = "30210-05.html";
  132. }
  133. break;
  134. }
  135. }
  136. return htmltext;
  137. }
  138. @Override
  139. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  140. {
  141. final QuestState qs = getRandomPartyMemberState(killer, -1, 3, npc);
  142. if (qs != null)
  143. {
  144. final ItemChanceHolder item = MONSTER_CHANCES.get(npc.getId());
  145. giveItemRandomly(qs.getPlayer(), npc, item.getId(), item.getCount(), 0, item.getChance(), true);
  146. }
  147. return super.onKill(npc, killer, isSummon);
  148. }
  149. }