Q00903_TheCallOfAntharas.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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.Q00903_TheCallOfAntharas;
  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 Antharas (903)
  30. * @author Zoey76
  31. */
  32. public class Q00903_TheCallOfAntharas extends Quest
  33. {
  34. // NPC
  35. private static final int THEODRIC = 30755;
  36. // Monsters
  37. private static final int BEHEMOTH_DRAGON = 29069;
  38. private static final int TARASK_DRAGON = 29190;
  39. // Items
  40. private static final int TARASK_DRAGONS_LEATHER_FRAGMENT = 21991;
  41. private static final int BEHEMOTH_DRAGON_LEATHER = 21992;
  42. private static final int SCROLL_ANTHARAS_CALL = 21897;
  43. private static final int PORTAL_STONE = 3865;
  44. // Misc
  45. private static final int MIN_LEVEL = 83;
  46. public Q00903_TheCallOfAntharas()
  47. {
  48. super(903, Q00903_TheCallOfAntharas.class.getSimpleName(), "The Call of Antharas");
  49. addStartNpc(THEODRIC);
  50. addTalkId(THEODRIC);
  51. addKillId(BEHEMOTH_DRAGON, TARASK_DRAGON);
  52. registerQuestItems(TARASK_DRAGONS_LEATHER_FRAGMENT, BEHEMOTH_DRAGON_LEATHER);
  53. }
  54. @Override
  55. public void actionForEachPlayer(L2PcInstance player, L2Npc npc, boolean isSummon)
  56. {
  57. final QuestState st = getQuestState(player, false);
  58. if ((st != null) && Util.checkIfInRange(1500, npc, player, false))
  59. {
  60. switch (npc.getId())
  61. {
  62. case BEHEMOTH_DRAGON:
  63. {
  64. st.giveItems(BEHEMOTH_DRAGON_LEATHER, 1);
  65. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  66. break;
  67. }
  68. case TARASK_DRAGON:
  69. {
  70. st.giveItems(TARASK_DRAGONS_LEATHER_FRAGMENT, 1);
  71. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  72. break;
  73. }
  74. }
  75. if (st.hasQuestItems(BEHEMOTH_DRAGON_LEATHER) && st.hasQuestItems(TARASK_DRAGONS_LEATHER_FRAGMENT))
  76. {
  77. st.setCond(2, true);
  78. }
  79. }
  80. }
  81. @Override
  82. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  83. {
  84. final QuestState st = getQuestState(player, false);
  85. if (st == null)
  86. {
  87. return null;
  88. }
  89. String htmltext = null;
  90. if ((player.getLevel() >= MIN_LEVEL) && st.hasQuestItems(PORTAL_STONE))
  91. {
  92. switch (event)
  93. {
  94. case "30755-05.htm":
  95. {
  96. htmltext = event;
  97. break;
  98. }
  99. case "30755-06.html":
  100. {
  101. st.startQuest();
  102. htmltext = event;
  103. break;
  104. }
  105. }
  106. }
  107. return htmltext;
  108. }
  109. @Override
  110. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  111. {
  112. executeForEachPlayer(killer, npc, isSummon, true, false);
  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. if (player.getLevel() < MIN_LEVEL)
  129. {
  130. htmltext = "30755-03.html";
  131. }
  132. else if (!st.hasQuestItems(PORTAL_STONE))
  133. {
  134. htmltext = "30755-04.html";
  135. }
  136. else
  137. {
  138. htmltext = "30755-01.htm";
  139. }
  140. break;
  141. }
  142. case State.STARTED:
  143. {
  144. switch (st.getCond())
  145. {
  146. case 1:
  147. {
  148. htmltext = "30755-07.html";
  149. break;
  150. }
  151. case 2:
  152. {
  153. st.giveItems(SCROLL_ANTHARAS_CALL, 1);
  154. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  155. st.exitQuest(QuestType.DAILY, true);
  156. htmltext = "30755-08.html";
  157. break;
  158. }
  159. }
  160. break;
  161. }
  162. case State.COMPLETED:
  163. {
  164. if (!st.isNowAvailable())
  165. {
  166. htmltext = "30755-02.html";
  167. }
  168. else
  169. {
  170. st.setState(State.CREATED);
  171. if (player.getLevel() < MIN_LEVEL)
  172. {
  173. htmltext = "30755-03.html";
  174. }
  175. else if (!st.hasQuestItems(PORTAL_STONE))
  176. {
  177. htmltext = "30755-04.html";
  178. }
  179. else
  180. {
  181. htmltext = "30755-01.htm";
  182. }
  183. }
  184. break;
  185. }
  186. }
  187. return htmltext;
  188. }
  189. }