Advertisement
horato

Frintezza instance - patch

Jul 26th, 2011
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.14 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2J_DataPack
  3. Index: data/scripts/ai/individual/Frintezza.java
  4. ===================================================================
  5. --- data/scripts/ai/individual/Frintezza.java (revision 7999)
  6. +++ data/scripts/ai/individual/Frintezza.java (working copy)
  7. @@ -14,28 +14,34 @@
  8. */
  9. package ai.individual;
  10.  
  11. +import java.util.Calendar;
  12. import java.util.List;
  13. +import java.util.logging.Level;
  14. +import java.util.logging.Logger;
  15.  
  16. import javolution.util.FastList;
  17. import ai.group_template.L2AttackableAIScript;
  18.  
  19. -import com.l2jserver.Config;
  20. import com.l2jserver.gameserver.ai.CtrlIntention;
  21. -import com.l2jserver.gameserver.datatables.DoorTable;
  22. import com.l2jserver.gameserver.datatables.SkillTable;
  23. import com.l2jserver.gameserver.instancemanager.GrandBossManager;
  24. +import com.l2jserver.gameserver.instancemanager.InstanceManager;
  25. import com.l2jserver.gameserver.model.L2CommandChannel;
  26. import com.l2jserver.gameserver.model.L2Party;
  27. import com.l2jserver.gameserver.model.L2Skill;
  28. +import com.l2jserver.gameserver.model.L2World;
  29. import com.l2jserver.gameserver.model.actor.L2Attackable;
  30. import com.l2jserver.gameserver.model.actor.L2Character;
  31. import com.l2jserver.gameserver.model.actor.L2Npc;
  32. +import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
  33. import com.l2jserver.gameserver.model.actor.instance.L2GrandBossInstance;
  34. import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
  35. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  36. +import com.l2jserver.gameserver.model.quest.*;
  37. import com.l2jserver.gameserver.model.zone.type.L2BossZone;
  38. import com.l2jserver.gameserver.network.SystemMessageId;
  39. import com.l2jserver.gameserver.network.serverpackets.AbstractNpcInfo.NpcInfo;
  40. +import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
  41. import com.l2jserver.gameserver.network.serverpackets.Earthquake;
  42. import com.l2jserver.gameserver.network.serverpackets.MagicSkillCanceld;
  43. import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
  44. @@ -45,7 +51,7 @@
  45. import com.l2jserver.gameserver.network.serverpackets.SpecialCamera;
  46. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  47. import com.l2jserver.gameserver.skills.AbnormalEffect;
  48. -import com.l2jserver.gameserver.templates.StatsSet;
  49. +import com.l2jserver.gameserver.util.Util;
  50. import com.l2jserver.util.Rnd;
  51.  
  52. /**
  53. @@ -57,7 +63,8 @@
  54. *
  55. * Update by rocknow
  56. * Updated by L2jOff team
  57. - *
  58. + * Updated to use instances by horato
  59. + *
  60. * <BR>
  61. * Warn: be careful with adding new spawns {@link #getXFix(int)}
  62. *
  63. @@ -231,13 +238,16 @@
  64. private static final int GUIDE = 32011;
  65. private static final int CUBE = 29061;
  66.  
  67. + private static final int INSTANCEID = 136; // Taken from instancenames.xml, I have no idea if it is right but I hope so :}}
  68. +
  69. //Frintezza Status Tracking :
  70. private static final byte DORMANT = 0; //Frintezza is spawned and no one has entered yet. Entry is unlocked
  71. private static final byte WAITING = 1; //Frintezza is spawend and someone has entered, triggering a 30 minute window for additional people to enter
  72. //before he unleashes his attack. Entry is unlocked
  73. private static final byte FIGHTING = 2; //Frintezza is engaged in battle, annihilating his foes. Entry is locked
  74. - private static final byte DEAD = 3; //Frintezza has been killed. Entry is locked
  75.  
  76. + private static byte CurrentStatus = DORMANT;
  77. +
  78. private static long _LastAction = 0;
  79. private static int _Angle = 0;
  80. private static int _Heading = 0;
  81. @@ -258,6 +268,9 @@
  82. private static int _KillDarkChoirPlayer = 0;
  83. private static int _KillDarkChoirCaptain = 0;
  84.  
  85. + private static QuestState st = null;
  86. + private static boolean debugMSG = true;
  87. +
  88. private static L2BossZone _Zone;
  89. private L2GrandBossInstance frintezza, weakScarlet, strongScarlet, activeScarlet;
  90. private L2MonsterInstance demon1, demon2, demon3, demon4, portrait1, portrait2, portrait3, portrait4;
  91. @@ -267,6 +280,15 @@
  92. private static List<L2Npc> _Room2Mobs = new FastList<L2Npc>();
  93. private static List<L2Attackable> Minions = new FastList<L2Attackable>();
  94.  
  95. + private static List<String> _TimerControl = new FastList<String>();
  96. + // Initialization at 6:30 am on Wednesday and Saturday
  97. + private static final int RESET_HOUR = 6;
  98. + private static final int RESET_MIN = 30;
  99. + private static final int RESET_DAY_1 = 4;
  100. + private static final int RESET_DAY_2 = 7;
  101. + private static int currentInstanceID = 0;
  102. + private final static Logger _log = Logger.getLogger("FrintezzaInstance");
  103. +
  104. // Boss: Frintezza
  105. public Frintezza(int id, String name, String descr)
  106. {
  107. @@ -278,22 +300,12 @@
  108. addTalkId(GUIDE);
  109. addStartNpc(CUBE);
  110. addTalkId(CUBE);
  111. - StatsSet info = GrandBossManager.getInstance().getStatsSet(FRINTEZZA);
  112. - int status = GrandBossManager.getInstance().getBossStatus(FRINTEZZA);
  113. - if (status == DEAD)
  114. - {
  115. - long temp = (info.getLong("respawn_time") - System.currentTimeMillis());
  116. - if (temp > 0)
  117. - startQuestTimer("frintezza_unlock", temp, null, null);
  118. - else
  119. - GrandBossManager.getInstance().setBossStatus(FRINTEZZA,DORMANT);
  120. - }
  121. - else if (status != DORMANT)
  122. - GrandBossManager.getInstance().setBossStatus(FRINTEZZA,DORMANT);
  123. -
  124. +
  125. + /*
  126. //tempfix for messed door cords
  127. for (int i = 0; i < 8; i++)
  128. - DoorTable.getInstance().getDoor(17130051+i).setRange(0, 0, 0, 0, 0, 0);
  129. + InstanceManager.getInstance().getInstance(currentInstanceID).getDoor(17130051 + i).setRange(0, 0, 0, 0, 0, 0);
  130. + */
  131. }
  132.  
  133. @Override
  134. @@ -428,18 +440,26 @@
  135. else if (event.equalsIgnoreCase("close"))
  136. {
  137. for (int i = 17130051; i <= 17130058; i++)
  138. - DoorTable.getInstance().getDoor(i).closeMe();
  139. + {
  140. + L2DoorInstance door = InstanceManager.getInstance().getInstance(currentInstanceID).getDoor(i);
  141. + if(door != null)
  142. + door.closeMe();
  143. + }
  144. for (int i = 17130061; i <= 17130070; i++)
  145. - DoorTable.getInstance().getDoor(i).closeMe();
  146. -
  147. - DoorTable.getInstance().getDoor(17130042).closeMe();
  148. - DoorTable.getInstance().getDoor(17130043).closeMe();
  149. - DoorTable.getInstance().getDoor(17130045).closeMe();
  150. - DoorTable.getInstance().getDoor(17130046).closeMe();
  151. + {
  152. + L2DoorInstance door = InstanceManager.getInstance().getInstance(currentInstanceID).getDoor(i);
  153. + if(door != null)
  154. + door.closeMe();
  155. + }
  156. +
  157. + InstanceManager.getInstance().getInstance(currentInstanceID).getDoor(17130042).closeMe();
  158. + InstanceManager.getInstance().getInstance(currentInstanceID).getDoor(17130043).closeMe();
  159. + InstanceManager.getInstance().getInstance(currentInstanceID).getDoor(17130045).closeMe();
  160. + InstanceManager.getInstance().getInstance(currentInstanceID).getDoor(17130046).closeMe();
  161. }
  162. else if (event.equalsIgnoreCase("loc_check"))
  163. {
  164. - if (GrandBossManager.getInstance().getBossStatus(FRINTEZZA) == FIGHTING)
  165. + if (CurrentStatus == FIGHTING)
  166. {
  167. if (!_Zone.isInsideZone(npc))
  168. npc.teleToLocation(getXFix(174232),getYFix(-88020),getZFix(-5116));
  169. @@ -449,7 +469,7 @@
  170. }
  171. else if (event.equalsIgnoreCase("camera_1"))
  172. {
  173. - GrandBossManager.getInstance().setBossStatus(FRINTEZZA,FIGHTING);
  174. + CurrentStatus = FIGHTING;
  175.  
  176. _frintezzaDummy = addSpawn(29052,174240,-89805,-5022,16048,false,0);
  177. _frintezzaDummy.setIsInvul(true);
  178. @@ -491,7 +511,6 @@
  179. _Zone.broadcastPacket(new SpecialCamera(_overheadDummy.getObjectId(),300, 90, -10, 6500, 7000,0,0,1,0));
  180.  
  181. frintezza = (L2GrandBossInstance) addSpawn(FRINTEZZA,174240,-89805,-5022,16048,false,0);
  182. - GrandBossManager.getInstance().addBoss(frintezza);
  183. frintezza.setIsImmobilized(true);
  184. frintezza.setIsInvul(true);
  185. frintezza.disableAllSkills();
  186. @@ -1158,6 +1177,8 @@
  187. else if (event.equalsIgnoreCase("room_final"))
  188. {
  189. _Zone.broadcastPacket(new NpcSay(npc.getObjectId(),1,npc.getNpcId(),"Exceeded his time limit, challenge failed!"));
  190. + for(L2PcInstance playerInsideTezza : _PlayersInside)
  191. + playerInsideTezza.setInstanceId(0);
  192. _Zone.oustAllPlayers();
  193.  
  194. cancelQuestTimers("waiting");
  195. @@ -1166,16 +1187,48 @@
  196. startQuestTimer("close", 1000, npc, null);
  197. startQuestTimer("room1_del", 1000, npc, null);
  198. startQuestTimer("room2_del", 1000, npc, null);
  199. -
  200. - GrandBossManager.getInstance().setBossStatus(FRINTEZZA,DORMANT);
  201. + startQuestTimer("destroy_instance", 30000, npc, null);
  202. }
  203. + else if (event.equalsIgnoreCase("all_dead_frintezza_despawn"))
  204. + {
  205. + temp = (System.currentTimeMillis() - _LastAction);
  206. + if (temp > 30000)
  207. + {
  208. + for(L2PcInstance playerInsideTezza : _PlayersInside)
  209. + {
  210. + playerInsideTezza.setInstanceId(0);
  211. + playerInsideTezza.removeNotifyQuestOfDeath(st);
  212. + }
  213. + _Zone.oustAllPlayers();
  214. + cancelQuestTimers("all_dead_frintezza_despawn");
  215. + cancelQuestTimers("waiting");
  216. + cancelQuestTimers("loc_check");
  217. + cancelQuestTimers("room_final");
  218. + cancelQuestTimers("spawn_minion");
  219. + startQuestTimer("clean", 1000, npc, null);
  220. + startQuestTimer("close", 1000, npc, null);
  221. + startQuestTimer("attack_stop", 1000, npc, null);
  222. + startQuestTimer("room1_del", 1000, npc, null);
  223. + startQuestTimer("room2_del", 1000, npc, null);
  224. + startQuestTimer("room3_del", 1000, npc, null);
  225. + startQuestTimer("minions_despawn", 1000, npc, null);
  226. + startQuestTimer("destroy_instance", 30000, npc, null);
  227. +
  228. + }
  229. + }
  230. else if (event.equalsIgnoreCase("frintezza_despawn"))
  231. {
  232. temp = (System.currentTimeMillis() - _LastAction);
  233. if (temp > 900000)
  234. {
  235. + for(L2PcInstance playerInsideTezza : _PlayersInside)
  236. + {
  237. + playerInsideTezza.setInstanceId(0);
  238. + playerInsideTezza.removeNotifyQuestOfDeath(st);
  239. + }
  240. _Zone.oustAllPlayers();
  241.  
  242. + cancelQuestTimers("frintezza_despawn");
  243. cancelQuestTimers("waiting");
  244. cancelQuestTimers("loc_check");
  245. cancelQuestTimers("room_final");
  246. @@ -1187,10 +1240,7 @@
  247. startQuestTimer("room2_del", 1000, npc, null);
  248. startQuestTimer("room3_del", 1000, npc, null);
  249. startQuestTimer("minions_despawn", 1000, npc, null);
  250. -
  251. - GrandBossManager.getInstance().setBossStatus(FRINTEZZA,DORMANT);
  252. -
  253. - cancelQuestTimers("frintezza_despawn");
  254. + startQuestTimer("destroy_instance", 30000, npc, null);
  255. }
  256. }
  257. else if (event.equalsIgnoreCase("minions_despawn"))
  258. @@ -1208,24 +1258,37 @@
  259. if (npc != null && !npc.isDead() && frintezza != null && !frintezza.isDead())
  260. {
  261. L2Attackable mob = (L2Attackable)addSpawn(npc.getNpcId()+2,npc.getX(),npc.getY(),npc.getZ(),npc.getHeading(),false,0);
  262. - mob.setIsRaidMinion(true);
  263. - Minions.add(mob);
  264. -
  265. - startQuestTimer("action", 200, mob, null);
  266. - startQuestTimer("spawn_minion", 18000, npc, null);
  267. + if(mob != null)
  268. + {
  269. + mob.setIsRaidMinion(true);
  270. + Minions.add(mob);
  271. +
  272. + startQuestTimer("action", 200, mob, null);
  273. + startQuestTimer("spawn_minion", 18000, npc, null);
  274. + }
  275. }
  276. }
  277. else if (event.equalsIgnoreCase("spawn_cubes"))
  278. {
  279. - addSpawn(CUBE,174232,-88020,-5114,16384,false,900000);
  280. + addSpawn(CUBE, 174232, -88020, -5114, 16384, false, 900000);
  281. + startQuestTimer("frintezza_despawn", 60000, null, null, true);
  282. }
  283. - else if (event.equalsIgnoreCase("frintezza_unlock"))
  284. - {
  285. - GrandBossManager.getInstance().setBossStatus(FRINTEZZA,DORMANT);
  286. - }
  287. else if (event.equalsIgnoreCase("remove_players"))
  288. {
  289. + for(L2PcInstance playerInsideTezza : _PlayersInside)
  290. + playerInsideTezza.setInstanceId(0);
  291. _Zone.oustAllPlayers();
  292. +
  293. + }else if (event.equalsIgnoreCase("destroy_instance"))
  294. + {
  295. + if(debugMSG)
  296. + L2World.getInstance().getPlayer("xCorsiN").sendPacket(new CreatureSay(L2World.getInstance().getPlayer("xCorsiN").getObjectId(), 2, "xCorsiN", "Tezza's entrance is opened."));
  297. + InstanceManager.getInstance().destroyInstance(currentInstanceID);
  298. + for(String timer : _TimerControl)
  299. + cancelQuestTimers(timer);
  300. + _TimerControl.clear();
  301. +
  302. + CurrentStatus = DORMANT;
  303. }
  304.  
  305. return super.onAdvEvent(event, npc, player);
  306. @@ -1238,77 +1301,116 @@
  307. {
  308. int x = 150037 + Rnd.get(500);
  309. int y = -57720 + Rnd.get(500);
  310. + player.removeNotifyQuestOfDeath(st);
  311. + player.setInstanceId(0);
  312. player.teleToLocation(x, y, -2976);
  313. +
  314. + if(!_PlayersInside.isEmpty())
  315. + _PlayersInside.remove(player);
  316. +
  317. + if(_PlayersInside.isEmpty())
  318. + startQuestTimer("destroy_instance", 30000, npc, null);
  319. +
  320. return null;
  321. }
  322.  
  323. - String htmltext = "";
  324. - if (GrandBossManager.getInstance().getBossStatus(FRINTEZZA) == DEAD)
  325. + if(CurrentStatus != DORMANT)
  326. + return "<html><body>Someone is already inside instance. Try again later.</body></html>";
  327. +
  328. + st = player.getQuestState(getName());
  329. +
  330. + if (player.getParty() == null || player.getParty().getCommandChannel() == null || player.getParty().getCommandChannel().getChannelLeader() != player)
  331. + return "<html><body>I speak only with command channel leader.</body></html>";
  332. +
  333. + if (player.getParty().getCommandChannel().getMemberCount() < 36 || player.getParty().getCommandChannel().getMemberCount() > 45)
  334. + return "<html><body>Your command channel have incorrect size. You need between 36 and 45 players.</body></html>";
  335. +
  336. + if (player.getInventory().getItemByItemId(8073) == null)
  337. + return "<html><body>You dont have required item.</body></html>";
  338. +
  339. + L2CommandChannel CC = player.getParty().getCommandChannel();
  340. + for (L2Party _party : CC.getPartys())
  341. {
  342. - htmltext = "<html><body>There is nothing beyond the Magic Force Field. Come back later.<br>(You may not enter because Frintezza is not inside the Imperial Tomb.)</body></html>";
  343. - }
  344. - else if (GrandBossManager.getInstance().getBossStatus(FRINTEZZA) == DORMANT)
  345. - {
  346. - if ((!player.isInParty() || !player.getParty().isLeader(player))
  347. - || (player.getParty().getCommandChannel() == null)
  348. - || (player.getParty().getCommandChannel().getChannelLeader() != player))
  349. + if (_party == null)
  350. + continue;
  351. + for (L2PcInstance _member : _party.getPartyMembers())
  352. {
  353. - htmltext = "<html><body>No reaction. Contact must be initiated by the Command Channel Leader.</body></html>";
  354. - }
  355. - else if (player.getParty().getCommandChannel().getPartys().size() < 4 || player.getParty().getCommandChannel().getPartys().size() > 5)
  356. - {
  357. - htmltext = "<html><body>Your command channel needs to have at least 4 parties and a maximum of 5.</body></html>";
  358. - }
  359. - else if (player.getInventory().getItemByItemId(8073) == null)
  360. - {
  361. - htmltext = "<html><body>You dont have required item.</body></html>";
  362. - }
  363. - else
  364. - {
  365. - player.destroyItemByItemId("Quest", 8073, 1, player, true);
  366. - L2CommandChannel CC = player.getParty().getCommandChannel();
  367. - GrandBossManager.getInstance().setBossStatus(FRINTEZZA, WAITING);
  368. -
  369. - startQuestTimer("close", 0, npc, null);
  370. - startQuestTimer("room1_spawn", 5000, npc, null);
  371. - startQuestTimer("room_final", 2100000, npc, null);
  372. - startQuestTimer("frintezza_despawn", 60000, npc, null, true);
  373. -
  374. - _LastAction = System.currentTimeMillis();
  375. - for (L2Party party : CC.getPartys())
  376. + if (_member == null)
  377. + continue;
  378. +
  379. + if (_member.getLevel() < 80)
  380. + return "<html><body>Player " + _member.getName() + " have too low level. Minimum level required is 80.</body></html>";
  381. + if (!Util.checkIfInRange(1000, player, _member, false))
  382. + return "<html><body>" + _member.getName() + " is not near NPC.</body></html>";
  383. +
  384. + Long reentertime = InstanceManager.getInstance().getInstanceTime(_member.getObjectId(), INSTANCEID);
  385. + if (System.currentTimeMillis() < reentertime)
  386. {
  387. - if (party == null)
  388. - continue;
  389. - for (L2PcInstance member : party.getPartyMembers())
  390. - {
  391. - if (member == null || member.getLevel() < 74)
  392. - continue;
  393. - if (!member.isInsideRadius(npc, 700, false, false))
  394. - continue;
  395. - if (_PlayersInside.size() > 45)
  396. - {
  397. - member.sendMessage("The number of challenges have been full, so can not enter.");
  398. - break;
  399. - }
  400. - _PlayersInside.add(member);
  401. - _Zone.allowPlayerEntry(member, 300);
  402. - member.teleToLocation(getXFix(_invadeLoc[_LocCycle][0]) + Rnd.get(50), getYFix(_invadeLoc[_LocCycle][1]) + Rnd.get(50), getZFix(_invadeLoc[_LocCycle][2]));
  403. - }
  404. - if (_PlayersInside.size() > 45)
  405. - break;
  406. -
  407. - _LocCycle++;
  408. - if (_LocCycle >= 6)
  409. - _LocCycle = 1;
  410. + return "<html><body>" + _member.getName() + " may not reenter yet.</body></html>";
  411. }
  412. +
  413. }
  414. }
  415. + ClearVariables();
  416. + currentInstanceID = InstanceManager.getInstance().createDynamicInstance("Frintezza.xml");
  417. +
  418. + if(debugMSG)
  419. + {
  420. + if(player.getClan() != null)
  421. + L2World.getInstance().getPlayer("xCorsiN").sendPacket(new CreatureSay(L2World.getInstance().getPlayer("xCorsiN").getObjectId(), 2, "xCorsiN", player.getClan()+" clan with leader "+player.getName()+" entered to tezza."));
  422. else
  423. - htmltext = "<html><body>Someone else is already inside the Magic Force Field. Try again later.</body></html>";
  424. -
  425. - return htmltext;
  426. + L2World.getInstance().getPlayer("xCorsiN").sendPacket(new CreatureSay(L2World.getInstance().getPlayer("xCorsiN").getObjectId(), 2, "xCorsiN", "CC leader "+player.getName()+" without clan entered to tezza."));
  427. + }
  428. +
  429. + player.destroyItemByItemId("Quest", 8073, 1, player, true);
  430. + CurrentStatus = WAITING;
  431. +
  432. + startQuestTimer("close", 0, npc, null);
  433. + startQuestTimer("room1_spawn", 5000, npc, null);
  434. + startQuestTimer("room_final", 2100000, npc, null);
  435. + startQuestTimer("frintezza_despawn", 60000, npc, null, true);
  436. +
  437. + _LastAction = System.currentTimeMillis();
  438. + for (L2Party party : CC.getPartys())
  439. + {
  440. + if (party == null)
  441. + continue;
  442. + for (L2PcInstance member : party.getPartyMembers())
  443. + {
  444. + _PlayersInside.add(member);
  445. + _Zone.allowPlayerEntry(member, 300);
  446. + member.addNotifyQuestOfDeath(st);
  447. + member.setInstanceId(currentInstanceID);
  448. + member.teleToLocation(getXFix(_invadeLoc[_LocCycle][0]) + Rnd.get(50), getYFix(_invadeLoc[_LocCycle][1]) + Rnd.get(50), getZFix(_invadeLoc[_LocCycle][2]));
  449. + }
  450. + _LocCycle++;
  451. + if (_LocCycle >= 6)
  452. + _LocCycle = 1;
  453. + }
  454. +
  455. + setInstanceTimeRestrictions();
  456. + _log.log(Level.INFO, "Frintezza's instance with ID "+currentInstanceID+" has been created by player "+player.getName());
  457. + return "";
  458. }
  459.  
  460. + private void ClearVariables()
  461. + {
  462. + _PlayersInside.clear();
  463. + _TimerControl.clear();
  464. + _KillHallAlarmDevice = 0;
  465. + _KillDarkChoirPlayer = 0;
  466. + _KillDarkChoirCaptain = 0;
  467. + currentInstanceID = 0;
  468. + _LastAction = 0;
  469. + _LocCycle = 0;
  470. + _CheckDie = 0;
  471. + _OnCheck = 0;
  472. + _Abnormal = 0;
  473. + _OnMorph = 0;
  474. + _SecondMorph = 0;
  475. + _ThirdMorph = 0;
  476. + }
  477. +
  478. @Override
  479. public String onAttack (L2Npc npc, L2PcInstance attacker, int damage, boolean isPet)
  480. {
  481. @@ -1392,14 +1494,7 @@
  482. startQuestTimer("room3_del", 60000, npc, null);
  483. startQuestTimer("minions_despawn", 60000, npc, null);
  484. startQuestTimer("remove_players", 900000, npc, null);
  485. -
  486. - GrandBossManager.getInstance().setBossStatus(FRINTEZZA,DEAD);
  487. - long respawnTime = (long)Config.Interval_Of_Frintezza_Spawn + Rnd.get(Config.Random_Of_Frintezza_Spawn);
  488. - startQuestTimer("frintezza_unlock", respawnTime, npc, null);
  489. - // also save the respawn time so that the info is maintained past reboots
  490. - StatsSet info = GrandBossManager.getInstance().getStatsSet(FRINTEZZA);
  491. - info.set("respawn_time", System.currentTimeMillis() + respawnTime);
  492. - GrandBossManager.getInstance().setStatsSet(FRINTEZZA,info);
  493. + startQuestTimer("destroy_instance", 900001, npc, null);
  494. }
  495. else if (npc.getNpcId() == 18328)
  496. {
  497. @@ -1408,13 +1503,13 @@
  498. {
  499. startQuestTimer("room1_del", 100, npc, null);
  500. startQuestTimer("room2_spawn", 100, npc, null);
  501. -
  502. - DoorTable.getInstance().getDoor(17130042).openMe();
  503. - DoorTable.getInstance().getDoor(17130043).openMe();
  504. - // DoorTable.getInstance().getDoor(17130045).openMe();
  505. - // DoorTable.getInstance().getDoor(17130046).openMe();
  506. +
  507. + InstanceManager.getInstance().getInstance(currentInstanceID).getDoor(17130042).openMe();
  508. + InstanceManager.getInstance().getInstance(currentInstanceID).getDoor(17130043).openMe();
  509. + // InstanceManager.getInstance().getInstance(currentInstanceID).getDoor(17130045).openMe();
  510. + // InstanceManager.getInstance().getInstance(currentInstanceID).getDoor(17130046).openMe();
  511. for (int i = 17130051; i <= 17130058; i++)
  512. - DoorTable.getInstance().getDoor(i).openMe();
  513. + InstanceManager.getInstance().getInstance(currentInstanceID).getDoor(i).openMe();
  514. }
  515. }
  516. else if (npc.getNpcId() == 18339)
  517. @@ -1422,10 +1517,10 @@
  518. _KillDarkChoirPlayer ++;
  519. if (_KillDarkChoirPlayer == 2)
  520. {
  521. - DoorTable.getInstance().getDoor(17130042).closeMe();
  522. - DoorTable.getInstance().getDoor(17130043).closeMe();
  523. - DoorTable.getInstance().getDoor(17130045).closeMe();
  524. - DoorTable.getInstance().getDoor(17130046).closeMe();
  525. + InstanceManager.getInstance().getInstance(currentInstanceID).getDoor(17130042).closeMe();
  526. + InstanceManager.getInstance().getInstance(currentInstanceID).getDoor(17130043).closeMe();
  527. + InstanceManager.getInstance().getInstance(currentInstanceID).getDoor(17130045).closeMe();
  528. + InstanceManager.getInstance().getInstance(currentInstanceID).getDoor(17130046).closeMe();
  529. int outside = 0;
  530. for (L2PcInstance room2_pc : _PlayersInside)
  531. {
  532. @@ -1441,7 +1536,7 @@
  533. else
  534. {
  535. for (int i = 17130061; i <= 17130070; i++)
  536. - DoorTable.getInstance().getDoor(i).openMe();
  537. + InstanceManager.getInstance().getInstance(currentInstanceID).getDoor(i).openMe();
  538.  
  539. startQuestTimer("room2_spawn2", 1000, npc, null);
  540. }
  541. @@ -1454,8 +1549,8 @@
  542. {
  543. startQuestTimer("room2_del", 100, npc, null);
  544.  
  545. - DoorTable.getInstance().getDoor(17130045).openMe();
  546. - DoorTable.getInstance().getDoor(17130046).openMe();
  547. + InstanceManager.getInstance().getInstance(currentInstanceID).getDoor(17130045).openMe();
  548. + InstanceManager.getInstance().getInstance(currentInstanceID).getDoor(17130046).openMe();
  549.  
  550. startQuestTimer("waiting", 180000, npc, null);
  551. cancelQuestTimers("room_final");
  552. @@ -1464,7 +1559,26 @@
  553.  
  554. return super.onKill(npc,killer,isPet);
  555. }
  556. -
  557. +
  558. + @Override
  559. + public String onDeath(L2Character killer, L2Character victim, QuestState qs)
  560. + {
  561. + for(L2PcInstance player : _PlayersInside)
  562. + if(!player.isDead())
  563. + return "";
  564. + _log.log(Level.INFO, "Everyone inside Frintezza are dead. Closing instance in 30s.");
  565. + for(L2PcInstance playerInside : _PlayersInside)
  566. + playerInside.removeNotifyQuestOfDeath(st);
  567. +
  568. + if(debugMSG)
  569. + L2World.getInstance().getPlayer("xCorsiN").sendPacket(new CreatureSay(L2World.getInstance().getPlayer("xCorsiN").getObjectId(), 2, "xCorsiN", "Attemp to kill Tezza failed"));
  570. +
  571. + startQuestTimer("all_dead_frintezza_despawn", 1000, null, null, true);
  572. + return super.onDeath(killer, victim, qs);
  573. + }
  574. +
  575. +
  576. +
  577. /**
  578. * Override spawn method to correct spawn cords after lair move<BR>
  579. * TODO: Update cords in script, im just lazy :)
  580. @@ -1472,8 +1586,9 @@
  581. @Override
  582. public L2Npc addSpawn(int npcId, int x, int y, int z, int heading, boolean randomOffset, long despawnDelay, boolean isSummonSpawn, int instanceId)
  583. {
  584. +
  585. // cords fix:
  586. - return super.addSpawn(npcId, getXFix(x), getYFix(y), getZFix(z), heading, randomOffset, despawnDelay, isSummonSpawn, instanceId);
  587. + return super.addSpawn(npcId, getXFix(x), getYFix(y), getZFix(z), heading, randomOffset, despawnDelay, isSummonSpawn, currentInstanceID);
  588. }
  589.  
  590.  
  591. @@ -1503,6 +1618,47 @@
  592. return z + 4065;
  593. }
  594.  
  595. + protected void setInstanceTimeRestrictions()
  596. + {
  597. + Calendar reenter = Calendar.getInstance();
  598. + reenter.set(Calendar.MINUTE, RESET_MIN);
  599. + reenter.set(Calendar.HOUR_OF_DAY, RESET_HOUR);
  600. + // if time is >= RESET_HOUR - roll to the next day
  601. + if (reenter.getTimeInMillis() <= System.currentTimeMillis())
  602. + reenter.add(Calendar.DAY_OF_MONTH, 1);
  603. + if (reenter.get(Calendar.DAY_OF_WEEK) <= RESET_DAY_1)
  604. + while (reenter.get(Calendar.DAY_OF_WEEK) != RESET_DAY_1)
  605. + reenter.add(Calendar.DAY_OF_MONTH, 1);
  606. + else
  607. + while (reenter.get(Calendar.DAY_OF_WEEK) != RESET_DAY_2)
  608. + reenter.add(Calendar.DAY_OF_MONTH, 1);
  609. +
  610. + // set instance reenter time for all allowed players
  611. + for (L2PcInstance playerInside : _PlayersInside)
  612. + InstanceManager.getInstance().setInstanceTime(playerInside.getObjectId(), INSTANCEID, reenter.getTimeInMillis());
  613. + }
  614. +
  615. + @Override
  616. + public void startQuestTimer(String name, long time, L2Npc npc, L2PcInstance player)
  617. + {
  618. + _TimerControl.add(name);
  619. + super.startQuestTimer(name, time, npc, player);
  620. + }
  621. +
  622. + @Override
  623. + public void startQuestTimer(String name, long time, L2Npc npc, L2PcInstance player, boolean repeating)
  624. + {
  625. + _TimerControl.add(name);
  626. + super.startQuestTimer(name, time, npc, player, repeating);
  627. + }
  628. +
  629. + @Override
  630. + public void cancelQuestTimers(String name)
  631. + {
  632. + _TimerControl.remove(name);
  633. + super.cancelQuestTimers(name);
  634. + }
  635. +
  636. public static void main(String[] args)
  637. {
  638. // now call the constructor (starts up the ai)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement