Q00131_BirdInACage.java 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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.Q00131_BirdInACage;
  20. import com.l2jserver.gameserver.model.Location;
  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. /**
  27. * Bird in a Cage (131)
  28. * @author Zoey76
  29. */
  30. public class Q00131_BirdInACage extends Quest
  31. {
  32. // NPCs
  33. private static final int KANIS = 32264;
  34. private static final int PARME = 32271;
  35. // Items
  36. private static final int ECHO_CRYSTAL_OF_FREE_THOUGHT = 9783;
  37. private static final int PARMES_LETTER = 9784;
  38. private static final int FIRE_STONE = 9546;
  39. // Locations
  40. private static final Location INSTANCE_EXIT = new Location(143281, 148843, -12004);
  41. // Misc
  42. private static final int MIN_LEVEL = 78;
  43. public Q00131_BirdInACage()
  44. {
  45. super(131, Q00131_BirdInACage.class.getSimpleName(), "Bird in a Cage");
  46. addStartNpc(KANIS);
  47. addTalkId(KANIS, PARME);
  48. registerQuestItems(ECHO_CRYSTAL_OF_FREE_THOUGHT, PARMES_LETTER);
  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 null;
  57. }
  58. String htmltext = null;
  59. switch (event)
  60. {
  61. case "32264-04.html":
  62. {
  63. if (player.getLevel() >= MIN_LEVEL)
  64. {
  65. st.startQuest();
  66. htmltext = event;
  67. }
  68. break;
  69. }
  70. case "32264-06.html":
  71. {
  72. if (st.isCond(1))
  73. {
  74. htmltext = event;
  75. }
  76. break;
  77. }
  78. case "32264-07.html":
  79. {
  80. if (st.isCond(1))
  81. {
  82. st.setCond(2);
  83. htmltext = event;
  84. }
  85. break;
  86. }
  87. case "32264-09.html":
  88. case "32264-10.html":
  89. case "32264-11.html":
  90. {
  91. if (st.isCond(2))
  92. {
  93. htmltext = event;
  94. }
  95. break;
  96. }
  97. case "32264-12.html":
  98. {
  99. if (st.isCond(2))
  100. {
  101. st.giveItems(ECHO_CRYSTAL_OF_FREE_THOUGHT, 1);
  102. st.setCond(3, true);
  103. htmltext = event;
  104. }
  105. break;
  106. }
  107. case "32264-14.html":
  108. case "32264-15.html":
  109. {
  110. if (st.isCond(3))
  111. {
  112. htmltext = event;
  113. }
  114. break;
  115. }
  116. case "32264-17.html":
  117. {
  118. if (st.isCond(4) && st.hasQuestItems(PARMES_LETTER))
  119. {
  120. st.takeItems(PARMES_LETTER, -1);
  121. st.setCond(5);
  122. htmltext = event;
  123. }
  124. break;
  125. }
  126. case "32264-19.html":
  127. {
  128. if (st.isCond(5) && st.hasQuestItems(ECHO_CRYSTAL_OF_FREE_THOUGHT))
  129. {
  130. st.addExpAndSp(250677, 25019);
  131. st.giveItems(FIRE_STONE + getRandom(4), 4);
  132. st.exitQuest(false, true);
  133. htmltext = event;
  134. }
  135. break;
  136. }
  137. case "32271-03.html":
  138. {
  139. if (st.isCond(3))
  140. {
  141. htmltext = event;
  142. }
  143. break;
  144. }
  145. case "32271-04.html":
  146. {
  147. if (st.isCond(3))
  148. {
  149. st.giveItems(PARMES_LETTER, 1);
  150. st.setCond(4, true);
  151. player.setInstanceId(0);
  152. player.teleToLocation(INSTANCE_EXIT, true);
  153. htmltext = event;
  154. }
  155. break;
  156. }
  157. }
  158. return htmltext;
  159. }
  160. @Override
  161. public String onTalk(L2Npc npc, L2PcInstance player)
  162. {
  163. final QuestState st = getQuestState(player, true);
  164. String htmltext = getNoQuestMsg(player);
  165. if (st == null)
  166. {
  167. return htmltext;
  168. }
  169. switch (st.getState())
  170. {
  171. case State.COMPLETED:
  172. {
  173. htmltext = getAlreadyCompletedMsg(player);
  174. break;
  175. }
  176. case State.CREATED:
  177. {
  178. if (npc.getId() == KANIS)
  179. {
  180. htmltext = (player.getLevel() >= MIN_LEVEL) ? "32264-01.htm" : "32264-02.html";
  181. }
  182. break;
  183. }
  184. case State.STARTED:
  185. {
  186. if (npc.getId() == KANIS)
  187. {
  188. switch (st.getCond())
  189. {
  190. case 1:
  191. {
  192. htmltext = "32264-05.html";
  193. break;
  194. }
  195. case 2:
  196. {
  197. htmltext = "32264-08.html";
  198. break;
  199. }
  200. case 3:
  201. {
  202. htmltext = "32264-13.html";
  203. break;
  204. }
  205. case 4:
  206. {
  207. htmltext = "32264-16.html";
  208. break;
  209. }
  210. case 5:
  211. {
  212. htmltext = "32264-18.html";
  213. break;
  214. }
  215. }
  216. }
  217. else if (npc.getId() == PARME)
  218. {
  219. if (st.getCond() < 3)
  220. {
  221. htmltext = "32271-01.html";
  222. }
  223. else if (st.isCond(3))
  224. {
  225. htmltext = "32271-02.html";
  226. }
  227. }
  228. break;
  229. }
  230. }
  231. return htmltext;
  232. }
  233. }