Q00258_BringWolfPelts.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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.Q00258_BringWolfPelts;
  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. /**
  29. * Bring Wolf Pelts (258)
  30. * @author xban1x
  31. */
  32. public final class Q00258_BringWolfPelts extends Quest
  33. {
  34. // Npc
  35. private static final int LECTOR = 30001;
  36. // Item
  37. private static final int WOLF_PELT = 702;
  38. // Monsters
  39. private static final int[] MONSTERS = new int[]
  40. {
  41. 20120, // Wolf
  42. 20442, // Elder Wolf
  43. };
  44. // Rewards
  45. private static final Map<Integer, Integer> REWARDS = new HashMap<>();
  46. static
  47. {
  48. REWARDS.put(390, 1); // Cotton Shirt
  49. REWARDS.put(29, 6); // Leather Pants
  50. REWARDS.put(22, 9); // Leather Shirt
  51. REWARDS.put(1119, 13); // Short Leather Gloves
  52. REWARDS.put(426, 16); // Tunic
  53. }
  54. // Misc
  55. private static final int MIN_LVL = 3;
  56. private static final int WOLF_PELT_COUNT = 40;
  57. public Q00258_BringWolfPelts()
  58. {
  59. super(258, Q00258_BringWolfPelts.class.getSimpleName(), "Bring Wolf Pelts");
  60. addStartNpc(LECTOR);
  61. addTalkId(LECTOR);
  62. addKillId(MONSTERS);
  63. registerQuestItems(WOLF_PELT);
  64. }
  65. @Override
  66. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  67. {
  68. final QuestState st = getQuestState(player, false);
  69. if ((st != null) && event.equalsIgnoreCase("30001-03.html"))
  70. {
  71. st.startQuest();
  72. return event;
  73. }
  74. return null;
  75. }
  76. @Override
  77. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  78. {
  79. final QuestState st = getQuestState(killer, false);
  80. if ((st != null) && st.isCond(1))
  81. {
  82. st.giveItems(WOLF_PELT, 1);
  83. if (st.getQuestItemsCount(WOLF_PELT) >= WOLF_PELT_COUNT)
  84. {
  85. st.setCond(2, true);
  86. }
  87. else
  88. {
  89. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  90. }
  91. }
  92. return super.onKill(npc, killer, isSummon);
  93. }
  94. @Override
  95. public String onTalk(L2Npc npc, L2PcInstance player)
  96. {
  97. final QuestState st = getQuestState(player, true);
  98. String htmltext = getNoQuestMsg(player);
  99. if (st == null)
  100. {
  101. return htmltext;
  102. }
  103. switch (st.getState())
  104. {
  105. case State.CREATED:
  106. {
  107. htmltext = (player.getLevel() >= MIN_LVL) ? "30001-02.htm" : "30001-01.html";
  108. break;
  109. }
  110. case State.STARTED:
  111. {
  112. switch (st.getCond())
  113. {
  114. case 1:
  115. {
  116. htmltext = "30001-04.html";
  117. break;
  118. }
  119. case 2:
  120. {
  121. if (st.getQuestItemsCount(WOLF_PELT) >= WOLF_PELT_COUNT)
  122. {
  123. final int chance = getRandom(16);
  124. for (Map.Entry<Integer, Integer> reward : REWARDS.entrySet())
  125. {
  126. if (chance < reward.getValue())
  127. {
  128. st.giveItems(reward.getKey(), 1);
  129. break;
  130. }
  131. }
  132. st.exitQuest(true, true);
  133. htmltext = "30001-05.html";
  134. break;
  135. }
  136. }
  137. }
  138. break;
  139. }
  140. }
  141. return htmltext;
  142. }
  143. }