Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.34 KB | None | 0 0
  1. package hellbound.Naia;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Iterator;
  5. import javolution.util.FastMap;
  6.  
  7. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  8. import com.l2jserver.gameserver.instancemanager.InstanceManager.InstanceWorld;
  9. import com.l2jserver.gameserver.model.L2Party;
  10. import com.l2jserver.gameserver.model.L2Skill;
  11. import com.l2jserver.gameserver.model.actor.L2Npc;
  12. import com.l2jserver.gameserver.model.actor.L2Summon;
  13. import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
  14. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  15. import com.l2jserver.gameserver.model.quest.Quest;
  16. import com.l2jserver.gameserver.model.quest.QuestState;
  17. import com.l2jserver.gameserver.network.SystemMessageId;
  18. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  19. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  20. import com.l2jserver.gameserver.util.Util;
  21. import com.l2jserver.util.Rnd;
  22.  
  23.  
  24. public class Naia extends Quest
  25. {
  26. private class teleCoord
  27. {
  28. int instanceId;
  29. int x;
  30. int y;
  31. int z;
  32. }
  33. private class TNNpc
  34. {
  35. public L2Npc npc;
  36. public boolean isDead = false;
  37. }
  38. private class TNRoom
  39. {
  40. public ArrayList<TNNpc> npcRoomList = new ArrayList<TNNpc>();
  41. }
  42. public class TNWorld extends InstanceWorld
  43. {
  44. public ArrayList<L2Npc> npcContolerList = new ArrayList<L2Npc>();
  45. public FastMap<String, TNRoom> rooms = new FastMap<String, TNRoom>().shared();
  46. //public ArrayList<L2Character> PlayerInZone = new ArrayList<L2Character>();
  47. public ArrayList<L2PcInstance> PlsInInstance = new ArrayList<L2PcInstance>();
  48. public L2Npc elpy = null;
  49. public boolean isMainParty = false;
  50. public int numberOfParties = 0;
  51. public int partyEntered = 0 ;
  52. public boolean naiaIsDone = false;
  53.  
  54. public TNWorld()
  55. {
  56. InstanceManager.getInstance().super();
  57. }
  58. }
  59. private static boolean DEBUG = true;
  60. private static final String qn = "Naia";
  61. private static int[] NaiaMob = { 18490, 18491, 18493, 22393, 22394, 22395, 22411, 22412, 22413, 22414, 22415, 22439, 22440, 22441, 22442, 25604, 25605, 25606, 25607, 25608, 25609, 25610, 25611, 25612, 25613 };
  62. private static int[] IC = { 18494,18495,18496,18497,18498,18499,18500,18501,18502,18503,18504,18505, 18506};
  63. private final static int[][] IC_COORD = {
  64. {-46199, 246119, -9133, 32767}, //ws 0
  65. {-48992, 249171, -9132, 879}, //1
  66. {-51627, 246109, -9998, 16042}, //2
  67. {-48980, 243410, -9999,32767}, //3
  68. {-46199,246132,-9998,49952}, //4
  69. {-49332, 248580, -9999, 56600}, //5 Spawn in 1st rb room
  70. {-51636, 246116, -10860, 17864}, //6
  71. {-48541,243693, -10860, 23911}, //7 in boss room
  72. {-46226, 246120, -11718, 49151}, //8
  73. {-49320, 248561, -11721, 55801}, //9 in boss room
  74. {-51625, 246166, -12581, 16004}, //10
  75. {-48261, 243650, -13386, 32767}, //11
  76. };
  77. private final static int[][] BOSSES = //Used to store 4 bosses
  78. {
  79. {25609, -45472, 247462, -13957, 47813},
  80. {25610, -45472, 247462, -13957, 47813},
  81. {25611, -45472, 247462, -13957, 47813},
  82. {25612, -45472, 247462, -13957, 47813}
  83. };
  84.  
  85. private final static int [][] EXIT_NPC = {
  86. {18506, -45230, 248372, -14190, 13986},
  87. {18506, -46146, 248125, -14191, 24541},
  88. {18506, -44562, 247703, -14191, 2786 },
  89. {18506, -44802, 246783, -14190, 56795},
  90. {18506, -45723, 246533, -14191, 46562},
  91. {18506, -46400, 247202, -14190, 35881}
  92. };
  93.  
  94. private final static int [][] SPORES =
  95. {
  96. { 25605, -45725, 246538, -14192, 45892 },
  97. { 25606, -44567, 247697, -14192, 2810 },
  98. { 25607, -46145, 248116, -14192, 24848 },
  99. { 25608, -45234, 246538, -14191, 51727 },
  100. { 25605, -44814, 248123, -14191, 8121 },
  101. { 25606, -46395, 247696, -14191, 30119 },
  102. { 25607, -44806, 246779, -14191, 57414 },
  103. { 25608, -45235, 248365, -14191, 13993 },
  104. { 25605, -46393, 247206, -14191, 35486 },
  105. { 25606, -44562, 247206, -14191, 62746 },
  106. { 25607, -45724, 248362, -14192, 19111 },
  107. { 25608, -46145, 246786, -14192, 41005 },
  108. { 25613, -45675, 246719, -14192, 46825 },
  109. { 25613, -46020, 246907, -14192, 29412 },
  110. { 25613, -46221, 247255, -14192, 21673 },
  111. { 25613, -46224, 247653, -14192, 16109 },
  112. { 25613, -46026, 247991, -14192, 10467 },
  113. { 25613, -45684, 248194, -14192, 4728 },
  114. { 25613, -45287, 248192, -14192, 64612 },
  115. { 25613, -44935, 247995, -14192, 59571 },
  116. { 25613, -44740, 247652, -14192, 52771 },
  117. { 25613, -44738, 247253, -14192, 49946 },
  118. { 25613, -44935, 246909, -14192, 49151 },
  119. { 25613, -45278, 246712, -14192, 37969 }
  120. };
  121.  
  122. public static void main(String[] args)
  123. {
  124. new Naia(-1, qn, "hellbound");
  125. }
  126. //CopyOnWriteArrayList
  127. public ArrayList<L2Npc> roofControllerList = new ArrayList<L2Npc>();
  128. public ArrayList<L2Npc> npcRoofList = new ArrayList<L2Npc>();
  129.  
  130. private boolean isSpawnWard = false;
  131. private boolean isSpawnLock = false;
  132.  
  133. private boolean isSpawnController = false;
  134.  
  135. public Naia(int id, String name, String descr)
  136. {
  137. super(id, name, descr);
  138. addStartNpc(18492);
  139. addFirstTalkId(18492);
  140. addTalkId(18492);
  141. for (final int icnpc : IC)
  142. {
  143. addStartNpc(icnpc);
  144. addFirstTalkId(icnpc);
  145. addTalkId(icnpc);
  146. }
  147. for (final int mob : NaiaMob)
  148. addKillId(mob);
  149. //addEnterZoneId(12016);
  150. //addExitZoneId(12016);
  151. addAttackId(18491);
  152. SpawnRoofNpc();
  153. }
  154.  
  155. private boolean checkConditions(L2PcInstance player)
  156. {
  157. if(DEBUG)
  158. return true;
  159. if(player.getParty() == null || player.getParty().getCommandChannel() == null)
  160. {
  161. player.sendMessage("You must enter with at least 2 full parties ( 18 members level 80 minimum ) in a Command Channel");
  162. return false;
  163. }
  164.  
  165. if(player.getParty() != null || player.getParty().getCommandChannel() != null)
  166. {
  167. final L2Party party = player.getParty();
  168. if ( party.getCommandChannel().getMembers().size() < 4)//18 )
  169. {
  170. player.sendMessage("You must enter with at least 2 full parties ( 18 members level 80 minimum ) in a Command Channel");
  171. return false;
  172. }
  173.  
  174. else if (party.getCommandChannel().getChannelLeader() != player)
  175. {
  176. player.sendMessage("Only the Command Channel Leader Can Talk to Me");
  177. return false;
  178. }
  179. else if (party.getCommandChannel().getMembers().size() > 45)
  180. {
  181. player.sendMessage("You can't enter with more than 45 members");
  182. return false;
  183. }
  184. else
  185. {
  186. for (final L2PcInstance channelMember : party.getCommandChannel().getMembers())
  187. {
  188. if (channelMember.getLevel() < 80)
  189. {
  190. final SystemMessage sm = new SystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT);
  191. sm.addPcName(channelMember);
  192. player.sendPacket(sm);
  193. return false;
  194. }
  195.  
  196. else if (!Util.checkIfInRange(500, player, channelMember, true))
  197. {
  198. final SystemMessage sm = new SystemMessage(SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED);
  199. sm.addPcName(channelMember);
  200. player.sendPacket(sm);
  201. return false;
  202. }
  203. }
  204. }
  205.  
  206. return true;
  207. }
  208. player.sendMessage("Only the Command Channel Leader with minimum 18 members lvl 80 Can Talk to Me");
  209. return false;
  210. }
  211.  
  212. private boolean checkConditions2(L2PcInstance player)
  213. {
  214. if(DEBUG)
  215. return true;
  216.  
  217. if(player.getParty() == null || player.getParty().getCommandChannel() == null)
  218. {
  219. player.sendMessage("You must enter with at least 2 full parties ( 14 members level 80 minimum ) in a Command Channel");
  220. return false;
  221. }
  222.  
  223. else if(player.getParty() != null || player.getParty().getCommandChannel() != null)
  224. {
  225. final L2Party party = player.getParty();
  226.  
  227. if (player != player.getParty().getLeader())
  228. {
  229. player.sendMessage("Only a leader of a party in Command Channel can talk to me.");
  230. return false;
  231. }
  232.  
  233. else if ( party.getCommandChannel().getMembers().size() < 4)//14 )
  234. {
  235. player.sendMessage("You must enter with at least 2 parties ( min 14 members level 80 minimum ) in a Command Channel");
  236. return false;
  237. }
  238.  
  239. else if (party.getCommandChannel().getMembers().size() > 45)
  240. {
  241. player.sendMessage("You can't enter with more than 45 members");
  242. return false;
  243. }
  244. else
  245. {
  246. for (final L2PcInstance partyMember : party.getPartyMembers())
  247. {
  248. if (partyMember.getLevel() < 80)
  249. {
  250. final SystemMessage sm = new SystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT);
  251. sm.addPcName(partyMember);
  252. player.sendPacket(sm);
  253. return false;
  254. }
  255.  
  256. else if (!Util.checkIfInRange(500, player, partyMember, true))
  257. {
  258. final SystemMessage sm = new SystemMessage(SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED);
  259. sm.addPcName(partyMember);
  260. player.sendPacket(sm);
  261. return false;
  262. }
  263. }
  264. }
  265.  
  266. return true;
  267. }
  268. player.sendMessage("Only the party Leader in command channel that contains minimum 14 members lvl 80 Can Talk to Me");
  269. return false;
  270. }
  271.  
  272. private boolean checkKillProgress(L2Npc npc, TNRoom room)
  273. {
  274. boolean cont = true;
  275. for (final TNNpc npcobj : room.npcRoomList)
  276. {
  277. if (npcobj.npc == npc)
  278. npcobj.isDead = true;
  279. if (!npcobj.isDead)
  280. cont = false;
  281. }
  282. return cont;
  283. }
  284.  
  285. protected void closeDoor(int doorId, int instanceId)
  286. {
  287. for (final L2DoorInstance door : InstanceManager.getInstance().getInstance(instanceId).getDoors())
  288. if (door.getDoorId() == doorId)
  289. if (door.getOpen())
  290. door.closeMe();
  291. }
  292.  
  293. private final void enterInstance(L2PcInstance player, String template, teleCoord teleto)
  294. {
  295. if(DEBUG)
  296. {
  297. int instanceId = InstanceManager.getInstance().createDynamicInstance(template);
  298. TNWorld world = new TNWorld();
  299. world.instanceId = instanceId;
  300. teleto.instanceId = instanceId;
  301. InstanceManager.getInstance().addWorld(world);
  302. world.allowed.add(player.getObjectId());
  303.  
  304. if (player.getQuestState(qn) == null)
  305. {
  306. newQuestState(player);
  307. }
  308.  
  309. teleportplayer(player, teleto);
  310. world.PlsInInstance.add(player);
  311. addSpawn(IC[world.status], IC_COORD[world.status][0], IC_COORD[world.status][1], IC_COORD[world.status][2], IC_COORD[world.status][3], false, 0, false, world.instanceId);
  312. openDoor(18250001, world.instanceId);
  313. /*for (final L2Npc control : roofControllerList)
  314. {
  315. if (control.getNpcId() == 18492)
  316. {
  317. control.deleteMe();
  318. roofControllerList.remove(control);
  319. }
  320. }*/
  321. for (Iterator<L2Npc> it = roofControllerList.iterator() ; it.hasNext();)
  322. {
  323. L2Npc controller = it.next();
  324. if (controller.getNpcId() == 18492)
  325. {
  326. controller.deleteMe();
  327. it.remove();
  328. }
  329. }
  330.  
  331. isSpawnController = false;
  332. isSpawnWard = false;
  333. isSpawnLock = false;
  334. startQuestTimer("respawn_roof",180000 , null, null);
  335. return;
  336. }
  337. if(player.getInstanceId() != 0 && !DEBUG)
  338. {
  339. player.sendMessage("You are already in another instance Teleportation aborted.");
  340. return ;
  341. }
  342. if (!DEBUG)
  343. {
  344. int counter = 0;
  345. for(L2Party party : player.getParty().getCommandChannel().getPartys())
  346. {
  347. counter++;
  348. int instanceId = InstanceManager.getInstance().createDynamicInstance(template);
  349. TNWorld world = new TNWorld();
  350. world.instanceId = instanceId;
  351. teleto.instanceId = instanceId;
  352. InstanceManager.getInstance().addWorld(world);
  353.  
  354. _log.info("Tower Of Naia: started " + template + " Instance: " + instanceId + " created for party leader : " + party.getLeader().getName()
  355. + ", The CCL is :" + party.getCommandChannel().getChannelLeader().getName() + ".");
  356.  
  357. for (L2PcInstance partyMember : party.getPartyMembers())
  358. {
  359. world.allowed.add(partyMember.getObjectId());
  360.  
  361. if (partyMember.getQuestState(qn) == null)
  362. {
  363. newQuestState(partyMember);
  364. }
  365. if (partyMember == party.getCommandChannel().getChannelLeader())
  366. {
  367. world.isMainParty = true;
  368. }
  369. teleportplayer(partyMember, teleto);
  370. world.PlsInInstance.add(partyMember);
  371. }
  372.  
  373. addSpawn(IC[world.status], IC_COORD[world.status][0], IC_COORD[world.status][1], IC_COORD[world.status][2], IC_COORD[world.status][3], false, 0, false, world.instanceId);
  374. openDoor(18250001, world.instanceId);
  375. }
  376. /*
  377. for (final L2Npc control : roofControllerList)
  378. {
  379. if (control.getNpcId() == 18492)
  380. {
  381. control.deleteMe();
  382. roofControllerList.remove(control);
  383. }
  384. }
  385. */
  386. for (Iterator<L2Npc> it = roofControllerList.iterator() ; it.hasNext();)
  387. {
  388. L2Npc controller = it.next();
  389. if (controller.getNpcId() == 18492)
  390. {
  391. controller.deleteMe();
  392. it.remove();
  393. }
  394. }
  395. isSpawnController = false;
  396. isSpawnWard = false;
  397. isSpawnLock = false;
  398. startQuestTimer("respawn_roof",180000 , null, null);
  399. InstanceWorld mainInstance = InstanceManager.getInstance().getPlayerWorld(player.getParty().getCommandChannel().getChannelLeader());
  400. if (mainInstance instanceof TNWorld)
  401. {
  402. TNWorld mainWorld = (TNWorld) mainInstance;
  403. mainWorld.numberOfParties = counter;
  404. }
  405. return ;
  406. }
  407. }
  408.  
  409. /*final L2Party party = player.getParty();
  410.  
  411. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  412. final FastMap<Integer, Instance> instanceMap = InstanceManager.getInstance().getInstances();
  413. if (!checkConditions(player))
  414. return 0;
  415.  
  416. for (final Instance temp : instanceMap.values())
  417. {
  418. if(temp.getName().contains("TowerOfNaia"))
  419. {
  420. IsNaia = 1;
  421. instanceId = temp.getId();
  422. world = InstanceManager.getInstance().getWorld(instanceId);
  423. world.instanceId = instanceId;
  424. teleto.instanceId = instanceId;
  425. if (DEBUG)
  426. {
  427. if (player != LeaderChannel)
  428. {
  429. player.sendMessage("Leader is not player in instance check"); //mising txt
  430. return 0;
  431. }
  432. }
  433. else if ( party.getCommandChannel().getChannelLeader() != LeaderChannel )
  434. {
  435. player.sendMessage("You are not the party channel Leader"); //mising txt
  436. return 0;
  437. }
  438. }
  439. }
  440.  
  441. if ( IsNaia == 0 )
  442. {
  443. instanceId = InstanceManager.getInstance().createDynamicInstance(template);
  444. world = new TNWorld();
  445. world.instanceId = instanceId;
  446. teleto.instanceId = instanceId;
  447. InstanceManager.getInstance().addWorld(world);
  448. _log.info("Tower Of Naia: started " + template + " Instance: " + instanceId + " created");
  449. if(DEBUG)
  450. {
  451. LeaderChannel = player;
  452. }
  453. else
  454. {
  455. LeaderChannel = party.getCommandChannel().getChannelLeader();
  456. }
  457. }
  458. final Instance InstanceZone = InstanceManager.getInstance().getInstance(world.instanceId);
  459. final TNWorld wroof = (TNWorld) world;
  460. if (DEBUG)
  461. {
  462. if (player.getQuestState(qn) == null)
  463. newQuestState(player);
  464. teleportplayer(player, teleto);
  465. wroof.PlsInInstance.add(player);
  466. startQuestTimer("stopfight_30",1800000,null,player);
  467. }
  468. else if (InstanceZone.getPlayers().size() + party.getPartyMembers().size() < 46)
  469. for (final L2PcInstance partyMember : party.getPartyMembers())
  470. {
  471. if (partyMember.getQuestState(qn) == null)
  472. newQuestState(partyMember);
  473. teleportplayer(partyMember, teleto);
  474. wroof.PlsInInstance.add(partyMember);
  475. startQuestTimer("stopfight_30",1800000,null,partyMember);
  476. }
  477. else
  478. {
  479. player.sendMessage("SomeThing Wrong"); //mising txt
  480. return 0;
  481. }
  482. addSpawn(IC[world.status], IC_COORD[world.status][0], IC_COORD[world.status][1], IC_COORD[world.status][2], IC_COORD[world.status][3], false, 0, false, world.instanceId);
  483. openDoor(18250001, world.instanceId);
  484. isSpawnController = false;
  485. isSpawnWard = false;
  486. isSpawnLock = false;
  487. for (final L2Npc control : roofControllerList)
  488. {
  489. if (control.getNpcId() == 18492)
  490. {
  491. control.deleteMe();
  492. roofControllerList.remove(control);
  493. }
  494. }
  495. startQuestTimer("respawn_roof",180000 , null, player);
  496. return instanceId;
  497. }
  498. */
  499.  
  500. private void exitInstance(L2PcInstance player, teleCoord tele)
  501. {
  502. final InstanceWorld insworld = InstanceManager.getInstance().getWorld(player.getInstanceId());
  503. if (insworld instanceof TNWorld)
  504. {
  505. final TNWorld world = (TNWorld) insworld;
  506. for (final L2PcInstance plr : world.PlsInInstance)
  507. {
  508. plr.sendMessage("Exit Instance");
  509. plr.setInstanceId(0);
  510. plr.teleToLocation(tele.x, tele.y, tele.z);
  511. }
  512. }
  513. }
  514.  
  515. private void goToBeleth(L2PcInstance player, teleCoord tele)
  516. {
  517. final InstanceWorld insworld = InstanceManager.getInstance().getWorld(player.getInstanceId());
  518. if (DEBUG && insworld instanceof TNWorld )
  519. {
  520. final TNWorld world = (TNWorld) insworld;
  521. world.naiaIsDone = true;
  522. player.setInstanceId(tele.instanceId);
  523. player.teleToLocation(tele.x, tele.y, tele.z);
  524.  
  525. return;
  526. }
  527.  
  528. final InstanceWorld mainWorldIns = InstanceManager.getInstance().getWorld(player.getParty().getCommandChannel().getChannelLeader().getInstanceId());
  529.  
  530. if (insworld instanceof TNWorld && mainWorldIns instanceof TNWorld)
  531. {
  532. final TNWorld world = (TNWorld) insworld;
  533. final TNWorld mainWorld = (TNWorld) mainWorldIns;
  534. if ( world.status == 13 )
  535. {
  536.  
  537. for (final L2PcInstance plr : player.getParty().getPartyMembers())
  538. {
  539. plr.setInstanceId(tele.instanceId);
  540. plr.teleToLocation(tele.x, tele.y, tele.z);
  541. world.allowed.remove(world.allowed.indexOf(plr.getObjectId()));
  542. mainWorld.allowed.add(plr.getObjectId());
  543. }
  544. mainWorld.partyEntered++;
  545. if (mainWorld.numberOfParties == mainWorld.partyEntered)
  546. {
  547. mainWorld.naiaIsDone = true;
  548. _log.info("Tower of naia is Done , Command channel Leader name is : "+ player.getParty().getCommandChannel().getChannelLeader().getName());
  549. }
  550. }
  551. }
  552. }
  553.  
  554.  
  555. @Override
  556. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  557. {
  558. if (player != null)
  559. {
  560. final InstanceWorld insworld = InstanceManager.getInstance().getWorld(player.getInstanceId());
  561. final TNRoom Room = new TNRoom();
  562. TNNpc roomnpc;
  563. TNWorld world;
  564.  
  565. //final int NpcId = npc.getNpcId();
  566.  
  567. if (insworld instanceof TNWorld)
  568. {
  569. world = (TNWorld) insworld;
  570. if(event.equalsIgnoreCase("startfight") && player.getInstanceId() == world.instanceId && Util.contains(IC, npc.getNpcId()))
  571. if (!world.npcContolerList.contains(npc))
  572. {
  573. world.npcContolerList.add(npc);
  574. startQuestTimer("stopfight", 300000, npc, player);
  575. Room.npcRoomList.clear();
  576. if(npc.getNpcId() == 18494)
  577. {
  578. closeDoor(18250001, world.instanceId);
  579. world.status = 1;
  580. for (int i = 0; i < 6; i++)
  581. {
  582. roomnpc = new TNNpc();
  583. roomnpc.npc = addSpawn(22393 + Rnd.get(2), -45700 - Rnd.get(1000), 245600 + Rnd.get(1000), -9125, Rnd.get(65000), false, 0, false, world.instanceId);
  584. Room.npcRoomList.add(roomnpc);
  585. }
  586. world.rooms.put("Room_1", Room);
  587. }
  588. else if(npc.getNpcId() == 18495)
  589. {
  590. closeDoor(18250003, world.instanceId);
  591. world.status = 2;
  592. for (int i = 0; i < 6; i++)
  593. {
  594. roomnpc = new TNNpc();
  595. roomnpc.npc = addSpawn(22439, -48100 - Rnd.get(1600), 249000 + Rnd.get(300), -9123, Rnd.get(65000), false, 0, false, world.instanceId);
  596. Room.npcRoomList.add(roomnpc);
  597. }
  598. world.rooms.put("Room_2", Room);
  599.  
  600. }
  601. else if(npc.getNpcId() == 18496)
  602. {
  603. closeDoor(18250005, world.instanceId);
  604. world.status = 3;
  605. for (int i = 0; i < 6; i++)
  606. {
  607. roomnpc = new TNNpc();
  608. roomnpc.npc = addSpawn(22441, -51120 - Rnd.get(1000), 245600 + Rnd.get(1000), -9990, Rnd.get(65000), false, 0, false, world.instanceId);
  609. Room.npcRoomList.add(roomnpc);
  610. }
  611. world.rooms.put("Room_3", Room);
  612.  
  613. }
  614. else if(npc.getNpcId() == 18497)
  615. {
  616. closeDoor(18250007, world.instanceId);
  617. world.status = 4;
  618. for (int i = 0; i < 6; i++)
  619. {
  620. roomnpc = new TNNpc();
  621. roomnpc.npc = addSpawn(22440, -48100 - Rnd.get(1600), 243250 + Rnd.get(300), -9990, Rnd.get(65000), false, 0, false, world.instanceId);
  622. Room.npcRoomList.add(roomnpc);
  623. }
  624. world.rooms.put("Room_4", Room);
  625.  
  626. }
  627. else if(npc.getNpcId() == 18498)
  628. {
  629. closeDoor(18250009, world.instanceId);
  630. world.status = 5;
  631. roomnpc = new TNNpc();
  632. roomnpc.npc = addSpawn(22393, -45700 - Rnd.get(1000), 245600 + Rnd.get(1000), -9990, Rnd.get(65000), false, 0, false, world.instanceId);
  633. Room.npcRoomList.add(roomnpc);
  634. roomnpc = new TNNpc();
  635. roomnpc.npc = addSpawn(22415, -45700 - Rnd.get(1000), 245600 + Rnd.get(1000), -9990, Rnd.get(65000), false, 0, false, world.instanceId);
  636. Room.npcRoomList.add(roomnpc);
  637. roomnpc = new TNNpc();
  638. roomnpc.npc = addSpawn(22411, -45700 - Rnd.get(1000), 245600 + Rnd.get(1000), -9990, Rnd.get(65000), false, 0, false, world.instanceId);
  639. Room.npcRoomList.add(roomnpc);
  640. world.rooms.put("Room_5", Room);
  641. for (int i = 0; i < 3; i++)
  642. {
  643. roomnpc = new TNNpc();
  644. roomnpc.npc = addSpawn(22394, -45700 - Rnd.get(1000), 245600 + Rnd.get(1000), -9990, Rnd.get(65000), false, 0, false, world.instanceId);
  645. Room.npcRoomList.add(roomnpc);
  646. }
  647. world.rooms.put("Room_5", Room);
  648.  
  649. }
  650. else if(npc.getNpcId() == 18499)
  651. {
  652. closeDoor(18250011, world.instanceId);
  653. world.status = 6;
  654. for (int i = 0; i < 6; i++)
  655. {
  656. roomnpc = new TNNpc();
  657. roomnpc.npc = addSpawn(22395, -48500 - Rnd.get(800), 247800 + Rnd.get(800), -9990, Rnd.get(65000), false, 0, false, world.instanceId);
  658. Room.npcRoomList.add(roomnpc);
  659. }
  660. world.rooms.put("Room_6", Room);
  661. }
  662. else if(npc.getNpcId() == 18500)
  663. {
  664. closeDoor(18250013, world.instanceId);
  665. world.status = 7;
  666. for (int i = 0; i < 6; i++)
  667. {
  668. roomnpc = new TNNpc();
  669. roomnpc.npc = addSpawn(22414 + Rnd.get(2), -51200 - Rnd.get(800), 245600 + Rnd.get(800), -10852, Rnd.get(65000), false, 0, false, world.instanceId);
  670. Room.npcRoomList.add(roomnpc);
  671. }
  672. world.rooms.put("Room_7", Room);
  673. }
  674. else if(npc.getNpcId() == 18501)
  675. {
  676. closeDoor(18250015, world.instanceId);
  677. world.status = 8;
  678. for (int i = 0; i < 6; i++)
  679. {
  680. roomnpc = new TNNpc();
  681. roomnpc.npc = addSpawn(22395, -48550 - Rnd.get(700), 243700 + Rnd.get(700), -10854, Rnd.get(65000), false, 0, false, world.instanceId);
  682. Room.npcRoomList.add(roomnpc);
  683. }
  684. world.rooms.put("Room_8", Room);
  685. }
  686. else if(npc.getNpcId() == 18502)
  687. {
  688. closeDoor(18250017, world.instanceId);
  689. world.status = 9;
  690. for (int i = 0; i < 3; i++)
  691. {
  692. roomnpc = new TNNpc();
  693. roomnpc.npc = addSpawn(22441, -45700 - Rnd.get(1000), 245600 + Rnd.get(1000), -11712, Rnd.get(65000), false, 0, false, world.instanceId);
  694. Room.npcRoomList.add(roomnpc);
  695. roomnpc = new TNNpc();
  696. roomnpc.npc = addSpawn(22442, -45700 - Rnd.get(1000), 245600 + Rnd.get(1000), -11712, Rnd.get(65000), false, 0, false, world.instanceId);
  697. Room.npcRoomList.add(roomnpc);
  698. }
  699. world.rooms.put("Room_9", Room);
  700. }
  701. else if(npc.getNpcId() == 18503)
  702. {
  703. closeDoor(18250019, world.instanceId);
  704. world.status = 10;
  705. for (int i = 0; i < 6; i++)
  706. {
  707. roomnpc = new TNNpc();
  708. roomnpc.npc = addSpawn(22395, -48550 - Rnd.get(700), 247800 + Rnd.get(700), -11712, Rnd.get(65000), false, 0, false, world.instanceId);
  709. Room.npcRoomList.add(roomnpc);
  710. }
  711. world.rooms.put("Room_10", Room);
  712. }
  713. else if(npc.getNpcId() == 18504)
  714. {
  715. closeDoor(18250021, world.instanceId);
  716. world.status = 11;
  717. for (int i = 0; i < 6; i++)
  718. {
  719. roomnpc = new TNNpc();
  720. roomnpc.npc = addSpawn(22413, -51100 - Rnd.get(1000), 245500 + Rnd.get(1200), -12575, Rnd.get(65000), false, 0, false, world.instanceId);
  721. Room.npcRoomList.add(roomnpc);
  722. }
  723. world.rooms.put("Room_11", Room);
  724. }
  725. else if(npc.getNpcId() == 18505)
  726. {
  727. closeDoor(18250023, world.instanceId);
  728. world.status = 12;
  729. for (int i = 0; i < 6; i++)
  730. {
  731. roomnpc = new TNNpc();
  732. roomnpc.npc = addSpawn(18490, -47700 - Rnd.get(1100), 243100 + Rnd.get(1000), -13379, Rnd.get(65000), false, 0, false, world.instanceId);
  733. Room.npcRoomList.add(roomnpc);
  734. }
  735. world.elpy = addSpawn( 25604, -44938, 248334, -14194, 57995, false, 0, false, world.instanceId);
  736. world.rooms.put("Room_12", Room);
  737. }
  738. }
  739. else
  740. return "<html><body>Ingenious Contraption:<br>Button is activated.</body></html>";
  741.  
  742. if(event.equalsIgnoreCase("SpawnSpores") && player.getInstanceId() == world.instanceId)
  743. {
  744. closeDoor(18250025, world.instanceId);
  745. world.status = 13;
  746. for (int i = 0 ; i < 24 ; i++)
  747. {
  748. roomnpc = new TNNpc();
  749. roomnpc.npc = addSpawn( SPORES[i][0], SPORES[i][1], SPORES[i][2], SPORES[i][3], SPORES[i][4], false, 0, false, world.instanceId);
  750. roomnpc.npc.setIsNoRndWalk(true);
  751. Room.npcRoomList.add(roomnpc);
  752. }
  753. world.rooms.put("Room_13", Room);
  754. }
  755. if (event.equals("stopfight"))
  756. {
  757. final teleCoord tele = new teleCoord();
  758. tele.x = 16323 ;
  759. tele.y = 209090 ;
  760. tele.z = -9365 ;
  761. world.rooms.clear();
  762. world.npcContolerList.clear();
  763. exitInstance(player,tele);
  764. cancelQuestTimers("stopfight_30");
  765. }
  766. /*if (event.equals("stopfight_30"))
  767. {
  768. final teleCoord tele = new teleCoord();
  769. tele.x = 16430;
  770. tele.y = 244437;
  771. tele.z = 11618;
  772. world.rooms.clear();
  773. world.npcContolerList.clear();
  774. exitInstance(player,tele);
  775. cancelQuestTimers("stopfight");
  776. }*/
  777.  
  778. if (event.equalsIgnoreCase("GoToBeleth"))
  779. {
  780. if (DEBUG)
  781. {
  782. player.sendMessage("Regrouping Parties Going to Beleth");
  783. final teleCoord tele = new teleCoord();
  784. tele.x = 16310;
  785. tele.y = 209323;
  786. tele.z = -9365;
  787. tele.instanceId = world.instanceId;
  788. goToBeleth(player, tele);
  789. }
  790.  
  791. else if (player.getParty().getCommandChannel() !=null)
  792. {
  793. InstanceWorld temp = InstanceManager.getInstance().getPlayerWorld(player.getParty().getCommandChannel().getChannelLeader());
  794. int instanceId = player.getParty().getCommandChannel().getChannelLeader().getInstanceId();
  795. if (temp instanceof TNWorld && instanceId != 0)
  796. {
  797. final teleCoord tele = new teleCoord();
  798. tele.x = 16310;
  799. tele.y = 209323;
  800. tele.z = -9365;
  801. tele.instanceId = instanceId;
  802. goToBeleth(player, tele);
  803. }
  804.  
  805. }
  806. else
  807. {
  808. player.sendMessage("Wrong Conditions !!");
  809. return "";
  810. }
  811.  
  812. }
  813. }
  814. if (event.equalsIgnoreCase("enternaia"))
  815. {
  816. if (DEBUG)
  817. {
  818. player.sendMessage("Event enter Naia");
  819. }
  820. final teleCoord tele = new teleCoord();
  821. tele.x = -47240;
  822. tele.y = 246120;
  823. tele.z = -9125;
  824. enterInstance(player, "TowerOfNaia.xml", tele);
  825. }
  826. }
  827. else if (event.equalsIgnoreCase("respawn_roof"))
  828. {
  829. if (roofControllerList.size() > 0)
  830. {
  831. //for (L2Npc controller : roofControllerList)
  832. //{
  833. //if (controller.getNpcId() == 18492)
  834. //{
  835. //controller.deleteMe();
  836. //roofControllerList.remove(controller);
  837. //}
  838. //}
  839. for (Iterator<L2Npc> it= roofControllerList.iterator();it.hasNext();)
  840. {
  841. L2Npc controller = it.next();
  842. if (controller.getNpcId() == 18492)
  843. {
  844. controller.deleteMe();
  845. it.remove();
  846. }
  847. }
  848. }
  849. if (npcRoofList.size() > 0)
  850. {
  851. //for (L2Npc rfNpc : npcRoofList)
  852. //{
  853. //if (rfNpc.getNpcId() == 18491 || rfNpc.getNpcId() == 18493 )
  854. //{
  855. //rfNpc.deleteMe();
  856. //npcRoofList.remove(rfNpc);
  857. //}
  858. //}
  859. for (Iterator<L2Npc> it = npcRoofList.iterator(); it.hasNext();)
  860. {
  861. L2Npc rfNpc = it.next();
  862. if (rfNpc.getNpcId() == 18491 || rfNpc.getNpcId() == 18493)
  863. {
  864. rfNpc.deleteMe();
  865. it.remove();
  866. }
  867. }
  868. }
  869. isSpawnController = false;
  870. isSpawnLock = false;
  871. isSpawnWard = false;
  872. SpawnRoofNpc();
  873. }
  874. return "";
  875. }
  876.  
  877. @Override
  878. public String onAttack (L2Npc npc, L2PcInstance attacker, int damage, boolean isPet, L2Skill skill)
  879. {
  880. if(npc.getNpcId() == 18491 && npcRoofList.size() < 2 && npc.getCurrentHp() < npc.getMaxHp()*0.4 && !isSpawnWard)
  881. {
  882. for(int i = 0; i < 4; i++)
  883. {
  884. final L2Npc roofmob = addSpawn(18493,16100 + Rnd.get(600),244100 + Rnd.get(600),11620,Rnd.get(65000),false,0,false,0);
  885. npcRoofList.add(roofmob);
  886. }
  887. isSpawnWard = true;
  888. }
  889. return "";
  890. }
  891.  
  892. /* @Override
  893. public String onEnterZone(L2Character character, L2ZoneType zone)
  894. {
  895. TNWorld world;
  896. if (character instanceof L2PcInstance)
  897. {
  898. final InstanceWorld tmpw = InstanceManager.getInstance().getWorld(character.getInstanceId());
  899. final Instance instance = InstanceManager.getInstance().getInstance(character.getInstanceId());
  900. if (tmpw instanceof TNWorld && instance != null && zone.getId() == 12016)
  901. {
  902. character.sendMessage("Enterzone");
  903. world = (TNWorld) tmpw;
  904. world.PlayerInZone.add(character);
  905. if ( world.PlayerInZone.size() == instance.getPlayers().size() && npcRoofList.size() == 0)
  906. {
  907. cancelQuestTimers("stopfight_30");
  908. world.PlsInInstance.clear();
  909. npcContolerList.clear();
  910. for (final L2DoorInstance door : InstanceManager.getInstance().getInstance(world.instanceId).getDoors())
  911. if (door.getDoorId() != 18250025)
  912. door.closeMe();
  913. if(!isSpawncontroller)
  914. SpawnRoofNpc();
  915. }
  916. }
  917. }
  918. return super.onEnterZone(character, zone);
  919. }
  920.  
  921. @Override
  922. public String onExitZone(L2Character character, L2ZoneType zone)
  923. {
  924. TNWorld world;
  925. if (character instanceof L2PcInstance)
  926. {
  927.  
  928. final InstanceWorld tmpw = InstanceManager.getInstance().getWorld(character.getInstanceId());
  929. final Instance instance = InstanceManager.getInstance().getInstance(character.getInstanceId());
  930. if (tmpw instanceof TNWorld && instance != null && zone.getId() == 12016)
  931. {
  932. character.sendMessage("Exit Zone");
  933. world = (TNWorld) tmpw;
  934. world.PlayerInZone.remove(character);
  935. }
  936. }
  937. return super.onExitZone(character, zone);
  938. }
  939. */
  940. @Override
  941. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  942. {
  943. final QuestState st = player.getQuestState(getName());
  944. if (st == null)
  945. newQuestState(player);
  946.  
  947. final int NpcId = npc.getNpcId();
  948. if (NpcId == 18492 )
  949. {
  950. if(npcRoofList.size() > 0 )
  951. {
  952. npc.deleteMe();
  953. roofControllerList.remove(npc);
  954. isSpawnController = false;
  955. /*for(final L2Npc rfnpc : npcRoofList)
  956. if (rfnpc.getNpcId() == 18491)
  957. {
  958. rfnpc.deleteMe();
  959. npcRoofList.remove(rfnpc);
  960. }*/
  961.  
  962. for (Iterator<L2Npc> it = npcRoofList.iterator(); it.hasNext(); )
  963. {
  964. L2Npc rfnpc = it.next();
  965. if (rfnpc.getNpcId() == 18491)
  966. {
  967. rfnpc.deleteMe();
  968. it.remove();
  969. }
  970. }
  971. isSpawnLock = false;
  972. startQuestTimer("respawn_roof",(180 + Rnd.get(120))*1000,null,null);
  973. }
  974. else if (checkConditions(player))
  975. return "18492.htm";
  976. }
  977. else if (NpcId == 18506 && checkConditions2(player) )
  978. return "ToBeleth.htm";
  979. else if (Util.contains(IC, NpcId) && NpcId != 18506)
  980. {
  981. if (player.getParty() == null)
  982. {
  983. player.sendMessage("Only a party leader can talk to me ");
  984. return "";
  985. }
  986. else if (player != player.getParty().getLeader())
  987. {
  988. player.sendMessage("Only a party leader can talk to me ");
  989. return"";
  990. }
  991. else if (true)
  992. {
  993.  
  994. for (final L2PcInstance partyMember : player.getParty().getPartyMembers())
  995. {
  996. if (!Util.checkIfInRange(500, player, partyMember, true))
  997. {
  998. final SystemMessage sm = new SystemMessage(SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED);
  999. sm.addPcName(partyMember);
  1000. player.sendPacket(sm);
  1001. return "";
  1002. }
  1003. }
  1004. }
  1005. return "Start.htm";
  1006.  
  1007. }
  1008.  
  1009. return "";
  1010. }
  1011.  
  1012. @Override
  1013. public String onKill(L2Npc npc, L2PcInstance player, boolean isPet)
  1014. {
  1015. final InstanceWorld insid = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  1016. if (insid instanceof TNWorld)
  1017. {
  1018. TNRoom Room;
  1019. TNNpc roomnpc;
  1020. final TNWorld world = (TNWorld) insid;
  1021. final int ws = world.status;
  1022.  
  1023. if ( ws == 5 && npc.getNpcId() == 22415)
  1024. {
  1025. Room = new TNRoom();
  1026. for (int i = 1; i < 3; i++)
  1027. {
  1028. roomnpc = new TNNpc();
  1029. roomnpc.npc = addSpawn(22412, -45700 - Rnd.get(1000), 245600 + Rnd.get(1000), -9990, Rnd.get(65000), false, 0, false, world.instanceId);
  1030. Room.npcRoomList.add(roomnpc);
  1031. }
  1032. world.rooms.put("Room_5", Room);
  1033. }
  1034. else if ( ws == 7 )
  1035. {
  1036. if ( npc.getNpcId() == 22414 || npc.getNpcId() == 22415)
  1037. if (checkKillProgress(npc, world.rooms.get("Room_"+String.valueOf(ws))))
  1038. {
  1039. Room = new TNRoom();
  1040. for (int i = 1; i < 3; i++)
  1041. {
  1042. roomnpc = new TNNpc();
  1043. roomnpc.npc = addSpawn(22412, -51200 - Rnd.get(800), 245600 + Rnd.get(800), -10852, Rnd.get(65000), false, 0, false, world.instanceId);
  1044. Room.npcRoomList.add(roomnpc);
  1045. }
  1046. world.rooms.put("Room_7", Room);
  1047. }
  1048. }
  1049. else if (ws == 13)
  1050. {
  1051. if ( npc.getNpcId() == 25605 || npc.getNpcId() == 25606 || npc.getNpcId() == 25607 || npc.getNpcId() == 25608 || npc.getNpcId() == 25613)
  1052. {
  1053. if (DEBUG)
  1054. _log.info("NPC true");
  1055. if (checkKillProgress(npc, world.rooms.get("Room_"+String.valueOf(ws))))
  1056. {
  1057. if (DEBUG)
  1058. _log.info("room Empty true");
  1059. Room = new TNRoom();
  1060.  
  1061. int spawnChance = Rnd.get(4);
  1062. roomnpc = new TNNpc();
  1063. roomnpc.npc = addSpawn(BOSSES[spawnChance][0],BOSSES[spawnChance][1],BOSSES[spawnChance][2],BOSSES[spawnChance][3], BOSSES[spawnChance][4], false, 0, false, world.instanceId);
  1064. Room.npcRoomList.add(roomnpc);
  1065.  
  1066. world.rooms.put("Room_13", Room);
  1067. }
  1068. }
  1069. }
  1070.  
  1071. if (checkKillProgress(npc, world.rooms.get("Room_"+String.valueOf(ws))))
  1072. {
  1073. if (ws == 6)
  1074. openDoor(18250101,world.instanceId);
  1075. else if (ws == 8)
  1076. openDoor(18250102,world.instanceId);
  1077. else if (ws == 10)
  1078. openDoor(18250103,world.instanceId);
  1079. else if (ws < 13)
  1080. openDoor(18250000 + ws*2,world.instanceId);
  1081. if (ws < 13)
  1082. {
  1083. openDoor(18250001 + ws*2,world.instanceId);
  1084. cancelQuestTimers("stopfight");
  1085. }
  1086.  
  1087. if (ws < 12 )
  1088. {
  1089. addSpawn(IC[ws], IC_COORD[ws][0], IC_COORD[ws][1], IC_COORD[ws][2], IC_COORD[ws][3], false, 0, false, world.instanceId);
  1090. }
  1091. else if (ws == 12 && world.elpy != null && npc.getObjectId() == world.elpy.getObjectId() )
  1092. {
  1093. startQuestTimer("SpawnSpores", 300000, null, player);
  1094. world.elpy.broadcastPacket(new NpcSay(world.elpy.getObjectId(), 1, world.elpy.getNpcId(), "Huh ? Killing Elpys ?! Is that all you can do ?! All doors will be closed in 5 mins ! Stay in this Room, Lets show up !!"));
  1095. }
  1096. else if (ws == 13)
  1097. for (int i = 0 ;i < 6 ; i++)
  1098. addSpawn (EXIT_NPC[i][0], EXIT_NPC[i][1], EXIT_NPC[i][2], EXIT_NPC[i][3], EXIT_NPC[i][4], false, 0, false, world.instanceId);
  1099. }
  1100. }
  1101.  
  1102. if ( npc.getNpcId() == 18491 || npc.getNpcId() == 18493)
  1103. npcRoofList.remove(npc);
  1104. return "";
  1105. }
  1106.  
  1107. protected void openDoor(int doorId, int instanceId)
  1108. {
  1109. for (final L2DoorInstance door : InstanceManager.getInstance().getInstance(instanceId).getDoors())
  1110. if (door.getDoorId() == doorId)
  1111. door.openMe();
  1112. }
  1113.  
  1114. private void SpawnRoofNpc()
  1115. {
  1116. if (!isSpawnLock && !isSpawnController)
  1117. {
  1118. final L2Npc roofnpc = addSpawn(18491,16409,244437,11618,0,false,0,false,0);
  1119. roofnpc.setIsNoRndWalk(true);
  1120. isSpawnLock = true;
  1121. npcRoofList.add(roofnpc);
  1122. final L2Npc roofcontr = addSpawn(18492,16640,244400,11618,33300,false,0,false,0);
  1123. roofControllerList.add(roofcontr);
  1124. isSpawnController = true;
  1125. }
  1126. }
  1127.  
  1128. private void teleportplayer(L2PcInstance player, teleCoord teleto)
  1129. {
  1130. player.setInstanceId(teleto.instanceId);
  1131. player.teleToLocation(teleto.x, teleto.y, teleto.z);
  1132. final L2Summon pet = player.getPet();
  1133. if (pet != null)
  1134. {
  1135. pet.setInstanceId(teleto.instanceId);
  1136. pet.teleToLocation(teleto.x, teleto.y, teleto.z);
  1137. }
  1138. }
  1139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement