Q00645_GhostsOfBatur.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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.Q00645_GhostsOfBatur;
  20. import com.l2jserver.gameserver.enums.QuestSound;
  21. import com.l2jserver.gameserver.model.actor.L2Npc;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.model.quest.Quest;
  24. import com.l2jserver.gameserver.model.quest.QuestState;
  25. import com.l2jserver.gameserver.model.quest.State;
  26. import com.l2jserver.gameserver.util.Util;
  27. /**
  28. * Ghosts of Batur (645)
  29. * @author Zoey76
  30. */
  31. public class Q00645_GhostsOfBatur extends Quest
  32. {
  33. // NPC
  34. private static final int KARUDA = 32017;
  35. // Monsters
  36. private static final int CONTAMINATED_MOREK_WARRIOR = 22703;
  37. private static final int CONTAMINATED_BATUR_WARRIOR = 22704;
  38. private static final int CONTAMINATED_BATUR_COMMANDER = 22705;
  39. // Items
  40. private static final int CURSED_GRAVE_GOODS = 8089; // Old item
  41. private static final int CURSED_BURIAL_ITEMS = 14861; // New item
  42. // Misc
  43. private static final int MIN_LEVEL = 80;
  44. private static final int[] CHANCES =
  45. {
  46. 516,
  47. 664,
  48. 686
  49. };
  50. public Q00645_GhostsOfBatur()
  51. {
  52. super(645, Q00645_GhostsOfBatur.class.getSimpleName(), "Ghosts of Batur");
  53. addStartNpc(KARUDA);
  54. addTalkId(KARUDA);
  55. addKillId(CONTAMINATED_MOREK_WARRIOR, CONTAMINATED_BATUR_WARRIOR, CONTAMINATED_BATUR_COMMANDER);
  56. registerQuestItems(CURSED_GRAVE_GOODS);
  57. }
  58. @Override
  59. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  60. {
  61. final QuestState st = getQuestState(player, false);
  62. if (st == null)
  63. {
  64. return null;
  65. }
  66. String htmltext = null;
  67. if (player.getLevel() >= MIN_LEVEL)
  68. {
  69. switch (event)
  70. {
  71. case "32017-03.htm":
  72. {
  73. st.startQuest();
  74. htmltext = event;
  75. break;
  76. }
  77. case "32017-06.html":
  78. case "32017-08.html":
  79. {
  80. htmltext = event;
  81. break;
  82. }
  83. case "32017-09.html":
  84. {
  85. st.exitQuest(true, true);
  86. htmltext = event;
  87. break;
  88. }
  89. }
  90. }
  91. return htmltext;
  92. }
  93. @Override
  94. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  95. {
  96. final L2PcInstance player = getRandomPartyMember(killer, 1);
  97. if ((player != null) && Util.checkIfInRange(1500, npc, player, false))
  98. {
  99. if (getRandom(1000) < CHANCES[npc.getId() - CONTAMINATED_MOREK_WARRIOR])
  100. {
  101. final QuestState st = getQuestState(player, false);
  102. st.giveItems(CURSED_BURIAL_ITEMS, 1);
  103. if (st.isCond(1) && (st.getQuestItemsCount(CURSED_BURIAL_ITEMS) >= 500))
  104. {
  105. st.setCond(2, true);
  106. }
  107. else
  108. {
  109. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  110. }
  111. }
  112. }
  113. return super.onKill(npc, killer, isSummon);
  114. }
  115. @Override
  116. public String onTalk(L2Npc npc, L2PcInstance player)
  117. {
  118. final QuestState st = getQuestState(player, true);
  119. if (st == null)
  120. {
  121. return getNoQuestMsg(player);
  122. }
  123. String htmltext = getNoQuestMsg(player);
  124. switch (st.getState())
  125. {
  126. case State.CREATED:
  127. {
  128. htmltext = (player.getLevel() >= MIN_LEVEL) ? "32017-01.htm" : "32017-02.html";
  129. break;
  130. }
  131. case State.STARTED:
  132. {
  133. // Support for old quest reward.
  134. final long count = st.getQuestItemsCount(CURSED_GRAVE_GOODS);
  135. if ((count > 0) && (count < 180))
  136. {
  137. st.giveAdena(56000 + (count * 64), false);
  138. st.addExpAndSp(138000, 7997);
  139. st.exitQuest(true, true);
  140. htmltext = "32017-07.html";
  141. }
  142. else
  143. {
  144. htmltext = st.hasQuestItems(CURSED_BURIAL_ITEMS) ? "32017-04.html" : "32017-05.html";
  145. }
  146. break;
  147. }
  148. }
  149. return htmltext;
  150. }
  151. }