DarkCloudMansion.java 33 KB

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