Q00040_ASpecialOrder.java 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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.Q00040_ASpecialOrder;
  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. import com.l2jserver.gameserver.model.quest.State;
  26. /**
  27. * A Special Order (40)
  28. * @author janiko
  29. */
  30. public final class Q00040_ASpecialOrder extends Quest
  31. {
  32. // NPCs
  33. private static final int HELVETIA = 30081;
  34. private static final int OFULLE = 31572;
  35. private static final int GESTO = 30511;
  36. // Items
  37. private static final int ORANGE_SWIFT_FISH = 6450;
  38. private static final int ORANGE_UGLY_FISH = 6451;
  39. private static final int ORANGE_WIDE_FISH = 6452;
  40. private static final int GOLDEN_COBOL = 5079;
  41. private static final int BUR_COBOL = 5082;
  42. private static final int GREAT_COBOL = 5084;
  43. private static final int WONDROUS_CUBIC = 10632;
  44. private static final int BOX_OF_FISH = 12764;
  45. private static final int BOX_OF_SEED = 12765;
  46. // Misc
  47. private static final int MIN_LVL = 40;
  48. public Q00040_ASpecialOrder()
  49. {
  50. super(40, Q00040_ASpecialOrder.class.getSimpleName(), "A Special Order");
  51. addStartNpc(HELVETIA);
  52. addTalkId(HELVETIA, OFULLE, GESTO);
  53. registerQuestItems(BOX_OF_FISH, BOX_OF_SEED);
  54. }
  55. @Override
  56. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  57. {
  58. final QuestState st = getQuestState(player, false);
  59. if (st == null)
  60. {
  61. return null;
  62. }
  63. String htmltext = null;
  64. switch (event)
  65. {
  66. case "accept":
  67. {
  68. st.setState(State.STARTED);
  69. st.playSound(QuestSound.ITEMSOUND_QUEST_ACCEPT);
  70. if (getRandomBoolean())
  71. {
  72. st.setCond(2);
  73. htmltext = "30081-03.html";
  74. }
  75. else
  76. {
  77. st.setCond(5);
  78. htmltext = "30081-04.html";
  79. }
  80. break;
  81. }
  82. case "30081-07.html":
  83. {
  84. if (st.isCond(4) && st.hasQuestItems(BOX_OF_FISH))
  85. {
  86. st.rewardItems(WONDROUS_CUBIC, 1);
  87. st.exitQuest(false, true);
  88. htmltext = event;
  89. }
  90. break;
  91. }
  92. case "30081-10.html":
  93. {
  94. if (st.isCond(7) && st.hasQuestItems(BOX_OF_SEED))
  95. {
  96. st.rewardItems(WONDROUS_CUBIC, 1);
  97. st.exitQuest(false, true);
  98. htmltext = event;
  99. }
  100. break;
  101. }
  102. case "31572-02.html":
  103. case "30511-02.html":
  104. {
  105. htmltext = event;
  106. break;
  107. }
  108. case "31572-03.html":
  109. {
  110. if (st.isCond(2))
  111. {
  112. st.setCond(3, true);
  113. htmltext = event;
  114. }
  115. break;
  116. }
  117. case "30511-03.html":
  118. {
  119. if (st.isCond(5))
  120. {
  121. st.setCond(6, true);
  122. htmltext = event;
  123. }
  124. break;
  125. }
  126. }
  127. return htmltext;
  128. }
  129. @Override
  130. public String onTalk(L2Npc npc, L2PcInstance player)
  131. {
  132. final QuestState st = getQuestState(player, true);
  133. String htmltext = getNoQuestMsg(player);
  134. if (st == null)
  135. {
  136. return htmltext;
  137. }
  138. switch (npc.getId())
  139. {
  140. case HELVETIA:
  141. {
  142. switch (st.getState())
  143. {
  144. case State.CREATED:
  145. {
  146. htmltext = (player.getLevel() >= MIN_LVL) ? "30081-01.htm" : "30081-02.htm";
  147. break;
  148. }
  149. case State.STARTED:
  150. {
  151. switch (st.getCond())
  152. {
  153. case 2:
  154. case 3:
  155. {
  156. htmltext = "30081-05.html";
  157. break;
  158. }
  159. case 4:
  160. {
  161. if (st.hasQuestItems(BOX_OF_FISH))
  162. {
  163. htmltext = "30081-06.html";
  164. }
  165. break;
  166. }
  167. case 5:
  168. case 6:
  169. {
  170. htmltext = "30081-08.html";
  171. break;
  172. }
  173. case 7:
  174. {
  175. if (st.hasQuestItems(BOX_OF_SEED))
  176. {
  177. htmltext = "30081-09.html";
  178. }
  179. break;
  180. }
  181. }
  182. break;
  183. }
  184. case State.COMPLETED:
  185. {
  186. htmltext = getAlreadyCompletedMsg(player);
  187. break;
  188. }
  189. }
  190. break;
  191. }
  192. case OFULLE:
  193. {
  194. switch (st.getCond())
  195. {
  196. case 2:
  197. {
  198. htmltext = "31572-01.html";
  199. break;
  200. }
  201. case 3:
  202. {
  203. if ((st.getQuestItemsCount(ORANGE_SWIFT_FISH) >= 10) && (st.getQuestItemsCount(ORANGE_UGLY_FISH) >= 10) && (st.getQuestItemsCount(ORANGE_WIDE_FISH) >= 10))
  204. {
  205. st.setCond(4, true);
  206. st.giveItems(BOX_OF_FISH, 1);
  207. takeItems(player, 10, ORANGE_SWIFT_FISH, ORANGE_UGLY_FISH, ORANGE_WIDE_FISH);
  208. htmltext = "31572-05.html";
  209. }
  210. else
  211. {
  212. htmltext = "31572-04.html";
  213. }
  214. break;
  215. }
  216. case 4:
  217. {
  218. htmltext = "31572-06.html";
  219. break;
  220. }
  221. }
  222. break;
  223. }
  224. case GESTO:
  225. {
  226. switch (st.getCond())
  227. {
  228. case 5:
  229. {
  230. htmltext = "30511-01.html";
  231. break;
  232. }
  233. case 6:
  234. {
  235. if ((st.getQuestItemsCount(GOLDEN_COBOL) >= 40) && (st.getQuestItemsCount(BUR_COBOL) >= 40) && (st.getQuestItemsCount(GREAT_COBOL) >= 40))
  236. {
  237. st.setCond(7, true);
  238. st.giveItems(BOX_OF_SEED, 1);
  239. takeItems(player, 40, GOLDEN_COBOL, BUR_COBOL, GREAT_COBOL);
  240. htmltext = "30511-05.html";
  241. }
  242. else
  243. {
  244. htmltext = "30511-04.html";
  245. }
  246. break;
  247. }
  248. case 7:
  249. {
  250. htmltext = "30511-06.html";
  251. break;
  252. }
  253. }
  254. break;
  255. }
  256. }
  257. return htmltext;
  258. }
  259. }