DarkCloudMansion.java 32 KB

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