Q00906_TheCallOfValakas.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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.Q00906_TheCallOfValakas;
  20. import com.l2jserver.gameserver.enums.QuestSound;
  21. import com.l2jserver.gameserver.enums.QuestType;
  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. import com.l2jserver.gameserver.util.Util;
  28. /**
  29. * The Call of Valakas (906)
  30. * @author Zoey76
  31. */
  32. public class Q00906_TheCallOfValakas extends Quest
  33. {
  34. // NPC
  35. private static final int KLEIN = 31540;
  36. // Monster
  37. private static final int LAVASAURUS_ALPHA = 29029;
  38. // Items
  39. private static final int LAVASAURUS_ALPHA_FRAGMENT = 21993;
  40. private static final int SCROLL_VALAKAS_CALL = 21895;
  41. private static final int VACUALITE_FLOATING_STONE = 7267;
  42. // Misc
  43. private static final int MIN_LEVEL = 83;
  44. public Q00906_TheCallOfValakas()
  45. {
  46. super(906, Q00906_TheCallOfValakas.class.getSimpleName(), "The Call of Valakas");
  47. addStartNpc(KLEIN);
  48. addTalkId(KLEIN);
  49. addKillId(LAVASAURUS_ALPHA);
  50. registerQuestItems(LAVASAURUS_ALPHA_FRAGMENT);
  51. }
  52. @Override
  53. public void actionForEachPlayer(L2PcInstance player, L2Npc npc, boolean isSummon)
  54. {
  55. final QuestState st = getQuestState(player, false);
  56. if ((st != null) && Util.checkIfInRange(1500, npc, player, false))
  57. {
  58. st.giveItems(LAVASAURUS_ALPHA_FRAGMENT, 1);
  59. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  60. st.setCond(2, true);
  61. }
  62. }
  63. @Override
  64. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  65. {
  66. final QuestState st = getQuestState(player, false);
  67. if (st == null)
  68. {
  69. return null;
  70. }
  71. String htmltext = null;
  72. if ((player.getLevel() >= MIN_LEVEL) && st.hasQuestItems(VACUALITE_FLOATING_STONE))
  73. {
  74. switch (event)
  75. {
  76. case "31540-05.htm":
  77. {
  78. htmltext = event;
  79. break;
  80. }
  81. case "31540-06.html":
  82. {
  83. st.startQuest();
  84. htmltext = event;
  85. break;
  86. }
  87. }
  88. }
  89. return htmltext;
  90. }
  91. @Override
  92. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  93. {
  94. executeForEachPlayer(killer, npc, isSummon, true, false);
  95. return super.onKill(npc, killer, isSummon);
  96. }
  97. @Override
  98. public String onTalk(L2Npc npc, L2PcInstance player)
  99. {
  100. final QuestState st = getQuestState(player, true);
  101. if (st == null)
  102. {
  103. return getNoQuestMsg(player);
  104. }
  105. String htmltext = getNoQuestMsg(player);
  106. switch (st.getState())
  107. {
  108. case State.CREATED:
  109. {
  110. if (player.getLevel() < MIN_LEVEL)
  111. {
  112. htmltext = "31540-03.html";
  113. }
  114. else if (!st.hasQuestItems(VACUALITE_FLOATING_STONE))
  115. {
  116. htmltext = "31540-04.html";
  117. }
  118. else
  119. {
  120. htmltext = "31540-01.htm";
  121. }
  122. break;
  123. }
  124. case State.STARTED:
  125. {
  126. switch (st.getCond())
  127. {
  128. case 1:
  129. {
  130. htmltext = "31540-07.html";
  131. break;
  132. }
  133. case 2:
  134. {
  135. st.giveItems(SCROLL_VALAKAS_CALL, 1);
  136. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  137. st.exitQuest(QuestType.DAILY, true);
  138. htmltext = "31540-08.html";
  139. break;
  140. }
  141. }
  142. break;
  143. }
  144. case State.COMPLETED:
  145. {
  146. if (!st.isNowAvailable())
  147. {
  148. htmltext = "31540-02.html";
  149. }
  150. else
  151. {
  152. st.setState(State.CREATED);
  153. if (player.getLevel() < MIN_LEVEL)
  154. {
  155. htmltext = "31540-03.html";
  156. }
  157. else if (!st.hasQuestItems(VACUALITE_FLOATING_STONE))
  158. {
  159. htmltext = "31540-04.html";
  160. }
  161. else
  162. {
  163. htmltext = "31540-01.htm";
  164. }
  165. }
  166. break;
  167. }
  168. }
  169. return htmltext;
  170. }
  171. }