Advertisement
horato

Frintezza instance - patch

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