Q00644_GraveRobberAnnihilation.java 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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.Q00644_GraveRobberAnnihilation;
  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.ItemHolder;
  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. * Grave Robber Annihilation (644)
  30. * @author netvirus
  31. */
  32. public final class Q00644_GraveRobberAnnihilation extends Quest
  33. {
  34. // NPC
  35. private static final int KARUDA = 32017;
  36. // Item
  37. private static final int ORC_GOODS = 8088;
  38. // Misc
  39. private static final int MIN_LVL = 20;
  40. private static final int ORC_GOODS_REQUIRED_COUNT = 120;
  41. // Monsters
  42. private static final Map<Integer, Double> MONSTER_DROP_CHANCES = new HashMap<>();
  43. // Rewards
  44. private static final Map<String, ItemHolder> REWARDS = new HashMap<>();
  45. static
  46. {
  47. MONSTER_DROP_CHANCES.put(22003, 0.714); // Grave Robber Scout
  48. MONSTER_DROP_CHANCES.put(22004, 0.841); // Grave Robber Lookout
  49. MONSTER_DROP_CHANCES.put(22005, 0.778); // Grave Robber Ranger
  50. MONSTER_DROP_CHANCES.put(22006, 0.746); // Grave Robber Guard
  51. MONSTER_DROP_CHANCES.put(22008, 0.810); // Grave Robber Fighter
  52. REWARDS.put("varnish", new ItemHolder(1865, 30)); // Varnish
  53. REWARDS.put("animalskin", new ItemHolder(1867, 40)); // Animal Skin
  54. REWARDS.put("animalbone", new ItemHolder(1872, 40)); // Animal Bone
  55. REWARDS.put("charcoal", new ItemHolder(1871, 30)); // Charcoal
  56. REWARDS.put("coal", new ItemHolder(1870, 30)); // Coal
  57. REWARDS.put("ironore", new ItemHolder(1869, 30)); // Iron Ore
  58. }
  59. public Q00644_GraveRobberAnnihilation()
  60. {
  61. super(644, Q00644_GraveRobberAnnihilation.class.getSimpleName(), "Grave Robber Annihilation");
  62. addStartNpc(KARUDA);
  63. addTalkId(KARUDA);
  64. addKillId(MONSTER_DROP_CHANCES.keySet());
  65. registerQuestItems(ORC_GOODS);
  66. }
  67. @Override
  68. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  69. {
  70. final QuestState st = getQuestState(player, false);
  71. String htmltext = null;
  72. if (st == null)
  73. {
  74. return htmltext;
  75. }
  76. switch (event)
  77. {
  78. case "32017-03.htm":
  79. {
  80. if (st.isCreated())
  81. {
  82. st.startQuest();
  83. htmltext = event;
  84. }
  85. break;
  86. }
  87. case "32017-06.html":
  88. {
  89. if (st.isCond(2) && (st.getQuestItemsCount(ORC_GOODS) >= ORC_GOODS_REQUIRED_COUNT))
  90. {
  91. htmltext = event;
  92. }
  93. break;
  94. }
  95. case "varnish":
  96. case "animalskin":
  97. case "animalbone":
  98. case "charcoal":
  99. case "coal":
  100. case "ironore":
  101. {
  102. if (st.isCond(2))
  103. {
  104. final ItemHolder reward = REWARDS.get(event);
  105. st.rewardItems(reward.getId(), reward.getCount());
  106. st.exitQuest(true, true);
  107. htmltext = "32017-07.html";
  108. }
  109. break;
  110. }
  111. }
  112. return htmltext;
  113. }
  114. @Override
  115. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  116. {
  117. final QuestState qs = getRandomPartyMemberState(killer, 1, 3, npc);
  118. if ((qs != null) && qs.giveItemRandomly(npc, ORC_GOODS, 1, ORC_GOODS_REQUIRED_COUNT, MONSTER_DROP_CHANCES.get(npc.getId()), true))
  119. {
  120. qs.setCond(2, true);
  121. }
  122. return super.onKill(npc, killer, isSummon);
  123. }
  124. @Override
  125. public String onTalk(L2Npc npc, L2PcInstance player)
  126. {
  127. final QuestState st = getQuestState(player, true);
  128. String htmltext = getNoQuestMsg(player);
  129. if (st == null)
  130. {
  131. return htmltext;
  132. }
  133. switch (st.getState())
  134. {
  135. case State.CREATED:
  136. {
  137. htmltext = ((player.getLevel() >= MIN_LVL) ? "32017-01.htm" : "32017-02.htm");
  138. break;
  139. }
  140. case State.STARTED:
  141. {
  142. if (st.isCond(2) && (st.getQuestItemsCount(ORC_GOODS) >= ORC_GOODS_REQUIRED_COUNT))
  143. {
  144. htmltext = "32017-04.html";
  145. }
  146. else
  147. {
  148. htmltext = "32017-05.html";
  149. }
  150. break;
  151. }
  152. }
  153. return htmltext;
  154. }
  155. }