DarkCloudMansion.java 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480
  1. /*
  2. * Copyright (C) 2004-2014 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 instances.DarkCloudMansion;
  20. import javolution.util.FastList;
  21. import javolution.util.FastMap;
  22. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  23. import com.l2jserver.gameserver.model.L2Party;
  24. import com.l2jserver.gameserver.model.Location;
  25. import com.l2jserver.gameserver.model.actor.L2Npc;
  26. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  27. import com.l2jserver.gameserver.model.entity.Instance;
  28. import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
  29. import com.l2jserver.gameserver.model.quest.Quest;
  30. import com.l2jserver.gameserver.model.quest.QuestState;
  31. import com.l2jserver.gameserver.model.skills.Skill;
  32. import com.l2jserver.gameserver.network.NpcStringId;
  33. import com.l2jserver.gameserver.network.SystemMessageId;
  34. import com.l2jserver.gameserver.network.clientpackets.Say2;
  35. import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
  36. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  37. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  38. /**
  39. * Dark Cloud Mansion instance zone.
  40. */
  41. public final class DarkCloudMansion extends Quest
  42. {
  43. private static final int INSTANCEID = 9;
  44. private static boolean debug = false;
  45. private static boolean noRndWalk = true;
  46. // Items
  47. private static int CC = 9690; // Contaminated Crystal
  48. // NPCs
  49. private static int YIYEN = 32282;
  50. private static int SOFaith = 32288; // Symbol of Faith
  51. private static int SOAdversity = 32289; // Symbol of Adversity
  52. private static int SOAdventure = 32290; // Symbol of Adventure
  53. private static int SOTruth = 32291; // Symbol of Truth
  54. private static int BSM = 32324; // Black Stone Monolith
  55. private static int SC = 22402; // Shadow Column
  56. // Mobs
  57. private static int[] CCG =
  58. {
  59. 18369,
  60. 18370
  61. }; // Chromatic Crystal Golem
  62. private static int[] BM =
  63. {
  64. 22272,
  65. 22273,
  66. 22274
  67. }; // Beleth's Minions
  68. private static int[] HG =
  69. {
  70. 22264,
  71. 22264
  72. }; // [22318,22319] #Hall Guards
  73. private static int[] BS =
  74. {
  75. 18371,
  76. 18372,
  77. 18373,
  78. 18374,
  79. 18375,
  80. 18376,
  81. 18377
  82. }; // Beleth's Samples
  83. private static int[] TOKILL =
  84. {
  85. 18371,
  86. 18372,
  87. 18373,
  88. 18374,
  89. 18375,
  90. 18376,
  91. 18377,
  92. 22318,
  93. 22319,
  94. 22272,
  95. 22273,
  96. 22274,
  97. 18369,
  98. 18370,
  99. 22402,
  100. 22264
  101. };
  102. // Doors/Walls
  103. private static int D1 = 24230001; // Starting Room
  104. private static int D2 = 24230002; // First Room
  105. private static int D3 = 24230005; // Second Room
  106. private static int D4 = 24230003; // Third Room
  107. private static int D5 = 24230004; // Forth Room
  108. private static int D6 = 24230006; // Fifth Room
  109. private static int W1 = 24230007; // Wall 1
  110. // private static int W2 = 24230008; // Wall 2
  111. // private static int W3 = 24230009; // Wall 3
  112. // private static int W4 = 24230010; // Wall 4
  113. // private static int W5 = 24230011; // Wall 5
  114. // private static int W6 = 24230012; // Wall 6
  115. // private static int W7 = 24230013; // Wall 7
  116. private static NpcStringId[] _spawnChat =
  117. {
  118. NpcStringId.IM_THE_REAL_ONE,
  119. NpcStringId.PICK_ME,
  120. NpcStringId.TRUST_ME,
  121. NpcStringId.NOT_THAT_DUDE_IM_THE_REAL_ONE,
  122. NpcStringId.DONT_BE_FOOLED_DONT_BE_FOOLED_IM_THE_REAL_ONE
  123. };
  124. private static NpcStringId[] _decayChat =
  125. {
  126. NpcStringId.IM_THE_REAL_ONE_PHEW,
  127. NpcStringId.CANT_YOU_EVEN_FIND_OUT,
  128. NpcStringId.FIND_ME
  129. };
  130. private static NpcStringId[] _successChat =
  131. {
  132. NpcStringId.HUH_HOW_DID_YOU_KNOW_IT_WAS_ME,
  133. NpcStringId.EXCELLENT_CHOICE_TEEHEE,
  134. NpcStringId.YOUVE_DONE_WELL,
  135. NpcStringId.OH_VERY_SENSIBLE
  136. };
  137. private static NpcStringId[] _faildChat =
  138. {
  139. NpcStringId.YOUVE_BEEN_FOOLED,
  140. NpcStringId.SORRY_BUT_IM_THE_FAKE_ONE
  141. };
  142. // Second room - random monolith order
  143. private static int[][] MonolithOrder = new int[][]
  144. {
  145. {
  146. 1,
  147. 2,
  148. 3,
  149. 4,
  150. 5,
  151. 6
  152. },
  153. {
  154. 6,
  155. 5,
  156. 4,
  157. 3,
  158. 2,
  159. 1
  160. },
  161. {
  162. 4,
  163. 5,
  164. 6,
  165. 3,
  166. 2,
  167. 1
  168. },
  169. {
  170. 2,
  171. 6,
  172. 3,
  173. 5,
  174. 1,
  175. 4
  176. },
  177. {
  178. 4,
  179. 1,
  180. 5,
  181. 6,
  182. 2,
  183. 3
  184. },
  185. {
  186. 3,
  187. 5,
  188. 1,
  189. 6,
  190. 2,
  191. 4
  192. },
  193. {
  194. 6,
  195. 1,
  196. 3,
  197. 4,
  198. 5,
  199. 2
  200. },
  201. {
  202. 5,
  203. 6,
  204. 1,
  205. 2,
  206. 4,
  207. 3
  208. },
  209. {
  210. 5,
  211. 2,
  212. 6,
  213. 3,
  214. 4,
  215. 1
  216. },
  217. {
  218. 1,
  219. 5,
  220. 2,
  221. 6,
  222. 3,
  223. 4
  224. },
  225. {
  226. 1,
  227. 2,
  228. 3,
  229. 6,
  230. 5,
  231. 4
  232. },
  233. {
  234. 6,
  235. 4,
  236. 3,
  237. 1,
  238. 5,
  239. 2
  240. },
  241. {
  242. 3,
  243. 5,
  244. 2,
  245. 4,
  246. 1,
  247. 6
  248. },
  249. {
  250. 3,
  251. 2,
  252. 4,
  253. 5,
  254. 1,
  255. 6
  256. },
  257. {
  258. 5,
  259. 4,
  260. 3,
  261. 1,
  262. 6,
  263. 2
  264. },
  265. };
  266. // Second room - golem spawn locatons - random
  267. private static int[][] GolemSpawn = new int[][]
  268. {
  269. {
  270. CCG[0],
  271. 148060,
  272. 181389
  273. },
  274. {
  275. CCG[1],
  276. 147910,
  277. 181173
  278. },
  279. {
  280. CCG[0],
  281. 147810,
  282. 181334
  283. },
  284. {
  285. CCG[1],
  286. 147713,
  287. 181179
  288. },
  289. {
  290. CCG[0],
  291. 147569,
  292. 181410
  293. },
  294. {
  295. CCG[1],
  296. 147810,
  297. 181517
  298. },
  299. {
  300. CCG[0],
  301. 147805,
  302. 181281
  303. }
  304. };
  305. // forth room - random shadow column
  306. private static int[][] ColumnRows = new int[][]
  307. {
  308. {
  309. 1,
  310. 1,
  311. 0,
  312. 1,
  313. 0
  314. },
  315. {
  316. 0,
  317. 1,
  318. 1,
  319. 0,
  320. 1
  321. },
  322. {
  323. 1,
  324. 0,
  325. 1,
  326. 1,
  327. 0
  328. },
  329. {
  330. 0,
  331. 1,
  332. 0,
  333. 1,
  334. 1
  335. },
  336. {
  337. 1,
  338. 0,
  339. 1,
  340. 0,
  341. 1
  342. }
  343. };
  344. // Fifth room - beleth order
  345. private static int[][] Beleths = new int[][]
  346. {
  347. {
  348. 1,
  349. 0,
  350. 1,
  351. 0,
  352. 1,
  353. 0,
  354. 0
  355. },
  356. {
  357. 0,
  358. 0,
  359. 1,
  360. 0,
  361. 1,
  362. 1,
  363. 0
  364. },
  365. {
  366. 0,
  367. 0,
  368. 0,
  369. 1,
  370. 0,
  371. 1,
  372. 1
  373. },
  374. {
  375. 1,
  376. 0,
  377. 1,
  378. 1,
  379. 0,
  380. 0,
  381. 0
  382. },
  383. {
  384. 1,
  385. 1,
  386. 0,
  387. 0,
  388. 0,
  389. 1,
  390. 0
  391. },
  392. {
  393. 0,
  394. 1,
  395. 0,
  396. 1,
  397. 0,
  398. 1,
  399. 0
  400. },
  401. {
  402. 0,
  403. 0,
  404. 0,
  405. 1,
  406. 1,
  407. 1,
  408. 0
  409. },
  410. {
  411. 1,
  412. 0,
  413. 1,
  414. 0,
  415. 0,
  416. 1,
  417. 0
  418. },
  419. {
  420. 0,
  421. 1,
  422. 1,
  423. 0,
  424. 0,
  425. 0,
  426. 1
  427. }
  428. };
  429. private DarkCloudMansion()
  430. {
  431. super(-1, DarkCloudMansion.class.getSimpleName(), "instances");
  432. addFirstTalkId(BSM);
  433. addFirstTalkId(SOTruth);
  434. addStartNpc(YIYEN);
  435. addTalkId(YIYEN);
  436. addTalkId(SOTruth);
  437. addAttackId(SC);
  438. addAttackId(BS);
  439. addAttackId(CCG);
  440. addKillId(TOKILL);
  441. }
  442. protected static class DMCNpc
  443. {
  444. public L2Npc npc;
  445. public boolean isDead = false;
  446. public L2Npc golem = null;
  447. public int status = 0;
  448. public int order = 0;
  449. public int count = 0;
  450. }
  451. protected static class DMCRoom
  452. {
  453. public FastList<DMCNpc> npcList = new FastList<>();
  454. public int counter = 0;
  455. public int reset = 0;
  456. public int founded = 0;
  457. public int[] Order;
  458. }
  459. protected class DMCWorld extends InstanceWorld
  460. {
  461. public FastMap<String, DMCRoom> rooms = new FastMap<>();
  462. }
  463. private boolean checkConditions(L2PcInstance player)
  464. {
  465. if (debug)
  466. {
  467. return true;
  468. }
  469. L2Party party = player.getParty();
  470. if (party == null)
  471. {
  472. player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER);
  473. return false;
  474. }
  475. if (party.getLeader() != player)
  476. {
  477. player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
  478. return false;
  479. }
  480. if (party.getMemberCount() > 2)
  481. {
  482. player.sendPacket(SystemMessageId.PARTY_EXCEEDED_THE_LIMIT_CANT_ENTER);
  483. return false;
  484. }
  485. for (L2PcInstance partyMember : party.getMembers())
  486. {
  487. if (partyMember.getLevel() < 78)
  488. {
  489. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT);
  490. sm.addPcName(partyMember);
  491. player.sendPacket(sm);
  492. return false;
  493. }
  494. if (!partyMember.isInsideRadius(player, 1000, true, true))
  495. {
  496. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED);
  497. sm.addPcName(partyMember);
  498. player.sendPacket(sm);
  499. return false;
  500. }
  501. }
  502. return true;
  503. }
  504. protected int enterInstance(L2PcInstance player, String template, Location loc)
  505. {
  506. int instanceId = 0;
  507. // check for existing instances for this player
  508. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  509. // existing instance
  510. if (world != null)
  511. {
  512. if (!(world instanceof DMCWorld))
  513. {
  514. player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
  515. return 0;
  516. }
  517. teleportPlayer(player, loc, world.getInstanceId());
  518. return instanceId;
  519. }
  520. // New instance
  521. if (!checkConditions(player))
  522. {
  523. return 0;
  524. }
  525. L2Party party = player.getParty();
  526. instanceId = InstanceManager.getInstance().createDynamicInstance(template);
  527. world = new DMCWorld();
  528. world.setInstanceId(instanceId);
  529. world.setTemplateId(INSTANCEID);
  530. InstanceManager.getInstance().addWorld(world);
  531. _log.info("DarkCloudMansion: started " + template + " Instance: " + instanceId + " created by player: " + player.getName());
  532. runStartRoom((DMCWorld) world);
  533. // teleport players
  534. if (debug && (party == null))
  535. {
  536. world.addAllowed(player.getObjectId());
  537. teleportPlayer(player, loc, instanceId);
  538. }
  539. else
  540. {
  541. for (L2PcInstance partyMember : party.getMembers())
  542. {
  543. if (partyMember.getQuestState(getName()) == null)
  544. {
  545. newQuestState(partyMember);
  546. }
  547. world.addAllowed(partyMember.getObjectId());
  548. teleportPlayer(partyMember, loc, instanceId);
  549. }
  550. }
  551. return instanceId;
  552. }
  553. protected void runStartRoom(DMCWorld world)
  554. {
  555. world.setStatus(0);
  556. DMCRoom StartRoom = new DMCRoom();
  557. DMCNpc thisnpc;
  558. thisnpc = new DMCNpc();
  559. thisnpc.npc = addSpawn(BM[0], 146817, 180335, -6117, 0, false, 0, false, world.getInstanceId());
  560. StartRoom.npcList.add(thisnpc);
  561. if (noRndWalk)
  562. {
  563. thisnpc.npc.setIsNoRndWalk(true);
  564. }
  565. thisnpc = new DMCNpc();
  566. thisnpc.npc = addSpawn(BM[0], 146741, 180589, -6117, 0, false, 0, false, world.getInstanceId());
  567. StartRoom.npcList.add(thisnpc);
  568. if (noRndWalk)
  569. {
  570. thisnpc.npc.setIsNoRndWalk(true);
  571. }
  572. world.rooms.put("StartRoom", StartRoom);
  573. if (debug)
  574. {
  575. _log.info("DarkCloudMansion: first room spawned in instance " + world.getInstanceId());
  576. }
  577. }
  578. protected void spawnHall(DMCWorld world)
  579. {
  580. DMCRoom Hall = new DMCRoom();
  581. DMCNpc thisnpc;
  582. world.rooms.remove("Hall"); // remove room instance to avoid adding mob every time
  583. thisnpc = new DMCNpc();
  584. thisnpc.npc = addSpawn(BM[1], 147217, 180112, -6117, 0, false, 0, false, world.getInstanceId());
  585. if (noRndWalk)
  586. {
  587. thisnpc.npc.setIsNoRndWalk(true);
  588. }
  589. Hall.npcList.add(thisnpc);
  590. thisnpc = new DMCNpc();
  591. thisnpc.npc = addSpawn(BM[2], 147217, 180209, -6117, 0, false, 0, false, world.getInstanceId());
  592. if (noRndWalk)
  593. {
  594. thisnpc.npc.setIsNoRndWalk(true);
  595. }
  596. Hall.npcList.add(thisnpc);
  597. thisnpc = new DMCNpc();
  598. thisnpc.npc = addSpawn(BM[1], 148521, 180112, -6117, 0, false, 0, false, world.getInstanceId());
  599. if (noRndWalk)
  600. {
  601. thisnpc.npc.setIsNoRndWalk(true);
  602. }
  603. Hall.npcList.add(thisnpc);
  604. thisnpc = new DMCNpc();
  605. thisnpc.npc = addSpawn(BM[0], 148521, 180209, -6117, 0, false, 0, false, world.getInstanceId());
  606. if (noRndWalk)
  607. {
  608. thisnpc.npc.setIsNoRndWalk(true);
  609. }
  610. Hall.npcList.add(thisnpc);
  611. thisnpc = new DMCNpc();
  612. thisnpc.npc = addSpawn(BM[1], 148525, 180910, -6117, 0, false, 0, false, world.getInstanceId());
  613. if (noRndWalk)
  614. {
  615. thisnpc.npc.setIsNoRndWalk(true);
  616. }
  617. Hall.npcList.add(thisnpc);
  618. thisnpc = new DMCNpc();
  619. thisnpc.npc = addSpawn(BM[2], 148435, 180910, -6117, 0, false, 0, false, world.getInstanceId());
  620. if (noRndWalk)
  621. {
  622. thisnpc.npc.setIsNoRndWalk(true);
  623. }
  624. Hall.npcList.add(thisnpc);
  625. thisnpc = new DMCNpc();
  626. thisnpc.npc = addSpawn(BM[1], 147242, 180910, -6117, 0, false, 0, false, world.getInstanceId());
  627. if (noRndWalk)
  628. {
  629. thisnpc.npc.setIsNoRndWalk(true);
  630. }
  631. Hall.npcList.add(thisnpc);
  632. thisnpc = new DMCNpc();
  633. thisnpc.npc = addSpawn(BM[2], 147242, 180819, -6117, 0, false, 0, false, world.getInstanceId());
  634. if (noRndWalk)
  635. {
  636. thisnpc.npc.setIsNoRndWalk(true);
  637. }
  638. Hall.npcList.add(thisnpc);
  639. world.rooms.put("Hall", Hall);
  640. if (debug)
  641. {
  642. _log.info("DarkCloudMansion: hall spawned");
  643. }
  644. }
  645. protected void runHall(DMCWorld world)
  646. {
  647. spawnHall(world);
  648. world.setStatus(1);
  649. openDoor(D1, world.getInstanceId());
  650. }
  651. protected void runFirstRoom(DMCWorld world)
  652. {
  653. DMCRoom FirstRoom = new DMCRoom();
  654. DMCNpc thisnpc;
  655. thisnpc = new DMCNpc();
  656. thisnpc.npc = addSpawn(HG[1], 147842, 179837, -6117, 0, false, 0, false, world.getInstanceId());
  657. if (noRndWalk)
  658. {
  659. thisnpc.npc.setIsNoRndWalk(true);
  660. }
  661. FirstRoom.npcList.add(thisnpc);
  662. thisnpc = new DMCNpc();
  663. thisnpc.npc = addSpawn(HG[0], 147711, 179708, -6117, 0, false, 0, false, world.getInstanceId());
  664. if (noRndWalk)
  665. {
  666. thisnpc.npc.setIsNoRndWalk(true);
  667. }
  668. FirstRoom.npcList.add(thisnpc);
  669. thisnpc = new DMCNpc();
  670. thisnpc.npc = addSpawn(HG[1], 147842, 179552, -6117, 0, false, 0, false, world.getInstanceId());
  671. if (noRndWalk)
  672. {
  673. thisnpc.npc.setIsNoRndWalk(true);
  674. }
  675. FirstRoom.npcList.add(thisnpc);
  676. thisnpc = new DMCNpc();
  677. thisnpc.npc = addSpawn(HG[0], 147964, 179708, -6117, 0, false, 0, false, world.getInstanceId());
  678. if (noRndWalk)
  679. {
  680. thisnpc.npc.setIsNoRndWalk(true);
  681. }
  682. FirstRoom.npcList.add(thisnpc);
  683. world.rooms.put("FirstRoom", FirstRoom);
  684. world.setStatus(2);
  685. openDoor(D2, world.getInstanceId());
  686. if (debug)
  687. {
  688. _log.info("DarkCloudMansion: spawned first room");
  689. }
  690. }
  691. protected void runHall2(DMCWorld world)
  692. {
  693. addSpawn(SOFaith, 147818, 179643, -6117, 0, false, 0, false, world.getInstanceId());
  694. spawnHall(world);
  695. world.setStatus(3);
  696. }
  697. protected void runSecondRoom(DMCWorld world)
  698. {
  699. DMCRoom SecondRoom = new DMCRoom();
  700. DMCNpc thisnpc;
  701. // TODO: find a better way to initialize to [1,0,0,0,0,0,0]
  702. SecondRoom.Order = new int[7];
  703. SecondRoom.Order[0] = 1;
  704. for (int i = 1; i < 7; i++)
  705. {
  706. SecondRoom.Order[i] = 0;
  707. }
  708. int i = getRandom(MonolithOrder.length);
  709. thisnpc = new DMCNpc();
  710. thisnpc.npc = addSpawn(BSM, 147800, 181150, -6117, 0, false, 0, false, world.getInstanceId());
  711. thisnpc.order = MonolithOrder[i][0];
  712. SecondRoom.npcList.add(thisnpc);
  713. thisnpc = new DMCNpc();
  714. thisnpc.npc = addSpawn(BSM, 147900, 181215, -6117, 0, false, 0, false, world.getInstanceId());
  715. thisnpc.order = MonolithOrder[i][1];
  716. SecondRoom.npcList.add(thisnpc);
  717. thisnpc = new DMCNpc();
  718. thisnpc.npc = addSpawn(BSM, 147900, 181345, -6117, 0, false, 0, false, world.getInstanceId());
  719. thisnpc.order = MonolithOrder[i][2];
  720. SecondRoom.npcList.add(thisnpc);
  721. thisnpc = new DMCNpc();
  722. thisnpc.npc = addSpawn(BSM, 147800, 181410, -6117, 0, false, 0, false, world.getInstanceId());
  723. thisnpc.order = MonolithOrder[i][3];
  724. SecondRoom.npcList.add(thisnpc);
  725. thisnpc = new DMCNpc();
  726. thisnpc.npc = addSpawn(BSM, 147700, 181345, -6117, 0, false, 0, false, world.getInstanceId());
  727. thisnpc.order = MonolithOrder[i][4];
  728. SecondRoom.npcList.add(thisnpc);
  729. thisnpc = new DMCNpc();
  730. thisnpc.npc = addSpawn(BSM, 147700, 181215, -6117, 0, false, 0, false, world.getInstanceId());
  731. thisnpc.order = MonolithOrder[i][5];
  732. SecondRoom.npcList.add(thisnpc);
  733. world.rooms.put("SecondRoom", SecondRoom);
  734. world.setStatus(4);
  735. openDoor(D3, world.getInstanceId());
  736. if (debug)
  737. {
  738. _log.info("DarkCloudMansion: spawned second room");
  739. }
  740. }
  741. protected void runHall3(DMCWorld world)
  742. {
  743. addSpawn(SOAdversity, 147808, 181281, -6117, 16383, false, 0, false, world.getInstanceId());
  744. spawnHall(world);
  745. world.setStatus(5);
  746. }
  747. protected void runThirdRoom(DMCWorld world)
  748. {
  749. DMCRoom ThirdRoom = new DMCRoom();
  750. DMCNpc thisnpc = new DMCNpc();
  751. thisnpc.isDead = false;
  752. thisnpc.npc = addSpawn(BM[1], 148765, 180450, -6117, 0, false, 0, false, world.getInstanceId());
  753. if (noRndWalk)
  754. {
  755. thisnpc.npc.setIsNoRndWalk(true);
  756. }
  757. ThirdRoom.npcList.add(thisnpc);
  758. thisnpc.npc = addSpawn(BM[2], 148865, 180190, -6117, 0, false, 0, false, world.getInstanceId());
  759. if (noRndWalk)
  760. {
  761. thisnpc.npc.setIsNoRndWalk(true);
  762. }
  763. ThirdRoom.npcList.add(thisnpc);
  764. thisnpc.npc = addSpawn(BM[1], 148995, 180190, -6117, 0, false, 0, false, world.getInstanceId());
  765. if (noRndWalk)
  766. {
  767. thisnpc.npc.setIsNoRndWalk(true);
  768. }
  769. ThirdRoom.npcList.add(thisnpc);
  770. thisnpc.npc = addSpawn(BM[0], 149090, 180450, -6117, 0, false, 0, false, world.getInstanceId());
  771. if (noRndWalk)
  772. {
  773. thisnpc.npc.setIsNoRndWalk(true);
  774. }
  775. ThirdRoom.npcList.add(thisnpc);
  776. thisnpc.npc = addSpawn(BM[1], 148995, 180705, -6117, 0, false, 0, false, world.getInstanceId());
  777. if (noRndWalk)
  778. {
  779. thisnpc.npc.setIsNoRndWalk(true);
  780. }
  781. ThirdRoom.npcList.add(thisnpc);
  782. thisnpc.npc = addSpawn(BM[2], 148865, 180705, -6117, 0, false, 0, false, world.getInstanceId());
  783. if (noRndWalk)
  784. {
  785. thisnpc.npc.setIsNoRndWalk(true);
  786. }
  787. ThirdRoom.npcList.add(thisnpc);
  788. world.rooms.put("ThirdRoom", ThirdRoom);
  789. world.setStatus(6);
  790. openDoor(D4, world.getInstanceId());
  791. if (debug)
  792. {
  793. _log.info("DarkCloudMansion: spawned third room");
  794. }
  795. }
  796. protected void runThirdRoom2(DMCWorld world)
  797. {
  798. addSpawn(SOAdventure, 148910, 178397, -6117, 16383, false, 0, false, world.getInstanceId());
  799. DMCRoom ThirdRoom = new DMCRoom();
  800. DMCNpc thisnpc = new DMCNpc();
  801. thisnpc.isDead = false;
  802. thisnpc.npc = addSpawn(BM[1], 148765, 180450, -6117, 0, false, 0, false, world.getInstanceId());
  803. if (noRndWalk)
  804. {
  805. thisnpc.npc.setIsNoRndWalk(true);
  806. }
  807. ThirdRoom.npcList.add(thisnpc);
  808. thisnpc.npc = addSpawn(BM[2], 148865, 180190, -6117, 0, false, 0, false, world.getInstanceId());
  809. if (noRndWalk)
  810. {
  811. thisnpc.npc.setIsNoRndWalk(true);
  812. }
  813. ThirdRoom.npcList.add(thisnpc);
  814. thisnpc.npc = addSpawn(BM[1], 148995, 180190, -6117, 0, false, 0, false, world.getInstanceId());
  815. if (noRndWalk)
  816. {
  817. thisnpc.npc.setIsNoRndWalk(true);
  818. }
  819. ThirdRoom.npcList.add(thisnpc);
  820. thisnpc.npc = addSpawn(BM[0], 149090, 180450, -6117, 0, false, 0, false, world.getInstanceId());
  821. if (noRndWalk)
  822. {
  823. thisnpc.npc.setIsNoRndWalk(true);
  824. }
  825. ThirdRoom.npcList.add(thisnpc);
  826. thisnpc.npc = addSpawn(BM[1], 148995, 180705, -6117, 0, false, 0, false, world.getInstanceId());
  827. if (noRndWalk)
  828. {
  829. thisnpc.npc.setIsNoRndWalk(true);
  830. }
  831. ThirdRoom.npcList.add(thisnpc);
  832. thisnpc.npc = addSpawn(BM[2], 148865, 180705, -6117, 0, false, 0, false, world.getInstanceId());
  833. if (noRndWalk)
  834. {
  835. thisnpc.npc.setIsNoRndWalk(true);
  836. }
  837. ThirdRoom.npcList.add(thisnpc);
  838. world.rooms.put("ThirdRoom2", ThirdRoom);
  839. world.setStatus(8);
  840. if (debug)
  841. {
  842. _log.info("DarkCloudMansion: spawned third room second time");
  843. }
  844. }
  845. protected void runForthRoom(DMCWorld world)
  846. {
  847. DMCRoom ForthRoom = new DMCRoom();
  848. ForthRoom.counter = 0;
  849. DMCNpc thisnpc;
  850. int temp[] = new int[7];
  851. int templist[][] = new int[7][5];
  852. int xx = 0;
  853. for (int i = 0; i < 7; i++)
  854. {
  855. temp[i] = getRandom(ColumnRows.length);
  856. }
  857. for (int i = 0; i < 7; i++)
  858. {
  859. templist[i] = ColumnRows[temp[i]];
  860. }
  861. for (int x = 148660; x < 149285; x += 125)
  862. {
  863. int yy = 0;
  864. for (int y = 179280; y > 178405; y -= 125)
  865. {
  866. thisnpc = new DMCNpc();
  867. thisnpc.npc = addSpawn(SC, x, y, -6115, 16215, false, 0, false, world.getInstanceId());
  868. thisnpc.status = templist[yy][xx];
  869. thisnpc.order = yy;
  870. ForthRoom.npcList.add(thisnpc);
  871. yy++;
  872. }
  873. xx++;
  874. }
  875. // TODO: unify this into previous loop
  876. for (DMCNpc npc : ForthRoom.npcList)
  877. {
  878. if (npc.status == 0)
  879. {
  880. npc.npc.setIsInvul(true);
  881. }
  882. }
  883. world.rooms.put("ForthRoom", ForthRoom);
  884. world.setStatus(7);
  885. openDoor(D5, world.getInstanceId());
  886. if (debug)
  887. {
  888. _log.info("DarkCloudMansion: spawned forth room");
  889. }
  890. }
  891. protected void runFifthRoom(DMCWorld world)
  892. {
  893. spawnFifthRoom(world);
  894. world.setStatus(9);
  895. openDoor(D6, world.getInstanceId());
  896. if (debug)
  897. {
  898. _log.info("DarkCloudMansion: spawned fifth room");
  899. }
  900. }
  901. private void spawnFifthRoom(DMCWorld world)
  902. {
  903. int idx = 0;
  904. int temp[] = new int[6];
  905. DMCRoom FifthRoom = new DMCRoom();
  906. DMCNpc thisnpc;
  907. temp = Beleths[getRandom(Beleths.length)];
  908. FifthRoom.reset = 0;
  909. FifthRoom.founded = 0;
  910. for (int x = 148720; x < 149175; x += 65)
  911. {
  912. thisnpc = new DMCNpc();
  913. thisnpc.npc = addSpawn(BS[idx], x, 182145, -6117, 48810, false, 0, false, world.getInstanceId());
  914. thisnpc.npc.setIsNoRndWalk(true);
  915. thisnpc.order = idx;
  916. thisnpc.status = temp[idx];
  917. thisnpc.count = 0;
  918. FifthRoom.npcList.add(thisnpc);
  919. if ((temp[idx] == 1) && (getRandom(100) < 95))
  920. {
  921. thisnpc.npc.broadcastPacket(new NpcSay(thisnpc.npc.getObjectId(), 0, thisnpc.npc.getId(), _spawnChat[getRandom(_spawnChat.length)]));
  922. }
  923. else if ((temp[idx] != 1) && (getRandom(100) < 67))
  924. {
  925. thisnpc.npc.broadcastPacket(new NpcSay(thisnpc.npc.getObjectId(), 0, thisnpc.npc.getId(), _spawnChat[getRandom(_spawnChat.length)]));
  926. }
  927. idx++;
  928. }
  929. world.rooms.put("FifthRoom", FifthRoom);
  930. }
  931. protected boolean checkKillProgress(L2Npc npc, DMCRoom room)
  932. {
  933. boolean cont = true;
  934. for (DMCNpc npcobj : room.npcList)
  935. {
  936. if (npcobj.npc == npc)
  937. {
  938. npcobj.isDead = true;
  939. }
  940. if (npcobj.isDead == false)
  941. {
  942. cont = false;
  943. }
  944. }
  945. return cont;
  946. }
  947. protected void spawnRndGolem(DMCWorld world, DMCNpc npc)
  948. {
  949. if (npc.golem != null)
  950. {
  951. return;
  952. }
  953. int i = getRandom(GolemSpawn.length);
  954. int mobId = GolemSpawn[i][0];
  955. int x = GolemSpawn[i][1];
  956. int y = GolemSpawn[i][2];
  957. npc.golem = addSpawn(mobId, x, y, -6117, 0, false, 0, false, world.getInstanceId());
  958. if (noRndWalk)
  959. {
  960. npc.golem.setIsNoRndWalk(true);
  961. }
  962. }
  963. protected void checkStone(L2Npc npc, int order[], DMCNpc npcObj, DMCWorld world)
  964. {
  965. for (int i = 1; i < 7; i++)
  966. {
  967. // if there is a non zero value in the precedent step, the sequence is ok
  968. if ((order[i] == 0) && (order[i - 1] != 0))
  969. {
  970. if ((npcObj.order == i) && (npcObj.status == 0))
  971. {
  972. order[i] = 1;
  973. npcObj.status = 1;
  974. npcObj.isDead = true;
  975. npc.broadcastPacket(new MagicSkillUse(npc, npc, 5441, 1, 1, 0));
  976. return;
  977. }
  978. }
  979. }
  980. spawnRndGolem(world, npcObj);
  981. }
  982. protected void endInstance(DMCWorld world)
  983. {
  984. world.setStatus(10);
  985. addSpawn(SOTruth, 148911, 181940, -6117, 16383, false, 0, false, world.getInstanceId());
  986. world.rooms.clear();
  987. if (debug)
  988. {
  989. _log.info("DarkCloudMansion: finished");
  990. }
  991. }
  992. protected void checkBelethSample(DMCWorld world, L2Npc npc, L2PcInstance player)
  993. {
  994. DMCRoom FifthRoom = world.rooms.get("FifthRoom");
  995. for (DMCNpc mob : FifthRoom.npcList)
  996. {
  997. if (mob.npc == npc)
  998. {
  999. if (mob.count == 0)
  1000. {
  1001. mob.count = 1;
  1002. if (mob.status == 1)
  1003. {
  1004. mob.npc.broadcastPacket(new NpcSay(mob.npc.getObjectId(), Say2.NPC_ALL, mob.npc.getId(), _successChat[getRandom(_successChat.length)]));
  1005. FifthRoom.founded += 1;
  1006. startQuestTimer("decayMe", 1500, npc, player);
  1007. }
  1008. else
  1009. {
  1010. FifthRoom.reset = 1;
  1011. mob.npc.broadcastPacket(new NpcSay(mob.npc.getObjectId(), Say2.NPC_ALL, mob.npc.getId(), _faildChat[getRandom(_faildChat.length)]));
  1012. startQuestTimer("decayChatBelethSamples", 4000, npc, player);
  1013. startQuestTimer("decayBelethSamples", 4500, npc, player);
  1014. }
  1015. }
  1016. else
  1017. {
  1018. return;
  1019. }
  1020. }
  1021. }
  1022. }
  1023. protected void killedBelethSample(DMCWorld world, L2Npc npc)
  1024. {
  1025. int decayedSamples = 0;
  1026. DMCRoom FifthRoom = world.rooms.get("FifthRoom");
  1027. for (DMCNpc mob : FifthRoom.npcList)
  1028. {
  1029. if (mob.npc == npc)
  1030. {
  1031. decayedSamples += 1;
  1032. mob.count = 2;
  1033. }
  1034. else
  1035. {
  1036. if (mob.count == 2)
  1037. {
  1038. decayedSamples += 1;
  1039. }
  1040. }
  1041. }
  1042. if (FifthRoom.reset == 1)
  1043. {
  1044. for (DMCNpc mob : FifthRoom.npcList)
  1045. {
  1046. if ((mob.count == 0) || ((mob.status == 1) && (mob.count != 2)))
  1047. {
  1048. decayedSamples += 1;
  1049. mob.npc.decayMe();
  1050. mob.count = 2;
  1051. }
  1052. }
  1053. if (decayedSamples == 7)
  1054. {
  1055. startQuestTimer("respawnFifth", 6000, npc, null);
  1056. }
  1057. }
  1058. else
  1059. {
  1060. if ((FifthRoom.reset == 0) && (FifthRoom.founded == 3))
  1061. {
  1062. for (DMCNpc mob : FifthRoom.npcList)
  1063. {
  1064. mob.npc.decayMe();
  1065. }
  1066. endInstance(world);
  1067. }
  1068. }
  1069. }
  1070. protected boolean allStonesDone(DMCWorld world)
  1071. {
  1072. DMCRoom SecondRoom = world.rooms.get("SecondRoom");
  1073. for (DMCNpc mob : SecondRoom.npcList)
  1074. {
  1075. if (mob.isDead)
  1076. {
  1077. continue;
  1078. }
  1079. return false;
  1080. }
  1081. return true;
  1082. }
  1083. protected void removeMonoliths(DMCWorld world)
  1084. {
  1085. DMCRoom SecondRoom = world.rooms.get("SecondRoom");
  1086. for (DMCNpc mob : SecondRoom.npcList)
  1087. {
  1088. mob.npc.decayMe();
  1089. }
  1090. }
  1091. protected void chkShadowColumn(DMCWorld world, L2Npc npc)
  1092. {
  1093. DMCRoom ForthRoom = world.rooms.get("ForthRoom");
  1094. for (DMCNpc mob : ForthRoom.npcList)
  1095. {
  1096. if (mob.npc == npc)
  1097. {
  1098. for (int i = 0; i < 7; i++)
  1099. {
  1100. if ((mob.order == i) && (ForthRoom.counter == i))
  1101. {
  1102. openDoor(W1 + i, world.getInstanceId());
  1103. ForthRoom.counter += 1;
  1104. if (ForthRoom.counter == 7)
  1105. {
  1106. runThirdRoom2(world);
  1107. }
  1108. }
  1109. }
  1110. }
  1111. }
  1112. }
  1113. @Override
  1114. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  1115. {
  1116. if (npc == null)
  1117. {
  1118. return "";
  1119. }
  1120. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1121. DMCWorld world;
  1122. if (tmpworld instanceof DMCWorld)
  1123. {
  1124. world = (DMCWorld) tmpworld;
  1125. }
  1126. else
  1127. {
  1128. return "";
  1129. }
  1130. if (world.rooms.containsKey("FifthRoom"))
  1131. {
  1132. DMCRoom FifthRoom = world.rooms.get("FifthRoom");
  1133. if (event.equalsIgnoreCase("decayMe"))
  1134. {
  1135. for (DMCNpc mob : FifthRoom.npcList)
  1136. {
  1137. if ((mob.npc == npc) || ((FifthRoom.reset == 0) && (FifthRoom.founded == 3)))
  1138. {
  1139. mob.npc.decayMe();
  1140. mob.count = 2;
  1141. }
  1142. }
  1143. if ((FifthRoom.reset == 0) && (FifthRoom.founded == 3))
  1144. {
  1145. endInstance(world);
  1146. }
  1147. }
  1148. else if (event.equalsIgnoreCase("decayBelethSamples"))
  1149. {
  1150. for (DMCNpc mob : FifthRoom.npcList)
  1151. {
  1152. if (mob.count == 0)
  1153. {
  1154. mob.npc.decayMe();
  1155. mob.count = 2;
  1156. }
  1157. }
  1158. }
  1159. else if (event.equalsIgnoreCase("decayChatBelethSamples"))
  1160. {
  1161. for (DMCNpc mob : FifthRoom.npcList)
  1162. {
  1163. if (mob.status == 1)
  1164. {
  1165. mob.npc.broadcastPacket(new NpcSay(mob.npc.getObjectId(), Say2.NPC_ALL, mob.npc.getId(), _decayChat[getRandom(_decayChat.length)]));
  1166. }
  1167. }
  1168. }
  1169. else if (event.equalsIgnoreCase("respawnFifth"))
  1170. {
  1171. spawnFifthRoom(world);
  1172. }
  1173. }
  1174. return "";
  1175. }
  1176. @Override
  1177. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  1178. {
  1179. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1180. DMCWorld world;
  1181. if (tmpworld instanceof DMCWorld)
  1182. {
  1183. world = (DMCWorld) tmpworld;
  1184. if (world.getStatus() == 0)
  1185. {
  1186. if (checkKillProgress(npc, world.rooms.get("StartRoom")))
  1187. {
  1188. runHall(world);
  1189. }
  1190. }
  1191. if (world.getStatus() == 1)
  1192. {
  1193. if (checkKillProgress(npc, world.rooms.get("Hall")))
  1194. {
  1195. runFirstRoom(world);
  1196. }
  1197. }
  1198. if (world.getStatus() == 2)
  1199. {
  1200. if (checkKillProgress(npc, world.rooms.get("FirstRoom")))
  1201. {
  1202. runHall2(world);
  1203. }
  1204. }
  1205. if (world.getStatus() == 3)
  1206. {
  1207. if (checkKillProgress(npc, world.rooms.get("Hall")))
  1208. {
  1209. runSecondRoom(world);
  1210. }
  1211. }
  1212. if (world.getStatus() == 4)
  1213. {
  1214. DMCRoom SecondRoom = world.rooms.get("SecondRoom");
  1215. for (DMCNpc mob : SecondRoom.npcList)
  1216. {
  1217. if (mob.golem == npc)
  1218. {
  1219. mob.golem = null;
  1220. }
  1221. }
  1222. }
  1223. if (world.getStatus() == 5)
  1224. {
  1225. if (checkKillProgress(npc, world.rooms.get("Hall")))
  1226. {
  1227. runThirdRoom(world);
  1228. }
  1229. }
  1230. if (world.getStatus() == 6)
  1231. {
  1232. if (checkKillProgress(npc, world.rooms.get("ThirdRoom")))
  1233. {
  1234. runForthRoom(world);
  1235. }
  1236. }
  1237. if (world.getStatus() == 7)
  1238. {
  1239. chkShadowColumn(world, npc);
  1240. }
  1241. if (world.getStatus() == 8)
  1242. {
  1243. if (checkKillProgress(npc, world.rooms.get("ThirdRoom2")))
  1244. {
  1245. runFifthRoom(world);
  1246. }
  1247. }
  1248. if (world.getStatus() == 9)
  1249. {
  1250. killedBelethSample(world, npc);
  1251. }
  1252. }
  1253. return "";
  1254. }
  1255. @Override
  1256. public String onAttack(L2Npc npc, L2PcInstance player, int damage, boolean isSummon, Skill skill)
  1257. {
  1258. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1259. DMCWorld world;
  1260. if (tmpworld instanceof DMCWorld)
  1261. {
  1262. world = (DMCWorld) tmpworld;
  1263. if (world.getStatus() == 7)
  1264. {
  1265. DMCRoom ForthRoom = world.rooms.get("ForthRoom");
  1266. for (DMCNpc mob : ForthRoom.npcList)
  1267. {
  1268. if (mob.npc == npc)
  1269. {
  1270. if (mob.npc.isInvul() && (getRandom(100) < 12))
  1271. {
  1272. if (debug)
  1273. {
  1274. _log.info("DarkCloudMansion: spawn room 4 guard");
  1275. }
  1276. addSpawn(BM[getRandom(BM.length)], player.getX(), player.getY(), player.getZ(), 0, false, 0, false, world.getInstanceId());
  1277. }
  1278. }
  1279. }
  1280. }
  1281. if (world.getStatus() == 9)
  1282. {
  1283. checkBelethSample(world, npc, player);
  1284. }
  1285. }
  1286. return "";
  1287. }
  1288. @Override
  1289. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  1290. {
  1291. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1292. DMCWorld world;
  1293. if (tmpworld instanceof DMCWorld)
  1294. {
  1295. world = (DMCWorld) tmpworld;
  1296. if (world.getStatus() == 4)
  1297. {
  1298. DMCRoom SecondRoom = world.rooms.get("SecondRoom");
  1299. for (DMCNpc mob : SecondRoom.npcList)
  1300. {
  1301. if (mob.npc == npc)
  1302. {
  1303. checkStone(npc, SecondRoom.Order, mob, world);
  1304. }
  1305. }
  1306. if (allStonesDone(world))
  1307. {
  1308. removeMonoliths(world);
  1309. runHall3(world);
  1310. }
  1311. }
  1312. if ((npc.getId() == SOTruth) && (world.getStatus() == 10))
  1313. {
  1314. npc.showChatWindow(player);
  1315. QuestState st = player.getQuestState(getName());
  1316. if (st == null)
  1317. {
  1318. st = newQuestState(player);
  1319. }
  1320. if (!st.hasQuestItems(CC))
  1321. {
  1322. st.giveItems(CC, 1);
  1323. }
  1324. }
  1325. }
  1326. return "";
  1327. }
  1328. @Override
  1329. public String onTalk(L2Npc npc, L2PcInstance player)
  1330. {
  1331. int npcId = npc.getId();
  1332. if (npcId == YIYEN)
  1333. {
  1334. enterInstance(player, "DarkCloudMansion.xml", new Location(146534, 180464, -6117));
  1335. }
  1336. else
  1337. {
  1338. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1339. DMCWorld world;
  1340. if (tmpworld instanceof DMCWorld)
  1341. {
  1342. world = (DMCWorld) tmpworld;
  1343. }
  1344. else
  1345. {
  1346. return "";
  1347. }
  1348. if (npcId == SOTruth)
  1349. {
  1350. if (world.isAllowed(player.getObjectId()))
  1351. {
  1352. if (debug)
  1353. {
  1354. _log.info("DarkCloudMansion - id " + player.getObjectId() + " removed from allowed player in this Instances.");
  1355. }
  1356. world.removeAllowed(player.getObjectId());
  1357. }
  1358. teleportPlayer(player, new Location(139968, 150367, -3111), 0);
  1359. int instanceId = npc.getInstanceId();
  1360. Instance instance = InstanceManager.getInstance().getInstance(instanceId);
  1361. if (instance.getPlayers().isEmpty())
  1362. {
  1363. InstanceManager.getInstance().destroyInstance(instanceId);
  1364. }
  1365. return "";
  1366. }
  1367. }
  1368. return "";
  1369. }
  1370. public static void main(String[] args)
  1371. {
  1372. new DarkCloudMansion();
  1373. }
  1374. }