Q00045_ToTalkingIsland.java 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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.Q00045_ToTalkingIsland;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import quests.Q00006_StepIntoTheFuture.Q00006_StepIntoTheFuture;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.model.holders.ItemHolder;
  26. import com.l2jserver.gameserver.model.quest.Quest;
  27. import com.l2jserver.gameserver.model.quest.QuestState;
  28. import com.l2jserver.gameserver.model.quest.State;
  29. /**
  30. * To Talking Island (45)
  31. * @author janiko
  32. */
  33. public final class Q00045_ToTalkingIsland extends Quest
  34. {
  35. // Npcs
  36. private static final int GALLADUCCI = 30097;
  37. private static final int GENTLER = 30094;
  38. private static final int SANDRA = 30090;
  39. private static final int DUSTIN = 30116;
  40. // Items
  41. private static final int MARK_OF_TRAVELER = 7570;
  42. private static final int GALLADUCCIS_ORDER_1 = 7563;
  43. private static final int GALLADUCCIS_ORDER_2 = 7564;
  44. private static final int GALLADUCCIS_ORDER_3 = 7565;
  45. private static final int PURIFIED_MAGIC_NECKLACE = 7566;
  46. private static final int GEMSTONE_POWDER = 7567;
  47. private static final int MAGIC_SWORD_HILT = 7568;
  48. // Misc
  49. private static final int MIN_LVL = 3;
  50. // Reward
  51. private static final int SCROLL_OF_ESCAPE_TALKING_ISLAND_VILLAGE = 7554;
  52. // Get condition for each npc
  53. private static Map<Integer, ItemHolder> NPC_ITEMS = new HashMap<>();
  54. static
  55. {
  56. NPC_ITEMS.put(GENTLER, new ItemHolder(1, GALLADUCCIS_ORDER_1));
  57. NPC_ITEMS.put(SANDRA, new ItemHolder(3, GALLADUCCIS_ORDER_2));
  58. NPC_ITEMS.put(DUSTIN, new ItemHolder(5, GALLADUCCIS_ORDER_3));
  59. }
  60. public Q00045_ToTalkingIsland()
  61. {
  62. super(45, Q00045_ToTalkingIsland.class.getSimpleName(), "To Talking Island");
  63. addStartNpc(GALLADUCCI);
  64. addTalkId(GALLADUCCI);
  65. addTalkId(NPC_ITEMS.keySet());
  66. registerQuestItems(GALLADUCCIS_ORDER_1, GALLADUCCIS_ORDER_2, GALLADUCCIS_ORDER_3, PURIFIED_MAGIC_NECKLACE, GEMSTONE_POWDER, MAGIC_SWORD_HILT);
  67. }
  68. @Override
  69. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  70. {
  71. final QuestState st = getQuestState(player, false);
  72. String htmltext = null;
  73. if (st == null)
  74. {
  75. return htmltext;
  76. }
  77. switch (event)
  78. {
  79. case "30097-04.htm":
  80. {
  81. if (st.isCreated())
  82. {
  83. st.startQuest();
  84. st.giveItems(GALLADUCCIS_ORDER_1, 1);
  85. htmltext = event;
  86. }
  87. break;
  88. }
  89. case "30094-02.html":
  90. {
  91. if (st.isCond(1) && st.hasQuestItems(GALLADUCCIS_ORDER_1))
  92. {
  93. st.takeItems(GALLADUCCIS_ORDER_1, 1);
  94. st.giveItems(MAGIC_SWORD_HILT, 1);
  95. st.setCond(2, true);
  96. htmltext = event;
  97. }
  98. else
  99. {
  100. htmltext = "30094-03.html";
  101. }
  102. break;
  103. }
  104. case "30097-07.html":
  105. {
  106. if (st.isCond(2) && st.hasQuestItems(MAGIC_SWORD_HILT))
  107. {
  108. st.takeItems(MAGIC_SWORD_HILT, 1);
  109. st.giveItems(GALLADUCCIS_ORDER_2, 1);
  110. st.setCond(3, true);
  111. htmltext = event;
  112. }
  113. else
  114. {
  115. htmltext = "30097-08.html";
  116. }
  117. break;
  118. }
  119. case "30090-02.html":
  120. {
  121. if (st.isCond(3) && st.hasQuestItems(GALLADUCCIS_ORDER_2))
  122. {
  123. st.takeItems(GALLADUCCIS_ORDER_2, 1);
  124. st.giveItems(GEMSTONE_POWDER, 1);
  125. st.setCond(4, true);
  126. htmltext = event;
  127. }
  128. else
  129. {
  130. htmltext = "30090-03.html";
  131. }
  132. break;
  133. }
  134. case "30097-11.html":
  135. {
  136. if (st.isCond(4) && st.hasQuestItems(GEMSTONE_POWDER))
  137. {
  138. st.takeItems(GEMSTONE_POWDER, 1);
  139. st.giveItems(GALLADUCCIS_ORDER_3, 1);
  140. st.setCond(5, true);
  141. htmltext = event;
  142. }
  143. else
  144. {
  145. htmltext = "30097-12.html";
  146. }
  147. break;
  148. }
  149. case "30116-02.html":
  150. {
  151. if (st.isCond(5) && st.hasQuestItems(GALLADUCCIS_ORDER_3))
  152. {
  153. st.takeItems(GALLADUCCIS_ORDER_3, 1);
  154. st.giveItems(PURIFIED_MAGIC_NECKLACE, 1);
  155. st.setCond(6, true);
  156. htmltext = event;
  157. }
  158. else
  159. {
  160. htmltext = "30116-03.html";
  161. }
  162. break;
  163. }
  164. case "30097-15.html":
  165. {
  166. if (st.isCond(6) && st.hasQuestItems(PURIFIED_MAGIC_NECKLACE))
  167. {
  168. st.giveItems(SCROLL_OF_ESCAPE_TALKING_ISLAND_VILLAGE, 1);
  169. st.exitQuest(false, true);
  170. htmltext = event;
  171. }
  172. else
  173. {
  174. htmltext = "30097-16.html";
  175. }
  176. break;
  177. }
  178. }
  179. return htmltext;
  180. }
  181. @Override
  182. public String onTalk(L2Npc npc, L2PcInstance talker)
  183. {
  184. QuestState st = getQuestState(talker, true);
  185. String htmltext = getNoQuestMsg(talker);
  186. if (st == null)
  187. {
  188. return htmltext;
  189. }
  190. switch (npc.getId())
  191. {
  192. case GALLADUCCI:
  193. {
  194. switch (st.getState())
  195. {
  196. case State.CREATED:
  197. {
  198. if (talker.getLevel() < MIN_LVL)
  199. {
  200. htmltext = "30097-03.html";
  201. }
  202. else
  203. {
  204. st = talker.getQuestState(Q00006_StepIntoTheFuture.class.getSimpleName());
  205. if ((st != null) && st.isCompleted() && st.hasQuestItems(MARK_OF_TRAVELER))
  206. {
  207. htmltext = "30097-01.htm";
  208. }
  209. else
  210. {
  211. htmltext = "30097-02.html";
  212. }
  213. }
  214. break;
  215. }
  216. case State.STARTED:
  217. {
  218. switch (st.getCond())
  219. {
  220. case 1:
  221. {
  222. htmltext = "30097-05.html";
  223. break;
  224. }
  225. case 2:
  226. {
  227. if (st.hasQuestItems(MAGIC_SWORD_HILT))
  228. {
  229. htmltext = "30097-06.html";
  230. }
  231. break;
  232. }
  233. case 3:
  234. {
  235. htmltext = "30097-09.html";
  236. break;
  237. }
  238. case 4:
  239. {
  240. if (st.hasQuestItems(GEMSTONE_POWDER))
  241. {
  242. htmltext = "30097-10.html";
  243. }
  244. break;
  245. }
  246. case 5:
  247. {
  248. htmltext = "30097-13.html";
  249. break;
  250. }
  251. case 6:
  252. {
  253. if (st.hasQuestItems(PURIFIED_MAGIC_NECKLACE))
  254. {
  255. htmltext = "30097-14.html";
  256. }
  257. break;
  258. }
  259. }
  260. break;
  261. }
  262. case State.COMPLETED:
  263. {
  264. htmltext = getAlreadyCompletedMsg(talker);
  265. break;
  266. }
  267. }
  268. break;
  269. }
  270. case GENTLER:
  271. case SANDRA:
  272. case DUSTIN:
  273. {
  274. if (st.isStarted())
  275. {
  276. final ItemHolder i = NPC_ITEMS.get(npc.getId());
  277. final int cond = i.getId();
  278. if (st.isCond(cond))
  279. {
  280. final int itemId = (int) i.getCount();
  281. if (st.hasQuestItems(itemId))
  282. {
  283. htmltext = npc.getId() + "-01.html";
  284. }
  285. }
  286. else if (st.isCond(cond + 1))
  287. {
  288. htmltext = npc.getId() + "-04.html";
  289. }
  290. }
  291. break;
  292. }
  293. }
  294. return htmltext;
  295. }
  296. }