Q10291_FireDragonDestroyer.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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.Q10291_FireDragonDestroyer;
  20. import java.util.function.Function;
  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. * Fire Dragon Destroyer (10291)
  29. * @author malyelfik
  30. */
  31. public class Q10291_FireDragonDestroyer extends Quest
  32. {
  33. // NPC
  34. private static final int KLEIN = 31540;
  35. // Monster
  36. private static final int VALAKAS = 29028;
  37. // Items
  38. private static final int FLOATING_STONE = 7267;
  39. private static final int POOR_NECKLACE = 15524;
  40. private static final int VALOR_NECKLACE = 15525;
  41. private static final int VALAKAS_SLAYER_CIRCLET = 8567;
  42. public Q10291_FireDragonDestroyer()
  43. {
  44. super(10291, Q10291_FireDragonDestroyer.class.getSimpleName(), "Fire Dragon Destroyer");
  45. addStartNpc(KLEIN);
  46. addTalkId(KLEIN);
  47. addKillId(VALAKAS);
  48. registerQuestItems(POOR_NECKLACE, VALOR_NECKLACE);
  49. }
  50. @Override
  51. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  52. {
  53. final QuestState st = getQuestState(player, false);
  54. if (st == null)
  55. {
  56. return getNoQuestMsg(player);
  57. }
  58. if (event.equals("31540-05.htm"))
  59. {
  60. st.startQuest();
  61. st.giveItems(POOR_NECKLACE, 1);
  62. }
  63. return event;
  64. }
  65. @Override
  66. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  67. {
  68. if (!player.isInParty())
  69. {
  70. return super.onKill(npc, player, isSummon);
  71. }
  72. Function<L2PcInstance, Boolean> rewardCheck = p ->
  73. {
  74. if (Util.checkIfInRange(8000, npc, p, false))
  75. {
  76. QuestState st = getQuestState(p, false);
  77. if ((st != null) && st.isCond(1) && st.hasQuestItems(POOR_NECKLACE))
  78. {
  79. st.takeItems(POOR_NECKLACE, -1);
  80. st.giveItems(VALOR_NECKLACE, 1);
  81. st.setCond(2, true);
  82. }
  83. }
  84. return true;
  85. };
  86. // Rewards go only to command channel, not to a single party or player.
  87. if (player.getParty().isInCommandChannel())
  88. {
  89. player.getParty().getCommandChannel().forEachMember(rewardCheck);
  90. }
  91. else
  92. {
  93. player.getParty().forEachMember(rewardCheck);
  94. }
  95. return super.onKill(npc, player, isSummon);
  96. }
  97. @Override
  98. public String onTalk(L2Npc npc, L2PcInstance player)
  99. {
  100. String htmltext = getNoQuestMsg(player);
  101. final QuestState st = getQuestState(player, true);
  102. if (st == null)
  103. {
  104. return htmltext;
  105. }
  106. switch (st.getState())
  107. {
  108. case State.CREATED:
  109. {
  110. if (player.getLevel() < 83)
  111. {
  112. htmltext = "31540-00.htm";
  113. }
  114. else
  115. {
  116. htmltext = st.hasQuestItems(FLOATING_STONE) ? "31540-02.htm" : "31540-01.htm";
  117. }
  118. break;
  119. }
  120. case State.STARTED:
  121. {
  122. if (st.isCond(1))
  123. {
  124. if (st.hasQuestItems(POOR_NECKLACE))
  125. {
  126. htmltext = "31540-06.html";
  127. }
  128. else
  129. {
  130. st.giveItems(POOR_NECKLACE, 1);
  131. htmltext = "31540-07.html";
  132. }
  133. }
  134. else if (st.isCond(2) && st.hasQuestItems(VALOR_NECKLACE))
  135. {
  136. htmltext = "31540-08.html";
  137. st.giveAdena(126549, true);
  138. st.addExpAndSp(717291, 77397);
  139. st.giveItems(VALAKAS_SLAYER_CIRCLET, 1);
  140. st.exitQuest(false, true);
  141. }
  142. break;
  143. }
  144. case State.COMPLETED:
  145. {
  146. htmltext = "31540-09.html";
  147. break;
  148. }
  149. }
  150. return htmltext;
  151. }
  152. }