Q00360_PlunderTheirSupplies.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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.Q00360_PlunderTheirSupplies;
  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. import com.l2jserver.gameserver.util.Util;
  29. /**
  30. * Plunder Supplies (360)
  31. * @author netvirus
  32. */
  33. public final class Q00360_PlunderTheirSupplies extends Quest
  34. {
  35. // Npc
  36. private static final int COLEMAN = 30873;
  37. // Misc
  38. private static final int MIN_LVL = 52;
  39. // Monsters
  40. private static final Map<Integer, Integer> MONSTER_DROP_CHANCES = new HashMap<>();
  41. // Items
  42. private static final int RECIPE_OF_SUPPLY = 5870;
  43. private static final int SUPPLY_ITEMS = 5872;
  44. private static final int SUSPICIOUS_DOCUMENT_PIECE = 5871;
  45. static
  46. {
  47. MONSTER_DROP_CHANCES.put(20666, 50); // Taik Orc Seeker
  48. MONSTER_DROP_CHANCES.put(20669, 75); // Taik Orc Supply Leader
  49. }
  50. public Q00360_PlunderTheirSupplies()
  51. {
  52. super(360, Q00360_PlunderTheirSupplies.class.getSimpleName(), "Plunder Their Supplies");
  53. addStartNpc(COLEMAN);
  54. addTalkId(COLEMAN);
  55. addKillId(MONSTER_DROP_CHANCES.keySet());
  56. registerQuestItems(SUPPLY_ITEMS, SUSPICIOUS_DOCUMENT_PIECE, RECIPE_OF_SUPPLY);
  57. }
  58. @Override
  59. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  60. {
  61. final QuestState st = getQuestState(player, false);
  62. String htmltext = null;
  63. if (st == null)
  64. {
  65. return htmltext;
  66. }
  67. switch (event)
  68. {
  69. case "30873-03.htm":
  70. case "30873-09.html":
  71. {
  72. htmltext = event;
  73. break;
  74. }
  75. case "30873-04.htm":
  76. {
  77. st.startQuest();
  78. htmltext = event;
  79. break;
  80. }
  81. case "30873-10.html":
  82. {
  83. st.exitQuest(false, true);
  84. htmltext = event;
  85. break;
  86. }
  87. }
  88. return htmltext;
  89. }
  90. @Override
  91. public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet)
  92. {
  93. final QuestState st = getQuestState(killer, false);
  94. if ((st == null) || !Util.checkIfInRange(1500, npc, killer, false))
  95. {
  96. return super.onKill(npc, killer, isPet);
  97. }
  98. if (getRandom(100) < MONSTER_DROP_CHANCES.get(npc.getId()))
  99. {
  100. st.giveItems(SUPPLY_ITEMS, 1);
  101. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  102. }
  103. if (getRandom(100) < 10)
  104. {
  105. if (st.getQuestItemsCount(SUSPICIOUS_DOCUMENT_PIECE) < 4)
  106. {
  107. st.giveItems(SUSPICIOUS_DOCUMENT_PIECE, 1);
  108. }
  109. else
  110. {
  111. st.giveItems(RECIPE_OF_SUPPLY, 1);
  112. st.takeItems(SUSPICIOUS_DOCUMENT_PIECE, -1);
  113. }
  114. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  115. }
  116. return super.onKill(npc, killer, isPet);
  117. }
  118. @Override
  119. public String onTalk(L2Npc npc, L2PcInstance player)
  120. {
  121. final QuestState st = getQuestState(player, true);
  122. String htmltext = getNoQuestMsg(player);
  123. if (st == null)
  124. {
  125. return htmltext;
  126. }
  127. switch (st.getState())
  128. {
  129. case State.CREATED:
  130. {
  131. htmltext = (player.getLevel() >= MIN_LVL) ? "30873-02.htm" : "30873-01.html";
  132. break;
  133. }
  134. case State.STARTED:
  135. {
  136. final long supplyCount = st.getQuestItemsCount(SUPPLY_ITEMS);
  137. final long recipeCount = st.getQuestItemsCount(RECIPE_OF_SUPPLY);
  138. if (supplyCount == 0)
  139. {
  140. if (recipeCount == 0)
  141. {
  142. htmltext = "30873-05.html";
  143. }
  144. else
  145. {
  146. st.giveAdena((recipeCount * 6000), true);
  147. st.takeItems(RECIPE_OF_SUPPLY, -1);
  148. htmltext = "30873-08.html";
  149. }
  150. }
  151. else
  152. {
  153. if (recipeCount == 0)
  154. {
  155. st.giveAdena(((supplyCount * 100) + 6000), true);
  156. st.takeItems(SUPPLY_ITEMS, -1);
  157. htmltext = "30873-06.html";
  158. }
  159. else
  160. {
  161. st.giveAdena((((supplyCount * 100) + 6000) + (recipeCount * 6000)), true);
  162. st.takeItems(SUPPLY_ITEMS, -1);
  163. st.takeItems(RECIPE_OF_SUPPLY, -1);
  164. htmltext = "30873-07.html";
  165. }
  166. }
  167. break;
  168. }
  169. }
  170. return htmltext;
  171. }
  172. }