Q00621_EggDelivery.java 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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.Q00621_EggDelivery;
  20. import java.util.Arrays;
  21. import java.util.List;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.quest.Quest;
  25. import com.l2jserver.gameserver.model.quest.QuestState;
  26. import com.l2jserver.gameserver.model.quest.State;
  27. /**
  28. * Egg Delivery (621)
  29. * @author Janiko
  30. */
  31. public final class Q00621_EggDelivery extends Quest
  32. {
  33. // NPCs
  34. private static final int JEREMY = 31521;
  35. private static final int PULIN = 31543;
  36. private static final int NAFF = 31544;
  37. private static final int CROCUS = 31545;
  38. private static final int KUBER = 31546;
  39. private static final int BOELIN = 31547;
  40. private static final int VALENTINE = 31584;
  41. // Items
  42. private static final int BOILED_EGG = 7195;
  43. private static final int EGG_PRICE = 7196;
  44. // Misc
  45. private static final int MIN_LVL = 68;
  46. // Reward
  47. private static final int QUICK_STEP_POTION = 734;
  48. private static final int SEALED_RING_OF_AURAKYRA = 6849;
  49. private static final int SEALED_SANDDRAGONS_EARING = 6847;
  50. private static final int SEALED_DRAGON_NECKLACE = 6851;
  51. // Talkers
  52. private static final List<Integer> TALKERS = Arrays.asList(NAFF, CROCUS, KUBER, BOELIN);
  53. public Q00621_EggDelivery()
  54. {
  55. super(621, Q00621_EggDelivery.class.getSimpleName(), "Egg Delivery");
  56. addStartNpc(JEREMY);
  57. addTalkId(JEREMY, PULIN, VALENTINE);
  58. addTalkId(TALKERS);
  59. registerQuestItems(BOILED_EGG, EGG_PRICE);
  60. }
  61. @Override
  62. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  63. {
  64. final QuestState qs = getQuestState(player, false);
  65. String htmltext = null;
  66. if (qs == null)
  67. {
  68. return htmltext;
  69. }
  70. switch (event)
  71. {
  72. case "31521-03.htm":
  73. {
  74. if (qs.isCreated())
  75. {
  76. qs.startQuest();
  77. giveItems(player, BOILED_EGG, 5);
  78. htmltext = event;
  79. }
  80. break;
  81. }
  82. case "31521-06.html":
  83. {
  84. if (qs.isCond(6))
  85. {
  86. if (getQuestItemsCount(player, EGG_PRICE) >= 5)
  87. {
  88. qs.setCond(7, true);
  89. takeItems(player, EGG_PRICE, -1);
  90. htmltext = event;
  91. }
  92. else
  93. {
  94. htmltext = "31521-07.html";
  95. }
  96. }
  97. break;
  98. }
  99. case "31543-02.html":
  100. {
  101. if (qs.isCond(1))
  102. {
  103. if (hasQuestItems(player, BOILED_EGG))
  104. {
  105. qs.setCond(2, true);
  106. takeItems(player, BOILED_EGG, 1);
  107. giveItems(player, EGG_PRICE, 1);
  108. htmltext = event;
  109. }
  110. else
  111. {
  112. htmltext = "31543-03.html";
  113. }
  114. }
  115. break;
  116. }
  117. case "31544-02.html":
  118. case "31545-02.html":
  119. case "31546-02.html":
  120. case "31547-02.html":
  121. {
  122. if (TALKERS.contains(npc.getId()) && qs.isCond(TALKERS.indexOf(npc.getId()) + 2))
  123. {
  124. if (hasQuestItems(player, BOILED_EGG))
  125. {
  126. qs.setCond(qs.getCond() + 1, true);
  127. takeItems(player, BOILED_EGG, 1);
  128. giveItems(player, EGG_PRICE, 1);
  129. htmltext = event;
  130. }
  131. else
  132. {
  133. htmltext = npc.getId() + "-03.html";
  134. }
  135. }
  136. break;
  137. }
  138. case "31584-02.html":
  139. {
  140. if (qs.isCond(7))
  141. {
  142. int rnd = getRandom(1000);
  143. if (rnd < 800)
  144. {
  145. rewardItems(player, QUICK_STEP_POTION, 1);
  146. giveAdena(player, 18800, true);
  147. }
  148. else if (rnd < 880)
  149. {
  150. rewardItems(player, SEALED_RING_OF_AURAKYRA, 1);
  151. }
  152. else if (rnd < 960)
  153. {
  154. rewardItems(player, SEALED_SANDDRAGONS_EARING, 1);
  155. }
  156. else if (rnd < 1000)
  157. {
  158. rewardItems(player, SEALED_DRAGON_NECKLACE, 1);
  159. }
  160. qs.exitQuest(true, true);
  161. htmltext = event;
  162. }
  163. break;
  164. }
  165. }
  166. return htmltext;
  167. }
  168. @Override
  169. public String onTalk(L2Npc npc, L2PcInstance talker)
  170. {
  171. final QuestState qs = getQuestState(talker, true);
  172. String htmltext = getNoQuestMsg(talker);
  173. switch (npc.getId())
  174. {
  175. case JEREMY:
  176. {
  177. switch (qs.getState())
  178. {
  179. case State.CREATED:
  180. {
  181. htmltext = (talker.getLevel() >= MIN_LVL) ? "31521-01.htm" : "31521-02.htm";
  182. break;
  183. }
  184. case State.STARTED:
  185. {
  186. switch (qs.getCond())
  187. {
  188. case 1:
  189. {
  190. htmltext = "31521-04.html";
  191. break;
  192. }
  193. case 6:
  194. {
  195. if (hasQuestItems(talker, EGG_PRICE))
  196. {
  197. htmltext = "31521-05.html";
  198. }
  199. break;
  200. }
  201. case 7:
  202. {
  203. if (!hasQuestItems(talker, BOILED_EGG))
  204. {
  205. htmltext = "31521-08.html";
  206. }
  207. break;
  208. }
  209. }
  210. break;
  211. }
  212. case State.COMPLETED:
  213. {
  214. htmltext = getAlreadyCompletedMsg(talker);
  215. break;
  216. }
  217. }
  218. break;
  219. }
  220. case PULIN:
  221. {
  222. if (qs.isStarted())
  223. {
  224. switch (qs.getCond())
  225. {
  226. case 1:
  227. {
  228. if (getQuestItemsCount(talker, BOILED_EGG) >= 5)
  229. {
  230. htmltext = "31543-01.html";
  231. }
  232. break;
  233. }
  234. case 2:
  235. {
  236. htmltext = "31543-04.html";
  237. break;
  238. }
  239. }
  240. }
  241. break;
  242. }
  243. case NAFF:
  244. case CROCUS:
  245. case KUBER:
  246. case BOELIN:
  247. {
  248. if (qs.isStarted())
  249. {
  250. final int cond = TALKERS.indexOf(npc.getId()) + 2;
  251. if (qs.isCond(cond) && hasQuestItems(talker, EGG_PRICE)) // 2,3,4,5
  252. {
  253. htmltext = npc.getId() + "-01.html";
  254. }
  255. else if (qs.isCond(cond + 1)) // 3,4,5,6
  256. {
  257. htmltext = npc.getId() + "-04.html";
  258. }
  259. }
  260. break;
  261. }
  262. case VALENTINE:
  263. {
  264. if (qs.isStarted() && qs.isCond(7))
  265. {
  266. htmltext = "31584-01.html";
  267. }
  268. break;
  269. }
  270. }
  271. return htmltext;
  272. }
  273. }