Q00197_SevenSignsTheSacredBookOfSeal.java 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  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.Q00197_SevenSignsTheSacredBookOfSeal;
  20. import quests.Q00196_SevenSignsSealOfTheEmperor.Q00196_SevenSignsSealOfTheEmperor;
  21. import com.l2jserver.gameserver.ai.CtrlIntention;
  22. import com.l2jserver.gameserver.enums.QuestSound;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  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. import com.l2jserver.gameserver.network.NpcStringId;
  30. import com.l2jserver.gameserver.network.clientpackets.Say2;
  31. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  32. /**
  33. * Seven Signs, The Sacred Book of Seal (197)
  34. * @author Adry_85
  35. */
  36. public final class Q00197_SevenSignsTheSacredBookOfSeal extends Quest
  37. {
  38. // NPCs
  39. private static final int SHILENS_EVIL_THOUGHTS = 27396;
  40. private static final int ORVEN = 30857;
  41. private static final int WOOD = 32593;
  42. private static final int LEOPARD = 32594;
  43. private static final int LAWRENCE = 32595;
  44. private static final int SOPHIA = 32596;
  45. // Items
  46. private static final int MYSTERIOUS_HAND_WRITTEN_TEXT = 13829;
  47. private static final int SCULPTURE_OF_DOUBT = 14354;
  48. // Misc
  49. private static final int MIN_LEVEL = 79;
  50. private boolean isBusy = false;
  51. public Q00197_SevenSignsTheSacredBookOfSeal()
  52. {
  53. super(197, Q00197_SevenSignsTheSacredBookOfSeal.class.getSimpleName(), "Seven Signs, the Sacred Book of Seal");
  54. addStartNpc(WOOD);
  55. addTalkId(WOOD, ORVEN, LEOPARD, LAWRENCE, SOPHIA);
  56. addKillId(SHILENS_EVIL_THOUGHTS);
  57. registerQuestItems(MYSTERIOUS_HAND_WRITTEN_TEXT, SCULPTURE_OF_DOUBT);
  58. }
  59. @Override
  60. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  61. {
  62. if ((npc.getId() == SHILENS_EVIL_THOUGHTS) && "despawn".equals(event))
  63. {
  64. if (!npc.isDead())
  65. {
  66. isBusy = false;
  67. npc.broadcastPacket(new NpcSay(npc.getObjectId(), Say2.NPC_ALL, npc.getId(), NpcStringId.NEXT_TIME_YOU_WILL_NOT_ESCAPE));
  68. npc.deleteMe();
  69. }
  70. return super.onAdvEvent(event, npc, player);
  71. }
  72. final QuestState st = getQuestState(player, false);
  73. if (st == null)
  74. {
  75. return null;
  76. }
  77. String htmltext = null;
  78. switch (event)
  79. {
  80. case "32593-02.htm":
  81. case "32593-03.htm":
  82. {
  83. htmltext = event;
  84. break;
  85. }
  86. case "32593-04.html":
  87. {
  88. st.startQuest();
  89. htmltext = event;
  90. break;
  91. }
  92. case "32593-08.html":
  93. {
  94. if (st.isCond(6) && st.hasQuestItems(MYSTERIOUS_HAND_WRITTEN_TEXT, SCULPTURE_OF_DOUBT))
  95. {
  96. htmltext = event;
  97. }
  98. break;
  99. }
  100. case "32593-09.html":
  101. {
  102. if (st.isCond(6))
  103. {
  104. if (player.getLevel() >= MIN_LEVEL)
  105. {
  106. st.addExpAndSp(52518015, 5817677);
  107. st.exitQuest(false, true);
  108. htmltext = event;
  109. }
  110. else
  111. {
  112. htmltext = "level_check.html";
  113. }
  114. }
  115. break;
  116. }
  117. case "30857-02.html":
  118. case "30857-03.html":
  119. {
  120. if (st.isCond(1))
  121. {
  122. htmltext = event;
  123. }
  124. break;
  125. }
  126. case "30857-04.html":
  127. {
  128. if (st.isCond(1))
  129. {
  130. st.setCond(2, true);
  131. htmltext = event;
  132. }
  133. break;
  134. }
  135. case "32594-02.html":
  136. {
  137. if (st.isCond(2))
  138. {
  139. htmltext = event;
  140. }
  141. break;
  142. }
  143. case "32594-03.html":
  144. {
  145. if (st.isCond(2))
  146. {
  147. st.setCond(3, true);
  148. htmltext = event;
  149. }
  150. break;
  151. }
  152. case "32595-02.html":
  153. case "32595-03.html":
  154. {
  155. if (st.isCond(3))
  156. {
  157. htmltext = event;
  158. }
  159. break;
  160. }
  161. case "32595-04.html":
  162. {
  163. if (st.isCond(3))
  164. {
  165. isBusy = true;
  166. npc.broadcastPacket(new NpcSay(npc.getObjectId(), Say2.NPC_ALL, npc.getId(), NpcStringId.S1_THAT_STRANGER_MUST_BE_DEFEATED_HERE_IS_THE_ULTIMATE_HELP).addStringParameter(player.getName()));
  167. final L2MonsterInstance monster = (L2MonsterInstance) addSpawn(SHILENS_EVIL_THOUGHTS, 152520, -57502, -3408, 0, false, 0, false);
  168. monster.broadcastPacket(new NpcSay(monster.getObjectId(), Say2.NPC_ALL, monster.getId(), NpcStringId.YOU_ARE_NOT_THE_OWNER_OF_THAT_ITEM));
  169. monster.setRunning();
  170. monster.addDamageHate(player, 0, 999);
  171. monster.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player);
  172. startQuestTimer("despawn", 300000, monster, null);
  173. }
  174. break;
  175. }
  176. case "32595-06.html":
  177. case "32595-07.html":
  178. case "32595-08.html":
  179. {
  180. if (st.isCond(4) && st.hasQuestItems(SCULPTURE_OF_DOUBT))
  181. {
  182. htmltext = event;
  183. }
  184. break;
  185. }
  186. case "32595-09.html":
  187. {
  188. if (st.isCond(4) && st.hasQuestItems(SCULPTURE_OF_DOUBT))
  189. {
  190. st.setCond(5, true);
  191. htmltext = event;
  192. }
  193. break;
  194. }
  195. case "32596-02.html":
  196. case "32596-03.html":
  197. {
  198. if (st.isCond(5) && st.hasQuestItems(SCULPTURE_OF_DOUBT))
  199. {
  200. htmltext = event;
  201. }
  202. break;
  203. }
  204. case "32596-04.html":
  205. {
  206. if (st.isCond(5) && st.hasQuestItems(SCULPTURE_OF_DOUBT))
  207. {
  208. st.giveItems(MYSTERIOUS_HAND_WRITTEN_TEXT, 1);
  209. st.setCond(6, true);
  210. htmltext = event;
  211. }
  212. break;
  213. }
  214. }
  215. return htmltext;
  216. }
  217. @Override
  218. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  219. {
  220. final L2PcInstance partyMember = getRandomPartyMember(player, 3);
  221. if (partyMember == null)
  222. {
  223. return null;
  224. }
  225. final QuestState st = getQuestState(partyMember, false);
  226. if (npc.isInsideRadius(partyMember, 1500, true, false))
  227. {
  228. st.giveItems(SCULPTURE_OF_DOUBT, 1);
  229. st.playSound(QuestSound.ITEMSOUND_QUEST_FINISH);
  230. st.setCond(4);
  231. }
  232. isBusy = false;
  233. cancelQuestTimers("despawn");
  234. npc.broadcastPacket(new NpcSay(npc.getObjectId(), Say2.NPC_ALL, npc.getId(), NpcStringId.S1_YOU_MAY_HAVE_WON_THIS_TIME_BUT_NEXT_TIME_I_WILL_SURELY_CAPTURE_YOU).addStringParameter(partyMember.getName()));
  235. return super.onKill(npc, player, isSummon);
  236. }
  237. @Override
  238. public String onTalk(L2Npc npc, L2PcInstance player)
  239. {
  240. QuestState st = getQuestState(player, true);
  241. String htmltext = getNoQuestMsg(player);
  242. switch (st.getState())
  243. {
  244. case State.COMPLETED:
  245. {
  246. htmltext = getAlreadyCompletedMsg(player);
  247. break;
  248. }
  249. case State.CREATED:
  250. {
  251. if (npc.getId() == WOOD)
  252. {
  253. st = player.getQuestState(Q00196_SevenSignsSealOfTheEmperor.class.getSimpleName());
  254. htmltext = ((player.getLevel() >= MIN_LEVEL) && (st != null) && (st.isCompleted())) ? "32593-01.htm" : "32593-05.html";
  255. }
  256. break;
  257. }
  258. case State.STARTED:
  259. {
  260. switch (npc.getId())
  261. {
  262. case WOOD:
  263. {
  264. if ((st.getCond() > 0) && (st.getCond() < 6))
  265. {
  266. htmltext = "32593-06.html";
  267. }
  268. else if (st.isCond(6))
  269. {
  270. if (st.hasQuestItems(MYSTERIOUS_HAND_WRITTEN_TEXT, SCULPTURE_OF_DOUBT))
  271. {
  272. htmltext = "32593-07.html";
  273. }
  274. }
  275. break;
  276. }
  277. case ORVEN:
  278. {
  279. if (st.isCond(1))
  280. {
  281. htmltext = "30857-01.html";
  282. }
  283. else if (st.getCond() >= 2)
  284. {
  285. htmltext = "30857-05.html";
  286. }
  287. break;
  288. }
  289. case LEOPARD:
  290. {
  291. if (st.isCond(2))
  292. {
  293. htmltext = "32594-01.html";
  294. }
  295. else if (st.getCond() >= 3)
  296. {
  297. htmltext = "32594-04.html";
  298. }
  299. break;
  300. }
  301. case LAWRENCE:
  302. {
  303. if (st.isCond(3))
  304. {
  305. if (isBusy)
  306. {
  307. htmltext = "32595-05.html";
  308. }
  309. else
  310. {
  311. htmltext = "32595-01.html";
  312. }
  313. }
  314. else if (st.isCond(4))
  315. {
  316. if (st.hasQuestItems(SCULPTURE_OF_DOUBT))
  317. {
  318. htmltext = "32595-06.html";
  319. }
  320. }
  321. else if (st.getCond() >= 5)
  322. {
  323. if (st.hasQuestItems(SCULPTURE_OF_DOUBT))
  324. {
  325. htmltext = "32595-10.html";
  326. }
  327. }
  328. break;
  329. }
  330. case SOPHIA:
  331. {
  332. if (st.isCond(5))
  333. {
  334. if (st.hasQuestItems(SCULPTURE_OF_DOUBT))
  335. {
  336. htmltext = "32596-01.html";
  337. }
  338. }
  339. else if (st.getCond() >= 6)
  340. {
  341. if (st.hasQuestItems(SCULPTURE_OF_DOUBT, MYSTERIOUS_HAND_WRITTEN_TEXT))
  342. {
  343. htmltext = "32596-05.html";
  344. }
  345. }
  346. break;
  347. }
  348. }
  349. break;
  350. }
  351. }
  352. return htmltext;
  353. }
  354. }