Q00311_ExpulsionOfEvilSpirits.java 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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.Q00311_ExpulsionOfEvilSpirits;
  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. /**
  28. * Expulsion of Evil Spirits (311)
  29. * @author Zoey76
  30. */
  31. public final class Q00311_ExpulsionOfEvilSpirits extends Quest
  32. {
  33. // NPC
  34. private static final int CHAIREN = 32655;
  35. // Items
  36. private static final int PROTECTION_SOULS_PENDANT = 14848;
  37. private static final int SOUL_CORE_CONTAINING_EVIL_SPIRIT = 14881;
  38. private static final int RAGNA_ORCS_AMULET = 14882;
  39. // Misc
  40. private static final int MIN_LEVEL = 80;
  41. private static final int SOUL_CORE_COUNT = 10;
  42. private static final int RAGNA_ORCS_KILLS_COUNT = 100;
  43. private static final int RAGNA_ORCS_AMULET_COUNT = 10;
  44. // Monsters
  45. private static final Map<Integer, Double> MONSTERS = new HashMap<>();
  46. static
  47. {
  48. MONSTERS.put(22691, 0.694); // Ragna Orc
  49. MONSTERS.put(22692, 0.716); // Ragna Orc Warrior
  50. MONSTERS.put(22693, 0.736); // Ragna Orc Hero
  51. MONSTERS.put(22694, 0.712); // Ragna Orc Commander
  52. MONSTERS.put(22695, 0.698); // Ragna Orc Healer
  53. MONSTERS.put(22696, 0.692); // Ragna Orc Shaman
  54. MONSTERS.put(22697, 0.640); // Ragna Orc Seer
  55. MONSTERS.put(22698, 0.716); // Ragna Orc Archer
  56. MONSTERS.put(22699, 0.752); // Ragna Orc Sniper
  57. MONSTERS.put(22701, 0.716); // Varangka's Dre Vanul
  58. MONSTERS.put(22702, 0.662); // Varangka's Destroyer
  59. }
  60. public Q00311_ExpulsionOfEvilSpirits()
  61. {
  62. super(311, Q00311_ExpulsionOfEvilSpirits.class.getSimpleName(), "Expulsion of Evil Spirits");
  63. addStartNpc(CHAIREN);
  64. addTalkId(CHAIREN);
  65. addKillId(MONSTERS.keySet());
  66. registerQuestItems(SOUL_CORE_CONTAINING_EVIL_SPIRIT, RAGNA_ORCS_AMULET);
  67. }
  68. @Override
  69. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  70. {
  71. final QuestState qs = getQuestState(player, false);
  72. if (qs == null)
  73. {
  74. return null;
  75. }
  76. String htmltext = null;
  77. if (player.getLevel() < MIN_LEVEL)
  78. {
  79. return null;
  80. }
  81. switch (event)
  82. {
  83. case "32655-03.htm":
  84. case "32655-15.html":
  85. {
  86. htmltext = event;
  87. break;
  88. }
  89. case "32655-04.htm":
  90. {
  91. qs.startQuest();
  92. htmltext = event;
  93. break;
  94. }
  95. case "32655-11.html":
  96. {
  97. if (getQuestItemsCount(player, SOUL_CORE_CONTAINING_EVIL_SPIRIT) >= SOUL_CORE_COUNT)
  98. {
  99. takeItems(player, SOUL_CORE_CONTAINING_EVIL_SPIRIT, SOUL_CORE_COUNT);
  100. giveItems(player, PROTECTION_SOULS_PENDANT, 1);
  101. htmltext = event;
  102. }
  103. else
  104. {
  105. htmltext = "32655-12.html";
  106. }
  107. break;
  108. }
  109. case "32655-13.html":
  110. {
  111. if (!hasQuestItems(player, SOUL_CORE_CONTAINING_EVIL_SPIRIT) && (getQuestItemsCount(player, RAGNA_ORCS_AMULET) >= RAGNA_ORCS_AMULET_COUNT))
  112. {
  113. qs.exitQuest(true, true);
  114. htmltext = event;
  115. }
  116. else
  117. {
  118. htmltext = "32655-14.html";
  119. }
  120. break;
  121. }
  122. }
  123. return htmltext;
  124. }
  125. @Override
  126. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  127. {
  128. final QuestState qs = getRandomPartyMemberState(killer, 1, 2, npc);
  129. if (qs != null)
  130. {
  131. final int count = qs.getMemoStateEx(1) + 1;
  132. if ((count >= RAGNA_ORCS_KILLS_COUNT) && (getRandom(20) < ((count % 100) + 1)))
  133. {
  134. qs.setMemoStateEx(1, 0);
  135. qs.giveItems(SOUL_CORE_CONTAINING_EVIL_SPIRIT, 1);
  136. qs.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  137. }
  138. else
  139. {
  140. qs.setMemoStateEx(1, count);
  141. }
  142. qs.giveItemRandomly(npc, RAGNA_ORCS_AMULET, 1, 0, MONSTERS.get(npc.getId()), true);
  143. }
  144. return super.onKill(npc, killer, isSummon);
  145. }
  146. @Override
  147. public String onTalk(L2Npc npc, L2PcInstance player)
  148. {
  149. final QuestState qs = getQuestState(player, true);
  150. String htmltext = getNoQuestMsg(player);
  151. if (qs == null)
  152. {
  153. return htmltext;
  154. }
  155. if (qs.isCreated())
  156. {
  157. htmltext = (player.getLevel() >= MIN_LEVEL) ? "32655-01.htm" : "32655-02.htm";
  158. }
  159. else if (qs.isStarted())
  160. {
  161. htmltext = !hasQuestItems(player, SOUL_CORE_CONTAINING_EVIL_SPIRIT, RAGNA_ORCS_AMULET) ? "32655-05.html" : "32655-06.html";
  162. }
  163. return htmltext;
  164. }
  165. }