Q00274_SkirmishWithTheWerewolves.java 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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.Q00274_SkirmishWithTheWerewolves;
  20. import com.l2jserver.gameserver.enums.QuestSound;
  21. import com.l2jserver.gameserver.enums.Race;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.quest.Quest;
  25. import com.l2jserver.gameserver.model.quest.QuestState;
  26. import com.l2jserver.gameserver.model.quest.State;
  27. /**
  28. * Skirmish with the Werewolves (274)
  29. * @author xban1x
  30. */
  31. public final class Q00274_SkirmishWithTheWerewolves extends Quest
  32. {
  33. // NPC
  34. private static final int BRUKURSE = 30569;
  35. // Monsters
  36. private static final int[] MONSTERS = new int[]
  37. {
  38. 20363, // Maraku Werewolf
  39. 20364, // Maraku Werewolf Chieftain
  40. };
  41. // Items
  42. private static final int NECKLACE_OF_COURAGE = 1506;
  43. private static final int NECKLACE_OF_VALOR = 1507;
  44. private static final int WEREWOLF_HEAD = 1477;
  45. private static final int WEREWOLF_TOTEM = 1501;
  46. // Misc
  47. private static final int MIN_LVL = 9;
  48. public Q00274_SkirmishWithTheWerewolves()
  49. {
  50. super(274, Q00274_SkirmishWithTheWerewolves.class.getSimpleName(), "Skirmish with the Werewolves");
  51. addStartNpc(BRUKURSE);
  52. addTalkId(BRUKURSE);
  53. addKillId(MONSTERS);
  54. registerQuestItems(WEREWOLF_HEAD, WEREWOLF_TOTEM);
  55. }
  56. @Override
  57. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  58. {
  59. final QuestState st = getQuestState(player, false);
  60. if ((st != null) && event.equalsIgnoreCase("30569-04.htm"))
  61. {
  62. st.startQuest();
  63. return event;
  64. }
  65. return null;
  66. }
  67. @Override
  68. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  69. {
  70. final QuestState st = getQuestState(killer, false);
  71. if ((st != null) && st.isCond(1))
  72. {
  73. st.giveItems(WEREWOLF_HEAD, 1);
  74. if (getRandom(100) <= 5)
  75. {
  76. st.giveItems(WEREWOLF_TOTEM, 1);
  77. }
  78. if (st.getQuestItemsCount(WEREWOLF_HEAD) >= 40)
  79. {
  80. st.setCond(2, true);
  81. }
  82. else
  83. {
  84. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  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. return htmltext;
  97. }
  98. switch (st.getState())
  99. {
  100. case State.CREATED:
  101. {
  102. if (hasAtLeastOneQuestItem(player, NECKLACE_OF_VALOR, NECKLACE_OF_COURAGE))
  103. {
  104. htmltext = (player.getRace() == Race.ORC) ? (player.getLevel() >= MIN_LVL) ? "30569-03.htm" : "30569-02.html" : "30569-01.html";
  105. }
  106. else
  107. {
  108. htmltext = "30569-08.html";
  109. }
  110. break;
  111. }
  112. case State.STARTED:
  113. {
  114. switch (st.getCond())
  115. {
  116. case 1:
  117. {
  118. htmltext = "30569-05.html";
  119. break;
  120. }
  121. case 2:
  122. {
  123. final long heads = st.getQuestItemsCount(WEREWOLF_HEAD);
  124. if (heads >= 40)
  125. {
  126. final long totems = st.getQuestItemsCount(WEREWOLF_TOTEM);
  127. st.giveAdena((heads * 30) + (totems * 600) + 2300, true);
  128. st.exitQuest(true, true);
  129. htmltext = (totems > 0) ? "30569-07.html" : "30569-06.html";
  130. }
  131. }
  132. }
  133. break;
  134. }
  135. }
  136. return htmltext;
  137. }
  138. }