HallOfSuffering.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927
  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 gracia.instances.SeedOfInfinity;
  20. import java.util.Calendar;
  21. import java.util.HashMap;
  22. import java.util.Map;
  23. import com.l2jserver.gameserver.ai.CtrlEvent;
  24. import com.l2jserver.gameserver.cache.HtmCache;
  25. import com.l2jserver.gameserver.datatables.SkillData;
  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.Skill;
  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 HashMap<>();
  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 TEMPLATE_ID = 115;
  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. public HallOfSuffering()
  400. {
  401. // TODO change name to use actual class name
  402. super(-1, "SeedOfInfinity", "gracia/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(), TEMPLATE_ID);
  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. // check for existing instances for this player
  463. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  464. // existing instance
  465. if (world != null)
  466. {
  467. if (!(world instanceof HSWorld))
  468. {
  469. player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
  470. return 0;
  471. }
  472. teleportPlayer(player, coords, world.getInstanceId());
  473. return world.getInstanceId();
  474. }
  475. // New instance
  476. if (!checkConditions(player))
  477. {
  478. return 0;
  479. }
  480. L2Party party = player.getParty();
  481. final int instanceId = InstanceManager.getInstance().createDynamicInstance(template);
  482. world = new HSWorld();
  483. world.setInstanceId(instanceId);
  484. world.setTemplateId(TEMPLATE_ID);
  485. world.setStatus(0);
  486. ((HSWorld) world).startTime = System.currentTimeMillis();
  487. ((HSWorld) world).ptLeaderName = player.getName();
  488. InstanceManager.getInstance().addWorld(world);
  489. _log.info("Hall Of Suffering started " + template + " Instance: " + instanceId + " created by player: " + player.getName());
  490. runTumors((HSWorld) world);
  491. // teleport players
  492. if (player.getParty() == null)
  493. {
  494. teleportPlayer(player, coords, instanceId);
  495. world.addAllowed(player.getObjectId());
  496. }
  497. else
  498. {
  499. for (L2PcInstance partyMember : party.getMembers())
  500. {
  501. teleportPlayer(partyMember, coords, instanceId);
  502. world.addAllowed(partyMember.getObjectId());
  503. if (partyMember.getQuestState(getName()) == null)
  504. {
  505. newQuestState(partyMember);
  506. }
  507. }
  508. }
  509. return instanceId;
  510. }
  511. protected boolean checkKillProgress(L2Npc mob, HSWorld world)
  512. {
  513. if (world.npcList.containsKey(mob))
  514. {
  515. world.npcList.put(mob, true);
  516. }
  517. for (boolean isDead : world.npcList.values())
  518. {
  519. if (!isDead)
  520. {
  521. return false;
  522. }
  523. }
  524. return true;
  525. }
  526. protected int[][] getRoomSpawns(int room)
  527. {
  528. switch (room)
  529. {
  530. case 0:
  531. return ROOM_1_MOBS;
  532. case 1:
  533. return ROOM_2_MOBS;
  534. case 2:
  535. return ROOM_3_MOBS;
  536. case 3:
  537. return ROOM_4_MOBS;
  538. case 4:
  539. return ROOM_5_MOBS;
  540. }
  541. _log.warning("");
  542. return new int[][] {};
  543. }
  544. protected void runTumors(HSWorld world)
  545. {
  546. for (int[] mob : getRoomSpawns(world.getStatus()))
  547. {
  548. L2Npc npc = addSpawn(mob[0], mob[1], mob[2], mob[3], 0, false, 0, false, world.getInstanceId());
  549. world.npcList.put(npc, false);
  550. }
  551. 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());
  552. mob.disableCoreAI(true);
  553. mob.setIsImmobilized(true);
  554. mob.setCurrentHp(mob.getMaxHp() * 0.5);
  555. world.npcList.put(mob, false);
  556. world.incStatus();
  557. }
  558. protected void runTwins(HSWorld world)
  559. {
  560. world.incStatus();
  561. 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());
  562. 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());
  563. world.klanikus.setIsMortal(false);
  564. world.klodekus.setIsMortal(false);
  565. }
  566. protected void bossSimpleDie(L2Npc boss)
  567. {
  568. // killing is only possible one time
  569. synchronized (this)
  570. {
  571. if (boss.isDead())
  572. {
  573. return;
  574. }
  575. // now reset currentHp to zero
  576. boss.setCurrentHp(0);
  577. boss.setIsDead(true);
  578. }
  579. // Set target to null and cancel Attack or Cast
  580. boss.setTarget(null);
  581. // Stop movement
  582. boss.stopMove(null);
  583. // Stop HP/MP/CP Regeneration task
  584. boss.getStatus().stopHpMpRegeneration();
  585. boss.stopAllEffectsExceptThoseThatLastThroughDeath();
  586. // Send the Server->Client packet StatusUpdate with current HP and MP to all other L2PcInstance to inform
  587. boss.broadcastStatusUpdate();
  588. // Notify L2Character AI
  589. boss.getAI().notifyEvent(CtrlEvent.EVT_DEAD);
  590. if (boss.getWorldRegion() != null)
  591. {
  592. boss.getWorldRegion().onDeath(boss);
  593. }
  594. }
  595. private void calcRewardItemId(HSWorld world)
  596. {
  597. Long finishDiff = System.currentTimeMillis() - world.startTime;
  598. if (finishDiff < 1260000)
  599. {
  600. world.rewardHtm = "32530-00.htm";
  601. world.rewardItemId = 13777;
  602. }
  603. else if (finishDiff < 1380000)
  604. {
  605. world.rewardHtm = "32530-01.htm";
  606. world.rewardItemId = 13778;
  607. }
  608. else if (finishDiff < 1500000)
  609. {
  610. world.rewardHtm = "32530-02.htm";
  611. world.rewardItemId = 13779;
  612. }
  613. else if (finishDiff < 1620000)
  614. {
  615. world.rewardHtm = "32530-03.htm";
  616. world.rewardItemId = 13780;
  617. }
  618. else if (finishDiff < 1740000)
  619. {
  620. world.rewardHtm = "32530-04.htm";
  621. world.rewardItemId = 13781;
  622. }
  623. else if (finishDiff < 1860000)
  624. {
  625. world.rewardHtm = "32530-05.htm";
  626. world.rewardItemId = 13782;
  627. }
  628. else if (finishDiff < 1980000)
  629. {
  630. world.rewardHtm = "32530-06.htm";
  631. world.rewardItemId = 13783;
  632. }
  633. else if (finishDiff < 2100000)
  634. {
  635. world.rewardHtm = "32530-07.htm";
  636. world.rewardItemId = 13784;
  637. }
  638. else if (finishDiff < 2220000)
  639. {
  640. world.rewardHtm = "32530-08.htm";
  641. world.rewardItemId = 13785;
  642. }
  643. else
  644. {
  645. world.rewardHtm = "32530-09.htm";
  646. world.rewardItemId = 13786;
  647. }
  648. }
  649. private String getPtLeaderText(L2PcInstance player, HSWorld world)
  650. {
  651. String htmltext = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "/data/scripts/instances/SeedOfInfinity/32530-10.htm");
  652. htmltext = htmltext.replaceAll("%ptLeader%", String.valueOf(world.ptLeaderName));
  653. return htmltext;
  654. }
  655. @Override
  656. public String onSkillSee(L2Npc npc, L2PcInstance caster, Skill skill, L2Object[] targets, boolean isSummon)
  657. {
  658. if (skill.hasEffectType(L2EffectType.REBALANCE_HP, L2EffectType.HEAL))
  659. {
  660. int hate = 2 * skill.getEffectPoint();
  661. if (hate < 2)
  662. {
  663. hate = 1000;
  664. }
  665. ((L2Attackable) npc).addDamageHate(caster, 0, hate);
  666. }
  667. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  668. }
  669. @Override
  670. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  671. {
  672. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  673. if (tmpworld instanceof HSWorld)
  674. {
  675. HSWorld world = (HSWorld) tmpworld;
  676. if (event.equalsIgnoreCase("spawnBossGuards"))
  677. {
  678. if (!world.klanikus.isInCombat() && !world.klodekus.isInCombat())
  679. {
  680. world.isBossesAttacked = false;
  681. return "";
  682. }
  683. 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());
  684. ((L2Attackable) mob).addDamageHate(((L2Attackable) npc).getMostHated(), 0, 1);
  685. if (getRandom(100) < 33)
  686. {
  687. 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());
  688. ((L2Attackable) mob).addDamageHate(((L2Attackable) npc).getMostHated(), 0, 1);
  689. }
  690. startQuestTimer("spawnBossGuards", BOSS_MINION_SPAWN_TIME, npc, null);
  691. }
  692. else if (event.equalsIgnoreCase("isTwinSeparated"))
  693. {
  694. if (Util.checkIfInRange(500, world.klanikus, world.klodekus, false))
  695. {
  696. world.klanikus.setIsInvul(false);
  697. world.klodekus.setIsInvul(false);
  698. }
  699. else
  700. {
  701. world.klanikus.setIsInvul(true);
  702. world.klodekus.setIsInvul(true);
  703. }
  704. startQuestTimer("isTwinSeparated", 10000, npc, null);
  705. }
  706. else if (event.equalsIgnoreCase("ressurectTwin"))
  707. {
  708. Skill skill = SkillData.getInstance().getSkill(5824, 1);
  709. L2Npc aliveTwin = (world.klanikus == npc ? world.klodekus : world.klanikus);
  710. npc.doRevive();
  711. npc.doCast(skill);
  712. npc.setCurrentHp(aliveTwin.getCurrentHp());
  713. // get most hated of other boss
  714. L2Character hated = ((L2MonsterInstance) aliveTwin).getMostHated();
  715. if (hated != null)
  716. {
  717. npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, hated, 1000);
  718. }
  719. aliveTwin.setIsInvul(true); // make other boss invul
  720. startQuestTimer("uninvul", BOSS_INVUL_TIME, aliveTwin, null);
  721. }
  722. else if (event.equals("uninvul"))
  723. {
  724. npc.setIsInvul(false);
  725. }
  726. }
  727. return "";
  728. }
  729. @Override
  730. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, Skill skill)
  731. {
  732. final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  733. if (tmpworld instanceof HSWorld)
  734. {
  735. final HSWorld world = (HSWorld) tmpworld;
  736. if (!world.isBossesAttacked)
  737. {
  738. world.isBossesAttacked = true;
  739. Calendar reenter = Calendar.getInstance();
  740. reenter.add(Calendar.HOUR, INSTANCEPENALTY);
  741. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_RESTRICTED);
  742. sm.addInstanceName(tmpworld.getTemplateId());
  743. // set instance reenter time for all allowed players
  744. for (int objectId : tmpworld.getAllowed())
  745. {
  746. L2PcInstance player = L2World.getInstance().getPlayer(objectId);
  747. if ((player != null) && player.isOnline())
  748. {
  749. InstanceManager.getInstance().setInstanceTime(objectId, tmpworld.getTemplateId(), reenter.getTimeInMillis());
  750. player.sendPacket(sm);
  751. }
  752. }
  753. startQuestTimer("spawnBossGuards", BOSS_MINION_SPAWN_TIME, npc, null);
  754. startQuestTimer("isTwinSeparated", 10000, npc, null);
  755. }
  756. else if (damage >= npc.getCurrentHp())
  757. {
  758. if (world.klanikus.isDead())
  759. {
  760. world.klanikus.setIsDead(false);
  761. world.klanikus.doDie(attacker);
  762. world.klodekus.doDie(attacker);
  763. }
  764. else if (((HSWorld) tmpworld).klodekus.isDead())
  765. {
  766. world.klodekus.setIsDead(false);
  767. world.klodekus.doDie(attacker);
  768. world.klanikus.doDie(attacker);
  769. }
  770. else
  771. {
  772. bossSimpleDie(npc);
  773. startQuestTimer("ressurectTwin", BOSS_RESSURECT_TIME, npc, null);
  774. }
  775. }
  776. }
  777. return null;
  778. }
  779. @Override
  780. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  781. {
  782. InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  783. if (tmpworld instanceof HSWorld)
  784. {
  785. HSWorld world = (HSWorld) tmpworld;
  786. if (npc.getId() == TUMOR_ALIVE)
  787. {
  788. addSpawn(TUMOR_DEAD, npc.getX(), npc.getY(), npc.getZ(), npc.getHeading(), false, 0, false, npc.getInstanceId());
  789. }
  790. if (world.getStatus() < 5)
  791. {
  792. if (checkKillProgress(npc, world))
  793. {
  794. runTumors(world);
  795. }
  796. }
  797. else if (world.getStatus() == 5)
  798. {
  799. if (checkKillProgress(npc, world))
  800. {
  801. runTwins(world);
  802. }
  803. }
  804. else if ((world.getStatus() == 6) && ((npc.getId() == KLODEKUS) || (npc.getId() == KLANIKUS)))
  805. {
  806. if (world.klanikus.isDead() && world.klodekus.isDead())
  807. {
  808. world.incStatus();
  809. // instance end
  810. calcRewardItemId(world);
  811. world.klanikus = null;
  812. world.klodekus = null;
  813. cancelQuestTimers("ressurectTwin");
  814. cancelQuestTimers("spawnBossGuards");
  815. cancelQuestTimers("isTwinSeparated");
  816. addSpawn(TEPIOS, TEPIOS_SPAWN[0], TEPIOS_SPAWN[1], TEPIOS_SPAWN[2], 0, false, 0, false, world.getInstanceId());
  817. }
  818. }
  819. }
  820. return "";
  821. }
  822. @Override
  823. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  824. {
  825. if (npc.getId() == TEPIOS)
  826. {
  827. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  828. if (((HSWorld) world).rewardItemId == -1)
  829. {
  830. _log.warning("Hall of Suffering: " + player.getName() + "(" + player.getObjectId() + ") is try to cheat!");
  831. return getPtLeaderText(player, (HSWorld) world);
  832. }
  833. else if (((HSWorld) world).isRewarded)
  834. {
  835. return "32530-11.htm";
  836. }
  837. else if ((player.getParty() != null) && (player.getParty().getLeaderObjectId() == player.getObjectId()))
  838. {
  839. return ((HSWorld) world).rewardHtm;
  840. }
  841. return getPtLeaderText(player, (HSWorld) world);
  842. }
  843. return "";
  844. }
  845. @Override
  846. public String onTalk(L2Npc npc, L2PcInstance player)
  847. {
  848. int npcId = npc.getId();
  849. QuestState st = player.getQuestState(getName());
  850. if (st == null)
  851. {
  852. st = newQuestState(player);
  853. }
  854. if (npcId == MOUTHOFEKIMUS)
  855. {
  856. enterInstance(player, "HallOfSuffering.xml", ENTER_TELEPORT);
  857. return "";
  858. }
  859. else if (npcId == TEPIOS)
  860. {
  861. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  862. if (((HSWorld) world).rewardItemId == -1)
  863. {
  864. _log.warning("Hall of Suffering: " + player.getName() + "(" + player.getObjectId() + ") is try to cheat!");
  865. return getPtLeaderText(player, (HSWorld) world);
  866. }
  867. else if (((HSWorld) world).isRewarded)
  868. {
  869. return "32530-11.htm";
  870. }
  871. else if ((player.getParty() != null) && (player.getParty().getLeaderObjectId() == player.getObjectId()))
  872. {
  873. ((HSWorld) world).isRewarded = true;
  874. for (L2PcInstance pl : player.getParty().getMembers())
  875. {
  876. st = pl.getQuestState(getName());
  877. if (st != null)
  878. {
  879. st.giveItems(736, 1);
  880. st.giveItems(((HSWorld) world).rewardItemId, 1);
  881. }
  882. }
  883. return "";
  884. }
  885. return getPtLeaderText(player, (HSWorld) world);
  886. }
  887. return "";
  888. }
  889. }