Q00132_MatrasCuriosity.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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.Q00132_MatrasCuriosity;
  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. /**
  26. * Matras' Curiosity (132)
  27. * @author GKR, Gladicek
  28. */
  29. public final class Q00132_MatrasCuriosity extends Quest
  30. {
  31. // NPCs
  32. private static final int MATRAS = 32245;
  33. private static final int DEMON_PRINCE = 25540;
  34. private static final int RANKU = 25542;
  35. // Items
  36. private static final int FIRE = 10521;
  37. private static final int WATER = 10522;
  38. private static final int EARTH = 10523;
  39. private static final int WIND = 10524;
  40. private static final int DARKNESS = 10525;
  41. private static final int DIVINITY = 10526;
  42. private static final int BLUEPRINT_RANKU = 9800;
  43. private static final int BLUEPRINT_PRINCE = 9801;
  44. public Q00132_MatrasCuriosity()
  45. {
  46. super(132, Q00132_MatrasCuriosity.class.getSimpleName(), "Matras' Curiosity");
  47. addStartNpc(MATRAS);
  48. addTalkId(MATRAS);
  49. addKillId(RANKU, DEMON_PRINCE);
  50. registerQuestItems(BLUEPRINT_RANKU, BLUEPRINT_PRINCE);
  51. }
  52. @Override
  53. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  54. {
  55. final QuestState st = getQuestState(player, false);
  56. if (st == null)
  57. {
  58. return getNoQuestMsg(player);
  59. }
  60. String htmltext = event;
  61. if (event.equalsIgnoreCase("32245-03.htm") && (player.getLevel() >= 76) && !st.isCompleted())
  62. {
  63. if (st.isCreated())
  64. {
  65. st.startQuest();
  66. st.set("rewarded_prince", "1");
  67. st.set("rewarded_ranku", "1");
  68. }
  69. else
  70. {
  71. htmltext = "32245-03a.htm";
  72. }
  73. }
  74. else if (event.equalsIgnoreCase("32245-07.htm") && st.isCond(3) && !st.isCompleted())
  75. {
  76. st.giveAdena(65884, true);
  77. st.addExpAndSp(50541, 5094);
  78. st.giveItems(FIRE, 1);
  79. st.giveItems(WATER, 1);
  80. st.giveItems(EARTH, 1);
  81. st.giveItems(WIND, 1);
  82. st.giveItems(DARKNESS, 1);
  83. st.giveItems(DIVINITY, 1);
  84. st.exitQuest(false, true);
  85. }
  86. return htmltext;
  87. }
  88. @Override
  89. public final String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  90. {
  91. L2PcInstance pl = null;
  92. switch (npc.getId())
  93. {
  94. case DEMON_PRINCE:
  95. pl = getRandomPartyMember(player, "rewarded_prince", "1");
  96. if (pl != null)
  97. {
  98. final QuestState st = getQuestState(pl, false);
  99. st.giveItems(BLUEPRINT_PRINCE, 1);
  100. st.set("rewarded_prince", "2");
  101. if (st.hasQuestItems(BLUEPRINT_RANKU))
  102. {
  103. st.setCond(2, true);
  104. }
  105. else
  106. {
  107. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  108. }
  109. }
  110. break;
  111. case RANKU:
  112. pl = getRandomPartyMember(player, "rewarded_ranku", "1");
  113. if (pl != null)
  114. {
  115. final QuestState st = getQuestState(pl, false);
  116. st.giveItems(BLUEPRINT_RANKU, 1);
  117. st.set("rewarded_ranku", "2");
  118. if (st.hasQuestItems(BLUEPRINT_PRINCE))
  119. {
  120. st.setCond(2, true);
  121. }
  122. else
  123. {
  124. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  125. }
  126. }
  127. break;
  128. }
  129. return null;
  130. }
  131. @Override
  132. public final String onTalk(L2Npc npc, L2PcInstance player)
  133. {
  134. String htmltext = getNoQuestMsg(player);
  135. final QuestState st = getQuestState(player, true);
  136. if (st == null)
  137. {
  138. return htmltext;
  139. }
  140. if (st.isCreated())
  141. {
  142. htmltext = (player.getLevel() >= 76) ? "32245-01.htm" : "32245-02.htm";
  143. }
  144. else if (st.isCompleted())
  145. {
  146. htmltext = getAlreadyCompletedMsg(player);
  147. }
  148. else if (st.isStarted())
  149. {
  150. switch (st.getCond())
  151. {
  152. case 1:
  153. case 2:
  154. if (st.hasQuestItems(BLUEPRINT_RANKU) && st.hasQuestItems(BLUEPRINT_PRINCE))
  155. {
  156. st.takeItems(BLUEPRINT_RANKU, -1);
  157. st.takeItems(BLUEPRINT_PRINCE, -1);
  158. st.setCond(3, true);
  159. htmltext = "32245-05.htm";
  160. }
  161. else
  162. {
  163. htmltext = "32245-04.htm";
  164. }
  165. break;
  166. case 3:
  167. htmltext = "32245-06.htm";
  168. }
  169. }
  170. return htmltext;
  171. }
  172. }