Q00362_BardsMandolin.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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.Q00362_BardsMandolin;
  20. import com.l2jserver.gameserver.model.actor.L2Npc;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.quest.Quest;
  23. import com.l2jserver.gameserver.model.quest.QuestState;
  24. import com.l2jserver.gameserver.model.quest.State;
  25. /**
  26. * Bard's Mandolin (362)
  27. * @author Adry_85
  28. */
  29. public final class Q00362_BardsMandolin extends Quest
  30. {
  31. // NPCs
  32. private static final int WOODROW = 30837;
  33. private static final int NANARIN = 30956;
  34. private static final int SWAN = 30957;
  35. private static final int GALION = 30958;
  36. // Items
  37. private static final int SWANS_FLUTE = 4316;
  38. private static final int SWANS_LETTER = 4317;
  39. private static final int THEME_OF_JOURNEY = 4410;
  40. // Misc
  41. private static final int MIN_LEVEL = 15;
  42. public Q00362_BardsMandolin()
  43. {
  44. super(362, Q00362_BardsMandolin.class.getSimpleName(), "Bard's Mandolin");
  45. addStartNpc(SWAN);
  46. addTalkId(SWAN, GALION, WOODROW, NANARIN);
  47. registerQuestItems(SWANS_FLUTE, SWANS_LETTER);
  48. }
  49. @Override
  50. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  51. {
  52. final QuestState st = getQuestState(player, false);
  53. if (st == null)
  54. {
  55. return null;
  56. }
  57. String htmltext = null;
  58. switch (event)
  59. {
  60. case "30957-02.htm":
  61. {
  62. st.startQuest();
  63. st.setMemoState(1);
  64. htmltext = event;
  65. break;
  66. }
  67. case "30957-07.html":
  68. case "30957-08.html":
  69. {
  70. if (st.isMemoState(5))
  71. {
  72. st.giveAdena(10000, true);
  73. st.rewardItems(THEME_OF_JOURNEY, 1);
  74. st.exitQuest(true, true);
  75. htmltext = event;
  76. }
  77. break;
  78. }
  79. }
  80. return htmltext;
  81. }
  82. @Override
  83. public String onTalk(L2Npc npc, L2PcInstance player)
  84. {
  85. final QuestState st = getQuestState(player, true);
  86. String htmltext = getNoQuestMsg(player);
  87. switch (st.getState())
  88. {
  89. case State.CREATED:
  90. {
  91. if (npc.getId() == SWAN)
  92. {
  93. htmltext = (player.getLevel() >= MIN_LEVEL) ? "30957-01.htm" : "30957-03.html";
  94. }
  95. break;
  96. }
  97. case State.STARTED:
  98. {
  99. switch (npc.getId())
  100. {
  101. case SWAN:
  102. {
  103. switch (st.getMemoState())
  104. {
  105. case 1:
  106. case 2:
  107. {
  108. htmltext = "30957-04.html";
  109. break;
  110. }
  111. case 3:
  112. {
  113. st.setCond(4, true);
  114. st.setMemoState(4);
  115. st.giveItems(SWANS_LETTER, 1);
  116. htmltext = "30957-05.html";
  117. break;
  118. }
  119. case 4:
  120. {
  121. htmltext = "30957-05.html";
  122. break;
  123. }
  124. case 5:
  125. {
  126. htmltext = "30957-06.html";
  127. break;
  128. }
  129. }
  130. break;
  131. }
  132. case GALION:
  133. {
  134. if (st.isMemoState(2))
  135. {
  136. st.setMemoState(3);
  137. st.setCond(3, true);
  138. st.giveItems(SWANS_FLUTE, 1);
  139. htmltext = "30958-01.html";
  140. }
  141. else if (st.getMemoState() >= 3)
  142. {
  143. htmltext = "30958-02.html";
  144. }
  145. break;
  146. }
  147. case WOODROW:
  148. {
  149. if (st.isMemoState(1))
  150. {
  151. st.setMemoState(2);
  152. st.setCond(2, true);
  153. htmltext = "30837-01.html";
  154. }
  155. else if (st.isMemoState(2))
  156. {
  157. htmltext = "30837-02.html";
  158. }
  159. else if (st.getMemoState() >= 3)
  160. {
  161. htmltext = "30837-03.html";
  162. }
  163. break;
  164. }
  165. case NANARIN:
  166. {
  167. if (st.isMemoState(4) && st.hasQuestItems(SWANS_FLUTE, SWANS_LETTER))
  168. {
  169. st.setMemoState(5);
  170. st.setCond(5, true);
  171. st.takeItems(SWANS_FLUTE, -1);
  172. st.takeItems(SWANS_LETTER, -1);
  173. htmltext = "30956-01.html";
  174. }
  175. else if (st.getMemoState() >= 5)
  176. {
  177. htmltext = "30956-02.html";
  178. }
  179. break;
  180. }
  181. }
  182. break;
  183. }
  184. }
  185. return htmltext;
  186. }
  187. }