DarkCloudMansion.java 30 KB

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