Q00128_PailakaSongOfIceAndFire.java 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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.Q00128_PailakaSongOfIceAndFire;
  20. import com.l2jserver.gameserver.enums.QuestSound;
  21. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.entity.Instance;
  25. import com.l2jserver.gameserver.model.holders.SkillHolder;
  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. * Pailaka - Song of Ice and Fire (128)
  31. * @author Gnacik, St3eT
  32. */
  33. public final class Q00128_PailakaSongOfIceAndFire extends Quest
  34. {
  35. // NPCs
  36. private static final int ADLER1 = 32497;
  37. private static final int ADLER2 = 32510;
  38. private static final int SINAI = 32500;
  39. private static final int INSPECTOR = 32507;
  40. private static final int HILLAS = 18610;
  41. private static final int PAPION = 18609;
  42. private static final int KINSUS = 18608;
  43. private static final int GARGOS = 18607;
  44. private static final int ADIANTUM = 18620;
  45. // Items
  46. private static final int SWORD = 13034;
  47. private static final int ENH_SWORD1 = 13035;
  48. private static final int ENH_SWORD2 = 13036;
  49. private static final int BOOK1 = 13130;
  50. private static final int BOOK2 = 13131;
  51. private static final int BOOK3 = 13132;
  52. private static final int BOOK4 = 13133;
  53. private static final int BOOK5 = 13134;
  54. private static final int BOOK6 = 13135;
  55. private static final int BOOK7 = 13136;
  56. private static final int WATER_ESSENCE = 13038;
  57. private static final int FIRE_ESSENCE = 13039;
  58. private static final int SHIELD_POTION = 13032;
  59. private static final int HEAL_POTION = 13033;
  60. private static final int FIRE_ENHANCER = 13040;
  61. private static final int WATER_ENHANCER = 13041;
  62. private static final int[] REWARDS =
  63. {
  64. 13294, // Pailaka Ring
  65. 13293, // Pailaka Earring
  66. 736, // Scroll of Escape
  67. };
  68. // Skills
  69. private static SkillHolder VITALITY_REPLENISHING = new SkillHolder(5774, 1);
  70. // Misc
  71. private static final int MIN_LEVEL = 36;
  72. private static final int MAX_LEVEL = 42;
  73. private static final int EXIT_TIME = 5;
  74. public Q00128_PailakaSongOfIceAndFire()
  75. {
  76. super(128, Q00128_PailakaSongOfIceAndFire.class.getSimpleName(), "Pailaka - Song of Ice and Fire");
  77. addStartNpc(ADLER1);
  78. addTalkId(ADLER1, ADLER2, SINAI, INSPECTOR);
  79. addKillId(HILLAS, PAPION, KINSUS, GARGOS, ADIANTUM);
  80. registerQuestItems(SWORD, ENH_SWORD1, ENH_SWORD2, BOOK1, BOOK2, BOOK3, BOOK4, BOOK5, BOOK6, BOOK7, WATER_ESSENCE, FIRE_ESSENCE, SHIELD_POTION, HEAL_POTION, FIRE_ENHANCER, WATER_ENHANCER);
  81. }
  82. @Override
  83. public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  84. {
  85. String htmltext = null;
  86. final QuestState st = getQuestState(player, false);
  87. if (st == null)
  88. {
  89. return getNoQuestMsg(player);
  90. }
  91. switch (event)
  92. {
  93. case "32500-02.htm":
  94. case "32500-03.htm":
  95. case "32500-04.htm":
  96. case "32500-05.htm":
  97. case "32497-02.htm":
  98. case "32507-07.htm":
  99. case "32497-04.htm":
  100. {
  101. htmltext = event;
  102. break;
  103. }
  104. case "32497-03.htm":
  105. {
  106. if (!st.isStarted())
  107. {
  108. st.startQuest();
  109. htmltext = event;
  110. }
  111. break;
  112. }
  113. case "32500-06.htm":
  114. {
  115. if (st.isCond(1))
  116. {
  117. st.setCond(2, true);
  118. giveItems(player, SWORD, 1);
  119. giveItems(player, BOOK1, 1);
  120. htmltext = event;
  121. }
  122. break;
  123. }
  124. case "32507-04.htm":
  125. {
  126. if (st.isCond(3))
  127. {
  128. st.setCond(4, true);
  129. takeItems(player, SWORD, -1);
  130. takeItems(player, WATER_ESSENCE, -1);
  131. takeItems(player, BOOK2, -1);
  132. giveItems(player, BOOK3, 1);
  133. giveItems(player, ENH_SWORD1, 1);
  134. htmltext = event;
  135. }
  136. break;
  137. }
  138. case "32507-08.htm":
  139. {
  140. if (st.isCond(6))
  141. {
  142. st.setCond(7, true);
  143. takeItems(player, ENH_SWORD1, -1);
  144. takeItems(player, BOOK5, -1);
  145. takeItems(player, FIRE_ESSENCE, -1);
  146. giveItems(player, ENH_SWORD2, 1);
  147. giveItems(player, BOOK6, 1);
  148. htmltext = event;
  149. }
  150. break;
  151. }
  152. case "32510-02.htm":
  153. {
  154. st.exitQuest(false, true);
  155. Instance inst = InstanceManager.getInstance().getInstance(npc.getInstanceId());
  156. inst.setDuration(EXIT_TIME * 60000);
  157. inst.setEmptyDestroyTime(0);
  158. if (inst.containsPlayer(player.getObjectId()))
  159. {
  160. npc.setTarget(player);
  161. npc.doCast(VITALITY_REPLENISHING.getSkill());
  162. addExpAndSp(player, 810000, 50000);
  163. for (int id : REWARDS)
  164. {
  165. giveItems(player, id, 1);
  166. }
  167. }
  168. htmltext = event;
  169. break;
  170. }
  171. }
  172. return htmltext;
  173. }
  174. @Override
  175. public final String onTalk(L2Npc npc, L2PcInstance player)
  176. {
  177. String htmltext = getNoQuestMsg(player);
  178. final QuestState st = getQuestState(player, true);
  179. if (st == null)
  180. {
  181. return htmltext;
  182. }
  183. switch (npc.getId())
  184. {
  185. case ADLER1:
  186. {
  187. switch (st.getState())
  188. {
  189. case State.CREATED:
  190. {
  191. if (player.getLevel() < MIN_LEVEL)
  192. {
  193. htmltext = "32497-05.htm";
  194. }
  195. else if (player.getLevel() > MAX_LEVEL)
  196. {
  197. htmltext = "32497-06.htm";
  198. }
  199. else
  200. {
  201. htmltext = "32497-01.htm";
  202. }
  203. break;
  204. }
  205. case State.STARTED:
  206. {
  207. if (st.getCond() > 1)
  208. {
  209. htmltext = "32497-00.htm";
  210. }
  211. else
  212. {
  213. htmltext = "32497-03.htm";
  214. }
  215. break;
  216. }
  217. case State.COMPLETED:
  218. {
  219. htmltext = "32497-07.htm";
  220. break;
  221. }
  222. default:
  223. {
  224. htmltext = "32497-01.htm";
  225. break;
  226. }
  227. }
  228. break;
  229. }
  230. case SINAI:
  231. {
  232. if (st.getCond() > 1)
  233. {
  234. htmltext = "32500-00.htm";
  235. }
  236. else
  237. {
  238. htmltext = "32500-01.htm";
  239. }
  240. break;
  241. }
  242. case INSPECTOR:
  243. {
  244. switch (st.getCond())
  245. {
  246. case 1:
  247. {
  248. htmltext = "32507-01.htm";
  249. break;
  250. }
  251. case 2:
  252. {
  253. htmltext = "32507-02.htm";
  254. break;
  255. }
  256. case 3:
  257. {
  258. htmltext = "32507-03.htm";
  259. break;
  260. }
  261. case 4:
  262. case 5:
  263. {
  264. htmltext = "32507-05.htm";
  265. break;
  266. }
  267. case 6:
  268. {
  269. htmltext = "32507-06.htm";
  270. break;
  271. }
  272. default:
  273. {
  274. htmltext = "32507-09.htm";
  275. break;
  276. }
  277. }
  278. break;
  279. }
  280. case ADLER2:
  281. {
  282. if (st.isCompleted())
  283. {
  284. htmltext = "32510-00.htm";
  285. }
  286. else if (st.isCond(9))
  287. {
  288. htmltext = "32510-01.htm";
  289. }
  290. break;
  291. }
  292. }
  293. return htmltext;
  294. }
  295. @Override
  296. public final String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  297. {
  298. final QuestState st = getQuestState(player, false);
  299. if ((st != null) && st.isStarted())
  300. {
  301. switch (npc.getId())
  302. {
  303. case HILLAS:
  304. {
  305. if (st.isCond(2))
  306. {
  307. st.setCond(3);
  308. playSound(player, QuestSound.ITEMSOUND_QUEST_ITEMGET);
  309. takeItems(player, BOOK1, -1);
  310. giveItems(player, BOOK2, 1);
  311. giveItems(player, WATER_ESSENCE, 1);
  312. }
  313. addSpawn(PAPION, -53903, 181484, -4555, 30456, false, 0, false, npc.getInstanceId());
  314. break;
  315. }
  316. case PAPION:
  317. {
  318. if (st.isCond(4))
  319. {
  320. st.setCond(5);
  321. takeItems(player, BOOK3, -1);
  322. giveItems(player, BOOK4, 1);
  323. playSound(player, QuestSound.ITEMSOUND_QUEST_ITEMGET);
  324. }
  325. addSpawn(KINSUS, -61415, 181418, -4818, 63852, false, 0, false, npc.getInstanceId());
  326. break;
  327. }
  328. case KINSUS:
  329. {
  330. if (st.isCond(5))
  331. {
  332. st.setCond(6);
  333. playSound(player, QuestSound.ITEMSOUND_QUEST_ITEMGET);
  334. takeItems(player, BOOK4, -1);
  335. giveItems(player, BOOK5, 1);
  336. giveItems(player, FIRE_ESSENCE, 1);
  337. }
  338. addSpawn(GARGOS, -61354, 183624, -4821, 63613, false, 0, false, npc.getInstanceId());
  339. break;
  340. }
  341. case GARGOS:
  342. {
  343. if (st.isCond(7))
  344. {
  345. st.setCond(8);
  346. playSound(player, QuestSound.ITEMSOUND_QUEST_ITEMGET);
  347. takeItems(player, BOOK6, -1);
  348. giveItems(player, BOOK7, 1);
  349. }
  350. addSpawn(ADIANTUM, -53297, 185027, -4617, 1512, false, 0, false, npc.getInstanceId());
  351. break;
  352. }
  353. case ADIANTUM:
  354. {
  355. if (st.isCond(8))
  356. {
  357. st.setCond(9);
  358. playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
  359. takeItems(player, BOOK7, -1);
  360. addSpawn(ADLER2, -53297, 185027, -4617, 33486, false, 0, false, npc.getInstanceId());
  361. }
  362. break;
  363. }
  364. }
  365. }
  366. return super.onKill(npc, player, isSummon);
  367. }
  368. }