Q00904_DragonTrophyAntharas.java 4.2 KB

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