HallOfSuffering.java 22 KB

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