Q00114_ResurrectionOfAnOldManager.java 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  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.Q00114_ResurrectionOfAnOldManager;
  20. import quests.Q00121_PavelTheGiant.Q00121_PavelTheGiant;
  21. import com.l2jserver.gameserver.ai.CtrlIntention;
  22. import com.l2jserver.gameserver.model.actor.L2Attackable;
  23. import com.l2jserver.gameserver.model.actor.L2Character;
  24. import com.l2jserver.gameserver.model.actor.L2Npc;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.model.itemcontainer.Inventory;
  27. import com.l2jserver.gameserver.model.quest.Quest;
  28. import com.l2jserver.gameserver.model.quest.QuestState;
  29. import com.l2jserver.gameserver.model.quest.State;
  30. import com.l2jserver.gameserver.network.NpcStringId;
  31. import com.l2jserver.gameserver.network.clientpackets.Say2;
  32. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  33. /**
  34. * Resurrection of an Old Manager (114)<br>
  35. * Original Jython script by Kerberos
  36. * @author malyelfik
  37. */
  38. public class Q00114_ResurrectionOfAnOldManager extends Quest
  39. {
  40. // NPCs
  41. private static final int NEWYEAR = 31961;
  42. private static final int YUMI = 32041;
  43. private static final int STONES = 32046;
  44. private static final int WENDY = 32047;
  45. private static final int BOX = 32050;
  46. // Items
  47. private static final int STARSTONE = 8287;
  48. private static final int LETTER = 8288;
  49. private static final int STARSTONE2 = 8289;
  50. private static final int DETCTOR = 8090;
  51. private static final int DETCTOR2 = 8091;
  52. // Monster
  53. private static final int GUARDIAN = 27318;
  54. private static L2Attackable golem = null;
  55. public Q00114_ResurrectionOfAnOldManager()
  56. {
  57. super(114, Q00114_ResurrectionOfAnOldManager.class.getSimpleName(), "Resurrection of an Old Manager");
  58. addStartNpc(YUMI);
  59. addTalkId(YUMI, WENDY, BOX, STONES, NEWYEAR);
  60. addKillId(GUARDIAN);
  61. addSeeCreatureId(STONES);
  62. registerQuestItems(STARSTONE, STARSTONE2, DETCTOR, DETCTOR2, LETTER);
  63. }
  64. @Override
  65. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  66. {
  67. final QuestState st = getQuestState(player, false);
  68. if (st == null)
  69. {
  70. return null;
  71. }
  72. String htmltext = event;
  73. switch (event)
  74. {
  75. // Yumi
  76. case "32041-04.htm":
  77. st.startQuest();
  78. break;
  79. case "32041-08.html":
  80. st.set("talk", "1");
  81. break;
  82. case "32041-09.html":
  83. st.setCond(2, true);
  84. st.unset("talk");
  85. break;
  86. case "32041-12.html":
  87. switch (st.getCond())
  88. {
  89. case 3:
  90. htmltext = "32041-12.html";
  91. break;
  92. case 4:
  93. htmltext = "32041-13.html";
  94. break;
  95. case 5:
  96. htmltext = "32041-14.html";
  97. break;
  98. }
  99. break;
  100. case "32041-15.html":
  101. st.set("talk", "1");
  102. break;
  103. case "32041-23.html":
  104. st.set("talk", "2");
  105. break;
  106. case "32041-26.html":
  107. st.setCond(6, true);
  108. st.unset("talk");
  109. break;
  110. case "32041-31.html":
  111. st.giveItems(DETCTOR, 1);
  112. st.setCond(17, true);
  113. break;
  114. case "32041-34.html":
  115. st.set("talk", "1");
  116. st.takeItems(DETCTOR2, 1);
  117. break;
  118. case "32041-38.html":
  119. if (st.getInt("choice") == 2)
  120. {
  121. htmltext = "32041-37.html";
  122. }
  123. break;
  124. case "32041-39.html":
  125. st.unset("talk");
  126. st.setCond(20, true);
  127. break;
  128. case "32041-40.html":
  129. st.setCond(21, true);
  130. st.unset("talk");
  131. st.giveItems(LETTER, 1);
  132. break;
  133. // Suspicious-Looking Pile of Stones
  134. case "32046-03.html":
  135. st.setCond(19, true);
  136. break;
  137. case "32046-07.html":
  138. st.addExpAndSp(1846611, 144270);
  139. st.exitQuest(false, true);
  140. break;
  141. // Wendy
  142. case "32047-02.html":
  143. if (st.getInt("talk") == 0)
  144. {
  145. st.set("talk", "1");
  146. }
  147. break;
  148. case "32047-03.html":
  149. if (st.getInt("talk1") == 0)
  150. {
  151. st.set("talk1", "1");
  152. }
  153. break;
  154. case "32047-05.html":
  155. if ((st.getInt("talk") == 0) || (st.getInt("talk1") == 0))
  156. {
  157. htmltext = "32047-04.html";
  158. }
  159. break;
  160. case "32047-06.html":
  161. st.set("choice", "1");
  162. st.setCond(3, true);
  163. st.unset("talk1");
  164. st.unset("talk");
  165. break;
  166. case "32047-07.html":
  167. st.set("choice", "2");
  168. st.setCond(4, true);
  169. st.unset("talk1");
  170. st.unset("talk");
  171. break;
  172. case "32047-09.html":
  173. st.set("choice", "3");
  174. st.setCond(5, true);
  175. st.unset("talk1");
  176. st.unset("talk");
  177. break;
  178. case "32047-14ab.html":
  179. st.set("choice", "3");
  180. st.setCond(7, true);
  181. break;
  182. case "32047-14b.html":
  183. st.setCond(10, true);
  184. break;
  185. case "32047-15b.html":
  186. if ((golem == null) || ((golem != null) && golem.isDead()))
  187. {
  188. golem = (L2Attackable) addSpawn(GUARDIAN, 96977, -110625, -3280, 0, false, 0);
  189. golem.broadcastPacket(new NpcSay(golem.getObjectId(), Say2.NPC_ALL, golem.getId(), NpcStringId.YOU_S1_YOU_ATTACKED_WENDY_PREPARE_TO_DIE).addStringParameter(player.getName()));
  190. golem.setRunning();
  191. golem.addDamageHate(player, 0, 999);
  192. golem.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player);
  193. st.set("spawned", "1");
  194. startQuestTimer("golem_despawn", 300000, null, player);
  195. }
  196. else if (st.getInt("spawned") == 1)
  197. {
  198. htmltext = "32047-17b.html";
  199. }
  200. else
  201. {
  202. htmltext = "32047-16b.html";
  203. }
  204. break;
  205. case "32047-20a.html":
  206. st.setCond(8, true);
  207. break;
  208. case "32047-20b.html":
  209. st.setCond(12, true);
  210. break;
  211. case "32047-20c.html":
  212. st.setCond(13, true);
  213. break;
  214. case "32047-21a.html":
  215. st.setCond(9, true);
  216. break;
  217. case "32047-23a.html":
  218. st.setCond(23, true);
  219. break;
  220. case "32047-23c.html":
  221. st.takeItems(STARSTONE, 1);
  222. st.setCond(15, true);
  223. break;
  224. case "32047-29c.html":
  225. if (player.getAdena() >= 3000)
  226. {
  227. st.giveItems(STARSTONE2, 1);
  228. st.takeItems(Inventory.ADENA_ID, 3000);
  229. st.unset("talk");
  230. st.setCond(26, true);
  231. }
  232. else
  233. {
  234. htmltext = "32047-29ca.html";
  235. }
  236. break;
  237. case "32047-30c.html":
  238. st.set("talk", "1");
  239. break;
  240. // Box
  241. case "32050-01r.html":
  242. st.set("talk", "1");
  243. break;
  244. case "32050-03.html":
  245. st.giveItems(STARSTONE, 1);
  246. st.setCond(14, true);
  247. st.unset("talk");
  248. break;
  249. case "32050-05.html":
  250. st.setCond(24, true);
  251. st.giveItems(STARSTONE2, 1);
  252. break;
  253. // Newyear
  254. case "31961-02.html":
  255. st.takeItems(LETTER, 1);
  256. st.giveItems(STARSTONE2, 1);
  257. st.setCond(22, true);
  258. break;
  259. // Quest timer
  260. case "golem_despawn":
  261. st.unset("spawned");
  262. golem.broadcastPacket(new NpcSay(golem.getObjectId(), Say2.NPC_ALL, golem.getId(), NpcStringId.S1_YOUR_ENEMY_WAS_DRIVEN_OUT_I_WILL_NOW_WITHDRAW_AND_AWAIT_YOUR_NEXT_COMMAND).addStringParameter(player.getName()));
  263. golem.deleteMe();
  264. golem = null;
  265. htmltext = null;
  266. break;
  267. // HTMLs
  268. case "32041-05.html":
  269. case "32041-06.html":
  270. case "32041-07.html":
  271. case "32041-17.html":
  272. case "32041-18.html":
  273. case "32041-19.html":
  274. case "32041-20.html":
  275. case "32041-21.html":
  276. case "32041-22.html":
  277. case "32041-25.html":
  278. case "32041-29.html":
  279. case "32041-30.html":
  280. case "32041-35.html":
  281. case "32041-36.html":
  282. case "32046-05.html":
  283. case "32046-06.html":
  284. case "32047-06a.html":
  285. case "32047-12a.html":
  286. case "32047-12b.html":
  287. case "32047-12c.html":
  288. case "32047-13a.html":
  289. case "32047-14a.html":
  290. case "32047-13b.html":
  291. case "32047-13c.html":
  292. case "32047-14c.html":
  293. case "32047-15c.html":
  294. case "32047-17c.html":
  295. case "32047-13ab.html":
  296. case "32047-15a.html":
  297. case "32047-16a.html":
  298. case "32047-16c.html":
  299. case "32047-18a.html":
  300. case "32047-19a.html":
  301. case "32047-18ab.html":
  302. case "32047-19ab.html":
  303. case "32047-18c.html":
  304. case "32047-17a.html":
  305. case "32047-19c.html":
  306. case "32047-21b.html":
  307. case "32047-27c.html":
  308. case "32047-28c.html":
  309. break;
  310. default:
  311. htmltext = null;
  312. break;
  313. }
  314. return htmltext;
  315. }
  316. @Override
  317. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  318. {
  319. final QuestState st = getQuestState(player, false);
  320. if ((st != null) && st.isCond(10) && (st.getInt("spawned") == 1))
  321. {
  322. npc.broadcastPacket(new NpcSay(npc.getObjectId(), Say2.NPC_ALL, npc.getId(), NpcStringId.THIS_ENEMY_IS_FAR_TOO_POWERFUL_FOR_ME_TO_FIGHT_I_MUST_WITHDRAW));
  323. st.setCond(11, true);
  324. st.unset("spawned");
  325. cancelQuestTimers("golem_despawn");
  326. }
  327. return super.onKill(npc, player, isSummon);
  328. }
  329. @Override
  330. public String onSeeCreature(L2Npc npc, L2Character creature, boolean isSummon)
  331. {
  332. if (creature.isPlayer())
  333. {
  334. final QuestState st = creature.getActingPlayer().getQuestState(getName());
  335. if ((st != null) && st.isCond(17))
  336. {
  337. st.takeItems(DETCTOR, 1);
  338. st.giveItems(DETCTOR2, 1);
  339. st.setCond(18, true);
  340. showOnScreenMsg(creature.getActingPlayer(), NpcStringId.THE_RADIO_SIGNAL_DETECTOR_IS_RESPONDING_A_SUSPICIOUS_PILE_OF_STONES_CATCHES_YOUR_EYE, 2, 4500);
  341. }
  342. }
  343. return super.onSeeCreature(npc, creature, isSummon);
  344. }
  345. @Override
  346. public String onTalk(L2Npc npc, L2PcInstance player)
  347. {
  348. String htmltext = getNoQuestMsg(player);
  349. final QuestState st = getQuestState(player, true);
  350. if (st == null)
  351. {
  352. return getNoQuestMsg(player);
  353. }
  354. int talk = st.getInt("talk");
  355. switch (npc.getId())
  356. {
  357. case YUMI:
  358. switch (st.getState())
  359. {
  360. case State.CREATED:
  361. final QuestState prev = player.getQuestState(Q00121_PavelTheGiant.class.getSimpleName());
  362. if ((prev != null) && prev.isCompleted())
  363. {
  364. htmltext = (player.getLevel() >= 70) ? "32041-02.htm" : "32041-03.htm";
  365. }
  366. else
  367. {
  368. htmltext = "32041-01.htm";
  369. }
  370. break;
  371. case State.STARTED:
  372. switch (st.getCond())
  373. {
  374. case 1:
  375. htmltext = (talk == 1) ? "32041-08.html" : "32041-04.htm";
  376. break;
  377. case 2:
  378. htmltext = "32041-10.html";
  379. break;
  380. case 3:
  381. case 4:
  382. case 5:
  383. switch (talk)
  384. {
  385. case 0:
  386. htmltext = "32041-11.html";
  387. break;
  388. case 1:
  389. htmltext = "32041-16.html";
  390. break;
  391. case 2:
  392. htmltext = "32041-24.html";
  393. break;
  394. }
  395. break;
  396. case 6:
  397. case 7:
  398. case 8:
  399. case 10:
  400. case 11:
  401. case 13:
  402. case 14:
  403. case 15:
  404. htmltext = "32041-27.html";
  405. break;
  406. case 9:
  407. case 12:
  408. case 16:
  409. htmltext = "32041-28.html";
  410. break;
  411. case 17:
  412. case 18:
  413. htmltext = "32041-32.html";
  414. break;
  415. case 19:
  416. htmltext = (talk == 1) ? "32041-34z.html" : "32041-33.html";
  417. break;
  418. case 20:
  419. htmltext = "32041-39z.html";
  420. break;
  421. case 21:
  422. htmltext = "32041-40z.html";
  423. break;
  424. case 22:
  425. case 25:
  426. case 26:
  427. st.setCond(27, true);
  428. htmltext = "32041-41.html";
  429. break;
  430. case 27:
  431. htmltext = "32041-42.html";
  432. break;
  433. }
  434. break;
  435. case State.COMPLETED:
  436. htmltext = getAlreadyCompletedMsg(player);
  437. break;
  438. }
  439. break;
  440. case WENDY:
  441. if (st.isStarted())
  442. {
  443. switch (st.getCond())
  444. {
  445. case 2:
  446. htmltext = ((talk == 1) && (st.getInt("talk1") == 1)) ? "32047-05.html" : "32047-01.html";
  447. break;
  448. case 3:
  449. htmltext = "32047-06b.html";
  450. break;
  451. case 4:
  452. htmltext = "32047-08.html";
  453. break;
  454. case 5:
  455. htmltext = "32047-10.html";
  456. break;
  457. case 6:
  458. switch (st.getInt("choice"))
  459. {
  460. case 1:
  461. htmltext = "32047-11a.html";
  462. break;
  463. case 2:
  464. htmltext = "32047-11b.html";
  465. break;
  466. case 3:
  467. htmltext = "32047-11c.html";
  468. break;
  469. }
  470. break;
  471. case 7:
  472. htmltext = "32047-11c.html";
  473. break;
  474. case 8:
  475. htmltext = "32047-17a.html";
  476. break;
  477. case 9:
  478. case 12:
  479. case 16:
  480. htmltext = "32047-25c.html";
  481. break;
  482. case 10:
  483. htmltext = "32047-18b.html";
  484. break;
  485. case 11:
  486. htmltext = "32047-19b.html";
  487. break;
  488. case 13:
  489. htmltext = "32047-21c.html";
  490. break;
  491. case 14:
  492. htmltext = "32047-22c.html";
  493. break;
  494. case 15:
  495. st.setCond(16, true);
  496. htmltext = "32047-24c.html";
  497. break;
  498. case 20:
  499. if (st.getInt("choice") == 1)
  500. {
  501. htmltext = "32047-22a.html";
  502. }
  503. else
  504. {
  505. htmltext = (talk == 1) ? "32047-31c.html" : "32047-26c.html";
  506. }
  507. break;
  508. case 23:
  509. htmltext = "32047-23z.html";
  510. break;
  511. case 24:
  512. st.setCond(25, true);
  513. htmltext = "32047-24a.html";
  514. break;
  515. case 25:
  516. htmltext = "32047-24a.html";
  517. break;
  518. case 26:
  519. htmltext = "32047-32c.html";
  520. break;
  521. }
  522. }
  523. break;
  524. case NEWYEAR:
  525. if (st.isStarted())
  526. {
  527. switch (st.getCond())
  528. {
  529. case 21:
  530. htmltext = "31961-01.html";
  531. break;
  532. case 22:
  533. htmltext = "31961-03.html";
  534. break;
  535. }
  536. }
  537. break;
  538. case BOX:
  539. if (st.isStarted())
  540. {
  541. switch (st.getCond())
  542. {
  543. case 13:
  544. htmltext = (talk == 1) ? "32050-02.html" : "32050-01.html";
  545. break;
  546. case 14:
  547. htmltext = "32050-04.html";
  548. break;
  549. case 23:
  550. htmltext = "32050-04b.html";
  551. break;
  552. case 24:
  553. htmltext = "32050-05z.html";
  554. break;
  555. }
  556. }
  557. break;
  558. case STONES:
  559. if (st.isStarted())
  560. {
  561. switch (st.getCond())
  562. {
  563. case 18:
  564. htmltext = "32046-02.html";
  565. break;
  566. case 19:
  567. htmltext = "32046-03.html";
  568. break;
  569. case 27:
  570. htmltext = "32046-04.html";
  571. break;
  572. }
  573. }
  574. break;
  575. }
  576. return htmltext;
  577. }
  578. }