Q00165_ShilensHunt.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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.Q00165_ShilensHunt;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import com.l2jserver.gameserver.enums.QuestSound;
  23. import com.l2jserver.gameserver.enums.Race;
  24. import com.l2jserver.gameserver.model.actor.L2Npc;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.model.quest.Quest;
  27. import com.l2jserver.gameserver.model.quest.QuestState;
  28. import com.l2jserver.gameserver.model.quest.State;
  29. /**
  30. * Shilen's Hunt (165)
  31. * @author xban1x
  32. */
  33. public class Q00165_ShilensHunt extends Quest
  34. {
  35. // NPC
  36. private static final int NELSYA = 30348;
  37. // Monsters
  38. private static final Map<Integer, Integer> MONSTERS = new HashMap<>();
  39. static
  40. {
  41. MONSTERS.put(20456, 3); // Ashen Wolf
  42. MONSTERS.put(20529, 1); // Young Brown Keltir
  43. MONSTERS.put(20532, 1); // Brown Keltir
  44. MONSTERS.put(20536, 2); // Elder Brown Keltir
  45. }
  46. // Items
  47. private static final int LESSER_HEALING_POTION = 1060;
  48. private static final int DARK_BEZOAR = 1160;
  49. // Misc
  50. private static final int MIN_LVL = 3;
  51. private static final int REQUIRED_COUNT = 13;
  52. public Q00165_ShilensHunt()
  53. {
  54. super(165, Q00165_ShilensHunt.class.getSimpleName(), "Shilen's Hunt");
  55. addStartNpc(NELSYA);
  56. addTalkId(NELSYA);
  57. addKillId(MONSTERS.keySet());
  58. registerQuestItems(DARK_BEZOAR);
  59. }
  60. @Override
  61. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  62. {
  63. final QuestState st = getQuestState(player, false);
  64. if ((st != null) && event.equalsIgnoreCase("30348-03.htm"))
  65. {
  66. st.startQuest();
  67. return event;
  68. }
  69. return null;
  70. }
  71. @Override
  72. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  73. {
  74. final QuestState st = getQuestState(killer, false);
  75. if ((st != null) && st.isCond(1) && (getRandom(3) < MONSTERS.get(npc.getId())))
  76. {
  77. st.giveItems(DARK_BEZOAR, 1);
  78. if (st.getQuestItemsCount(DARK_BEZOAR) < REQUIRED_COUNT)
  79. {
  80. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  81. }
  82. else
  83. {
  84. st.setCond(2, true);
  85. }
  86. }
  87. return super.onKill(npc, killer, isSummon);
  88. }
  89. @Override
  90. public String onTalk(L2Npc npc, L2PcInstance player)
  91. {
  92. final QuestState st = getQuestState(player, true);
  93. String htmltext = getNoQuestMsg(player);
  94. if (st != null)
  95. {
  96. switch (st.getState())
  97. {
  98. case State.CREATED:
  99. {
  100. htmltext = (player.getRace() == Race.DARK_ELF) ? (player.getLevel() >= MIN_LVL) ? "30348-02.htm" : "30348-01.htm" : "30348-00.htm";
  101. break;
  102. }
  103. case State.STARTED:
  104. {
  105. if (st.isCond(2) && (st.getQuestItemsCount(DARK_BEZOAR) >= REQUIRED_COUNT))
  106. {
  107. st.giveItems(LESSER_HEALING_POTION, 5);
  108. st.addExpAndSp(1000, 0);
  109. st.exitQuest(false, true);
  110. htmltext = "30348-05.html";
  111. }
  112. else
  113. {
  114. htmltext = "30348-04.html";
  115. }
  116. break;
  117. }
  118. case State.COMPLETED:
  119. {
  120. htmltext = getAlreadyCompletedMsg(player);
  121. break;
  122. }
  123. }
  124. }
  125. return htmltext;
  126. }
  127. }