Beleth.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805
  1. /*
  2. * Copyright (C) 2004-2015 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 ai.individual;
  20. import java.util.List;
  21. import java.util.concurrent.CopyOnWriteArrayList;
  22. import ai.npc.AbstractNpcAI;
  23. import com.l2jserver.Config;
  24. import com.l2jserver.gameserver.ai.CtrlIntention;
  25. import com.l2jserver.gameserver.cache.HtmCache;
  26. import com.l2jserver.gameserver.data.xml.impl.DoorData;
  27. import com.l2jserver.gameserver.instancemanager.GrandBossManager;
  28. import com.l2jserver.gameserver.instancemanager.ZoneManager;
  29. import com.l2jserver.gameserver.model.L2Object;
  30. import com.l2jserver.gameserver.model.Location;
  31. import com.l2jserver.gameserver.model.StatsSet;
  32. import com.l2jserver.gameserver.model.actor.L2Attackable;
  33. import com.l2jserver.gameserver.model.actor.L2Character;
  34. import com.l2jserver.gameserver.model.actor.L2Npc;
  35. import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
  36. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  37. import com.l2jserver.gameserver.model.effects.L2EffectType;
  38. import com.l2jserver.gameserver.model.holders.ItemHolder;
  39. import com.l2jserver.gameserver.model.holders.SkillHolder;
  40. import com.l2jserver.gameserver.model.skills.Skill;
  41. import com.l2jserver.gameserver.model.zone.L2ZoneType;
  42. import com.l2jserver.gameserver.network.serverpackets.DoorStatusUpdate;
  43. import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
  44. import com.l2jserver.gameserver.network.serverpackets.PlaySound;
  45. import com.l2jserver.gameserver.network.serverpackets.SocialAction;
  46. import com.l2jserver.gameserver.network.serverpackets.SpecialCamera;
  47. import com.l2jserver.gameserver.network.serverpackets.StaticObject;
  48. import com.l2jserver.gameserver.util.Util;
  49. /**
  50. * Beleth's AI.
  51. * @author Treat, Sahar
  52. */
  53. public final class Beleth extends AbstractNpcAI
  54. {
  55. // Status
  56. private static final int ALIVE = 0;
  57. private static final int INIT = 1;
  58. private static final int FIGHT = 2;
  59. private static final int DEAD = 3;
  60. // NPCs
  61. private static final int REAL_BELETH = 29118;
  62. private static final int FAKE_BELETH = 29119;
  63. private static final int STONE_COFFIN = 32470;
  64. private static final int ELF = 29128;
  65. private static final int WHIRPOOL = 29125;
  66. // Zones
  67. private static final L2ZoneType ZONE = ZoneManager.getInstance().getZoneById(12018);
  68. private static final Location BELETH_SPAWN = new Location(16323, 213059, -9357, 49152);
  69. // Skills
  70. private static final SkillHolder BLEED = new SkillHolder(5495, 1);
  71. private static final SkillHolder FIREBALL = new SkillHolder(5496, 1);
  72. private static final SkillHolder HORN_OF_RISING = new SkillHolder(5497, 1);
  73. private static final SkillHolder LIGHTENING = new SkillHolder(5499, 1);
  74. // Doors
  75. private static final int DOOR1 = 20240001;
  76. private static final int DOOR2 = 20240002;
  77. private static final int DOOR3 = 20240003;
  78. // Items
  79. private static final ItemHolder RING = new ItemHolder(10314, 1);
  80. // Variables
  81. private L2Npc _camera1;
  82. private L2Npc _camera2;
  83. private L2Npc _camera3;
  84. private L2Npc _camera4;
  85. private L2Npc _whirpool;
  86. private L2Npc _beleth;
  87. private L2Npc _priest;
  88. private L2Npc _stone;
  89. private L2PcInstance _killer;
  90. private int _allowedObjId;
  91. private int _killedCount;
  92. private final List<L2Npc> _minions = new CopyOnWriteArrayList<>();
  93. private Beleth()
  94. {
  95. super(Beleth.class.getSimpleName(), "ai/individual");
  96. addEnterZoneId(ZONE.getId());
  97. registerMobs(REAL_BELETH, FAKE_BELETH);
  98. addStartNpc(STONE_COFFIN);
  99. addTalkId(STONE_COFFIN);
  100. addFirstTalkId(ELF);
  101. StatsSet info = GrandBossManager.getInstance().getStatsSet(REAL_BELETH);
  102. int status = GrandBossManager.getInstance().getBossStatus(REAL_BELETH);
  103. if (status == DEAD)
  104. {
  105. final long time = (info.getLong("respawn_time") - System.currentTimeMillis());
  106. if (time > 0)
  107. {
  108. startQuestTimer("BELETH_UNLOCK", time, null, null);
  109. }
  110. else
  111. {
  112. GrandBossManager.getInstance().setBossStatus(REAL_BELETH, ALIVE);
  113. }
  114. }
  115. else if (status != ALIVE)
  116. {
  117. GrandBossManager.getInstance().setBossStatus(REAL_BELETH, ALIVE);
  118. }
  119. DoorData.getInstance().getDoor(DOOR1).openMe();
  120. }
  121. @Override
  122. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  123. {
  124. switch (event)
  125. {
  126. case "BELETH_UNLOCK":
  127. {
  128. GrandBossManager.getInstance().setBossStatus(REAL_BELETH, ALIVE);
  129. DoorData.getInstance().getDoor(DOOR1).openMe();
  130. break;
  131. }
  132. case "CAST":
  133. {
  134. if (!npc.isDead() && !npc.isCastingNow())
  135. {
  136. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
  137. npc.doCast(FIREBALL.getSkill());
  138. }
  139. break;
  140. }
  141. case "SPAWN1":
  142. {
  143. ZONE.getCharactersInside().forEach(c ->
  144. {
  145. c.disableAllSkills();
  146. c.setIsInvul(true);
  147. c.setIsImmobilized(true);
  148. });
  149. _camera1 = addSpawn(29120, new Location(16323, 213142, -9357));
  150. _camera2 = addSpawn(29121, new Location(16323, 210741, -9357));
  151. _camera3 = addSpawn(29122, new Location(16323, 213170, -9357));
  152. _camera4 = addSpawn(29123, new Location(16323, 214917, -9356));
  153. ZONE.broadcastPacket(new PlaySound(1, "BS07_A", 1, _camera1.getObjectId(), _camera1.getX(), _camera1.getY(), _camera1.getZ()));
  154. ZONE.broadcastPacket(new SpecialCamera(_camera1, 400, 75, -25, 0, 2500, 0, 0, 1, 0, 0));
  155. ZONE.broadcastPacket(new SpecialCamera(_camera1, 400, 75, -25, 0, 2500, 0, 0, 1, 0, 0));
  156. startQuestTimer("SPAWN2", 300, null, null);
  157. break;
  158. }
  159. case "SPAWN2":
  160. {
  161. ZONE.broadcastPacket(new SpecialCamera(_camera1, 1800, -45, -45, 5000, 5000, 0, 0, 1, 0, 0));
  162. startQuestTimer("SPAWN3", 4900, null, null);
  163. break;
  164. }
  165. case "SPAWN3":
  166. {
  167. ZONE.broadcastPacket(new SpecialCamera(_camera1, 2500, -120, -45, 5000, 5000, 0, 0, 1, 0, 0));
  168. startQuestTimer("SPAWN4", 4900, null, null);
  169. break;
  170. }
  171. case "SPAWN4":
  172. {
  173. ZONE.broadcastPacket(new SpecialCamera(_camera2, 2200, 130, 0, 0, 1500, -20, 15, 1, 0, 0));
  174. startQuestTimer("SPAWN5", 1400, null, null);
  175. break;
  176. }
  177. case "SPAWN5":
  178. {
  179. ZONE.broadcastPacket(new SpecialCamera(_camera2, 2300, 100, 0, 2000, 4500, 0, 10, 1, 0, 0));
  180. startQuestTimer("SPAWN6", 2500, null, null);
  181. break;
  182. }
  183. case "SPAWN6":
  184. {
  185. final L2DoorInstance door = DoorData.getInstance().getDoor(DOOR1);
  186. door.closeMe();
  187. ZONE.broadcastPacket(new StaticObject(door, false));
  188. ZONE.broadcastPacket(new DoorStatusUpdate(door));
  189. startQuestTimer("SPAWN7", 1700, null, null);
  190. break;
  191. }
  192. case "SPAWN7":
  193. {
  194. ZONE.broadcastPacket(new SpecialCamera(_camera4, 1500, 210, 0, 0, 1500, 0, 0, 1, 0, 0));
  195. ZONE.broadcastPacket(new SpecialCamera(_camera4, 900, 255, 0, 5000, 6500, 0, 10, 1, 0, 0));
  196. startQuestTimer("SPAWN8", 6000, null, null);
  197. break;
  198. }
  199. case "SPAWN8":
  200. {
  201. _whirpool = addSpawn(WHIRPOOL, new Location(16323, 214917, -9356));
  202. ZONE.broadcastPacket(new SpecialCamera(_camera4, 900, 255, 0, 0, 1500, 0, 10, 1, 0, 0));
  203. startQuestTimer("SPAWN9", 1000, null, null);
  204. break;
  205. }
  206. case "SPAWN9":
  207. {
  208. ZONE.broadcastPacket(new SpecialCamera(_camera4, 1000, 255, 0, 7000, 17000, 0, 25, 1, 0, 0));
  209. startQuestTimer("SPAWN10", 3000, null, null);
  210. break;
  211. }
  212. case "SPAWN10":
  213. {
  214. _beleth = addSpawn(REAL_BELETH, new Location(16321, 214211, -9352, 49369));
  215. _beleth.disableAllSkills();
  216. _beleth.setIsInvul(true);
  217. _beleth.setIsImmobilized(true);
  218. startQuestTimer("SPAWN11", 200, null, null);
  219. break;
  220. }
  221. case "SPAWN11":
  222. {
  223. ZONE.broadcastPacket(new SocialAction(_beleth.getObjectId(), 1));
  224. for (int i = 0; i < 6; i++)
  225. {
  226. int x = (int) ((150 * Math.cos(i * 1.046666667)) + 16323);
  227. int y = (int) ((150 * Math.sin(i * 1.046666667)) + 213059);
  228. L2Npc minion = addSpawn(FAKE_BELETH, new Location(x, y, -9357, 49152));
  229. minion.setShowSummonAnimation(true);
  230. minion.decayMe();
  231. _minions.add(minion);
  232. }
  233. startQuestTimer("SPAWN12", 6800, null, null);
  234. break;
  235. }
  236. case "SPAWN12":
  237. {
  238. ZONE.broadcastPacket(new SpecialCamera(_beleth, 0, 270, -5, 0, 4000, 0, 0, 1, 0, 0));
  239. startQuestTimer("SPAWN13", 3500, null, null);
  240. break;
  241. }
  242. case "SPAWN13":
  243. {
  244. ZONE.broadcastPacket(new SpecialCamera(_beleth, 800, 270, 10, 3000, 6000, 0, 0, 1, 0, 0));
  245. startQuestTimer("SPAWN14", 5000, null, null);
  246. break;
  247. }
  248. case "SPAWN14":
  249. {
  250. ZONE.broadcastPacket(new SpecialCamera(_camera3, 100, 270, 15, 0, 5000, 0, 0, 1, 0, 0));
  251. ZONE.broadcastPacket(new SpecialCamera(_camera3, 100, 270, 15, 0, 5000, 0, 0, 1, 0, 0));
  252. startQuestTimer("SPAWN15", 100, null, null);
  253. break;
  254. }
  255. case "SPAWN15":
  256. {
  257. ZONE.broadcastPacket(new SpecialCamera(_camera3, 100, 270, 15, 3000, 6000, 0, 5, 1, 0, 0));
  258. startQuestTimer("SPAWN16", 1400, null, null);
  259. break;
  260. }
  261. case "SPAWN16":
  262. {
  263. _beleth.teleToLocation(BELETH_SPAWN);
  264. startQuestTimer("SPAWN17", 200, null, null);
  265. break;
  266. }
  267. case "SPAWN17":
  268. {
  269. ZONE.broadcastPacket(new MagicSkillUse(_beleth, _beleth, 5532, 1, 2000, 0));
  270. startQuestTimer("SPAWN18", 2000, null, null);
  271. break;
  272. }
  273. case "SPAWN18":
  274. {
  275. ZONE.broadcastPacket(new SpecialCamera(_camera3, 700, 270, 20, 1500, 8000, 0, 0, 1, 0, 0));
  276. startQuestTimer("SPAWN19", 6900, null, null);
  277. break;
  278. }
  279. case "SPAWN19":
  280. {
  281. ZONE.broadcastPacket(new SpecialCamera(_camera3, 40, 260, 0, 0, 4000, 0, 0, 1, 0, 0));
  282. for (L2Npc fakeBeleth : _minions)
  283. {
  284. fakeBeleth.spawnMe();
  285. fakeBeleth.disableAllSkills();
  286. fakeBeleth.setIsInvul(true);
  287. fakeBeleth.setIsImmobilized(true);
  288. }
  289. startQuestTimer("SPAWN20", 3000, null, null);
  290. break;
  291. }
  292. case "SPAWN20":
  293. {
  294. ZONE.broadcastPacket(new SpecialCamera(_camera3, 40, 280, 0, 0, 4000, 5, 0, 1, 0, 0));
  295. startQuestTimer("SPAWN21", 3000, null, null);
  296. break;
  297. }
  298. case "SPAWN21":
  299. {
  300. ZONE.broadcastPacket(new SpecialCamera(_camera3, 5, 250, 5, 0, 13000, 20, 15, 1, 0, 0));
  301. startQuestTimer("SPAWN22", 1000, null, null);
  302. break;
  303. }
  304. case "SPAWN22":
  305. {
  306. ZONE.broadcastPacket(new SocialAction(_beleth.getObjectId(), 3));
  307. startQuestTimer("SPAWN23", 4000, null, null);
  308. break;
  309. }
  310. case "SPAWN23":
  311. {
  312. ZONE.broadcastPacket(new MagicSkillUse(_beleth, _beleth, 5533, 1, 2000, 0));
  313. startQuestTimer("SPAWN24", 6800, null, null);
  314. break;
  315. }
  316. case "SPAWN24":
  317. {
  318. _beleth.deleteMe();
  319. _beleth = null;
  320. for (L2Npc fakeBeleth : _minions)
  321. {
  322. fakeBeleth.deleteMe();
  323. }
  324. _minions.clear();
  325. _camera1.deleteMe();
  326. _camera2.deleteMe();
  327. _camera3.deleteMe();
  328. _camera4.deleteMe();
  329. for (L2Character c : ZONE.getCharactersInside())
  330. {
  331. c.enableAllSkills();
  332. c.setIsInvul(false);
  333. c.setIsImmobilized(false);
  334. }
  335. startQuestTimer("SPAWN25", 60000, null, null);
  336. break;
  337. }
  338. case "SPAWN25":
  339. {
  340. int a = 0;
  341. for (int i = 0; i < 16; i++)
  342. {
  343. a++;
  344. int x = (int) ((650 * Math.cos(i * 0.39)) + 16323);
  345. int y = (int) ((650 * Math.sin(i * 0.39)) + 213170);
  346. npc = addSpawn(FAKE_BELETH, new Location(x, y, -9357, 49152));
  347. _minions.add(npc);
  348. if (a >= 2)
  349. {
  350. npc.setIsOverloaded(true);
  351. a = 0;
  352. }
  353. }
  354. int[] xm = new int[16];
  355. int[] ym = new int[16];
  356. for (int i = 0; i < 4; i++)
  357. {
  358. xm[i] = (int) ((1700 * Math.cos((i * 1.57) + 0.78)) + 16323);
  359. ym[i] = (int) ((1700 * Math.sin((i * 1.57) + 0.78)) + 213170);
  360. npc = addSpawn(FAKE_BELETH, new Location(xm[i], ym[i], -9357, 49152));
  361. npc.setIsImmobilized(true);
  362. _minions.add(npc);
  363. }
  364. xm[4] = (xm[0] + xm[1]) / 2;
  365. ym[4] = (ym[0] + ym[1]) / 2;
  366. npc = addSpawn(FAKE_BELETH, new Location(xm[4], ym[4], -9357, 49152));
  367. npc.setIsImmobilized(true);
  368. _minions.add(npc);
  369. xm[5] = (xm[1] + xm[2]) / 2;
  370. ym[5] = (ym[1] + ym[2]) / 2;
  371. npc = addSpawn(FAKE_BELETH, new Location(xm[5], ym[5], -9357, 49152));
  372. npc.setIsImmobilized(true);
  373. _minions.add(npc);
  374. xm[6] = (xm[2] + xm[3]) / 2;
  375. ym[6] = (ym[2] + ym[3]) / 2;
  376. npc = addSpawn(FAKE_BELETH, new Location(xm[6], ym[6], -9357, 49152));
  377. npc.setIsImmobilized(true);
  378. _minions.add(npc);
  379. xm[7] = (xm[3] + xm[0]) / 2;
  380. ym[7] = (ym[3] + ym[0]) / 2;
  381. npc = addSpawn(FAKE_BELETH, new Location(xm[7], ym[7], -9357, 49152));
  382. npc.setIsImmobilized(true);
  383. _minions.add(npc);
  384. xm[8] = (xm[0] + xm[4]) / 2;
  385. ym[8] = (ym[0] + ym[4]) / 2;
  386. _minions.add(addSpawn(FAKE_BELETH, new Location(xm[8], ym[8], -9357, 49152)));
  387. xm[9] = (xm[4] + xm[1]) / 2;
  388. ym[9] = (ym[4] + ym[1]) / 2;
  389. _minions.add(addSpawn(FAKE_BELETH, new Location(xm[9], ym[9], -9357, 49152)));
  390. xm[10] = (xm[1] + xm[5]) / 2;
  391. ym[10] = (ym[1] + ym[5]) / 2;
  392. _minions.add(addSpawn(FAKE_BELETH, new Location(xm[10], ym[10], -9357, 49152)));
  393. xm[11] = (xm[5] + xm[2]) / 2;
  394. ym[11] = (ym[5] + ym[2]) / 2;
  395. _minions.add(addSpawn(FAKE_BELETH, new Location(xm[11], ym[11], -9357, 49152)));
  396. xm[12] = (xm[2] + xm[6]) / 2;
  397. ym[12] = (ym[2] + ym[6]) / 2;
  398. _minions.add(addSpawn(FAKE_BELETH, new Location(xm[12], ym[12], -9357, 49152)));
  399. xm[13] = (xm[6] + xm[3]) / 2;
  400. ym[13] = (ym[6] + ym[3]) / 2;
  401. _minions.add(addSpawn(FAKE_BELETH, new Location(xm[13], ym[13], -9357, 49152)));
  402. xm[14] = (xm[3] + xm[7]) / 2;
  403. ym[14] = (ym[3] + ym[7]) / 2;
  404. _minions.add(addSpawn(FAKE_BELETH, new Location(xm[14], ym[14], -9357, 49152)));
  405. xm[15] = (xm[7] + xm[0]) / 2;
  406. ym[15] = (ym[7] + ym[0]) / 2;
  407. _minions.add(addSpawn(FAKE_BELETH, new Location(xm[15], ym[15], -9357, 49152)));
  408. _allowedObjId = _minions.get(getRandom(_minions.size())).getObjectId();
  409. break;
  410. }
  411. case "SPAWN_REAL":
  412. {
  413. _beleth = addSpawn(REAL_BELETH, new Location(16323, 213170, -9357, 49152));
  414. break;
  415. }
  416. case "SPAWN26":
  417. {
  418. _beleth.doDie(null);
  419. _camera1 = addSpawn(29122, new Location(16323, 213170, -9357));
  420. _camera1.broadcastPacket(new PlaySound(1, "BS07_D", 1, _camera1.getObjectId(), _camera1.getX(), _camera1.getY(), _camera1.getZ()));
  421. ZONE.broadcastPacket(new SpecialCamera(_camera1, 400, 290, 25, 0, 10000, 0, 0, 1, 0, 0));
  422. ZONE.broadcastPacket(new SpecialCamera(_camera1, 400, 290, 25, 0, 10000, 0, 0, 1, 0, 0));
  423. ZONE.broadcastPacket(new SpecialCamera(_camera1, 400, 110, 25, 4000, 10000, 0, 0, 1, 0, 0));
  424. ZONE.broadcastPacket(new SocialAction(_beleth.getObjectId(), 5));
  425. startQuestTimer("SPAWN27", 4000, null, null);
  426. break;
  427. }
  428. case "SPAWN27":
  429. {
  430. ZONE.broadcastPacket(new SpecialCamera(_camera1, 400, 295, 25, 4000, 5000, 0, 0, 1, 0, 0));
  431. startQuestTimer("SPAWN28", 4500, null, null);
  432. break;
  433. }
  434. case "SPAWN28":
  435. {
  436. ZONE.broadcastPacket(new SpecialCamera(_camera1, 400, 295, 10, 4000, 11000, 0, 25, 1, 0, 0));
  437. startQuestTimer("SPAWN29", 9000, null, null);
  438. break;
  439. }
  440. case "SPAWN29":
  441. {
  442. ZONE.broadcastPacket(new SpecialCamera(_camera1, 250, 90, 25, 0, 1000, 0, 0, 1, 0, 0));
  443. ZONE.broadcastPacket(new SpecialCamera(_camera1, 250, 90, 25, 0, 10000, 0, 0, 1, 0, 0));
  444. startQuestTimer("SPAWN30", 2000, null, null);
  445. break;
  446. }
  447. case "SPAWN30":
  448. {
  449. _priest.spawnMe();
  450. _beleth.deleteMe();
  451. _camera2 = addSpawn(29121, new Location(14056, 213170, -9357));
  452. startQuestTimer("SPAWN31", 3500, null, null);
  453. break;
  454. }
  455. case "SPAWN31":
  456. {
  457. ZONE.broadcastPacket(new SpecialCamera(_camera2, 800, 180, 0, 0, 4000, 0, 10, 1, 0, 0));
  458. ZONE.broadcastPacket(new SpecialCamera(_camera2, 800, 180, 0, 0, 4000, 0, 10, 1, 0, 0));
  459. L2DoorInstance door2 = DoorData.getInstance().getDoor(DOOR2);
  460. door2.openMe();
  461. ZONE.broadcastPacket(new StaticObject(door2, false));
  462. ZONE.broadcastPacket(new DoorStatusUpdate(door2));
  463. DoorData.getInstance().getDoor(DOOR3).openMe();
  464. _camera1.deleteMe();
  465. _camera2.deleteMe();
  466. _whirpool.deleteMe();
  467. for (L2Character c : ZONE.getCharactersInside())
  468. {
  469. c.enableAllSkills();
  470. c.setIsInvul(false);
  471. c.setIsImmobilized(false);
  472. }
  473. break;
  474. }
  475. }
  476. return super.onAdvEvent(event, npc, player);
  477. }
  478. @Override
  479. public String onEnterZone(L2Character character, L2ZoneType zone)
  480. {
  481. if (character.isPlayer() && (GrandBossManager.getInstance().getBossStatus(REAL_BELETH) == INIT))
  482. {
  483. if (_priest != null)
  484. {
  485. _priest.deleteMe();
  486. }
  487. if (_stone != null)
  488. {
  489. _stone.deleteMe();
  490. }
  491. GrandBossManager.getInstance().setBossStatus(REAL_BELETH, FIGHT);
  492. startQuestTimer("SPAWN1", 300000, null, null);
  493. }
  494. return super.onEnterZone(character, zone);
  495. }
  496. @Override
  497. public String onSkillSee(L2Npc npc, L2PcInstance player, Skill skill, L2Object[] targets, boolean isSummon)
  498. {
  499. if (!npc.isDead() && (npc.getId() == REAL_BELETH) && !npc.isCastingNow() && skill.hasEffectType(L2EffectType.HEAL) && (getRandom(100) < 80))
  500. {
  501. npc.setTarget(player);
  502. npc.doCast(HORN_OF_RISING.getSkill());
  503. }
  504. return null;
  505. }
  506. @Override
  507. public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isSummon)
  508. {
  509. if (!npc.isDead() && !npc.isCastingNow())
  510. {
  511. if (getRandom(100) < 40)
  512. {
  513. if (!npc.getKnownList().getKnownPlayersInRadius(200).isEmpty())
  514. {
  515. npc.doCast(BLEED.getSkill());
  516. return null;
  517. }
  518. }
  519. npc.setTarget(player);
  520. npc.doCast(FIREBALL.getSkill());
  521. }
  522. return null;
  523. }
  524. @Override
  525. public String onSpellFinished(L2Npc npc, L2PcInstance player, Skill skill)
  526. {
  527. if (!npc.isDead() && !npc.isCastingNow())
  528. {
  529. if (!player.isDead())
  530. {
  531. final double distance2 = npc.calculateDistance(player, false, false);
  532. if ((distance2 > 890) && !npc.isMovementDisabled())
  533. {
  534. npc.setTarget(player);
  535. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, player);
  536. double speed = npc.isRunning() ? npc.getRunSpeed() : npc.getWalkSpeed();
  537. int time = (int) (((distance2 - 890) / speed) * 1000);
  538. startQuestTimer("CAST", time, npc, null);
  539. }
  540. else if (distance2 < 890)
  541. {
  542. npc.setTarget(player);
  543. npc.doCast(FIREBALL.getSkill());
  544. }
  545. return null;
  546. }
  547. if (getRandom(100) < 40)
  548. {
  549. if (!npc.getKnownList().getKnownPlayersInRadius(200).isEmpty())
  550. {
  551. npc.doCast(LIGHTENING.getSkill());
  552. return null;
  553. }
  554. }
  555. for (L2PcInstance plr : npc.getKnownList().getKnownPlayersInRadius(950))
  556. {
  557. npc.setTarget(plr);
  558. npc.doCast(FIREBALL.getSkill());
  559. return null;
  560. }
  561. ((L2Attackable) npc).clearAggroList();
  562. }
  563. return null;
  564. }
  565. @Override
  566. public String onSpawn(L2Npc npc)
  567. {
  568. npc.setRunning();
  569. if (!npc.getKnownList().getKnownPlayersInRadius(300).isEmpty() && (getRandom(100) < 60))
  570. {
  571. npc.doCast(BLEED.getSkill());
  572. }
  573. if (npc.getId() == REAL_BELETH)
  574. {
  575. npc.getSpawn().setRespawnDelay(0);
  576. }
  577. return null;
  578. }
  579. @Override
  580. public String onTalk(L2Npc npc, L2PcInstance player)
  581. {
  582. String html;
  583. if ((_killer != null) && (player.getObjectId() == _killer.getObjectId()))
  584. {
  585. _killer = null;
  586. giveItems(player, RING);
  587. html = "32470a.htm";
  588. }
  589. else
  590. {
  591. html = "32470b.htm";
  592. }
  593. return HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "data/html/default/" + html);
  594. }
  595. @Override
  596. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  597. {
  598. return onTalk(npc, player);
  599. }
  600. @Override
  601. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon)
  602. {
  603. if (getRandom(100) < 40)
  604. {
  605. return null;
  606. }
  607. final double distance = npc.calculateDistance(attacker, false, false);
  608. if ((distance > 500) || (getRandom(100) < 80))
  609. {
  610. for (L2Npc beleth : _minions)
  611. {
  612. if ((beleth != null) && !beleth.isDead() && Util.checkIfInRange(900, beleth, attacker, false) && !beleth.isCastingNow())
  613. {
  614. beleth.setTarget(attacker);
  615. beleth.doCast(FIREBALL.getSkill());
  616. }
  617. }
  618. if ((_beleth != null) && !_beleth.isDead() && Util.checkIfInRange(900, _beleth, attacker, false) && !_beleth.isCastingNow())
  619. {
  620. _beleth.setTarget(attacker);
  621. _beleth.doCast(FIREBALL.getSkill());
  622. }
  623. }
  624. else if (!npc.isDead() && !npc.isCastingNow())
  625. {
  626. if (!npc.getKnownList().getKnownPlayersInRadius(200).isEmpty())
  627. {
  628. npc.doCast(LIGHTENING.getSkill());
  629. return null;
  630. }
  631. ((L2Attackable) npc).clearAggroList();
  632. }
  633. return null;
  634. }
  635. @Override
  636. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  637. {
  638. if (npc.getId() == REAL_BELETH)
  639. {
  640. setBelethKiller(killer);
  641. GrandBossManager.getInstance().setBossStatus(REAL_BELETH, DEAD);
  642. final long respawnTime = (Config.BELETH_SPAWN_INTERVAL + getRandom(-Config.BELETH_SPAWN_RANDOM, Config.BELETH_SPAWN_RANDOM)) * 3600000;
  643. StatsSet info = GrandBossManager.getInstance().getStatsSet(REAL_BELETH);
  644. info.set("respawn_time", System.currentTimeMillis() + respawnTime);
  645. GrandBossManager.getInstance().setStatsSet(REAL_BELETH, info);
  646. startQuestTimer("BELETH_UNLOCK", respawnTime, null, null);
  647. deleteAll();
  648. npc.deleteMe();
  649. for (L2Character c : ZONE.getCharactersInside())
  650. {
  651. c.disableAllSkills();
  652. c.setIsInvul(true);
  653. c.setIsImmobilized(true);
  654. }
  655. _beleth = addSpawn(REAL_BELETH, new Location(16323, 213170, -9357, 49152));
  656. _beleth.disableAllSkills();
  657. _beleth.setIsInvul(true);
  658. _beleth.setIsImmobilized(true);
  659. _priest = addSpawn(ELF, new Location(_beleth));
  660. _priest.setShowSummonAnimation(true);
  661. _priest.decayMe();
  662. _stone = addSpawn(STONE_COFFIN, new Location(12470, 215607, -9381, 49152));
  663. startQuestTimer("SPAWN26", 1000, null, null);
  664. }
  665. else if ((npc.getId() == FAKE_BELETH) && (npc.getObjectId() == _allowedObjId))
  666. {
  667. deleteAll();
  668. _killedCount++;
  669. if (_killedCount >= 5)
  670. {
  671. startQuestTimer("SPAWN_REAL", 60000, null, null);
  672. }
  673. else
  674. {
  675. startQuestTimer("SPAWN25", 60000, null, null);
  676. }
  677. }
  678. return null;
  679. }
  680. private void setBelethKiller(L2PcInstance killer)
  681. {
  682. if (killer.getParty() != null)
  683. {
  684. if (killer.getParty().getCommandChannel() != null)
  685. {
  686. _killer = killer.getParty().getCommandChannel().getLeader();
  687. }
  688. else
  689. {
  690. _killer = killer.getParty().getLeader();
  691. }
  692. }
  693. else
  694. {
  695. _killer = killer;
  696. }
  697. }
  698. private void deleteAll()
  699. {
  700. _minions.stream().filter(n -> !n.isDead()).forEach(n ->
  701. {
  702. n.abortCast();
  703. n.setTarget(null);
  704. n.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  705. n.deleteMe();
  706. });
  707. _allowedObjId = 0;
  708. }
  709. public static void main(String[] args)
  710. {
  711. new Beleth();
  712. }
  713. }