Beleth.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  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. }
  158. case "SPAWN2":
  159. {
  160. ZONE.broadcastPacket(new SpecialCamera(_camera1, 1800, -45, -45, 5000, 5000, 0, 0, 1, 0, 0));
  161. startQuestTimer("SPAWN3", 4900, null, null);
  162. }
  163. case "SPAWN3":
  164. {
  165. ZONE.broadcastPacket(new SpecialCamera(_camera1, 2500, -120, -45, 5000, 5000, 0, 0, 1, 0, 0));
  166. startQuestTimer("SPAWN4", 4900, null, null);
  167. }
  168. case "SPAWN4":
  169. {
  170. ZONE.broadcastPacket(new SpecialCamera(_camera2, 2200, 130, 0, 0, 1500, -20, 15, 1, 0, 0));
  171. startQuestTimer("SPAWN5", 1400, null, null);
  172. }
  173. case "SPAWN5":
  174. {
  175. ZONE.broadcastPacket(new SpecialCamera(_camera2, 2300, 100, 0, 2000, 4500, 0, 10, 1, 0, 0));
  176. startQuestTimer("SPAWN6", 2500, null, null);
  177. }
  178. case "SPAWN6":
  179. {
  180. final L2DoorInstance door = DoorData.getInstance().getDoor(DOOR1);
  181. door.closeMe();
  182. ZONE.broadcastPacket(new StaticObject(door, false));
  183. ZONE.broadcastPacket(new DoorStatusUpdate(door));
  184. startQuestTimer("SPAWN7", 1700, null, null);
  185. }
  186. case "SPAWN7":
  187. {
  188. ZONE.broadcastPacket(new SpecialCamera(_camera4, 1500, 210, 0, 0, 1500, 0, 0, 1, 0, 0));
  189. ZONE.broadcastPacket(new SpecialCamera(_camera4, 900, 255, 0, 5000, 6500, 0, 10, 1, 0, 0));
  190. startQuestTimer("SPAWN8", 6000, null, null);
  191. }
  192. case "SPAWN8":
  193. {
  194. _whirpool = addSpawn(WHIRPOOL, new Location(16323, 214917, -9356));
  195. ZONE.broadcastPacket(new SpecialCamera(_camera4, 900, 255, 0, 0, 1500, 0, 10, 1, 0, 0));
  196. startQuestTimer("SPAWN9", 1000, null, null);
  197. }
  198. case "SPAWN9":
  199. {
  200. ZONE.broadcastPacket(new SpecialCamera(_camera4, 1000, 255, 0, 7000, 17000, 0, 25, 1, 0, 0));
  201. startQuestTimer("SPAWN10", 3000, null, null);
  202. }
  203. case "SPAWN10":
  204. {
  205. _beleth = addSpawn(REAL_BELETH, new Location(16321, 214211, -9352, 49369));
  206. _beleth.disableAllSkills();
  207. _beleth.setIsInvul(true);
  208. _beleth.setIsImmobilized(true);
  209. startQuestTimer("SPAWN11", 200, null, null);
  210. }
  211. case "SPAWN11":
  212. {
  213. ZONE.broadcastPacket(new SocialAction(_beleth.getObjectId(), 1));
  214. for (int i = 0; i < 6; i++)
  215. {
  216. int x = (int) ((150 * Math.cos(i * 1.046666667)) + 16323);
  217. int y = (int) ((150 * Math.sin(i * 1.046666667)) + 213059);
  218. L2Npc minion = addSpawn(FAKE_BELETH, new Location(x, y, -9357, 49152));
  219. minion.setShowSummonAnimation(true);
  220. minion.decayMe();
  221. _minions.add(minion);
  222. }
  223. startQuestTimer("SPAWN12", 6800, null, null);
  224. }
  225. case "SPAWN12":
  226. {
  227. ZONE.broadcastPacket(new SpecialCamera(_beleth, 0, 270, -5, 0, 4000, 0, 0, 1, 0, 0));
  228. startQuestTimer("SPAWN13", 3500, null, null);
  229. }
  230. case "SPAWN13":
  231. {
  232. ZONE.broadcastPacket(new SpecialCamera(_beleth, 800, 270, 10, 3000, 6000, 0, 0, 1, 0, 0));
  233. startQuestTimer("SPAWN14", 5000, null, null);
  234. }
  235. case "SPAWN14":
  236. {
  237. ZONE.broadcastPacket(new SpecialCamera(_camera3, 100, 270, 15, 0, 5000, 0, 0, 1, 0, 0));
  238. ZONE.broadcastPacket(new SpecialCamera(_camera3, 100, 270, 15, 0, 5000, 0, 0, 1, 0, 0));
  239. startQuestTimer("SPAWN15", 100, null, null);
  240. }
  241. case "SPAWN15":
  242. {
  243. ZONE.broadcastPacket(new SpecialCamera(_camera3, 100, 270, 15, 3000, 6000, 0, 5, 1, 0, 0));
  244. startQuestTimer("SPAWN16", 1400, null, null);
  245. }
  246. case "SPAWN16":
  247. {
  248. _beleth.teleToLocation(BELETH_SPAWN);
  249. startQuestTimer("SPAWN17", 200, null, null);
  250. }
  251. case "SPAWN17":
  252. {
  253. ZONE.broadcastPacket(new MagicSkillUse(_beleth, _beleth, 5532, 1, 2000, 0));
  254. startQuestTimer("SPAWN18", 2000, null, null);
  255. }
  256. case "SPAWN18":
  257. {
  258. ZONE.broadcastPacket(new SpecialCamera(_camera3, 700, 270, 20, 1500, 8000, 0, 0, 1, 0, 0));
  259. startQuestTimer("SPAWN19", 6900, null, null);
  260. }
  261. case "SPAWN19":
  262. {
  263. ZONE.broadcastPacket(new SpecialCamera(_camera3, 40, 260, 0, 0, 4000, 0, 0, 1, 0, 0));
  264. for (L2Npc fakeBeleth : _minions)
  265. {
  266. fakeBeleth.spawnMe();
  267. fakeBeleth.disableAllSkills();
  268. fakeBeleth.setIsInvul(true);
  269. fakeBeleth.setIsImmobilized(true);
  270. }
  271. startQuestTimer("SPAWN20", 3000, null, null);
  272. }
  273. case "SPAWN20":
  274. {
  275. ZONE.broadcastPacket(new SpecialCamera(_camera3, 40, 280, 0, 0, 4000, 5, 0, 1, 0, 0));
  276. startQuestTimer("SPAWN21", 3000, null, null);
  277. }
  278. case "SPAWN21":
  279. {
  280. ZONE.broadcastPacket(new SpecialCamera(_camera3, 5, 250, 5, 0, 13000, 20, 15, 1, 0, 0));
  281. startQuestTimer("SPAWN22", 1000, null, null);
  282. }
  283. case "SPAWN22":
  284. {
  285. ZONE.broadcastPacket(new SocialAction(_beleth.getObjectId(), 3));
  286. startQuestTimer("SPAWN23", 4000, null, null);
  287. }
  288. case "SPAWN23":
  289. {
  290. ZONE.broadcastPacket(new MagicSkillUse(_beleth, _beleth, 5533, 1, 2000, 0));
  291. startQuestTimer("SPAWN24", 6800, null, null);
  292. }
  293. case "SPAWN24":
  294. {
  295. _beleth.deleteMe();
  296. _beleth = null;
  297. for (L2Npc fakeBeleth : _minions)
  298. {
  299. fakeBeleth.deleteMe();
  300. }
  301. _minions.clear();
  302. _camera1.deleteMe();
  303. _camera2.deleteMe();
  304. _camera3.deleteMe();
  305. _camera4.deleteMe();
  306. for (L2Character c : ZONE.getCharactersInside())
  307. {
  308. c.enableAllSkills();
  309. c.setIsInvul(false);
  310. c.setIsImmobilized(false);
  311. }
  312. startQuestTimer("SPAWN25", 60000, null, null);
  313. }
  314. case "SPAWN25":
  315. {
  316. int a = 0;
  317. for (int i = 0; i < 16; i++)
  318. {
  319. a++;
  320. int x = (int) ((650 * Math.cos(i * 0.39)) + 16323);
  321. int y = (int) ((650 * Math.sin(i * 0.39)) + 213170);
  322. npc = addSpawn(FAKE_BELETH, new Location(x, y, -9357, 49152));
  323. _minions.add(npc);
  324. if (a >= 2)
  325. {
  326. npc.setIsOverloaded(true);
  327. a = 0;
  328. }
  329. }
  330. int[] xm = new int[16];
  331. int[] ym = new int[16];
  332. for (int i = 0; i < 4; i++)
  333. {
  334. xm[i] = (int) ((1700 * Math.cos((i * 1.57) + 0.78)) + 16323);
  335. ym[i] = (int) ((1700 * Math.sin((i * 1.57) + 0.78)) + 213170);
  336. npc = addSpawn(FAKE_BELETH, new Location(xm[i], ym[i], -9357, 49152));
  337. npc.setIsImmobilized(true);
  338. _minions.add(npc);
  339. }
  340. xm[4] = (xm[0] + xm[1]) / 2;
  341. ym[4] = (ym[0] + ym[1]) / 2;
  342. npc = addSpawn(FAKE_BELETH, new Location(xm[4], ym[4], -9357, 49152));
  343. npc.setIsImmobilized(true);
  344. _minions.add(npc);
  345. xm[5] = (xm[1] + xm[2]) / 2;
  346. ym[5] = (ym[1] + ym[2]) / 2;
  347. npc = addSpawn(FAKE_BELETH, new Location(xm[5], ym[5], -9357, 49152));
  348. npc.setIsImmobilized(true);
  349. _minions.add(npc);
  350. xm[6] = (xm[2] + xm[3]) / 2;
  351. ym[6] = (ym[2] + ym[3]) / 2;
  352. npc = addSpawn(FAKE_BELETH, new Location(xm[6], ym[6], -9357, 49152));
  353. npc.setIsImmobilized(true);
  354. _minions.add(npc);
  355. xm[7] = (xm[3] + xm[0]) / 2;
  356. ym[7] = (ym[3] + ym[0]) / 2;
  357. npc = addSpawn(FAKE_BELETH, new Location(xm[7], ym[7], -9357, 49152));
  358. npc.setIsImmobilized(true);
  359. _minions.add(npc);
  360. xm[8] = (xm[0] + xm[4]) / 2;
  361. ym[8] = (ym[0] + ym[4]) / 2;
  362. _minions.add(addSpawn(FAKE_BELETH, new Location(xm[8], ym[8], -9357, 49152)));
  363. xm[9] = (xm[4] + xm[1]) / 2;
  364. ym[9] = (ym[4] + ym[1]) / 2;
  365. _minions.add(addSpawn(FAKE_BELETH, new Location(xm[9], ym[9], -9357, 49152)));
  366. xm[10] = (xm[1] + xm[5]) / 2;
  367. ym[10] = (ym[1] + ym[5]) / 2;
  368. _minions.add(addSpawn(FAKE_BELETH, new Location(xm[10], ym[10], -9357, 49152)));
  369. xm[11] = (xm[5] + xm[2]) / 2;
  370. ym[11] = (ym[5] + ym[2]) / 2;
  371. _minions.add(addSpawn(FAKE_BELETH, new Location(xm[11], ym[11], -9357, 49152)));
  372. xm[12] = (xm[2] + xm[6]) / 2;
  373. ym[12] = (ym[2] + ym[6]) / 2;
  374. _minions.add(addSpawn(FAKE_BELETH, new Location(xm[12], ym[12], -9357, 49152)));
  375. xm[13] = (xm[6] + xm[3]) / 2;
  376. ym[13] = (ym[6] + ym[3]) / 2;
  377. _minions.add(addSpawn(FAKE_BELETH, new Location(xm[13], ym[13], -9357, 49152)));
  378. xm[14] = (xm[3] + xm[7]) / 2;
  379. ym[14] = (ym[3] + ym[7]) / 2;
  380. _minions.add(addSpawn(FAKE_BELETH, new Location(xm[14], ym[14], -9357, 49152)));
  381. xm[15] = (xm[7] + xm[0]) / 2;
  382. ym[15] = (ym[7] + ym[0]) / 2;
  383. _minions.add(addSpawn(FAKE_BELETH, new Location(xm[15], ym[15], -9357, 49152)));
  384. _allowedObjId = _minions.get(getRandom(_minions.size())).getObjectId();
  385. }
  386. case "SPAWN_REAL":
  387. {
  388. _beleth = addSpawn(REAL_BELETH, new Location(16323, 213170, -9357, 49152));
  389. }
  390. case "SPAWN26":
  391. {
  392. _beleth.doDie(null);
  393. _camera1 = addSpawn(29122, new Location(16323, 213170, -9357));
  394. _camera1.broadcastPacket(new PlaySound(1, "BS07_D", 1, _camera1.getObjectId(), _camera1.getX(), _camera1.getY(), _camera1.getZ()));
  395. ZONE.broadcastPacket(new SpecialCamera(_camera1, 400, 290, 25, 0, 10000, 0, 0, 1, 0, 0));
  396. ZONE.broadcastPacket(new SpecialCamera(_camera1, 400, 290, 25, 0, 10000, 0, 0, 1, 0, 0));
  397. ZONE.broadcastPacket(new SpecialCamera(_camera1, 400, 110, 25, 4000, 10000, 0, 0, 1, 0, 0));
  398. ZONE.broadcastPacket(new SocialAction(_beleth.getObjectId(), 5));
  399. startQuestTimer("SPAWN27", 4000, null, null);
  400. }
  401. case "SPAWN27":
  402. {
  403. ZONE.broadcastPacket(new SpecialCamera(_camera1, 400, 295, 25, 4000, 5000, 0, 0, 1, 0, 0));
  404. startQuestTimer("SPAWN28", 4500, null, null);
  405. }
  406. case "SPAWN28":
  407. {
  408. ZONE.broadcastPacket(new SpecialCamera(_camera1, 400, 295, 10, 4000, 11000, 0, 25, 1, 0, 0));
  409. startQuestTimer("SPAWN29", 9000, null, null);
  410. }
  411. case "SPAWN29":
  412. {
  413. ZONE.broadcastPacket(new SpecialCamera(_camera1, 250, 90, 25, 0, 1000, 0, 0, 1, 0, 0));
  414. ZONE.broadcastPacket(new SpecialCamera(_camera1, 250, 90, 25, 0, 10000, 0, 0, 1, 0, 0));
  415. startQuestTimer("SPAWN30", 2000, null, null);
  416. }
  417. case "SPAWN30":
  418. {
  419. _priest.spawnMe();
  420. _beleth.deleteMe();
  421. _camera2 = addSpawn(29121, new Location(14056, 213170, -9357));
  422. startQuestTimer("SPAWN31", 3500, null, null);
  423. }
  424. case "SPAWN31":
  425. {
  426. ZONE.broadcastPacket(new SpecialCamera(_camera2, 800, 180, 0, 0, 4000, 0, 10, 1, 0, 0));
  427. ZONE.broadcastPacket(new SpecialCamera(_camera2, 800, 180, 0, 0, 4000, 0, 10, 1, 0, 0));
  428. L2DoorInstance door2 = DoorData.getInstance().getDoor(DOOR2);
  429. door2.openMe();
  430. ZONE.broadcastPacket(new StaticObject(door2, false));
  431. ZONE.broadcastPacket(new DoorStatusUpdate(door2));
  432. DoorData.getInstance().getDoor(DOOR3).openMe();
  433. _camera1.deleteMe();
  434. _camera2.deleteMe();
  435. _whirpool.deleteMe();
  436. for (L2Character c : ZONE.getCharactersInside())
  437. {
  438. c.enableAllSkills();
  439. c.setIsInvul(false);
  440. c.setIsImmobilized(false);
  441. }
  442. }
  443. }
  444. return super.onAdvEvent(event, npc, player);
  445. }
  446. @Override
  447. public String onEnterZone(L2Character character, L2ZoneType zone)
  448. {
  449. if (character.isPlayer() && (GrandBossManager.getInstance().getBossStatus(REAL_BELETH) == INIT))
  450. {
  451. if (_priest != null)
  452. {
  453. _priest.deleteMe();
  454. }
  455. if (_stone != null)
  456. {
  457. _stone.deleteMe();
  458. }
  459. GrandBossManager.getInstance().setBossStatus(REAL_BELETH, FIGHT);
  460. startQuestTimer("SPAWN1", 300000, null, null);
  461. }
  462. return super.onEnterZone(character, zone);
  463. }
  464. @Override
  465. public String onSkillSee(L2Npc npc, L2PcInstance player, Skill skill, L2Object[] targets, boolean isSummon)
  466. {
  467. if (!npc.isDead() && (npc.getId() == REAL_BELETH) && !npc.isCastingNow() && skill.hasEffectType(L2EffectType.HEAL) && (getRandom(100) < 80))
  468. {
  469. npc.setTarget(player);
  470. npc.doCast(HORN_OF_RISING.getSkill());
  471. }
  472. return null;
  473. }
  474. @Override
  475. public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isSummon)
  476. {
  477. if (!npc.isDead() && !npc.isCastingNow())
  478. {
  479. if (getRandom(100) < 40)
  480. {
  481. if (!npc.getKnownList().getKnownPlayersInRadius(200).isEmpty())
  482. {
  483. npc.doCast(BLEED.getSkill());
  484. return null;
  485. }
  486. }
  487. npc.setTarget(player);
  488. npc.doCast(FIREBALL.getSkill());
  489. }
  490. return null;
  491. }
  492. @Override
  493. public String onSpellFinished(L2Npc npc, L2PcInstance player, Skill skill)
  494. {
  495. if (!npc.isDead() && !npc.isCastingNow())
  496. {
  497. if (!player.isDead())
  498. {
  499. final double distance2 = npc.calculateDistance(player, false, false);
  500. if ((distance2 > 890) && !npc.isMovementDisabled())
  501. {
  502. npc.setTarget(player);
  503. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, player);
  504. double speed = npc.isRunning() ? npc.getRunSpeed() : npc.getWalkSpeed();
  505. int time = (int) (((distance2 - 890) / speed) * 1000);
  506. startQuestTimer("CAST", time, npc, null);
  507. }
  508. else if (distance2 < 890)
  509. {
  510. npc.setTarget(player);
  511. npc.doCast(FIREBALL.getSkill());
  512. }
  513. return null;
  514. }
  515. if (getRandom(100) < 40)
  516. {
  517. if (!npc.getKnownList().getKnownPlayersInRadius(200).isEmpty())
  518. {
  519. npc.doCast(LIGHTENING.getSkill());
  520. return null;
  521. }
  522. }
  523. for (L2PcInstance plr : npc.getKnownList().getKnownPlayersInRadius(950))
  524. {
  525. npc.setTarget(plr);
  526. npc.doCast(FIREBALL.getSkill());
  527. return null;
  528. }
  529. ((L2Attackable) npc).clearAggroList();
  530. }
  531. return null;
  532. }
  533. @Override
  534. public String onSpawn(L2Npc npc)
  535. {
  536. npc.setRunning();
  537. if (!npc.getKnownList().getKnownPlayersInRadius(300).isEmpty() && (getRandom(100) < 60))
  538. {
  539. npc.doCast(BLEED.getSkill());
  540. }
  541. if (npc.getId() == REAL_BELETH)
  542. {
  543. npc.getSpawn().setRespawnDelay(0);
  544. }
  545. return null;
  546. }
  547. @Override
  548. public String onTalk(L2Npc npc, L2PcInstance player)
  549. {
  550. String html;
  551. if ((_killer != null) && (player.getObjectId() == _killer.getObjectId()))
  552. {
  553. _killer = null;
  554. giveItems(player, RING);
  555. html = "32470a.htm";
  556. }
  557. else
  558. {
  559. html = "32470b.htm";
  560. }
  561. return HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "data/html/default/" + html);
  562. }
  563. @Override
  564. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  565. {
  566. return onTalk(npc, player);
  567. }
  568. @Override
  569. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon)
  570. {
  571. if (getRandom(100) < 40)
  572. {
  573. return null;
  574. }
  575. final double distance = npc.calculateDistance(attacker, false, false);
  576. if ((distance > 500) || (getRandom(100) < 80))
  577. {
  578. for (L2Npc beleth : _minions)
  579. {
  580. if ((beleth != null) && !beleth.isDead() && Util.checkIfInRange(900, beleth, attacker, false) && !beleth.isCastingNow())
  581. {
  582. beleth.setTarget(attacker);
  583. beleth.doCast(FIREBALL.getSkill());
  584. }
  585. }
  586. if ((_beleth != null) && !_beleth.isDead() && Util.checkIfInRange(900, _beleth, attacker, false) && !_beleth.isCastingNow())
  587. {
  588. _beleth.setTarget(attacker);
  589. _beleth.doCast(FIREBALL.getSkill());
  590. }
  591. }
  592. else if (!npc.isDead() && !npc.isCastingNow())
  593. {
  594. if (!npc.getKnownList().getKnownPlayersInRadius(200).isEmpty())
  595. {
  596. npc.doCast(LIGHTENING.getSkill());
  597. return null;
  598. }
  599. ((L2Attackable) npc).clearAggroList();
  600. }
  601. return null;
  602. }
  603. @Override
  604. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  605. {
  606. if (npc.getId() == REAL_BELETH)
  607. {
  608. setBelethKiller(killer);
  609. GrandBossManager.getInstance().setBossStatus(REAL_BELETH, DEAD);
  610. final long respawnTime = (Config.BELETH_SPAWN_INTERVAL + getRandom(-Config.BELETH_SPAWN_RANDOM, Config.BELETH_SPAWN_RANDOM)) * 3600000;
  611. StatsSet info = GrandBossManager.getInstance().getStatsSet(REAL_BELETH);
  612. info.set("respawn_time", System.currentTimeMillis() + respawnTime);
  613. GrandBossManager.getInstance().setStatsSet(REAL_BELETH, info);
  614. startQuestTimer("BELETH_UNLOCK", respawnTime, null, null);
  615. deleteAll();
  616. npc.deleteMe();
  617. for (L2Character c : ZONE.getCharactersInside())
  618. {
  619. c.disableAllSkills();
  620. c.setIsInvul(true);
  621. c.setIsImmobilized(true);
  622. }
  623. _beleth = addSpawn(REAL_BELETH, new Location(16323, 213170, -9357, 49152));
  624. _beleth.disableAllSkills();
  625. _beleth.setIsInvul(true);
  626. _beleth.setIsImmobilized(true);
  627. _priest = addSpawn(ELF, new Location(_beleth));
  628. _priest.setShowSummonAnimation(true);
  629. _priest.decayMe();
  630. _stone = addSpawn(STONE_COFFIN, new Location(12470, 215607, -9381, 49152));
  631. startQuestTimer("SPAWN26", 1000, null, null);
  632. }
  633. else if ((npc.getId() == FAKE_BELETH) && (npc.getObjectId() == _allowedObjId))
  634. {
  635. deleteAll();
  636. _killedCount++;
  637. if (_killedCount >= 5)
  638. {
  639. startQuestTimer("SPAWN_REAL", 60000, null, null);
  640. }
  641. else
  642. {
  643. startQuestTimer("SPAWN25", 60000, null, null);
  644. }
  645. }
  646. return null;
  647. }
  648. private void setBelethKiller(L2PcInstance killer)
  649. {
  650. if (killer.getParty() != null)
  651. {
  652. if (killer.getParty().getCommandChannel() != null)
  653. {
  654. _killer = killer.getParty().getCommandChannel().getLeader();
  655. }
  656. else
  657. {
  658. _killer = killer.getParty().getLeader();
  659. }
  660. }
  661. else
  662. {
  663. _killer = killer;
  664. }
  665. }
  666. private void deleteAll()
  667. {
  668. _minions.stream().filter(n -> !n.isDead()).forEach(n ->
  669. {
  670. n.abortCast();
  671. n.setTarget(null);
  672. n.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  673. n.deleteMe();
  674. });
  675. _allowedObjId = 0;
  676. }
  677. public static void main(String[] args)
  678. {
  679. new Beleth();
  680. }
  681. }