DarkCloudMansion.java 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468
  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 TEMPLATE_ID = 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 void enterInstance(L2PcInstance player, String template, Location loc)
  505. {
  506. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  507. if (world != null)
  508. {
  509. if (!(world instanceof DMCWorld))
  510. {
  511. player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
  512. return;
  513. }
  514. teleportPlayer(player, loc, world.getInstanceId());
  515. return;
  516. }
  517. if (!checkConditions(player))
  518. {
  519. return;
  520. }
  521. L2Party party = player.getParty();
  522. final int instanceId = InstanceManager.getInstance().createDynamicInstance(template);
  523. world = new DMCWorld();
  524. world.setInstanceId(instanceId);
  525. world.setTemplateId(TEMPLATE_ID);
  526. InstanceManager.getInstance().addWorld(world);
  527. _log.info("DarkCloudMansion: started " + template + " Instance: " + instanceId + " created by player: " + player.getName());
  528. runStartRoom((DMCWorld) world);
  529. // teleport players
  530. if (debug && (party == null))
  531. {
  532. world.addAllowed(player.getObjectId());
  533. teleportPlayer(player, loc, instanceId);
  534. }
  535. else
  536. {
  537. for (L2PcInstance partyMember : party.getMembers())
  538. {
  539. getQuestState(partyMember, true);
  540. world.addAllowed(partyMember.getObjectId());
  541. teleportPlayer(partyMember, loc, instanceId);
  542. }
  543. }
  544. }
  545. protected void runStartRoom(DMCWorld world)
  546. {
  547. world.setStatus(0);
  548. DMCRoom StartRoom = new DMCRoom();
  549. DMCNpc thisnpc;
  550. thisnpc = new DMCNpc();
  551. thisnpc.npc = addSpawn(BM[0], 146817, 180335, -6117, 0, false, 0, false, world.getInstanceId());
  552. StartRoom.npcList.add(thisnpc);
  553. if (noRndWalk)
  554. {
  555. thisnpc.npc.setIsNoRndWalk(true);
  556. }
  557. thisnpc = new DMCNpc();
  558. thisnpc.npc = addSpawn(BM[0], 146741, 180589, -6117, 0, false, 0, false, world.getInstanceId());
  559. StartRoom.npcList.add(thisnpc);
  560. if (noRndWalk)
  561. {
  562. thisnpc.npc.setIsNoRndWalk(true);
  563. }
  564. world.rooms.put("StartRoom", StartRoom);
  565. if (debug)
  566. {
  567. _log.info("DarkCloudMansion: first room spawned in instance " + world.getInstanceId());
  568. }
  569. }
  570. protected void spawnHall(DMCWorld world)
  571. {
  572. DMCRoom Hall = new DMCRoom();
  573. DMCNpc thisnpc;
  574. world.rooms.remove("Hall"); // remove room instance to avoid adding mob every time
  575. thisnpc = new DMCNpc();
  576. thisnpc.npc = addSpawn(BM[1], 147217, 180112, -6117, 0, false, 0, false, world.getInstanceId());
  577. if (noRndWalk)
  578. {
  579. thisnpc.npc.setIsNoRndWalk(true);
  580. }
  581. Hall.npcList.add(thisnpc);
  582. thisnpc = new DMCNpc();
  583. thisnpc.npc = addSpawn(BM[2], 147217, 180209, -6117, 0, false, 0, false, world.getInstanceId());
  584. if (noRndWalk)
  585. {
  586. thisnpc.npc.setIsNoRndWalk(true);
  587. }
  588. Hall.npcList.add(thisnpc);
  589. thisnpc = new DMCNpc();
  590. thisnpc.npc = addSpawn(BM[1], 148521, 180112, -6117, 0, false, 0, false, world.getInstanceId());
  591. if (noRndWalk)
  592. {
  593. thisnpc.npc.setIsNoRndWalk(true);
  594. }
  595. Hall.npcList.add(thisnpc);
  596. thisnpc = new DMCNpc();
  597. thisnpc.npc = addSpawn(BM[0], 148521, 180209, -6117, 0, false, 0, false, world.getInstanceId());
  598. if (noRndWalk)
  599. {
  600. thisnpc.npc.setIsNoRndWalk(true);
  601. }
  602. Hall.npcList.add(thisnpc);
  603. thisnpc = new DMCNpc();
  604. thisnpc.npc = addSpawn(BM[1], 148525, 180910, -6117, 0, false, 0, false, world.getInstanceId());
  605. if (noRndWalk)
  606. {
  607. thisnpc.npc.setIsNoRndWalk(true);
  608. }
  609. Hall.npcList.add(thisnpc);
  610. thisnpc = new DMCNpc();
  611. thisnpc.npc = addSpawn(BM[2], 148435, 180910, -6117, 0, false, 0, false, world.getInstanceId());
  612. if (noRndWalk)
  613. {
  614. thisnpc.npc.setIsNoRndWalk(true);
  615. }
  616. Hall.npcList.add(thisnpc);
  617. thisnpc = new DMCNpc();
  618. thisnpc.npc = addSpawn(BM[1], 147242, 180910, -6117, 0, false, 0, false, world.getInstanceId());
  619. if (noRndWalk)
  620. {
  621. thisnpc.npc.setIsNoRndWalk(true);
  622. }
  623. Hall.npcList.add(thisnpc);
  624. thisnpc = new DMCNpc();
  625. thisnpc.npc = addSpawn(BM[2], 147242, 180819, -6117, 0, false, 0, false, world.getInstanceId());
  626. if (noRndWalk)
  627. {
  628. thisnpc.npc.setIsNoRndWalk(true);
  629. }
  630. Hall.npcList.add(thisnpc);
  631. world.rooms.put("Hall", Hall);
  632. if (debug)
  633. {
  634. _log.info("DarkCloudMansion: hall spawned");
  635. }
  636. }
  637. protected void runHall(DMCWorld world)
  638. {
  639. spawnHall(world);
  640. world.setStatus(1);
  641. openDoor(D1, world.getInstanceId());
  642. }
  643. protected void runFirstRoom(DMCWorld world)
  644. {
  645. DMCRoom FirstRoom = new DMCRoom();
  646. DMCNpc thisnpc;
  647. thisnpc = new DMCNpc();
  648. thisnpc.npc = addSpawn(HG[1], 147842, 179837, -6117, 0, false, 0, false, world.getInstanceId());
  649. if (noRndWalk)
  650. {
  651. thisnpc.npc.setIsNoRndWalk(true);
  652. }
  653. FirstRoom.npcList.add(thisnpc);
  654. thisnpc = new DMCNpc();
  655. thisnpc.npc = addSpawn(HG[0], 147711, 179708, -6117, 0, false, 0, false, world.getInstanceId());
  656. if (noRndWalk)
  657. {
  658. thisnpc.npc.setIsNoRndWalk(true);
  659. }
  660. FirstRoom.npcList.add(thisnpc);
  661. thisnpc = new DMCNpc();
  662. thisnpc.npc = addSpawn(HG[1], 147842, 179552, -6117, 0, false, 0, false, world.getInstanceId());
  663. if (noRndWalk)
  664. {
  665. thisnpc.npc.setIsNoRndWalk(true);
  666. }
  667. FirstRoom.npcList.add(thisnpc);
  668. thisnpc = new DMCNpc();
  669. thisnpc.npc = addSpawn(HG[0], 147964, 179708, -6117, 0, false, 0, false, world.getInstanceId());
  670. if (noRndWalk)
  671. {
  672. thisnpc.npc.setIsNoRndWalk(true);
  673. }
  674. FirstRoom.npcList.add(thisnpc);
  675. world.rooms.put("FirstRoom", FirstRoom);
  676. world.setStatus(2);
  677. openDoor(D2, world.getInstanceId());
  678. if (debug)
  679. {
  680. _log.info("DarkCloudMansion: spawned first room");
  681. }
  682. }
  683. protected void runHall2(DMCWorld world)
  684. {
  685. addSpawn(SOFaith, 147818, 179643, -6117, 0, false, 0, false, world.getInstanceId());
  686. spawnHall(world);
  687. world.setStatus(3);
  688. }
  689. protected void runSecondRoom(DMCWorld world)
  690. {
  691. DMCRoom SecondRoom = new DMCRoom();
  692. DMCNpc thisnpc;
  693. // TODO: find a better way to initialize to [1,0,0,0,0,0,0]
  694. SecondRoom.Order = new int[7];
  695. SecondRoom.Order[0] = 1;
  696. for (int i = 1; i < 7; i++)
  697. {
  698. SecondRoom.Order[i] = 0;
  699. }
  700. int i = getRandom(MonolithOrder.length);
  701. thisnpc = new DMCNpc();
  702. thisnpc.npc = addSpawn(BSM, 147800, 181150, -6117, 0, false, 0, false, world.getInstanceId());
  703. thisnpc.order = MonolithOrder[i][0];
  704. SecondRoom.npcList.add(thisnpc);
  705. thisnpc = new DMCNpc();
  706. thisnpc.npc = addSpawn(BSM, 147900, 181215, -6117, 0, false, 0, false, world.getInstanceId());
  707. thisnpc.order = MonolithOrder[i][1];
  708. SecondRoom.npcList.add(thisnpc);
  709. thisnpc = new DMCNpc();
  710. thisnpc.npc = addSpawn(BSM, 147900, 181345, -6117, 0, false, 0, false, world.getInstanceId());
  711. thisnpc.order = MonolithOrder[i][2];
  712. SecondRoom.npcList.add(thisnpc);
  713. thisnpc = new DMCNpc();
  714. thisnpc.npc = addSpawn(BSM, 147800, 181410, -6117, 0, false, 0, false, world.getInstanceId());
  715. thisnpc.order = MonolithOrder[i][3];
  716. SecondRoom.npcList.add(thisnpc);
  717. thisnpc = new DMCNpc();
  718. thisnpc.npc = addSpawn(BSM, 147700, 181345, -6117, 0, false, 0, false, world.getInstanceId());
  719. thisnpc.order = MonolithOrder[i][4];
  720. SecondRoom.npcList.add(thisnpc);
  721. thisnpc = new DMCNpc();
  722. thisnpc.npc = addSpawn(BSM, 147700, 181215, -6117, 0, false, 0, false, world.getInstanceId());
  723. thisnpc.order = MonolithOrder[i][5];
  724. SecondRoom.npcList.add(thisnpc);
  725. world.rooms.put("SecondRoom", SecondRoom);
  726. world.setStatus(4);
  727. openDoor(D3, world.getInstanceId());
  728. if (debug)
  729. {
  730. _log.info("DarkCloudMansion: spawned second room");
  731. }
  732. }
  733. protected void runHall3(DMCWorld world)
  734. {
  735. addSpawn(SOAdversity, 147808, 181281, -6117, 16383, false, 0, false, world.getInstanceId());
  736. spawnHall(world);
  737. world.setStatus(5);
  738. }
  739. protected void runThirdRoom(DMCWorld world)
  740. {
  741. DMCRoom ThirdRoom = new DMCRoom();
  742. DMCNpc thisnpc = new DMCNpc();
  743. thisnpc.isDead = false;
  744. thisnpc.npc = addSpawn(BM[1], 148765, 180450, -6117, 0, false, 0, false, world.getInstanceId());
  745. if (noRndWalk)
  746. {
  747. thisnpc.npc.setIsNoRndWalk(true);
  748. }
  749. ThirdRoom.npcList.add(thisnpc);
  750. thisnpc.npc = addSpawn(BM[2], 148865, 180190, -6117, 0, false, 0, false, world.getInstanceId());
  751. if (noRndWalk)
  752. {
  753. thisnpc.npc.setIsNoRndWalk(true);
  754. }
  755. ThirdRoom.npcList.add(thisnpc);
  756. thisnpc.npc = addSpawn(BM[1], 148995, 180190, -6117, 0, false, 0, false, world.getInstanceId());
  757. if (noRndWalk)
  758. {
  759. thisnpc.npc.setIsNoRndWalk(true);
  760. }
  761. ThirdRoom.npcList.add(thisnpc);
  762. thisnpc.npc = addSpawn(BM[0], 149090, 180450, -6117, 0, false, 0, false, world.getInstanceId());
  763. if (noRndWalk)
  764. {
  765. thisnpc.npc.setIsNoRndWalk(true);
  766. }
  767. ThirdRoom.npcList.add(thisnpc);
  768. thisnpc.npc = addSpawn(BM[1], 148995, 180705, -6117, 0, false, 0, false, world.getInstanceId());
  769. if (noRndWalk)
  770. {
  771. thisnpc.npc.setIsNoRndWalk(true);
  772. }
  773. ThirdRoom.npcList.add(thisnpc);
  774. thisnpc.npc = addSpawn(BM[2], 148865, 180705, -6117, 0, false, 0, false, world.getInstanceId());
  775. if (noRndWalk)
  776. {
  777. thisnpc.npc.setIsNoRndWalk(true);
  778. }
  779. ThirdRoom.npcList.add(thisnpc);
  780. world.rooms.put("ThirdRoom", ThirdRoom);
  781. world.setStatus(6);
  782. openDoor(D4, world.getInstanceId());
  783. if (debug)
  784. {
  785. _log.info("DarkCloudMansion: spawned third room");
  786. }
  787. }
  788. protected void runThirdRoom2(DMCWorld world)
  789. {
  790. addSpawn(SOAdventure, 148910, 178397, -6117, 16383, false, 0, false, world.getInstanceId());
  791. DMCRoom ThirdRoom = new DMCRoom();
  792. DMCNpc thisnpc = new DMCNpc();
  793. thisnpc.isDead = false;
  794. thisnpc.npc = addSpawn(BM[1], 148765, 180450, -6117, 0, false, 0, false, world.getInstanceId());
  795. if (noRndWalk)
  796. {
  797. thisnpc.npc.setIsNoRndWalk(true);
  798. }
  799. ThirdRoom.npcList.add(thisnpc);
  800. thisnpc.npc = addSpawn(BM[2], 148865, 180190, -6117, 0, false, 0, false, world.getInstanceId());
  801. if (noRndWalk)
  802. {
  803. thisnpc.npc.setIsNoRndWalk(true);
  804. }
  805. ThirdRoom.npcList.add(thisnpc);
  806. thisnpc.npc = addSpawn(BM[1], 148995, 180190, -6117, 0, false, 0, false, world.getInstanceId());
  807. if (noRndWalk)
  808. {
  809. thisnpc.npc.setIsNoRndWalk(true);
  810. }
  811. ThirdRoom.npcList.add(thisnpc);
  812. thisnpc.npc = addSpawn(BM[0], 149090, 180450, -6117, 0, false, 0, false, world.getInstanceId());
  813. if (noRndWalk)
  814. {
  815. thisnpc.npc.setIsNoRndWalk(true);
  816. }
  817. ThirdRoom.npcList.add(thisnpc);
  818. thisnpc.npc = addSpawn(BM[1], 148995, 180705, -6117, 0, false, 0, false, world.getInstanceId());
  819. if (noRndWalk)
  820. {
  821. thisnpc.npc.setIsNoRndWalk(true);
  822. }
  823. ThirdRoom.npcList.add(thisnpc);
  824. thisnpc.npc = addSpawn(BM[2], 148865, 180705, -6117, 0, false, 0, false, world.getInstanceId());
  825. if (noRndWalk)
  826. {
  827. thisnpc.npc.setIsNoRndWalk(true);
  828. }
  829. ThirdRoom.npcList.add(thisnpc);
  830. world.rooms.put("ThirdRoom2", ThirdRoom);
  831. world.setStatus(8);
  832. if (debug)
  833. {
  834. _log.info("DarkCloudMansion: spawned third room second time");
  835. }
  836. }
  837. protected void runForthRoom(DMCWorld world)
  838. {
  839. DMCRoom ForthRoom = new DMCRoom();
  840. ForthRoom.counter = 0;
  841. DMCNpc thisnpc;
  842. int temp[] = new int[7];
  843. int templist[][] = new int[7][5];
  844. int xx = 0;
  845. for (int i = 0; i < 7; i++)
  846. {
  847. temp[i] = getRandom(ColumnRows.length);
  848. }
  849. for (int i = 0; i < 7; i++)
  850. {
  851. templist[i] = ColumnRows[temp[i]];
  852. }
  853. for (int x = 148660; x < 149285; x += 125)
  854. {
  855. int yy = 0;
  856. for (int y = 179280; y > 178405; y -= 125)
  857. {
  858. thisnpc = new DMCNpc();
  859. thisnpc.npc = addSpawn(SC, x, y, -6115, 16215, false, 0, false, world.getInstanceId());
  860. thisnpc.status = templist[yy][xx];
  861. thisnpc.order = yy;
  862. ForthRoom.npcList.add(thisnpc);
  863. yy++;
  864. }
  865. xx++;
  866. }
  867. // TODO: unify this into previous loop
  868. for (DMCNpc npc : ForthRoom.npcList)
  869. {
  870. if (npc.status == 0)
  871. {
  872. npc.npc.setIsInvul(true);
  873. }
  874. }
  875. world.rooms.put("ForthRoom", ForthRoom);
  876. world.setStatus(7);
  877. openDoor(D5, world.getInstanceId());
  878. if (debug)
  879. {
  880. _log.info("DarkCloudMansion: spawned forth room");
  881. }
  882. }
  883. protected void runFifthRoom(DMCWorld world)
  884. {
  885. spawnFifthRoom(world);
  886. world.setStatus(9);
  887. openDoor(D6, world.getInstanceId());
  888. if (debug)
  889. {
  890. _log.info("DarkCloudMansion: spawned fifth room");
  891. }
  892. }
  893. private void spawnFifthRoom(DMCWorld world)
  894. {
  895. int idx = 0;
  896. int temp[] = new int[6];
  897. DMCRoom FifthRoom = new DMCRoom();
  898. DMCNpc thisnpc;
  899. temp = Beleths[getRandom(Beleths.length)];
  900. FifthRoom.reset = 0;
  901. FifthRoom.founded = 0;
  902. for (int x = 148720; x < 149175; x += 65)
  903. {
  904. thisnpc = new DMCNpc();
  905. thisnpc.npc = addSpawn(BS[idx], x, 182145, -6117, 48810, false, 0, false, world.getInstanceId());
  906. thisnpc.npc.setIsNoRndWalk(true);
  907. thisnpc.order = idx;
  908. thisnpc.status = temp[idx];
  909. thisnpc.count = 0;
  910. FifthRoom.npcList.add(thisnpc);
  911. if ((temp[idx] == 1) && (getRandom(100) < 95))
  912. {
  913. thisnpc.npc.broadcastPacket(new NpcSay(thisnpc.npc.getObjectId(), 0, thisnpc.npc.getId(), _spawnChat[getRandom(_spawnChat.length)]));
  914. }
  915. else if ((temp[idx] != 1) && (getRandom(100) < 67))
  916. {
  917. thisnpc.npc.broadcastPacket(new NpcSay(thisnpc.npc.getObjectId(), 0, thisnpc.npc.getId(), _spawnChat[getRandom(_spawnChat.length)]));
  918. }
  919. idx++;
  920. }
  921. world.rooms.put("FifthRoom", FifthRoom);
  922. }
  923. protected boolean checkKillProgress(L2Npc npc, DMCRoom room)
  924. {
  925. boolean cont = true;
  926. for (DMCNpc npcobj : room.npcList)
  927. {
  928. if (npcobj.npc == npc)
  929. {
  930. npcobj.isDead = true;
  931. }
  932. if (npcobj.isDead == false)
  933. {
  934. cont = false;
  935. }
  936. }
  937. return cont;
  938. }
  939. protected void spawnRndGolem(DMCWorld world, DMCNpc npc)
  940. {
  941. if (npc.golem != null)
  942. {
  943. return;
  944. }
  945. int i = getRandom(GolemSpawn.length);
  946. int mobId = GolemSpawn[i][0];
  947. int x = GolemSpawn[i][1];
  948. int y = GolemSpawn[i][2];
  949. npc.golem = addSpawn(mobId, x, y, -6117, 0, false, 0, false, world.getInstanceId());
  950. if (noRndWalk)
  951. {
  952. npc.golem.setIsNoRndWalk(true);
  953. }
  954. }
  955. protected void checkStone(L2Npc npc, int order[], DMCNpc npcObj, DMCWorld world)
  956. {
  957. for (int i = 1; i < 7; i++)
  958. {
  959. // if there is a non zero value in the precedent step, the sequence is ok
  960. if ((order[i] == 0) && (order[i - 1] != 0))
  961. {
  962. if ((npcObj.order == i) && (npcObj.status == 0))
  963. {
  964. order[i] = 1;
  965. npcObj.status = 1;
  966. npcObj.isDead = true;
  967. npc.broadcastPacket(new MagicSkillUse(npc, npc, 5441, 1, 1, 0));
  968. return;
  969. }
  970. }
  971. }
  972. spawnRndGolem(world, npcObj);
  973. }
  974. protected void endInstance(DMCWorld world)
  975. {
  976. world.setStatus(10);
  977. addSpawn(SOTruth, 148911, 181940, -6117, 16383, false, 0, false, world.getInstanceId());
  978. world.rooms.clear();
  979. if (debug)
  980. {
  981. _log.info("DarkCloudMansion: finished");
  982. }
  983. }
  984. protected void checkBelethSample(DMCWorld world, L2Npc npc, L2PcInstance player)
  985. {
  986. DMCRoom FifthRoom = world.rooms.get("FifthRoom");
  987. for (DMCNpc mob : FifthRoom.npcList)
  988. {
  989. if (mob.npc == npc)
  990. {
  991. if (mob.count == 0)
  992. {
  993. mob.count = 1;
  994. if (mob.status == 1)
  995. {
  996. mob.npc.broadcastPacket(new NpcSay(mob.npc.getObjectId(), Say2.NPC_ALL, mob.npc.getId(), _successChat[getRandom(_successChat.length)]));
  997. FifthRoom.founded += 1;
  998. startQuestTimer("decayMe", 1500, npc, player);
  999. }
  1000. else
  1001. {
  1002. FifthRoom.reset = 1;
  1003. mob.npc.broadcastPacket(new NpcSay(mob.npc.getObjectId(), Say2.NPC_ALL, mob.npc.getId(), _faildChat[getRandom(_faildChat.length)]));
  1004. startQuestTimer("decayChatBelethSamples", 4000, npc, player);
  1005. startQuestTimer("decayBelethSamples", 4500, npc, player);
  1006. }
  1007. }
  1008. else
  1009. {
  1010. return;
  1011. }
  1012. }
  1013. }
  1014. }
  1015. protected void killedBelethSample(DMCWorld world, L2Npc npc)
  1016. {
  1017. int decayedSamples = 0;
  1018. DMCRoom FifthRoom = world.rooms.get("FifthRoom");
  1019. for (DMCNpc mob : FifthRoom.npcList)
  1020. {
  1021. if (mob.npc == npc)
  1022. {
  1023. decayedSamples += 1;
  1024. mob.count = 2;
  1025. }
  1026. else
  1027. {
  1028. if (mob.count == 2)
  1029. {
  1030. decayedSamples += 1;
  1031. }
  1032. }
  1033. }
  1034. if (FifthRoom.reset == 1)
  1035. {
  1036. for (DMCNpc mob : FifthRoom.npcList)
  1037. {
  1038. if ((mob.count == 0) || ((mob.status == 1) && (mob.count != 2)))
  1039. {
  1040. decayedSamples += 1;
  1041. mob.npc.decayMe();
  1042. mob.count = 2;
  1043. }
  1044. }
  1045. if (decayedSamples == 7)
  1046. {
  1047. startQuestTimer("respawnFifth", 6000, npc, null);
  1048. }
  1049. }
  1050. else
  1051. {
  1052. if ((FifthRoom.reset == 0) && (FifthRoom.founded == 3))
  1053. {
  1054. for (DMCNpc mob : FifthRoom.npcList)
  1055. {
  1056. mob.npc.decayMe();
  1057. }
  1058. endInstance(world);
  1059. }
  1060. }
  1061. }
  1062. protected boolean allStonesDone(DMCWorld world)
  1063. {
  1064. DMCRoom SecondRoom = world.rooms.get("SecondRoom");
  1065. for (DMCNpc mob : SecondRoom.npcList)
  1066. {
  1067. if (mob.isDead)
  1068. {
  1069. continue;
  1070. }
  1071. return false;
  1072. }
  1073. return true;
  1074. }
  1075. protected void removeMonoliths(DMCWorld world)
  1076. {
  1077. DMCRoom SecondRoom = world.rooms.get("SecondRoom");
  1078. for (DMCNpc mob : SecondRoom.npcList)
  1079. {
  1080. mob.npc.decayMe();
  1081. }
  1082. }
  1083. protected void chkShadowColumn(DMCWorld world, L2Npc npc)
  1084. {
  1085. DMCRoom ForthRoom = world.rooms.get("ForthRoom");
  1086. for (DMCNpc mob : ForthRoom.npcList)
  1087. {
  1088. if (mob.npc == npc)
  1089. {
  1090. for (int i = 0; i < 7; i++)
  1091. {
  1092. if ((mob.order == i) && (ForthRoom.counter == i))
  1093. {
  1094. openDoor(W1 + i, world.getInstanceId());
  1095. ForthRoom.counter += 1;
  1096. if (ForthRoom.counter == 7)
  1097. {
  1098. runThirdRoom2(world);
  1099. }
  1100. }
  1101. }
  1102. }
  1103. }
  1104. }
  1105. @Override
  1106. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  1107. {
  1108. if (npc == null)
  1109. {
  1110. return "";
  1111. }
  1112. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1113. DMCWorld world;
  1114. if (tmpworld instanceof DMCWorld)
  1115. {
  1116. world = (DMCWorld) tmpworld;
  1117. }
  1118. else
  1119. {
  1120. return "";
  1121. }
  1122. if (world.rooms.containsKey("FifthRoom"))
  1123. {
  1124. DMCRoom FifthRoom = world.rooms.get("FifthRoom");
  1125. if (event.equalsIgnoreCase("decayMe"))
  1126. {
  1127. for (DMCNpc mob : FifthRoom.npcList)
  1128. {
  1129. if ((mob.npc == npc) || ((FifthRoom.reset == 0) && (FifthRoom.founded == 3)))
  1130. {
  1131. mob.npc.decayMe();
  1132. mob.count = 2;
  1133. }
  1134. }
  1135. if ((FifthRoom.reset == 0) && (FifthRoom.founded == 3))
  1136. {
  1137. endInstance(world);
  1138. }
  1139. }
  1140. else if (event.equalsIgnoreCase("decayBelethSamples"))
  1141. {
  1142. for (DMCNpc mob : FifthRoom.npcList)
  1143. {
  1144. if (mob.count == 0)
  1145. {
  1146. mob.npc.decayMe();
  1147. mob.count = 2;
  1148. }
  1149. }
  1150. }
  1151. else if (event.equalsIgnoreCase("decayChatBelethSamples"))
  1152. {
  1153. for (DMCNpc mob : FifthRoom.npcList)
  1154. {
  1155. if (mob.status == 1)
  1156. {
  1157. mob.npc.broadcastPacket(new NpcSay(mob.npc.getObjectId(), Say2.NPC_ALL, mob.npc.getId(), _decayChat[getRandom(_decayChat.length)]));
  1158. }
  1159. }
  1160. }
  1161. else if (event.equalsIgnoreCase("respawnFifth"))
  1162. {
  1163. spawnFifthRoom(world);
  1164. }
  1165. }
  1166. return "";
  1167. }
  1168. @Override
  1169. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  1170. {
  1171. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1172. DMCWorld world;
  1173. if (tmpworld instanceof DMCWorld)
  1174. {
  1175. world = (DMCWorld) tmpworld;
  1176. if (world.getStatus() == 0)
  1177. {
  1178. if (checkKillProgress(npc, world.rooms.get("StartRoom")))
  1179. {
  1180. runHall(world);
  1181. }
  1182. }
  1183. if (world.getStatus() == 1)
  1184. {
  1185. if (checkKillProgress(npc, world.rooms.get("Hall")))
  1186. {
  1187. runFirstRoom(world);
  1188. }
  1189. }
  1190. if (world.getStatus() == 2)
  1191. {
  1192. if (checkKillProgress(npc, world.rooms.get("FirstRoom")))
  1193. {
  1194. runHall2(world);
  1195. }
  1196. }
  1197. if (world.getStatus() == 3)
  1198. {
  1199. if (checkKillProgress(npc, world.rooms.get("Hall")))
  1200. {
  1201. runSecondRoom(world);
  1202. }
  1203. }
  1204. if (world.getStatus() == 4)
  1205. {
  1206. DMCRoom SecondRoom = world.rooms.get("SecondRoom");
  1207. for (DMCNpc mob : SecondRoom.npcList)
  1208. {
  1209. if (mob.golem == npc)
  1210. {
  1211. mob.golem = null;
  1212. }
  1213. }
  1214. }
  1215. if (world.getStatus() == 5)
  1216. {
  1217. if (checkKillProgress(npc, world.rooms.get("Hall")))
  1218. {
  1219. runThirdRoom(world);
  1220. }
  1221. }
  1222. if (world.getStatus() == 6)
  1223. {
  1224. if (checkKillProgress(npc, world.rooms.get("ThirdRoom")))
  1225. {
  1226. runForthRoom(world);
  1227. }
  1228. }
  1229. if (world.getStatus() == 7)
  1230. {
  1231. chkShadowColumn(world, npc);
  1232. }
  1233. if (world.getStatus() == 8)
  1234. {
  1235. if (checkKillProgress(npc, world.rooms.get("ThirdRoom2")))
  1236. {
  1237. runFifthRoom(world);
  1238. }
  1239. }
  1240. if (world.getStatus() == 9)
  1241. {
  1242. killedBelethSample(world, npc);
  1243. }
  1244. }
  1245. return "";
  1246. }
  1247. @Override
  1248. public String onAttack(L2Npc npc, L2PcInstance player, int damage, boolean isSummon, Skill skill)
  1249. {
  1250. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1251. DMCWorld world;
  1252. if (tmpworld instanceof DMCWorld)
  1253. {
  1254. world = (DMCWorld) tmpworld;
  1255. if (world.getStatus() == 7)
  1256. {
  1257. DMCRoom ForthRoom = world.rooms.get("ForthRoom");
  1258. for (DMCNpc mob : ForthRoom.npcList)
  1259. {
  1260. if (mob.npc == npc)
  1261. {
  1262. if (mob.npc.isInvul() && (getRandom(100) < 12))
  1263. {
  1264. if (debug)
  1265. {
  1266. _log.info("DarkCloudMansion: spawn room 4 guard");
  1267. }
  1268. addSpawn(BM[getRandom(BM.length)], player.getX(), player.getY(), player.getZ(), 0, false, 0, false, world.getInstanceId());
  1269. }
  1270. }
  1271. }
  1272. }
  1273. if (world.getStatus() == 9)
  1274. {
  1275. checkBelethSample(world, npc, player);
  1276. }
  1277. }
  1278. return "";
  1279. }
  1280. @Override
  1281. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  1282. {
  1283. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1284. DMCWorld world;
  1285. if (tmpworld instanceof DMCWorld)
  1286. {
  1287. world = (DMCWorld) tmpworld;
  1288. if (world.getStatus() == 4)
  1289. {
  1290. DMCRoom SecondRoom = world.rooms.get("SecondRoom");
  1291. for (DMCNpc mob : SecondRoom.npcList)
  1292. {
  1293. if (mob.npc == npc)
  1294. {
  1295. checkStone(npc, SecondRoom.Order, mob, world);
  1296. }
  1297. }
  1298. if (allStonesDone(world))
  1299. {
  1300. removeMonoliths(world);
  1301. runHall3(world);
  1302. }
  1303. }
  1304. if ((npc.getId() == SOTruth) && (world.getStatus() == 10))
  1305. {
  1306. npc.showChatWindow(player);
  1307. QuestState st = getQuestState(player, true);
  1308. if (!st.hasQuestItems(CC))
  1309. {
  1310. st.giveItems(CC, 1);
  1311. }
  1312. }
  1313. }
  1314. return "";
  1315. }
  1316. @Override
  1317. public String onTalk(L2Npc npc, L2PcInstance player)
  1318. {
  1319. int npcId = npc.getId();
  1320. if (npcId == YIYEN)
  1321. {
  1322. enterInstance(player, "DarkCloudMansion.xml", new Location(146534, 180464, -6117));
  1323. }
  1324. else
  1325. {
  1326. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1327. DMCWorld world;
  1328. if (tmpworld instanceof DMCWorld)
  1329. {
  1330. world = (DMCWorld) tmpworld;
  1331. }
  1332. else
  1333. {
  1334. return "";
  1335. }
  1336. if (npcId == SOTruth)
  1337. {
  1338. if (world.isAllowed(player.getObjectId()))
  1339. {
  1340. if (debug)
  1341. {
  1342. _log.info("DarkCloudMansion - id " + player.getObjectId() + " removed from allowed player in this Instances.");
  1343. }
  1344. world.removeAllowed(player.getObjectId());
  1345. }
  1346. teleportPlayer(player, new Location(139968, 150367, -3111), 0);
  1347. int instanceId = npc.getInstanceId();
  1348. Instance instance = InstanceManager.getInstance().getInstance(instanceId);
  1349. if (instance.getPlayers().isEmpty())
  1350. {
  1351. InstanceManager.getInstance().destroyInstance(instanceId);
  1352. }
  1353. return "";
  1354. }
  1355. }
  1356. return "";
  1357. }
  1358. public static void main(String[] args)
  1359. {
  1360. new DarkCloudMansion();
  1361. }
  1362. }