HallOfSuffering.java 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934
  1. /*
  2. * Copyright (C) 2004-2014 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package instances.SeedOfInfinity;
  20. import java.util.Calendar;
  21. import java.util.Map;
  22. import javolution.util.FastMap;
  23. import com.l2jserver.gameserver.ai.CtrlEvent;
  24. import com.l2jserver.gameserver.cache.HtmCache;
  25. import com.l2jserver.gameserver.datatables.SkillTable;
  26. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  27. import com.l2jserver.gameserver.model.L2Object;
  28. import com.l2jserver.gameserver.model.L2Party;
  29. import com.l2jserver.gameserver.model.L2World;
  30. import com.l2jserver.gameserver.model.actor.L2Attackable;
  31. import com.l2jserver.gameserver.model.actor.L2Character;
  32. import com.l2jserver.gameserver.model.actor.L2Npc;
  33. import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
  34. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  35. import com.l2jserver.gameserver.model.effects.L2EffectType;
  36. import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
  37. import com.l2jserver.gameserver.model.quest.Quest;
  38. import com.l2jserver.gameserver.model.quest.QuestState;
  39. import com.l2jserver.gameserver.model.skills.L2Skill;
  40. import com.l2jserver.gameserver.network.SystemMessageId;
  41. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  42. import com.l2jserver.gameserver.util.Util;
  43. /**
  44. * Seed of Infinity (Hall of Suffering) instance zone.<br>
  45. * TODO:<br>
  46. * - after 15mins mobs are despawned<br>
  47. * - bound instance to quests<br>
  48. * @author Gigiikun, ZakaX, Didldak
  49. */
  50. public final class HallOfSuffering extends Quest
  51. {
  52. protected class HSWorld extends InstanceWorld
  53. {
  54. public Map<L2Npc, Boolean> npcList = new FastMap<>();
  55. public L2Npc klodekus = null;
  56. public L2Npc klanikus = null;
  57. public boolean isBossesAttacked = false;
  58. public long startTime = 0;
  59. public String ptLeaderName = "";
  60. public int rewardItemId = -1;
  61. public String rewardHtm = "";
  62. public boolean isRewarded = false;
  63. }
  64. private static final int INSTANCEID = 115; // this is the client number
  65. private static final boolean debug = false;
  66. // NPCs
  67. private static final int MOUTHOFEKIMUS = 32537;
  68. private static final int TEPIOS = 32530;
  69. // teleports
  70. private static final int[] ENTER_TELEPORT =
  71. {
  72. -187567,
  73. 205570,
  74. -9538
  75. };
  76. // mobs
  77. private static final int KLODEKUS = 25665;
  78. private static final int KLANIKUS = 25666;
  79. private static final int TUMOR_ALIVE = 18704;
  80. private static final int TUMOR_DEAD = 18705;
  81. private static final int[] TUMOR_MOBIDS =
  82. {
  83. 22509,
  84. 22510,
  85. 22511,
  86. 22512,
  87. 22513,
  88. 22514,
  89. 22515
  90. };
  91. private static final int[] TWIN_MOBIDS =
  92. {
  93. 22509,
  94. 22510,
  95. 22511,
  96. 22512,
  97. 22513
  98. };
  99. // Doors/Walls/Zones
  100. private static final int[][] ROOM_1_MOBS =
  101. {
  102. {
  103. 22509,
  104. -186296,
  105. 208200,
  106. -9544
  107. },
  108. {
  109. 22509,
  110. -186161,
  111. 208345,
  112. -9544
  113. },
  114. {
  115. 22509,
  116. -186296,
  117. 208403,
  118. -9544
  119. },
  120. {
  121. 22510,
  122. -186107,
  123. 208113,
  124. -9528
  125. },
  126. {
  127. 22510,
  128. -186350,
  129. 208200,
  130. -9544
  131. }
  132. };
  133. private static final int[][] ROOM_2_MOBS =
  134. {
  135. {
  136. 22511,
  137. -184433,
  138. 210953,
  139. -9536
  140. },
  141. {
  142. 22511,
  143. -184406,
  144. 211301,
  145. -9536
  146. },
  147. {
  148. 22509,
  149. -184541,
  150. 211272,
  151. -9544
  152. },
  153. {
  154. 22510,
  155. -184244,
  156. 211098,
  157. -9536
  158. },
  159. {
  160. 22510,
  161. -184352,
  162. 211243,
  163. -9536
  164. },
  165. {
  166. 22510,
  167. -184298,
  168. 211330,
  169. -9528
  170. }
  171. };
  172. private static final int[][] ROOM_3_MOBS =
  173. {
  174. {
  175. 22512,
  176. -182611,
  177. 213984,
  178. -9520
  179. },
  180. {
  181. 22512,
  182. -182908,
  183. 214071,
  184. -9520
  185. },
  186. {
  187. 22512,
  188. -182962,
  189. 213868,
  190. -9512
  191. },
  192. {
  193. 22509,
  194. -182881,
  195. 213955,
  196. -9512
  197. },
  198. {
  199. 22511,
  200. -182827,
  201. 213781,
  202. -9504
  203. },
  204. {
  205. 22511,
  206. -182530,
  207. 213984,
  208. -9528
  209. },
  210. {
  211. 22510,
  212. -182935,
  213. 213723,
  214. -9512
  215. },
  216. {
  217. 22510,
  218. -182557,
  219. 213868,
  220. -9520
  221. }
  222. };
  223. private static final int[][] ROOM_4_MOBS =
  224. {
  225. {
  226. 22514,
  227. -180958,
  228. 216860,
  229. -9544
  230. },
  231. {
  232. 22514,
  233. -181012,
  234. 216628,
  235. -9536
  236. },
  237. {
  238. 22514,
  239. -181120,
  240. 216715,
  241. -9536
  242. },
  243. {
  244. 22513,
  245. -180661,
  246. 216599,
  247. -9536
  248. },
  249. {
  250. 22513,
  251. -181039,
  252. 216599,
  253. -9536
  254. },
  255. {
  256. 22511,
  257. -180715,
  258. 216599,
  259. -9536
  260. },
  261. {
  262. 22511,
  263. -181012,
  264. 216889,
  265. -9536
  266. },
  267. {
  268. 22512,
  269. -180931,
  270. 216918,
  271. -9536
  272. },
  273. {
  274. 22512,
  275. -180742,
  276. 216628,
  277. -9536
  278. }
  279. };
  280. private static final int[][] ROOM_5_MOBS =
  281. {
  282. {
  283. 22512,
  284. -177372,
  285. 217854,
  286. -9536
  287. },
  288. {
  289. 22512,
  290. -177237,
  291. 218140,
  292. -9536
  293. },
  294. {
  295. 22512,
  296. -177021,
  297. 217647,
  298. -9528
  299. },
  300. {
  301. 22513,
  302. -177372,
  303. 217792,
  304. -9544
  305. },
  306. {
  307. 22513,
  308. -177372,
  309. 218053,
  310. -9536
  311. },
  312. {
  313. 22514,
  314. -177291,
  315. 217734,
  316. -9544
  317. },
  318. {
  319. 22514,
  320. -177264,
  321. 217792,
  322. -9544
  323. },
  324. {
  325. 22514,
  326. -177264,
  327. 218053,
  328. -9536
  329. },
  330. {
  331. 22515,
  332. -177156,
  333. 217792,
  334. -9536
  335. },
  336. {
  337. 22515,
  338. -177075,
  339. 217647,
  340. -9528
  341. }
  342. };
  343. private static final int[][] TUMOR_SPAWNS =
  344. {
  345. {
  346. -186327,
  347. 208286,
  348. -9544
  349. },
  350. {
  351. -184429,
  352. 211155,
  353. -9544
  354. },
  355. {
  356. -182811,
  357. 213871,
  358. -9496
  359. },
  360. {
  361. -181039,
  362. 216633,
  363. -9528
  364. },
  365. {
  366. -177264,
  367. 217760,
  368. -9544
  369. }
  370. };
  371. private static final int[][] TWIN_SPAWNS =
  372. {
  373. {
  374. 25665,
  375. -173727,
  376. 218169,
  377. -9536
  378. },
  379. {
  380. 25666,
  381. -173727,
  382. 218049,
  383. -9536
  384. }
  385. };
  386. private static final int[] TEPIOS_SPAWN =
  387. {
  388. -173727,
  389. 218109,
  390. -9536
  391. };
  392. // etc
  393. private static final int BOSS_INVUL_TIME = 30000; // in milisex
  394. private static final int BOSS_MINION_SPAWN_TIME = 60000; // in milisex
  395. private static final int BOSS_RESSURECT_TIME = 20000; // in milisex
  396. // Instance reenter time
  397. // default: 24h
  398. private static final int INSTANCEPENALTY = 24;
  399. private HallOfSuffering()
  400. {
  401. // TODO change name to use actual class name
  402. super(-1, "SeedOfInfinity", "instances");
  403. addStartNpc(MOUTHOFEKIMUS, TEPIOS);
  404. addTalkId(MOUTHOFEKIMUS, TEPIOS);
  405. addFirstTalkId(TEPIOS);
  406. addKillId(TUMOR_ALIVE, KLODEKUS, KLANIKUS);
  407. addAttackId(KLODEKUS, KLANIKUS);
  408. addSkillSeeId(TUMOR_MOBIDS);
  409. addKillId(TUMOR_MOBIDS);
  410. }
  411. private boolean checkConditions(L2PcInstance player)
  412. {
  413. if (debug)
  414. {
  415. return true;
  416. }
  417. L2Party party = player.getParty();
  418. if (party == null)
  419. {
  420. player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER);
  421. return false;
  422. }
  423. if (party.getLeader() != player)
  424. {
  425. player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
  426. return false;
  427. }
  428. for (L2PcInstance partyMember : party.getMembers())
  429. {
  430. if (partyMember.getLevel() < 75)
  431. {
  432. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT);
  433. sm.addPcName(partyMember);
  434. party.broadcastPacket(sm);
  435. return false;
  436. }
  437. if (!Util.checkIfInRange(1000, player, partyMember, true))
  438. {
  439. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED);
  440. sm.addPcName(partyMember);
  441. party.broadcastPacket(sm);
  442. return false;
  443. }
  444. Long reentertime = InstanceManager.getInstance().getInstanceTime(partyMember.getObjectId(), INSTANCEID);
  445. if (System.currentTimeMillis() < reentertime)
  446. {
  447. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_MAY_NOT_REENTER_YET);
  448. sm.addPcName(partyMember);
  449. party.broadcastPacket(sm);
  450. return false;
  451. }
  452. }
  453. return true;
  454. }
  455. private void teleportPlayer(L2PcInstance player, int[] coords, int instanceId)
  456. {
  457. player.setInstanceId(instanceId);
  458. player.teleToLocation(coords[0], coords[1], coords[2]);
  459. }
  460. protected int enterInstance(L2PcInstance player, String template, int[] coords)
  461. {
  462. int instanceId = 0;
  463. // check for existing instances for this player
  464. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  465. // existing instance
  466. if (world != null)
  467. {
  468. if (!(world instanceof HSWorld))
  469. {
  470. player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
  471. return 0;
  472. }
  473. teleportPlayer(player, coords, world.getInstanceId());
  474. return world.getInstanceId();
  475. }
  476. // New instance
  477. if (!checkConditions(player))
  478. {
  479. return 0;
  480. }
  481. L2Party party = player.getParty();
  482. instanceId = InstanceManager.getInstance().createDynamicInstance(template);
  483. world = new HSWorld();
  484. world.setInstanceId(instanceId);
  485. world.setTemplateId(INSTANCEID);
  486. world.setStatus(0);
  487. ((HSWorld) world).startTime = System.currentTimeMillis();
  488. ((HSWorld) world).ptLeaderName = player.getName();
  489. InstanceManager.getInstance().addWorld(world);
  490. _log.info("Hall Of Suffering started " + template + " Instance: " + instanceId + " created by player: " + player.getName());
  491. runTumors((HSWorld) world);
  492. // teleport players
  493. if (player.getParty() == null)
  494. {
  495. teleportPlayer(player, coords, instanceId);
  496. world.addAllowed(player.getObjectId());
  497. }
  498. else
  499. {
  500. for (L2PcInstance partyMember : party.getMembers())
  501. {
  502. teleportPlayer(partyMember, coords, instanceId);
  503. world.addAllowed(partyMember.getObjectId());
  504. if (partyMember.getQuestState(getName()) == null)
  505. {
  506. newQuestState(partyMember);
  507. }
  508. }
  509. }
  510. return instanceId;
  511. }
  512. protected boolean checkKillProgress(L2Npc mob, HSWorld world)
  513. {
  514. if (world.npcList.containsKey(mob))
  515. {
  516. world.npcList.put(mob, true);
  517. }
  518. for (boolean isDead : world.npcList.values())
  519. {
  520. if (!isDead)
  521. {
  522. return false;
  523. }
  524. }
  525. return true;
  526. }
  527. protected int[][] getRoomSpawns(int room)
  528. {
  529. switch (room)
  530. {
  531. case 0:
  532. return ROOM_1_MOBS;
  533. case 1:
  534. return ROOM_2_MOBS;
  535. case 2:
  536. return ROOM_3_MOBS;
  537. case 3:
  538. return ROOM_4_MOBS;
  539. case 4:
  540. return ROOM_5_MOBS;
  541. }
  542. _log.warning("");
  543. return new int[][] {};
  544. }
  545. protected void runTumors(HSWorld world)
  546. {
  547. for (int[] mob : getRoomSpawns(world.getStatus()))
  548. {
  549. L2Npc npc = addSpawn(mob[0], mob[1], mob[2], mob[3], 0, false, 0, false, world.getInstanceId());
  550. world.npcList.put(npc, false);
  551. }
  552. L2Npc mob = addSpawn(TUMOR_ALIVE, TUMOR_SPAWNS[world.getStatus()][0], TUMOR_SPAWNS[world.getStatus()][1], TUMOR_SPAWNS[world.getStatus()][2], 0, false, 0, false, world.getInstanceId());
  553. mob.disableCoreAI(true);
  554. mob.setIsImmobilized(true);
  555. mob.setCurrentHp(mob.getMaxHp() * 0.5);
  556. world.npcList.put(mob, false);
  557. world.incStatus();
  558. }
  559. protected void runTwins(HSWorld world)
  560. {
  561. world.incStatus();
  562. world.klodekus = addSpawn(TWIN_SPAWNS[0][0], TWIN_SPAWNS[0][1], TWIN_SPAWNS[0][2], TWIN_SPAWNS[0][3], 0, false, 0, false, world.getInstanceId());
  563. world.klanikus = addSpawn(TWIN_SPAWNS[1][0], TWIN_SPAWNS[1][1], TWIN_SPAWNS[1][2], TWIN_SPAWNS[1][3], 0, false, 0, false, world.getInstanceId());
  564. world.klanikus.setIsMortal(false);
  565. world.klodekus.setIsMortal(false);
  566. }
  567. protected void bossSimpleDie(L2Npc boss)
  568. {
  569. // killing is only possible one time
  570. synchronized (this)
  571. {
  572. if (boss.isDead())
  573. {
  574. return;
  575. }
  576. // now reset currentHp to zero
  577. boss.setCurrentHp(0);
  578. boss.setIsDead(true);
  579. }
  580. // Set target to null and cancel Attack or Cast
  581. boss.setTarget(null);
  582. // Stop movement
  583. boss.stopMove(null);
  584. // Stop HP/MP/CP Regeneration task
  585. boss.getStatus().stopHpMpRegeneration();
  586. boss.stopAllEffectsExceptThoseThatLastThroughDeath();
  587. // Send the Server->Client packet StatusUpdate with current HP and MP to all other L2PcInstance to inform
  588. boss.broadcastStatusUpdate();
  589. // Notify L2Character AI
  590. boss.getAI().notifyEvent(CtrlEvent.EVT_DEAD);
  591. if (boss.getWorldRegion() != null)
  592. {
  593. boss.getWorldRegion().onDeath(boss);
  594. }
  595. }
  596. private void calcRewardItemId(HSWorld world)
  597. {
  598. Long finishDiff = System.currentTimeMillis() - world.startTime;
  599. if (finishDiff < 1260000)
  600. {
  601. world.rewardHtm = "32530-00.htm";
  602. world.rewardItemId = 13777;
  603. }
  604. else if (finishDiff < 1380000)
  605. {
  606. world.rewardHtm = "32530-01.htm";
  607. world.rewardItemId = 13778;
  608. }
  609. else if (finishDiff < 1500000)
  610. {
  611. world.rewardHtm = "32530-02.htm";
  612. world.rewardItemId = 13779;
  613. }
  614. else if (finishDiff < 1620000)
  615. {
  616. world.rewardHtm = "32530-03.htm";
  617. world.rewardItemId = 13780;
  618. }
  619. else if (finishDiff < 1740000)
  620. {
  621. world.rewardHtm = "32530-04.htm";
  622. world.rewardItemId = 13781;
  623. }
  624. else if (finishDiff < 1860000)
  625. {
  626. world.rewardHtm = "32530-05.htm";
  627. world.rewardItemId = 13782;
  628. }
  629. else if (finishDiff < 1980000)
  630. {
  631. world.rewardHtm = "32530-06.htm";
  632. world.rewardItemId = 13783;
  633. }
  634. else if (finishDiff < 2100000)
  635. {
  636. world.rewardHtm = "32530-07.htm";
  637. world.rewardItemId = 13784;
  638. }
  639. else if (finishDiff < 2220000)
  640. {
  641. world.rewardHtm = "32530-08.htm";
  642. world.rewardItemId = 13785;
  643. }
  644. else
  645. {
  646. world.rewardHtm = "32530-09.htm";
  647. world.rewardItemId = 13786;
  648. }
  649. }
  650. private String getPtLeaderText(L2PcInstance player, HSWorld world)
  651. {
  652. String htmltext = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "/data/scripts/instances/SeedOfInfinity/32530-10.htm");
  653. htmltext = htmltext.replaceAll("%ptLeader%", String.valueOf(world.ptLeaderName));
  654. return htmltext;
  655. }
  656. @Override
  657. public String onSkillSee(L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isSummon)
  658. {
  659. if (skill.hasEffectType(L2EffectType.REBALANCE_HP, L2EffectType.HEAL, L2EffectType.HEAL_PERCENT))
  660. {
  661. int hate = 2 * skill.getEffectPoint();
  662. if (hate < 2)
  663. {
  664. hate = 1000;
  665. }
  666. ((L2Attackable) npc).addDamageHate(caster, 0, hate);
  667. }
  668. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  669. }
  670. @Override
  671. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  672. {
  673. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  674. if (tmpworld instanceof HSWorld)
  675. {
  676. HSWorld world = (HSWorld) tmpworld;
  677. if (event.equalsIgnoreCase("spawnBossGuards"))
  678. {
  679. if (!world.klanikus.isInCombat() && !world.klodekus.isInCombat())
  680. {
  681. world.isBossesAttacked = false;
  682. return "";
  683. }
  684. L2Npc mob = addSpawn(TWIN_MOBIDS[getRandom(TWIN_MOBIDS.length)], TWIN_SPAWNS[0][1], TWIN_SPAWNS[0][2], TWIN_SPAWNS[0][3], 0, false, 0, false, npc.getInstanceId());
  685. ((L2Attackable) mob).addDamageHate(((L2Attackable) npc).getMostHated(), 0, 1);
  686. if (getRandom(100) < 33)
  687. {
  688. mob = addSpawn(TWIN_MOBIDS[getRandom(TWIN_MOBIDS.length)], TWIN_SPAWNS[1][1], TWIN_SPAWNS[1][2], TWIN_SPAWNS[1][3], 0, false, 0, false, npc.getInstanceId());
  689. ((L2Attackable) mob).addDamageHate(((L2Attackable) npc).getMostHated(), 0, 1);
  690. }
  691. startQuestTimer("spawnBossGuards", BOSS_MINION_SPAWN_TIME, npc, null);
  692. }
  693. else if (event.equalsIgnoreCase("isTwinSeparated"))
  694. {
  695. if (Util.checkIfInRange(500, world.klanikus, world.klodekus, false))
  696. {
  697. world.klanikus.setIsInvul(false);
  698. world.klodekus.setIsInvul(false);
  699. }
  700. else
  701. {
  702. world.klanikus.setIsInvul(true);
  703. world.klodekus.setIsInvul(true);
  704. }
  705. startQuestTimer("isTwinSeparated", 10000, npc, null);
  706. }
  707. else if (event.equalsIgnoreCase("ressurectTwin"))
  708. {
  709. L2Skill skill = SkillTable.getInstance().getInfo(5824, 1);
  710. L2Npc aliveTwin = (world.klanikus == npc ? world.klodekus : world.klanikus);
  711. npc.doRevive();
  712. npc.doCast(skill);
  713. npc.setCurrentHp(aliveTwin.getCurrentHp());
  714. // get most hated of other boss
  715. L2Character hated = ((L2MonsterInstance) aliveTwin).getMostHated();
  716. if (hated != null)
  717. {
  718. npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, hated, 1000);
  719. }
  720. aliveTwin.setIsInvul(true); // make other boss invul
  721. startQuestTimer("uninvul", BOSS_INVUL_TIME, aliveTwin, null);
  722. }
  723. else if (event.equals("uninvul"))
  724. {
  725. npc.setIsInvul(false);
  726. }
  727. }
  728. return "";
  729. }
  730. @Override
  731. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, L2Skill skill)
  732. {
  733. final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  734. if (tmpworld instanceof HSWorld)
  735. {
  736. final HSWorld world = (HSWorld) tmpworld;
  737. if (!world.isBossesAttacked)
  738. {
  739. world.isBossesAttacked = true;
  740. Calendar reenter = Calendar.getInstance();
  741. reenter.add(Calendar.HOUR, INSTANCEPENALTY);
  742. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_RESTRICTED);
  743. sm.addInstanceName(tmpworld.getTemplateId());
  744. // set instance reenter time for all allowed players
  745. for (int objectId : tmpworld.getAllowed())
  746. {
  747. L2PcInstance player = L2World.getInstance().getPlayer(objectId);
  748. if ((player != null) && player.isOnline())
  749. {
  750. InstanceManager.getInstance().setInstanceTime(objectId, tmpworld.getTemplateId(), reenter.getTimeInMillis());
  751. player.sendPacket(sm);
  752. }
  753. }
  754. startQuestTimer("spawnBossGuards", BOSS_MINION_SPAWN_TIME, npc, null);
  755. startQuestTimer("isTwinSeparated", 10000, npc, null);
  756. }
  757. else if (damage >= npc.getCurrentHp())
  758. {
  759. if (world.klanikus.isDead())
  760. {
  761. world.klanikus.setIsDead(false);
  762. world.klanikus.doDie(attacker);
  763. world.klodekus.doDie(attacker);
  764. }
  765. else if (((HSWorld) tmpworld).klodekus.isDead())
  766. {
  767. world.klodekus.setIsDead(false);
  768. world.klodekus.doDie(attacker);
  769. world.klanikus.doDie(attacker);
  770. }
  771. else
  772. {
  773. bossSimpleDie(npc);
  774. startQuestTimer("ressurectTwin", BOSS_RESSURECT_TIME, npc, null);
  775. }
  776. }
  777. }
  778. return null;
  779. }
  780. @Override
  781. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  782. {
  783. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  784. if (tmpworld instanceof HSWorld)
  785. {
  786. HSWorld world = (HSWorld) tmpworld;
  787. if (npc.getId() == TUMOR_ALIVE)
  788. {
  789. addSpawn(TUMOR_DEAD, npc.getX(), npc.getY(), npc.getZ(), npc.getHeading(), false, 0, false, npc.getInstanceId());
  790. }
  791. if (world.getStatus() < 5)
  792. {
  793. if (checkKillProgress(npc, world))
  794. {
  795. runTumors(world);
  796. }
  797. }
  798. else if (world.getStatus() == 5)
  799. {
  800. if (checkKillProgress(npc, world))
  801. {
  802. runTwins(world);
  803. }
  804. }
  805. else if ((world.getStatus() == 6) && ((npc.getId() == KLODEKUS) || (npc.getId() == KLANIKUS)))
  806. {
  807. if (world.klanikus.isDead() && world.klodekus.isDead())
  808. {
  809. world.incStatus();
  810. // instance end
  811. calcRewardItemId(world);
  812. world.klanikus = null;
  813. world.klodekus = null;
  814. cancelQuestTimers("ressurectTwin");
  815. cancelQuestTimers("spawnBossGuards");
  816. cancelQuestTimers("isTwinSeparated");
  817. addSpawn(TEPIOS, TEPIOS_SPAWN[0], TEPIOS_SPAWN[1], TEPIOS_SPAWN[2], 0, false, 0, false, world.getInstanceId());
  818. }
  819. }
  820. }
  821. return "";
  822. }
  823. @Override
  824. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  825. {
  826. if (npc.getId() == TEPIOS)
  827. {
  828. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  829. if (((HSWorld) world).rewardItemId == -1)
  830. {
  831. _log.warning("Hall of Suffering: " + player.getName() + "(" + player.getObjectId() + ") is try to cheat!");
  832. return getPtLeaderText(player, (HSWorld) world);
  833. }
  834. else if (((HSWorld) world).isRewarded)
  835. {
  836. return "32530-11.htm";
  837. }
  838. else if ((player.getParty() != null) && (player.getParty().getLeaderObjectId() == player.getObjectId()))
  839. {
  840. return ((HSWorld) world).rewardHtm;
  841. }
  842. return getPtLeaderText(player, (HSWorld) world);
  843. }
  844. return "";
  845. }
  846. @Override
  847. public String onTalk(L2Npc npc, L2PcInstance player)
  848. {
  849. int npcId = npc.getId();
  850. QuestState st = player.getQuestState(getName());
  851. if (st == null)
  852. {
  853. st = newQuestState(player);
  854. }
  855. if (npcId == MOUTHOFEKIMUS)
  856. {
  857. enterInstance(player, "HallOfSuffering.xml", ENTER_TELEPORT);
  858. return "";
  859. }
  860. else if (npcId == TEPIOS)
  861. {
  862. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  863. if (((HSWorld) world).rewardItemId == -1)
  864. {
  865. _log.warning("Hall of Suffering: " + player.getName() + "(" + player.getObjectId() + ") is try to cheat!");
  866. return getPtLeaderText(player, (HSWorld) world);
  867. }
  868. else if (((HSWorld) world).isRewarded)
  869. {
  870. return "32530-11.htm";
  871. }
  872. else if ((player.getParty() != null) && (player.getParty().getLeaderObjectId() == player.getObjectId()))
  873. {
  874. ((HSWorld) world).isRewarded = true;
  875. for (L2PcInstance pl : player.getParty().getMembers())
  876. {
  877. st = pl.getQuestState(getName());
  878. if (st != null)
  879. {
  880. st.giveItems(736, 1);
  881. st.giveItems(((HSWorld) world).rewardItemId, 1);
  882. }
  883. }
  884. return "";
  885. }
  886. return getPtLeaderText(player, (HSWorld) world);
  887. }
  888. return "";
  889. }
  890. public static void main(String[] args)
  891. {
  892. new HallOfSuffering();
  893. }
  894. }