Q00260_OrcHunting.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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.Q00260_OrcHunting;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import quests.Q00281_HeadForTheHills.Q00281_HeadForTheHills;
  23. import com.l2jserver.gameserver.enums.QuestSound;
  24. import com.l2jserver.gameserver.enums.Race;
  25. import com.l2jserver.gameserver.model.actor.L2Npc;
  26. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  27. import com.l2jserver.gameserver.model.quest.Quest;
  28. import com.l2jserver.gameserver.model.quest.QuestState;
  29. import com.l2jserver.gameserver.model.quest.State;
  30. /**
  31. * Orc Hunting (260)
  32. * @author xban1x
  33. */
  34. public final class Q00260_OrcHunting extends Quest
  35. {
  36. // NPC
  37. private static final int RAYEN = 30221;
  38. // Items
  39. private static final int ORC_AMULET = 1114;
  40. private static final int ORC_NECKLACE = 1115;
  41. // Monsters
  42. private static final Map<Integer, Integer> MONSTERS = new HashMap<>();
  43. static
  44. {
  45. MONSTERS.put(20468, ORC_AMULET); // Kaboo Orc
  46. MONSTERS.put(20469, ORC_AMULET); // Kaboo Orc Archer
  47. MONSTERS.put(20470, ORC_AMULET); // Kaboo Orc Grunt
  48. MONSTERS.put(20471, ORC_NECKLACE); // Kaboo Orc Fighter
  49. MONSTERS.put(20472, ORC_NECKLACE); // Kaboo Orc Fighter Leader
  50. MONSTERS.put(20473, ORC_NECKLACE); // Kaboo Orc Fighter Lieutenant
  51. }
  52. // Misc
  53. private static final int MIN_LVL = 6;
  54. public Q00260_OrcHunting()
  55. {
  56. super(260, Q00260_OrcHunting.class.getSimpleName(), "Orc Hunting");
  57. addStartNpc(RAYEN);
  58. addTalkId(RAYEN);
  59. addKillId(MONSTERS.keySet());
  60. registerQuestItems(ORC_AMULET, ORC_NECKLACE);
  61. }
  62. @Override
  63. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  64. {
  65. final QuestState st = getQuestState(player, false);
  66. String htmltext = null;
  67. if (st == null)
  68. {
  69. return htmltext;
  70. }
  71. switch (event)
  72. {
  73. case "30221-04.htm":
  74. {
  75. st.startQuest();
  76. htmltext = event;
  77. break;
  78. }
  79. case "30221-07.html":
  80. {
  81. st.exitQuest(true, true);
  82. htmltext = event;
  83. break;
  84. }
  85. case "30221-08.html":
  86. {
  87. htmltext = event;
  88. break;
  89. }
  90. }
  91. return htmltext;
  92. }
  93. @Override
  94. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  95. {
  96. final QuestState st = getQuestState(killer, false);
  97. if ((st != null) && (getRandom(10) > 4))
  98. {
  99. st.giveItems(MONSTERS.get(npc.getId()), 1);
  100. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  101. }
  102. return super.onKill(npc, killer, isSummon);
  103. }
  104. @Override
  105. public String onTalk(L2Npc npc, L2PcInstance player)
  106. {
  107. final QuestState st = getQuestState(player, true);
  108. String htmltext = getNoQuestMsg(player);
  109. if (st == null)
  110. {
  111. return htmltext;
  112. }
  113. switch (st.getState())
  114. {
  115. case State.CREATED:
  116. {
  117. htmltext = (player.getRace() == Race.ELF) ? (player.getLevel() >= MIN_LVL) ? "30221-03.htm" : "30221-02.html" : "30221-01.html";
  118. break;
  119. }
  120. case State.STARTED:
  121. {
  122. if (hasAtLeastOneQuestItem(player, getRegisteredItemIds()))
  123. {
  124. final long amulets = st.getQuestItemsCount(ORC_AMULET);
  125. final long necklaces = st.getQuestItemsCount(ORC_NECKLACE);
  126. st.giveAdena(((amulets * 12) + (necklaces * 30) + ((amulets + necklaces) >= 10 ? 1000 : 0)), true);
  127. takeItems(player, -1, getRegisteredItemIds());
  128. Q00281_HeadForTheHills.giveNewbieReward(player);
  129. htmltext = "30221-06.html";
  130. }
  131. else
  132. {
  133. htmltext = "30221-05.html";
  134. }
  135. break;
  136. }
  137. }
  138. return htmltext;
  139. }
  140. }