DarkCloudMansion.java 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207
  1. /*
  2. * Copyright (C) 2004-2015 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package instances.DarkCloudMansion;
  20. import instances.AbstractInstance;
  21. import java.util.ArrayList;
  22. import java.util.List;
  23. import java.util.Map;
  24. import java.util.concurrent.ConcurrentHashMap;
  25. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  26. import com.l2jserver.gameserver.model.L2Party;
  27. import com.l2jserver.gameserver.model.Location;
  28. import com.l2jserver.gameserver.model.actor.L2Npc;
  29. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  30. import com.l2jserver.gameserver.model.entity.Instance;
  31. import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
  32. import com.l2jserver.gameserver.model.skills.Skill;
  33. import com.l2jserver.gameserver.network.NpcStringId;
  34. import com.l2jserver.gameserver.network.SystemMessageId;
  35. import com.l2jserver.gameserver.network.clientpackets.Say2;
  36. import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
  37. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  38. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  39. /**
  40. * Dark Cloud Mansion instance zone.
  41. */
  42. public final class DarkCloudMansion extends AbstractInstance
  43. {
  44. protected class DMCWorld extends InstanceWorld
  45. {
  46. protected Map<String, DMCRoom> rooms = new ConcurrentHashMap<>();
  47. }
  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. // Items
  103. private static int CC = 9690; // Contaminated Crystal
  104. // Misc
  105. private static final int TEMPLATE_ID = 9;
  106. private static int D1 = 24230001; // Starting Room
  107. private static int D2 = 24230002; // First Room
  108. private static int D3 = 24230005; // Second Room
  109. private static int D4 = 24230003; // Third Room
  110. private static int D5 = 24230004; // Forth Room
  111. private static int D6 = 24230006; // Fifth Room
  112. private static int W1 = 24230007; // Wall 1
  113. // private static int W2 = 24230008; // Wall 2
  114. // private static int W3 = 24230009; // Wall 3
  115. // private static int W4 = 24230010; // Wall 4
  116. // private static int W5 = 24230011; // Wall 5
  117. // private static int W6 = 24230012; // Wall 6
  118. // private static int W7 = 24230013; // Wall 7
  119. private static boolean debug = false;
  120. private static boolean noRndWalk = true;
  121. private static NpcStringId[] _spawnChat =
  122. {
  123. NpcStringId.IM_THE_REAL_ONE,
  124. NpcStringId.PICK_ME,
  125. NpcStringId.TRUST_ME,
  126. NpcStringId.NOT_THAT_DUDE_IM_THE_REAL_ONE,
  127. NpcStringId.DONT_BE_FOOLED_DONT_BE_FOOLED_IM_THE_REAL_ONE
  128. };
  129. private static NpcStringId[] _decayChat =
  130. {
  131. NpcStringId.IM_THE_REAL_ONE_PHEW,
  132. NpcStringId.CANT_YOU_EVEN_FIND_OUT,
  133. NpcStringId.FIND_ME
  134. };
  135. private static NpcStringId[] _successChat =
  136. {
  137. NpcStringId.HUH_HOW_DID_YOU_KNOW_IT_WAS_ME,
  138. NpcStringId.EXCELLENT_CHOICE_TEEHEE,
  139. NpcStringId.YOUVE_DONE_WELL,
  140. NpcStringId.OH_VERY_SENSIBLE
  141. };
  142. private static NpcStringId[] _faildChat =
  143. {
  144. NpcStringId.YOUVE_BEEN_FOOLED,
  145. NpcStringId.SORRY_BUT_IM_THE_FAKE_ONE
  146. };
  147. // @formatter:off
  148. // Second room - random monolith order
  149. private static int[][] MonolithOrder = new int[][]
  150. {
  151. {1, 2, 3, 4, 5, 6},
  152. {6, 5, 4, 3, 2, 1},
  153. {4 ,5, 6, 3, 2, 1},
  154. {2, 6, 3, 5, 1, 4},
  155. {4, 1, 5, 6, 2, 3},
  156. {3, 5, 1, 6, 2, 4},
  157. {6, 1, 3, 4, 5, 2},
  158. {5, 6, 1, 2, 4, 3},
  159. {5, 2, 6, 3, 4, 1},
  160. {1, 5, 2, 6, 3, 4},
  161. {1, 2, 3, 6, 5, 4},
  162. {6, 4, 3, 1, 5, 2},
  163. {3, 5, 2, 4, 1, 6},
  164. {3, 2, 4, 5, 1, 6},
  165. {5, 4, 3, 1, 6, 2},
  166. };
  167. // Second room - golem spawn locatons - random
  168. private static int[][] GolemSpawn = new int[][]
  169. {
  170. {CCG[0], 148060, 181389},
  171. {CCG[1], 147910, 181173},
  172. {CCG[0], 147810, 181334},
  173. {CCG[1], 147713, 181179},
  174. {CCG[0], 147569, 181410},
  175. {CCG[1], 147810, 181517},
  176. {CCG[0], 147805, 181281},
  177. };
  178. // forth room - random shadow column
  179. private static int[][] ColumnRows = new int[][]
  180. {
  181. {1, 1, 0, 1, 0},
  182. {0, 1, 1, 0, 1},
  183. {1, 0, 1, 1, 0},
  184. {0, 1, 0, 1, 1},
  185. {1, 0, 1, 0, 1},
  186. };
  187. // Fifth room - beleth order
  188. private static int[][] Beleths = new int[][]
  189. {
  190. {1, 0, 1, 0, 1, 0, 0},
  191. {0, 0, 1, 0, 1, 1, 0},
  192. {0, 0, 0, 1, 0, 1, 1},
  193. {1, 0, 1, 1, 0, 0, 0},
  194. {1, 1, 0, 0, 0, 1, 0},
  195. {0, 1, 0, 1, 0, 1, 0},
  196. {0, 0, 0, 1, 1, 1, 0},
  197. {1, 0, 1, 0, 0, 1, 0},
  198. {0, 1, 1, 0, 0, 0, 1},
  199. };
  200. // @formatter:on
  201. public DarkCloudMansion()
  202. {
  203. super(DarkCloudMansion.class.getSimpleName());
  204. addFirstTalkId(BSM, SOTruth);
  205. addStartNpc(YIYEN);
  206. addTalkId(YIYEN, SOTruth);
  207. addAttackId(SC);
  208. addAttackId(BS);
  209. addAttackId(CCG);
  210. addKillId(TOKILL);
  211. }
  212. protected static class DMCNpc
  213. {
  214. public L2Npc npc;
  215. public boolean isDead = false;
  216. public L2Npc golem = null;
  217. public int status = 0;
  218. public int order = 0;
  219. public int count = 0;
  220. }
  221. protected static class DMCRoom
  222. {
  223. public List<DMCNpc> npcList = new ArrayList<>();
  224. public int counter = 0;
  225. public int reset = 0;
  226. public int founded = 0;
  227. public int[] Order;
  228. }
  229. @Override
  230. protected boolean checkConditions(L2PcInstance player)
  231. {
  232. if (debug)
  233. {
  234. return true;
  235. }
  236. final L2Party party = player.getParty();
  237. if (party == null)
  238. {
  239. player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER);
  240. return false;
  241. }
  242. if (party.getLeader() != player)
  243. {
  244. player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
  245. return false;
  246. }
  247. if (party.getMemberCount() > 2)
  248. {
  249. player.sendPacket(SystemMessageId.PARTY_EXCEEDED_THE_LIMIT_CANT_ENTER);
  250. return false;
  251. }
  252. for (L2PcInstance partyMember : party.getMembers())
  253. {
  254. if (partyMember.getLevel() < 78)
  255. {
  256. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_S_LEVEL_REQUIREMENT_IS_NOT_SUFFICIENT_AND_CANNOT_BE_ENTERED);
  257. sm.addPcName(partyMember);
  258. player.sendPacket(sm);
  259. return false;
  260. }
  261. if (!partyMember.isInsideRadius(player, 1000, true, true))
  262. {
  263. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_A_LOCATION_WHICH_CANNOT_BE_ENTERED_THEREFORE_IT_CANNOT_BE_PROCESSED);
  264. sm.addPcName(partyMember);
  265. player.sendPacket(sm);
  266. return false;
  267. }
  268. }
  269. return true;
  270. }
  271. @Override
  272. public void onEnterInstance(L2PcInstance player, InstanceWorld world, boolean firstEntrance)
  273. {
  274. if (firstEntrance)
  275. {
  276. runStartRoom((DMCWorld) world);
  277. // teleport players
  278. if (debug && (player.getParty() == null))
  279. {
  280. world.addAllowed(player.getObjectId());
  281. teleportPlayer(player, new Location(146534, 180464, -6117), world.getInstanceId());
  282. }
  283. else
  284. {
  285. for (L2PcInstance partyMember : player.getParty().getMembers())
  286. {
  287. if (partyMember.getQuestState(getName()) == null)
  288. {
  289. newQuestState(partyMember);
  290. }
  291. world.addAllowed(partyMember.getObjectId());
  292. teleportPlayer(partyMember, new Location(146534, 180464, -6117), world.getInstanceId());
  293. }
  294. }
  295. }
  296. else
  297. {
  298. teleportPlayer(player, new Location(146534, 180464, -6117), world.getInstanceId());
  299. }
  300. }
  301. protected void runStartRoom(DMCWorld world)
  302. {
  303. world.setStatus(0);
  304. DMCRoom StartRoom = new DMCRoom();
  305. DMCNpc thisnpc;
  306. thisnpc = new DMCNpc();
  307. thisnpc.npc = addSpawn(BM[0], 146817, 180335, -6117, 0, false, 0, false, world.getInstanceId());
  308. StartRoom.npcList.add(thisnpc);
  309. if (noRndWalk)
  310. {
  311. thisnpc.npc.setIsNoRndWalk(true);
  312. }
  313. thisnpc = new DMCNpc();
  314. thisnpc.npc = addSpawn(BM[0], 146741, 180589, -6117, 0, false, 0, false, world.getInstanceId());
  315. StartRoom.npcList.add(thisnpc);
  316. if (noRndWalk)
  317. {
  318. thisnpc.npc.setIsNoRndWalk(true);
  319. }
  320. world.rooms.put("StartRoom", StartRoom);
  321. if (debug)
  322. {
  323. _log.info("DarkCloudMansion: first room spawned in instance " + world.getInstanceId());
  324. }
  325. }
  326. protected void spawnHall(DMCWorld world)
  327. {
  328. DMCRoom Hall = new DMCRoom();
  329. DMCNpc thisnpc;
  330. world.rooms.remove("Hall"); // remove room instance to avoid adding mob every time
  331. thisnpc = new DMCNpc();
  332. thisnpc.npc = addSpawn(BM[1], 147217, 180112, -6117, 0, false, 0, false, world.getInstanceId());
  333. if (noRndWalk)
  334. {
  335. thisnpc.npc.setIsNoRndWalk(true);
  336. }
  337. Hall.npcList.add(thisnpc);
  338. thisnpc = new DMCNpc();
  339. thisnpc.npc = addSpawn(BM[2], 147217, 180209, -6117, 0, false, 0, false, world.getInstanceId());
  340. if (noRndWalk)
  341. {
  342. thisnpc.npc.setIsNoRndWalk(true);
  343. }
  344. Hall.npcList.add(thisnpc);
  345. thisnpc = new DMCNpc();
  346. thisnpc.npc = addSpawn(BM[1], 148521, 180112, -6117, 0, false, 0, false, world.getInstanceId());
  347. if (noRndWalk)
  348. {
  349. thisnpc.npc.setIsNoRndWalk(true);
  350. }
  351. Hall.npcList.add(thisnpc);
  352. thisnpc = new DMCNpc();
  353. thisnpc.npc = addSpawn(BM[0], 148521, 180209, -6117, 0, false, 0, false, world.getInstanceId());
  354. if (noRndWalk)
  355. {
  356. thisnpc.npc.setIsNoRndWalk(true);
  357. }
  358. Hall.npcList.add(thisnpc);
  359. thisnpc = new DMCNpc();
  360. thisnpc.npc = addSpawn(BM[1], 148525, 180910, -6117, 0, false, 0, false, world.getInstanceId());
  361. if (noRndWalk)
  362. {
  363. thisnpc.npc.setIsNoRndWalk(true);
  364. }
  365. Hall.npcList.add(thisnpc);
  366. thisnpc = new DMCNpc();
  367. thisnpc.npc = addSpawn(BM[2], 148435, 180910, -6117, 0, false, 0, false, world.getInstanceId());
  368. if (noRndWalk)
  369. {
  370. thisnpc.npc.setIsNoRndWalk(true);
  371. }
  372. Hall.npcList.add(thisnpc);
  373. thisnpc = new DMCNpc();
  374. thisnpc.npc = addSpawn(BM[1], 147242, 180910, -6117, 0, false, 0, false, world.getInstanceId());
  375. if (noRndWalk)
  376. {
  377. thisnpc.npc.setIsNoRndWalk(true);
  378. }
  379. Hall.npcList.add(thisnpc);
  380. thisnpc = new DMCNpc();
  381. thisnpc.npc = addSpawn(BM[2], 147242, 180819, -6117, 0, false, 0, false, world.getInstanceId());
  382. if (noRndWalk)
  383. {
  384. thisnpc.npc.setIsNoRndWalk(true);
  385. }
  386. Hall.npcList.add(thisnpc);
  387. world.rooms.put("Hall", Hall);
  388. if (debug)
  389. {
  390. _log.info("DarkCloudMansion: hall spawned");
  391. }
  392. }
  393. protected void runHall(DMCWorld world)
  394. {
  395. spawnHall(world);
  396. world.setStatus(1);
  397. openDoor(D1, world.getInstanceId());
  398. }
  399. protected void runFirstRoom(DMCWorld world)
  400. {
  401. DMCRoom FirstRoom = new DMCRoom();
  402. DMCNpc thisnpc;
  403. thisnpc = new DMCNpc();
  404. thisnpc.npc = addSpawn(HG[1], 147842, 179837, -6117, 0, false, 0, false, world.getInstanceId());
  405. if (noRndWalk)
  406. {
  407. thisnpc.npc.setIsNoRndWalk(true);
  408. }
  409. FirstRoom.npcList.add(thisnpc);
  410. thisnpc = new DMCNpc();
  411. thisnpc.npc = addSpawn(HG[0], 147711, 179708, -6117, 0, false, 0, false, world.getInstanceId());
  412. if (noRndWalk)
  413. {
  414. thisnpc.npc.setIsNoRndWalk(true);
  415. }
  416. FirstRoom.npcList.add(thisnpc);
  417. thisnpc = new DMCNpc();
  418. thisnpc.npc = addSpawn(HG[1], 147842, 179552, -6117, 0, false, 0, false, world.getInstanceId());
  419. if (noRndWalk)
  420. {
  421. thisnpc.npc.setIsNoRndWalk(true);
  422. }
  423. FirstRoom.npcList.add(thisnpc);
  424. thisnpc = new DMCNpc();
  425. thisnpc.npc = addSpawn(HG[0], 147964, 179708, -6117, 0, false, 0, false, world.getInstanceId());
  426. if (noRndWalk)
  427. {
  428. thisnpc.npc.setIsNoRndWalk(true);
  429. }
  430. FirstRoom.npcList.add(thisnpc);
  431. world.rooms.put("FirstRoom", FirstRoom);
  432. world.setStatus(2);
  433. openDoor(D2, world.getInstanceId());
  434. if (debug)
  435. {
  436. _log.info("DarkCloudMansion: spawned first room");
  437. }
  438. }
  439. protected void runHall2(DMCWorld world)
  440. {
  441. addSpawn(SOFaith, 147818, 179643, -6117, 0, false, 0, false, world.getInstanceId());
  442. spawnHall(world);
  443. world.setStatus(3);
  444. }
  445. protected void runSecondRoom(DMCWorld world)
  446. {
  447. DMCRoom SecondRoom = new DMCRoom();
  448. DMCNpc thisnpc;
  449. // TODO: find a better way to initialize to [1,0,0,0,0,0,0]
  450. SecondRoom.Order = new int[7];
  451. SecondRoom.Order[0] = 1;
  452. for (int i = 1; i < 7; i++)
  453. {
  454. SecondRoom.Order[i] = 0;
  455. }
  456. int i = getRandom(MonolithOrder.length);
  457. thisnpc = new DMCNpc();
  458. thisnpc.npc = addSpawn(BSM, 147800, 181150, -6117, 0, false, 0, false, world.getInstanceId());
  459. thisnpc.order = MonolithOrder[i][0];
  460. SecondRoom.npcList.add(thisnpc);
  461. thisnpc = new DMCNpc();
  462. thisnpc.npc = addSpawn(BSM, 147900, 181215, -6117, 0, false, 0, false, world.getInstanceId());
  463. thisnpc.order = MonolithOrder[i][1];
  464. SecondRoom.npcList.add(thisnpc);
  465. thisnpc = new DMCNpc();
  466. thisnpc.npc = addSpawn(BSM, 147900, 181345, -6117, 0, false, 0, false, world.getInstanceId());
  467. thisnpc.order = MonolithOrder[i][2];
  468. SecondRoom.npcList.add(thisnpc);
  469. thisnpc = new DMCNpc();
  470. thisnpc.npc = addSpawn(BSM, 147800, 181410, -6117, 0, false, 0, false, world.getInstanceId());
  471. thisnpc.order = MonolithOrder[i][3];
  472. SecondRoom.npcList.add(thisnpc);
  473. thisnpc = new DMCNpc();
  474. thisnpc.npc = addSpawn(BSM, 147700, 181345, -6117, 0, false, 0, false, world.getInstanceId());
  475. thisnpc.order = MonolithOrder[i][4];
  476. SecondRoom.npcList.add(thisnpc);
  477. thisnpc = new DMCNpc();
  478. thisnpc.npc = addSpawn(BSM, 147700, 181215, -6117, 0, false, 0, false, world.getInstanceId());
  479. thisnpc.order = MonolithOrder[i][5];
  480. SecondRoom.npcList.add(thisnpc);
  481. world.rooms.put("SecondRoom", SecondRoom);
  482. world.setStatus(4);
  483. openDoor(D3, world.getInstanceId());
  484. if (debug)
  485. {
  486. _log.info("DarkCloudMansion: spawned second room");
  487. }
  488. }
  489. protected void runHall3(DMCWorld world)
  490. {
  491. addSpawn(SOAdversity, 147808, 181281, -6117, 16383, false, 0, false, world.getInstanceId());
  492. spawnHall(world);
  493. world.setStatus(5);
  494. }
  495. protected void runThirdRoom(DMCWorld world)
  496. {
  497. DMCRoom ThirdRoom = new DMCRoom();
  498. DMCNpc thisnpc = new DMCNpc();
  499. thisnpc.isDead = false;
  500. thisnpc.npc = addSpawn(BM[1], 148765, 180450, -6117, 0, false, 0, false, world.getInstanceId());
  501. if (noRndWalk)
  502. {
  503. thisnpc.npc.setIsNoRndWalk(true);
  504. }
  505. ThirdRoom.npcList.add(thisnpc);
  506. thisnpc.npc = addSpawn(BM[2], 148865, 180190, -6117, 0, false, 0, false, world.getInstanceId());
  507. if (noRndWalk)
  508. {
  509. thisnpc.npc.setIsNoRndWalk(true);
  510. }
  511. ThirdRoom.npcList.add(thisnpc);
  512. thisnpc.npc = addSpawn(BM[1], 148995, 180190, -6117, 0, false, 0, false, world.getInstanceId());
  513. if (noRndWalk)
  514. {
  515. thisnpc.npc.setIsNoRndWalk(true);
  516. }
  517. ThirdRoom.npcList.add(thisnpc);
  518. thisnpc.npc = addSpawn(BM[0], 149090, 180450, -6117, 0, false, 0, false, world.getInstanceId());
  519. if (noRndWalk)
  520. {
  521. thisnpc.npc.setIsNoRndWalk(true);
  522. }
  523. ThirdRoom.npcList.add(thisnpc);
  524. thisnpc.npc = addSpawn(BM[1], 148995, 180705, -6117, 0, false, 0, false, world.getInstanceId());
  525. if (noRndWalk)
  526. {
  527. thisnpc.npc.setIsNoRndWalk(true);
  528. }
  529. ThirdRoom.npcList.add(thisnpc);
  530. thisnpc.npc = addSpawn(BM[2], 148865, 180705, -6117, 0, false, 0, false, world.getInstanceId());
  531. if (noRndWalk)
  532. {
  533. thisnpc.npc.setIsNoRndWalk(true);
  534. }
  535. ThirdRoom.npcList.add(thisnpc);
  536. world.rooms.put("ThirdRoom", ThirdRoom);
  537. world.setStatus(6);
  538. openDoor(D4, world.getInstanceId());
  539. if (debug)
  540. {
  541. _log.info("DarkCloudMansion: spawned third room");
  542. }
  543. }
  544. protected void runThirdRoom2(DMCWorld world)
  545. {
  546. addSpawn(SOAdventure, 148910, 178397, -6117, 16383, false, 0, false, world.getInstanceId());
  547. DMCRoom ThirdRoom = new DMCRoom();
  548. DMCNpc thisnpc = new DMCNpc();
  549. thisnpc.isDead = false;
  550. thisnpc.npc = addSpawn(BM[1], 148765, 180450, -6117, 0, false, 0, false, world.getInstanceId());
  551. if (noRndWalk)
  552. {
  553. thisnpc.npc.setIsNoRndWalk(true);
  554. }
  555. ThirdRoom.npcList.add(thisnpc);
  556. thisnpc.npc = addSpawn(BM[2], 148865, 180190, -6117, 0, false, 0, false, world.getInstanceId());
  557. if (noRndWalk)
  558. {
  559. thisnpc.npc.setIsNoRndWalk(true);
  560. }
  561. ThirdRoom.npcList.add(thisnpc);
  562. thisnpc.npc = addSpawn(BM[1], 148995, 180190, -6117, 0, false, 0, false, world.getInstanceId());
  563. if (noRndWalk)
  564. {
  565. thisnpc.npc.setIsNoRndWalk(true);
  566. }
  567. ThirdRoom.npcList.add(thisnpc);
  568. thisnpc.npc = addSpawn(BM[0], 149090, 180450, -6117, 0, false, 0, false, world.getInstanceId());
  569. if (noRndWalk)
  570. {
  571. thisnpc.npc.setIsNoRndWalk(true);
  572. }
  573. ThirdRoom.npcList.add(thisnpc);
  574. thisnpc.npc = addSpawn(BM[1], 148995, 180705, -6117, 0, false, 0, false, world.getInstanceId());
  575. if (noRndWalk)
  576. {
  577. thisnpc.npc.setIsNoRndWalk(true);
  578. }
  579. ThirdRoom.npcList.add(thisnpc);
  580. thisnpc.npc = addSpawn(BM[2], 148865, 180705, -6117, 0, false, 0, false, world.getInstanceId());
  581. if (noRndWalk)
  582. {
  583. thisnpc.npc.setIsNoRndWalk(true);
  584. }
  585. ThirdRoom.npcList.add(thisnpc);
  586. world.rooms.put("ThirdRoom2", ThirdRoom);
  587. world.setStatus(8);
  588. if (debug)
  589. {
  590. _log.info("DarkCloudMansion: spawned third room second time");
  591. }
  592. }
  593. protected void runForthRoom(DMCWorld world)
  594. {
  595. DMCRoom ForthRoom = new DMCRoom();
  596. ForthRoom.counter = 0;
  597. DMCNpc thisnpc;
  598. int temp[] = new int[7];
  599. int templist[][] = new int[7][5];
  600. int xx = 0;
  601. for (int i = 0; i < 7; i++)
  602. {
  603. temp[i] = getRandom(ColumnRows.length);
  604. }
  605. for (int i = 0; i < 7; i++)
  606. {
  607. templist[i] = ColumnRows[temp[i]];
  608. }
  609. for (int x = 148660; x < 149285; x += 125)
  610. {
  611. int yy = 0;
  612. for (int y = 179280; y > 178405; y -= 125)
  613. {
  614. thisnpc = new DMCNpc();
  615. thisnpc.npc = addSpawn(SC, x, y, -6115, 16215, false, 0, false, world.getInstanceId());
  616. thisnpc.status = templist[yy][xx];
  617. thisnpc.order = yy;
  618. ForthRoom.npcList.add(thisnpc);
  619. yy++;
  620. }
  621. xx++;
  622. }
  623. // TODO: unify this into previous loop
  624. for (DMCNpc npc : ForthRoom.npcList)
  625. {
  626. if (npc.status == 0)
  627. {
  628. npc.npc.setIsInvul(true);
  629. }
  630. }
  631. world.rooms.put("ForthRoom", ForthRoom);
  632. world.setStatus(7);
  633. openDoor(D5, world.getInstanceId());
  634. if (debug)
  635. {
  636. _log.info("DarkCloudMansion: spawned forth room");
  637. }
  638. }
  639. protected void runFifthRoom(DMCWorld world)
  640. {
  641. spawnFifthRoom(world);
  642. world.setStatus(9);
  643. openDoor(D6, world.getInstanceId());
  644. if (debug)
  645. {
  646. _log.info("DarkCloudMansion: spawned fifth room");
  647. }
  648. }
  649. private void spawnFifthRoom(DMCWorld world)
  650. {
  651. int idx = 0;
  652. int temp[] = new int[6];
  653. DMCRoom FifthRoom = new DMCRoom();
  654. DMCNpc thisnpc;
  655. temp = Beleths[getRandom(Beleths.length)];
  656. FifthRoom.reset = 0;
  657. FifthRoom.founded = 0;
  658. for (int x = 148720; x < 149175; x += 65)
  659. {
  660. thisnpc = new DMCNpc();
  661. thisnpc.npc = addSpawn(BS[idx], x, 182145, -6117, 48810, false, 0, false, world.getInstanceId());
  662. thisnpc.npc.setIsNoRndWalk(true);
  663. thisnpc.order = idx;
  664. thisnpc.status = temp[idx];
  665. thisnpc.count = 0;
  666. FifthRoom.npcList.add(thisnpc);
  667. if ((temp[idx] == 1) && (getRandom(100) < 95))
  668. {
  669. thisnpc.npc.broadcastPacket(new NpcSay(thisnpc.npc.getObjectId(), 0, thisnpc.npc.getId(), _spawnChat[getRandom(_spawnChat.length)]));
  670. }
  671. else if ((temp[idx] != 1) && (getRandom(100) < 67))
  672. {
  673. thisnpc.npc.broadcastPacket(new NpcSay(thisnpc.npc.getObjectId(), 0, thisnpc.npc.getId(), _spawnChat[getRandom(_spawnChat.length)]));
  674. }
  675. idx++;
  676. }
  677. world.rooms.put("FifthRoom", FifthRoom);
  678. }
  679. protected boolean checkKillProgress(L2Npc npc, DMCRoom room)
  680. {
  681. boolean cont = true;
  682. for (DMCNpc npcobj : room.npcList)
  683. {
  684. if (npcobj.npc == npc)
  685. {
  686. npcobj.isDead = true;
  687. }
  688. if (npcobj.isDead == false)
  689. {
  690. cont = false;
  691. }
  692. }
  693. return cont;
  694. }
  695. protected void spawnRndGolem(DMCWorld world, DMCNpc npc)
  696. {
  697. if (npc.golem != null)
  698. {
  699. return;
  700. }
  701. int i = getRandom(GolemSpawn.length);
  702. int mobId = GolemSpawn[i][0];
  703. int x = GolemSpawn[i][1];
  704. int y = GolemSpawn[i][2];
  705. npc.golem = addSpawn(mobId, x, y, -6117, 0, false, 0, false, world.getInstanceId());
  706. if (noRndWalk)
  707. {
  708. npc.golem.setIsNoRndWalk(true);
  709. }
  710. }
  711. protected void checkStone(L2Npc npc, int order[], DMCNpc npcObj, DMCWorld world)
  712. {
  713. for (int i = 1; i < 7; i++)
  714. {
  715. // if there is a non zero value in the precedent step, the sequence is ok
  716. if ((order[i] == 0) && (order[i - 1] != 0))
  717. {
  718. if ((npcObj.order == i) && (npcObj.status == 0))
  719. {
  720. order[i] = 1;
  721. npcObj.status = 1;
  722. npcObj.isDead = true;
  723. npc.broadcastPacket(new MagicSkillUse(npc, npc, 5441, 1, 1, 0));
  724. return;
  725. }
  726. }
  727. }
  728. spawnRndGolem(world, npcObj);
  729. }
  730. protected void endInstance(DMCWorld world)
  731. {
  732. world.setStatus(10);
  733. addSpawn(SOTruth, 148911, 181940, -6117, 16383, false, 0, false, world.getInstanceId());
  734. world.rooms.clear();
  735. if (debug)
  736. {
  737. _log.info("DarkCloudMansion: finished");
  738. }
  739. }
  740. protected void checkBelethSample(DMCWorld world, L2Npc npc, L2PcInstance player)
  741. {
  742. DMCRoom FifthRoom = world.rooms.get("FifthRoom");
  743. for (DMCNpc mob : FifthRoom.npcList)
  744. {
  745. if (mob.npc == npc)
  746. {
  747. if (mob.count == 0)
  748. {
  749. mob.count = 1;
  750. if (mob.status == 1)
  751. {
  752. mob.npc.broadcastPacket(new NpcSay(mob.npc.getObjectId(), Say2.NPC_ALL, mob.npc.getId(), _successChat[getRandom(_successChat.length)]));
  753. FifthRoom.founded += 1;
  754. startQuestTimer("decayMe", 1500, npc, player);
  755. }
  756. else
  757. {
  758. FifthRoom.reset = 1;
  759. mob.npc.broadcastPacket(new NpcSay(mob.npc.getObjectId(), Say2.NPC_ALL, mob.npc.getId(), _faildChat[getRandom(_faildChat.length)]));
  760. startQuestTimer("decayChatBelethSamples", 4000, npc, player);
  761. startQuestTimer("decayBelethSamples", 4500, npc, player);
  762. }
  763. }
  764. else
  765. {
  766. return;
  767. }
  768. }
  769. }
  770. }
  771. protected void killedBelethSample(DMCWorld world, L2Npc npc)
  772. {
  773. int decayedSamples = 0;
  774. DMCRoom FifthRoom = world.rooms.get("FifthRoom");
  775. for (DMCNpc mob : FifthRoom.npcList)
  776. {
  777. if (mob.npc == npc)
  778. {
  779. decayedSamples += 1;
  780. mob.count = 2;
  781. }
  782. else
  783. {
  784. if (mob.count == 2)
  785. {
  786. decayedSamples += 1;
  787. }
  788. }
  789. }
  790. if (FifthRoom.reset == 1)
  791. {
  792. for (DMCNpc mob : FifthRoom.npcList)
  793. {
  794. if ((mob.count == 0) || ((mob.status == 1) && (mob.count != 2)))
  795. {
  796. decayedSamples += 1;
  797. mob.npc.decayMe();
  798. mob.count = 2;
  799. }
  800. }
  801. if (decayedSamples == 7)
  802. {
  803. startQuestTimer("respawnFifth", 6000, npc, null);
  804. }
  805. }
  806. else
  807. {
  808. if ((FifthRoom.reset == 0) && (FifthRoom.founded == 3))
  809. {
  810. for (DMCNpc mob : FifthRoom.npcList)
  811. {
  812. mob.npc.decayMe();
  813. }
  814. endInstance(world);
  815. }
  816. }
  817. }
  818. protected boolean allStonesDone(DMCWorld world)
  819. {
  820. DMCRoom SecondRoom = world.rooms.get("SecondRoom");
  821. for (DMCNpc mob : SecondRoom.npcList)
  822. {
  823. if (mob.isDead)
  824. {
  825. continue;
  826. }
  827. return false;
  828. }
  829. return true;
  830. }
  831. protected void removeMonoliths(DMCWorld world)
  832. {
  833. DMCRoom SecondRoom = world.rooms.get("SecondRoom");
  834. for (DMCNpc mob : SecondRoom.npcList)
  835. {
  836. mob.npc.decayMe();
  837. }
  838. }
  839. protected void chkShadowColumn(DMCWorld world, L2Npc npc)
  840. {
  841. DMCRoom ForthRoom = world.rooms.get("ForthRoom");
  842. for (DMCNpc mob : ForthRoom.npcList)
  843. {
  844. if (mob.npc == npc)
  845. {
  846. for (int i = 0; i < 7; i++)
  847. {
  848. if ((mob.order == i) && (ForthRoom.counter == i))
  849. {
  850. openDoor(W1 + i, world.getInstanceId());
  851. ForthRoom.counter += 1;
  852. if (ForthRoom.counter == 7)
  853. {
  854. runThirdRoom2(world);
  855. }
  856. }
  857. }
  858. }
  859. }
  860. }
  861. @Override
  862. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  863. {
  864. if (npc == null)
  865. {
  866. return "";
  867. }
  868. final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  869. final DMCWorld world;
  870. if (tmpworld instanceof DMCWorld)
  871. {
  872. world = (DMCWorld) tmpworld;
  873. }
  874. else
  875. {
  876. return "";
  877. }
  878. if (world.rooms.containsKey("FifthRoom"))
  879. {
  880. DMCRoom FifthRoom = world.rooms.get("FifthRoom");
  881. if (event.equalsIgnoreCase("decayMe"))
  882. {
  883. for (DMCNpc mob : FifthRoom.npcList)
  884. {
  885. if ((mob.npc == npc) || ((FifthRoom.reset == 0) && (FifthRoom.founded == 3)))
  886. {
  887. mob.npc.decayMe();
  888. mob.count = 2;
  889. }
  890. }
  891. if ((FifthRoom.reset == 0) && (FifthRoom.founded == 3))
  892. {
  893. endInstance(world);
  894. }
  895. }
  896. else if (event.equalsIgnoreCase("decayBelethSamples"))
  897. {
  898. for (DMCNpc mob : FifthRoom.npcList)
  899. {
  900. if (mob.count == 0)
  901. {
  902. mob.npc.decayMe();
  903. mob.count = 2;
  904. }
  905. }
  906. }
  907. else if (event.equalsIgnoreCase("decayChatBelethSamples"))
  908. {
  909. for (DMCNpc mob : FifthRoom.npcList)
  910. {
  911. if (mob.status == 1)
  912. {
  913. mob.npc.broadcastPacket(new NpcSay(mob.npc.getObjectId(), Say2.NPC_ALL, mob.npc.getId(), _decayChat[getRandom(_decayChat.length)]));
  914. }
  915. }
  916. }
  917. else if (event.equalsIgnoreCase("respawnFifth"))
  918. {
  919. spawnFifthRoom(world);
  920. }
  921. }
  922. return "";
  923. }
  924. @Override
  925. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  926. {
  927. final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  928. final DMCWorld world;
  929. if (tmpworld instanceof DMCWorld)
  930. {
  931. world = (DMCWorld) tmpworld;
  932. if (world.getStatus() == 0)
  933. {
  934. if (checkKillProgress(npc, world.rooms.get("StartRoom")))
  935. {
  936. runHall(world);
  937. }
  938. }
  939. if (world.getStatus() == 1)
  940. {
  941. if (checkKillProgress(npc, world.rooms.get("Hall")))
  942. {
  943. runFirstRoom(world);
  944. }
  945. }
  946. if (world.getStatus() == 2)
  947. {
  948. if (checkKillProgress(npc, world.rooms.get("FirstRoom")))
  949. {
  950. runHall2(world);
  951. }
  952. }
  953. if (world.getStatus() == 3)
  954. {
  955. if (checkKillProgress(npc, world.rooms.get("Hall")))
  956. {
  957. runSecondRoom(world);
  958. }
  959. }
  960. if (world.getStatus() == 4)
  961. {
  962. DMCRoom SecondRoom = world.rooms.get("SecondRoom");
  963. for (DMCNpc mob : SecondRoom.npcList)
  964. {
  965. if (mob.golem == npc)
  966. {
  967. mob.golem = null;
  968. }
  969. }
  970. }
  971. if (world.getStatus() == 5)
  972. {
  973. if (checkKillProgress(npc, world.rooms.get("Hall")))
  974. {
  975. runThirdRoom(world);
  976. }
  977. }
  978. if (world.getStatus() == 6)
  979. {
  980. if (checkKillProgress(npc, world.rooms.get("ThirdRoom")))
  981. {
  982. runForthRoom(world);
  983. }
  984. }
  985. if (world.getStatus() == 7)
  986. {
  987. chkShadowColumn(world, npc);
  988. }
  989. if (world.getStatus() == 8)
  990. {
  991. if (checkKillProgress(npc, world.rooms.get("ThirdRoom2")))
  992. {
  993. runFifthRoom(world);
  994. }
  995. }
  996. if (world.getStatus() == 9)
  997. {
  998. killedBelethSample(world, npc);
  999. }
  1000. }
  1001. return "";
  1002. }
  1003. @Override
  1004. public String onAttack(L2Npc npc, L2PcInstance player, int damage, boolean isSummon, Skill skill)
  1005. {
  1006. final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1007. final DMCWorld world;
  1008. if (tmpworld instanceof DMCWorld)
  1009. {
  1010. world = (DMCWorld) tmpworld;
  1011. if (world.getStatus() == 7)
  1012. {
  1013. DMCRoom ForthRoom = world.rooms.get("ForthRoom");
  1014. for (DMCNpc mob : ForthRoom.npcList)
  1015. {
  1016. if (mob.npc == npc)
  1017. {
  1018. if (mob.npc.isInvul() && (getRandom(100) < 12))
  1019. {
  1020. if (debug)
  1021. {
  1022. _log.info("DarkCloudMansion: spawn room 4 guard");
  1023. }
  1024. addSpawn(BM[getRandom(BM.length)], player.getX(), player.getY(), player.getZ(), 0, false, 0, false, world.getInstanceId());
  1025. }
  1026. }
  1027. }
  1028. }
  1029. if (world.getStatus() == 9)
  1030. {
  1031. checkBelethSample(world, npc, player);
  1032. }
  1033. }
  1034. return "";
  1035. }
  1036. @Override
  1037. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  1038. {
  1039. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1040. DMCWorld world;
  1041. if (tmpworld instanceof DMCWorld)
  1042. {
  1043. world = (DMCWorld) tmpworld;
  1044. if (world.getStatus() == 4)
  1045. {
  1046. DMCRoom SecondRoom = world.rooms.get("SecondRoom");
  1047. for (DMCNpc mob : SecondRoom.npcList)
  1048. {
  1049. if (mob.npc == npc)
  1050. {
  1051. checkStone(npc, SecondRoom.Order, mob, world);
  1052. }
  1053. }
  1054. if (allStonesDone(world))
  1055. {
  1056. removeMonoliths(world);
  1057. runHall3(world);
  1058. }
  1059. }
  1060. if ((npc.getId() == SOTruth) && (world.getStatus() == 10))
  1061. {
  1062. npc.showChatWindow(player);
  1063. if (!hasQuestItems(player, CC))
  1064. {
  1065. giveItems(player, CC, 1);
  1066. }
  1067. }
  1068. }
  1069. return "";
  1070. }
  1071. @Override
  1072. public String onTalk(L2Npc npc, L2PcInstance player)
  1073. {
  1074. final int npcId = npc.getId();
  1075. if (npcId == YIYEN)
  1076. {
  1077. enterInstance(player, new DMCWorld(), "DarkCloudMansion.xml", TEMPLATE_ID);
  1078. }
  1079. else
  1080. {
  1081. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1082. DMCWorld world;
  1083. if (tmpworld instanceof DMCWorld)
  1084. {
  1085. world = (DMCWorld) tmpworld;
  1086. }
  1087. else
  1088. {
  1089. return "";
  1090. }
  1091. if (npcId == SOTruth)
  1092. {
  1093. if (world.isAllowed(player.getObjectId()))
  1094. {
  1095. if (debug)
  1096. {
  1097. _log.info("DarkCloudMansion - id " + player.getObjectId() + " removed from allowed player in this Instances.");
  1098. }
  1099. world.removeAllowed(player.getObjectId());
  1100. }
  1101. teleportPlayer(player, new Location(139968, 150367, -3111), 0);
  1102. int instanceId = npc.getInstanceId();
  1103. Instance instance = InstanceManager.getInstance().getInstance(instanceId);
  1104. if (instance.getPlayers().isEmpty())
  1105. {
  1106. InstanceManager.getInstance().destroyInstance(instanceId);
  1107. }
  1108. return "";
  1109. }
  1110. }
  1111. return "";
  1112. }
  1113. }