Antharas.java 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052
  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.Antharas;
  20. import java.util.HashMap;
  21. import java.util.List;
  22. import java.util.Map;
  23. import ai.npc.AbstractNpcAI;
  24. import com.l2jserver.Config;
  25. import com.l2jserver.gameserver.ai.CtrlIntention;
  26. import com.l2jserver.gameserver.enums.MountType;
  27. import com.l2jserver.gameserver.instancemanager.GrandBossManager;
  28. import com.l2jserver.gameserver.instancemanager.ZoneManager;
  29. import com.l2jserver.gameserver.model.L2Party;
  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.L2GrandBossInstance;
  36. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  37. import com.l2jserver.gameserver.model.holders.SkillHolder;
  38. import com.l2jserver.gameserver.model.skills.Skill;
  39. import com.l2jserver.gameserver.model.zone.type.L2NoRestartZone;
  40. import com.l2jserver.gameserver.network.NpcStringId;
  41. import com.l2jserver.gameserver.network.serverpackets.Earthquake;
  42. import com.l2jserver.gameserver.network.serverpackets.ExShowScreenMessage;
  43. import com.l2jserver.gameserver.network.serverpackets.PlaySound;
  44. import com.l2jserver.gameserver.network.serverpackets.SocialAction;
  45. import com.l2jserver.gameserver.network.serverpackets.SpecialCamera;
  46. import com.l2jserver.gameserver.util.Broadcast;
  47. import com.l2jserver.gameserver.util.Util;
  48. /**
  49. * Antharas AI.
  50. * @author St3eT
  51. */
  52. public final class Antharas extends AbstractNpcAI
  53. {
  54. // NPC
  55. private static final int ANTHARAS = 29068; // Antharas
  56. private static final int BEHEMOTH = 29069; // Behemoth Dragon
  57. private static final int TERASQUE = 29190; // Tarask Dragon
  58. private static final int BOMBER = 29070; // Dragon Bomber
  59. private static final int HEART = 13001; // Heart of Warding
  60. private static final int CUBE = 31859; // Teleportation Cubic
  61. private static final Map<Integer, Location> INVISIBLE_NPC = new HashMap<>();
  62. {
  63. INVISIBLE_NPC.put(29077, new Location(177229, 113298, -7735)); // antaras_clear_npc_1
  64. INVISIBLE_NPC.put(29078, new Location(176707, 113585, -7735)); // antaras_clear_npc_2
  65. INVISIBLE_NPC.put(29079, new Location(176385, 113889, -7735)); // antaras_clear_npc_3
  66. INVISIBLE_NPC.put(29080, new Location(176082, 114241, -7735)); // antaras_clear_npc_4
  67. INVISIBLE_NPC.put(29081, new Location(176066, 114802, -7735)); // antaras_clear_npc_5
  68. INVISIBLE_NPC.put(29082, new Location(176095, 115313, -7735)); // antaras_clear_npc_6
  69. INVISIBLE_NPC.put(29083, new Location(176425, 115829, -7735)); // antaras_clear_npc_7
  70. INVISIBLE_NPC.put(29084, new Location(176949, 116378, -7735)); // antaras_clear_npc_8
  71. INVISIBLE_NPC.put(29085, new Location(177655, 116402, -7735)); // antaras_clear_npc_9
  72. INVISIBLE_NPC.put(29086, new Location(178248, 116395, -7735)); // antaras_clear_npc_10
  73. INVISIBLE_NPC.put(29087, new Location(178706, 115998, -7735)); // antaras_clear_npc_11
  74. INVISIBLE_NPC.put(29088, new Location(179208, 115452, -7735)); // antaras_clear_npc_12
  75. INVISIBLE_NPC.put(29089, new Location(179191, 115079, -7735)); // antaras_clear_npc_13
  76. INVISIBLE_NPC.put(29090, new Location(179221, 114546, -7735)); // antaras_clear_npc_14
  77. INVISIBLE_NPC.put(29091, new Location(178916, 113925, -7735)); // antaras_clear_npc_15
  78. INVISIBLE_NPC.put(29092, new Location(178782, 113814, -7735)); // antaras_clear_npc_16
  79. INVISIBLE_NPC.put(29093, new Location(178419, 113417, -7735)); // antaras_clear_npc_17
  80. INVISIBLE_NPC.put(29094, new Location(177855, 113282, -7735)); // antaras_clear_npc_18
  81. }
  82. // Item
  83. private static final int STONE = 3865; // Portal Stone
  84. // Skill
  85. private static final SkillHolder ANTH_JUMP = new SkillHolder(4106, 1); // Antharas Stun
  86. private static final SkillHolder ANTH_TAIL = new SkillHolder(4107, 1); // Antharas Stun
  87. private static final SkillHolder ANTH_FEAR = new SkillHolder(4108, 1); // Antharas Terror
  88. private static final SkillHolder ANTH_DEBUFF = new SkillHolder(4109, 1); // Curse of Antharas
  89. private static final SkillHolder ANTH_MOUTH = new SkillHolder(4110, 2); // Breath Attack
  90. private static final SkillHolder ANTH_BREATH = new SkillHolder(4111, 1); // Antharas Fossilization
  91. private static final SkillHolder ANTH_NORM_ATTACK = new SkillHolder(4112, 1); // Ordinary Attack
  92. private static final SkillHolder ANTH_NORM_ATTACK_EX = new SkillHolder(4113, 1); // Animal doing ordinary attack
  93. private static final SkillHolder ANTH_REGEN_1 = new SkillHolder(4125, 1); // Antharas Regeneration
  94. private static final SkillHolder ANTH_REGEN_2 = new SkillHolder(4239, 1); // Antharas Regeneration
  95. private static final SkillHolder ANTH_REGEN_3 = new SkillHolder(4240, 1); // Antharas Regeneration
  96. private static final SkillHolder ANTH_REGEN_4 = new SkillHolder(4241, 1); // Antharas Regeneration
  97. private static final SkillHolder DISPEL_BOM = new SkillHolder(5042, 1); // NPC Dispel Bomb
  98. private static final SkillHolder ANTH_ANTI_STRIDER = new SkillHolder(4258, 1); // Hinder Strider
  99. private static final SkillHolder ANTH_FEAR_SHORT = new SkillHolder(5092, 1); // Antharas Terror
  100. private static final SkillHolder ANTH_METEOR = new SkillHolder(5093, 1); // Antharas Meteor
  101. // Zone
  102. private static final L2NoRestartZone zone = ZoneManager.getInstance().getZoneById(70050, L2NoRestartZone.class); // Antharas Nest zone
  103. // Status
  104. private static final int ALIVE = 0;
  105. private static final int WAITING = 1;
  106. private static final int IN_FIGHT = 2;
  107. private static final int DEAD = 3;
  108. // Misc
  109. private static final int MAX_PEOPLE = 200; // Max allowed players
  110. private L2GrandBossInstance _antharas = null;
  111. private static long _lastAttack = 0;
  112. private static int _minionCount = 0;
  113. private static int minionMultipler = 0;
  114. private static int moveChance = 0;
  115. private static int sandStorm = 0;
  116. private static L2PcInstance attacker_1 = null;
  117. private static L2PcInstance attacker_2 = null;
  118. private static L2PcInstance attacker_3 = null;
  119. private static int attacker_1_hate = 0;
  120. private static int attacker_2_hate = 0;
  121. private static int attacker_3_hate = 0;
  122. private Antharas()
  123. {
  124. super(Antharas.class.getSimpleName(), "ai/individual");
  125. addStartNpc(HEART, CUBE);
  126. addTalkId(HEART, CUBE);
  127. addFirstTalkId(HEART);
  128. addSpawnId(INVISIBLE_NPC.keySet());
  129. addSpawnId(ANTHARAS);
  130. addMoveFinishedId(BOMBER);
  131. addAggroRangeEnterId(BOMBER);
  132. addSpellFinishedId(ANTHARAS);
  133. addAttackId(ANTHARAS, BOMBER, BEHEMOTH, TERASQUE);
  134. addKillId(ANTHARAS, TERASQUE, BEHEMOTH);
  135. final StatsSet info = GrandBossManager.getInstance().getStatsSet(ANTHARAS);
  136. final int curr_hp = info.getInt("currentHP");
  137. final int curr_mp = info.getInt("currentMP");
  138. final int loc_x = info.getInt("loc_x");
  139. final int loc_y = info.getInt("loc_y");
  140. final int loc_z = info.getInt("loc_z");
  141. final int heading = info.getInt("heading");
  142. final long respawnTime = info.getLong("respawn_time");
  143. switch (getStatus())
  144. {
  145. case ALIVE:
  146. {
  147. _antharas = (L2GrandBossInstance) addSpawn(ANTHARAS, 185708, 114298, -8221, 0, false, 0);
  148. _antharas.setCurrentHpMp(curr_hp, curr_mp);
  149. addBoss(_antharas);
  150. break;
  151. }
  152. case WAITING:
  153. {
  154. _antharas = (L2GrandBossInstance) addSpawn(ANTHARAS, 185708, 114298, -8221, 0, false, 0);
  155. _antharas.setCurrentHpMp(curr_hp, curr_mp);
  156. addBoss(_antharas);
  157. startQuestTimer("SPAWN_ANTHARAS", Config.ANTHARAS_WAIT_TIME * 60000, null, null);
  158. break;
  159. }
  160. case IN_FIGHT:
  161. {
  162. _antharas = (L2GrandBossInstance) addSpawn(ANTHARAS, loc_x, loc_y, loc_z, heading, false, 0);
  163. _antharas.setCurrentHpMp(curr_hp, curr_mp);
  164. addBoss(_antharas);
  165. _lastAttack = System.currentTimeMillis();
  166. startQuestTimer("CHECK_ATTACK", 60000, _antharas, null);
  167. startQuestTimer("SPAWN_MINION", 300000, _antharas, null);
  168. break;
  169. }
  170. case DEAD:
  171. {
  172. final long remain = respawnTime - System.currentTimeMillis();
  173. if (remain > 0)
  174. {
  175. startQuestTimer("CLEAR_STATUS", remain, null, null);
  176. }
  177. else
  178. {
  179. setStatus(ALIVE);
  180. _antharas = (L2GrandBossInstance) addSpawn(ANTHARAS, 185708, 114298, -8221, 0, false, 0);
  181. addBoss(_antharas);
  182. }
  183. break;
  184. }
  185. }
  186. }
  187. @Override
  188. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  189. {
  190. switch (event)
  191. {
  192. case "enter":
  193. {
  194. String htmltext = null;
  195. if (getStatus() == DEAD)
  196. {
  197. htmltext = "13001-01.html";
  198. }
  199. else if (getStatus() == IN_FIGHT)
  200. {
  201. htmltext = "13001-02.html";
  202. }
  203. else if (zone.getPlayersInside().size() >= MAX_PEOPLE)
  204. {
  205. htmltext = "13001-04.html";
  206. }
  207. else if (player.isInParty())
  208. {
  209. final L2Party party = player.getParty();
  210. final boolean isInCC = party.isInCommandChannel();
  211. final List<L2PcInstance> members = (isInCC) ? party.getCommandChannel().getMembers() : party.getMembers();
  212. final boolean isPartyLeader = (isInCC) ? party.getCommandChannel().isLeader(player) : party.isLeader(player);
  213. if (!isPartyLeader)
  214. {
  215. htmltext = "13001-05.html";
  216. }
  217. else if (!hasQuestItems(player, STONE))
  218. {
  219. htmltext = "13001-03.html";
  220. }
  221. else if (members.size() > (MAX_PEOPLE - zone.getPlayersInside().size()))
  222. {
  223. htmltext = "13001-04.html";
  224. }
  225. else
  226. {
  227. for (L2PcInstance member : members)
  228. {
  229. if (member.isInsideRadius(npc, 1000, true, false))
  230. {
  231. member.teleToLocation(179700 + getRandom(700), 113800 + getRandom(2100), -7709);
  232. }
  233. }
  234. if (getStatus() != WAITING)
  235. {
  236. setStatus(WAITING);
  237. startQuestTimer("SPAWN_ANTHARAS", Config.ANTHARAS_WAIT_TIME * 60000, null, null);
  238. }
  239. }
  240. }
  241. else
  242. {
  243. if (!hasQuestItems(player, STONE))
  244. {
  245. htmltext = "13001-03.html";
  246. }
  247. else
  248. {
  249. player.teleToLocation(179700 + getRandom(700), 113800 + getRandom(2100), -7709);
  250. if (getStatus() != WAITING)
  251. {
  252. setStatus(WAITING);
  253. startQuestTimer("SPAWN_ANTHARAS", Config.ANTHARAS_WAIT_TIME * 60000, null, null);
  254. }
  255. }
  256. }
  257. return htmltext;
  258. }
  259. case "teleportOut":
  260. {
  261. player.teleToLocation(79800 + getRandom(600), 151200 + getRandom(1100), -3534);
  262. break;
  263. }
  264. case "SPAWN_ANTHARAS":
  265. {
  266. _antharas.teleToLocation(181323, 114850, -7623, 32542);
  267. setStatus(IN_FIGHT);
  268. _lastAttack = System.currentTimeMillis();
  269. zone.broadcastPacket(new PlaySound("BS02_A"));
  270. startQuestTimer("CAMERA_1", 23, _antharas, null);
  271. break;
  272. }
  273. case "CAMERA_1":
  274. {
  275. zone.broadcastPacket(new SpecialCamera(npc, 700, 13, -19, 0, 10000, 20000, 0, 0, 0, 0, 0));
  276. startQuestTimer("CAMERA_2", 3000, npc, null);
  277. break;
  278. }
  279. case "CAMERA_2":
  280. {
  281. zone.broadcastPacket(new SpecialCamera(npc, 700, 13, 0, 6000, 10000, 20000, 0, 0, 0, 0, 0));
  282. startQuestTimer("CAMERA_3", 10000, npc, null);
  283. break;
  284. }
  285. case "CAMERA_3":
  286. {
  287. zone.broadcastPacket(new SpecialCamera(npc, 3700, 0, -3, 0, 10000, 10000, 0, 0, 0, 0, 0));
  288. zone.broadcastPacket(new SocialAction(npc.getObjectId(), 1));
  289. startQuestTimer("CAMERA_4", 200, npc, null);
  290. startQuestTimer("SOCIAL", 5200, npc, null);
  291. break;
  292. }
  293. case "CAMERA_4":
  294. {
  295. zone.broadcastPacket(new SpecialCamera(npc, 1100, 0, -3, 22000, 10000, 30000, 0, 0, 0, 0, 0));
  296. startQuestTimer("CAMERA_5", 10800, npc, null);
  297. break;
  298. }
  299. case "CAMERA_5":
  300. {
  301. zone.broadcastPacket(new SpecialCamera(npc, 1100, 0, -3, 300, 10000, 7000, 0, 0, 0, 0, 0));
  302. startQuestTimer("START_MOVE", 1900, npc, null);
  303. break;
  304. }
  305. case "SOCIAL":
  306. {
  307. zone.broadcastPacket(new SocialAction(npc.getObjectId(), 2));
  308. break;
  309. }
  310. case "START_MOVE":
  311. {
  312. for (L2PcInstance players : npc.getKnownList().getKnownPlayersInRadius(4000))
  313. {
  314. if (players.isHero())
  315. {
  316. zone.broadcastPacket(new ExShowScreenMessage(NpcStringId.S1_YOU_CANNOT_HOPE_TO_DEFEAT_ME_WITH_YOUR_MEAGER_STRENGTH, 2, 4000, players.getName()));
  317. break;
  318. }
  319. }
  320. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(179011, 114871, -7704));
  321. startQuestTimer("CHECK_ATTACK", 60000, npc, null);
  322. startQuestTimer("SPAWN_MINION", 300000, npc, null);
  323. break;
  324. }
  325. case "SET_REGEN":
  326. {
  327. if (npc != null)
  328. {
  329. if (npc.getCurrentHp() < (npc.getMaxHp() * 0.25))
  330. {
  331. if (!npc.isAffectedBySkill(ANTH_REGEN_4.getSkillId()))
  332. {
  333. npc.doCast(ANTH_REGEN_4.getSkill());
  334. }
  335. }
  336. else if (npc.getCurrentHp() < (npc.getMaxHp() * 0.5))
  337. {
  338. if (!npc.isAffectedBySkill(ANTH_REGEN_3.getSkillId()))
  339. {
  340. npc.doCast(ANTH_REGEN_3.getSkill());
  341. }
  342. }
  343. else if (npc.getCurrentHp() < (npc.getMaxHp() * 0.75))
  344. {
  345. if (!npc.isAffectedBySkill(ANTH_REGEN_2.getSkillId()))
  346. {
  347. npc.doCast(ANTH_REGEN_2.getSkill());
  348. }
  349. }
  350. else if (!npc.isAffectedBySkill(ANTH_REGEN_1.getSkillId()))
  351. {
  352. npc.doCast(ANTH_REGEN_1.getSkill());
  353. }
  354. startQuestTimer("SET_REGEN", 60000, npc, null);
  355. }
  356. break;
  357. }
  358. case "CHECK_ATTACK":
  359. {
  360. if ((npc != null) && ((_lastAttack + 900000) < System.currentTimeMillis()))
  361. {
  362. setStatus(ALIVE);
  363. for (L2Character charInside : zone.getCharactersInside())
  364. {
  365. if (charInside != null)
  366. {
  367. if (charInside.isNpc())
  368. {
  369. if (charInside.getId() == ANTHARAS)
  370. {
  371. charInside.teleToLocation(185708, 114298, -8221);
  372. }
  373. else
  374. {
  375. charInside.deleteMe();
  376. }
  377. }
  378. else if (charInside.isPlayer())
  379. {
  380. charInside.teleToLocation(79800 + getRandom(600), 151200 + getRandom(1100), -3534);
  381. }
  382. }
  383. }
  384. cancelQuestTimer("CHECK_ATTACK", npc, null);
  385. cancelQuestTimer("SPAWN_MINION", npc, null);
  386. }
  387. else if (npc != null)
  388. {
  389. if (attacker_1_hate > 10)
  390. {
  391. attacker_1_hate -= getRandom(10);
  392. }
  393. if (attacker_2_hate > 10)
  394. {
  395. attacker_2_hate -= getRandom(10);
  396. }
  397. if (attacker_3_hate > 10)
  398. {
  399. attacker_3_hate -= getRandom(10);
  400. }
  401. manageSkills(npc);
  402. startQuestTimer("CHECK_ATTACK", 60000, npc, null);
  403. }
  404. break;
  405. }
  406. case "SPAWN_MINION":
  407. {
  408. if ((minionMultipler > 1) && (_minionCount < (100 - (minionMultipler * 2))))
  409. {
  410. for (int i = 0; i < minionMultipler; i++)
  411. {
  412. addSpawn(BEHEMOTH, npc, true);
  413. addSpawn(TERASQUE, npc, true);
  414. }
  415. _minionCount += (minionMultipler * 2);
  416. }
  417. else if (_minionCount < 98)
  418. {
  419. addSpawn(BEHEMOTH, npc, true);
  420. addSpawn(TERASQUE, npc, true);
  421. _minionCount += 2;
  422. }
  423. else if (_minionCount < 99)
  424. {
  425. addSpawn((getRandomBoolean() ? BEHEMOTH : TERASQUE), npc, true);
  426. _minionCount++;
  427. }
  428. if ((getRandom(100) > 10) && (minionMultipler < 4))
  429. {
  430. minionMultipler++;
  431. }
  432. startQuestTimer("SPAWN_MINION", 300000, npc, null);
  433. break;
  434. }
  435. case "CLEAR_ZONE":
  436. {
  437. for (L2Character charInside : zone.getCharactersInside())
  438. {
  439. if (charInside != null)
  440. {
  441. if (charInside.isNpc())
  442. {
  443. charInside.deleteMe();
  444. }
  445. else if (charInside.isPlayer())
  446. {
  447. charInside.teleToLocation(79800 + getRandom(600), 151200 + getRandom(1100), -3534);
  448. }
  449. }
  450. }
  451. break;
  452. }
  453. case "TID_USED_FEAR":
  454. {
  455. if ((npc != null) && (sandStorm == 0))
  456. {
  457. sandStorm = 1;
  458. npc.disableCoreAI(true);
  459. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(177648, 114816, -7735));
  460. startQuestTimer("TID_FEAR_MOVE_TIMEOVER", 2000, npc, null);
  461. startQuestTimer("TID_FEAR_COOLTIME", 300000, npc, null);
  462. }
  463. break;
  464. }
  465. case "TID_FEAR_COOLTIME":
  466. {
  467. sandStorm = 0;
  468. break;
  469. }
  470. case "TID_FEAR_MOVE_TIMEOVER":
  471. {
  472. if ((sandStorm == 1) && (npc.getX() == 177648) && (npc.getY() == 114816))
  473. {
  474. sandStorm = 2;
  475. moveChance = 0;
  476. npc.disableCoreAI(false);
  477. INVISIBLE_NPC.entrySet().forEach(entry -> addSpawn(entry.getKey(), entry.getValue()));
  478. }
  479. else if (sandStorm == 1)
  480. {
  481. if (moveChance <= 3)
  482. {
  483. moveChance++;
  484. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(177648, 114816, -7735));
  485. startQuestTimer("TID_FEAR_MOVE_TIMEOVER", 5000, npc, null);
  486. }
  487. else
  488. {
  489. npc.teleToLocation(177648, 114816, -7735, npc.getHeading());
  490. startQuestTimer("TID_FEAR_MOVE_TIMEOVER", 1000, npc, null);
  491. }
  492. }
  493. break;
  494. }
  495. case "CLEAR_STATUS":
  496. {
  497. _antharas = (L2GrandBossInstance) addSpawn(ANTHARAS, 185708, 114298, -8221, 0, false, 0);
  498. addBoss(_antharas);
  499. Broadcast.toAllOnlinePlayers(new Earthquake(185708, 114298, -8221, 20, 10));
  500. setStatus(ALIVE);
  501. break;
  502. }
  503. case "SKIP_WAITING":
  504. {
  505. if (getStatus() == WAITING)
  506. {
  507. cancelQuestTimer("SPAWN_ANTHARAS", null, null);
  508. notifyEvent("SPAWN_ANTHARAS", null, null);
  509. player.sendMessage(getClass().getSimpleName() + ": Skipping waiting time ...");
  510. }
  511. else
  512. {
  513. player.sendMessage(getClass().getSimpleName() + ": You can't skip waiting time right now!");
  514. }
  515. break;
  516. }
  517. case "RESPAWN_ANTHARAS":
  518. {
  519. if (getStatus() == DEAD)
  520. {
  521. setRespawn(0);
  522. cancelQuestTimer("CLEAR_STATUS", null, null);
  523. notifyEvent("CLEAR_STATUS", null, null);
  524. player.sendMessage(getClass().getSimpleName() + ": Antharas has been respawned.");
  525. }
  526. else
  527. {
  528. player.sendMessage(getClass().getSimpleName() + ": You can't respawn antharas while antharas is alive!");
  529. }
  530. break;
  531. }
  532. case "DESPAWN_MINIONS":
  533. {
  534. if (getStatus() == IN_FIGHT)
  535. {
  536. _minionCount = 0;
  537. for (L2Character charInside : zone.getCharactersInside())
  538. {
  539. if ((charInside != null) && charInside.isNpc() && ((charInside.getId() == BEHEMOTH) || (charInside.getId() == TERASQUE)))
  540. {
  541. charInside.deleteMe();
  542. }
  543. }
  544. if (player != null) // Player dont will be null just when is this event called from GM command
  545. {
  546. player.sendMessage(getClass().getSimpleName() + ": All minions have been deleted!");
  547. }
  548. }
  549. else if (player != null) // Player dont will be null just when is this event called from GM command
  550. {
  551. player.sendMessage(getClass().getSimpleName() + ": You can't despawn minions right now!");
  552. }
  553. break;
  554. }
  555. case "ABORT_FIGHT":
  556. {
  557. if (getStatus() == IN_FIGHT)
  558. {
  559. setStatus(ALIVE);
  560. cancelQuestTimer("CHECK_ATTACK", _antharas, null);
  561. cancelQuestTimer("SPAWN_MINION", _antharas, null);
  562. for (L2Character charInside : zone.getCharactersInside())
  563. {
  564. if (charInside != null)
  565. {
  566. if (charInside.isNpc())
  567. {
  568. if (charInside.getId() == ANTHARAS)
  569. {
  570. charInside.teleToLocation(185708, 114298, -8221);
  571. }
  572. else
  573. {
  574. charInside.deleteMe();
  575. }
  576. }
  577. else if (charInside.isPlayer() && !charInside.isGM())
  578. {
  579. charInside.teleToLocation(79800 + getRandom(600), 151200 + getRandom(1100), -3534);
  580. }
  581. }
  582. }
  583. player.sendMessage(getClass().getSimpleName() + ": Fight has been aborted!");
  584. }
  585. else
  586. {
  587. player.sendMessage(getClass().getSimpleName() + ": You can't abort fight right now!");
  588. }
  589. break;
  590. }
  591. case "MANAGE_SKILL":
  592. {
  593. manageSkills(npc);
  594. break;
  595. }
  596. }
  597. return super.onAdvEvent(event, npc, player);
  598. }
  599. @Override
  600. public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isSummon)
  601. {
  602. npc.doCast(DISPEL_BOM.getSkill());
  603. npc.doDie(player);
  604. return super.onAggroRangeEnter(npc, player, isSummon);
  605. }
  606. @Override
  607. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, Skill skill)
  608. {
  609. _lastAttack = System.currentTimeMillis();
  610. if (npc.getId() == BOMBER)
  611. {
  612. if (npc.calculateDistance(attacker, true, false) < 230)
  613. {
  614. npc.doCast(DISPEL_BOM.getSkill());
  615. npc.doDie(attacker);
  616. }
  617. }
  618. else if (npc.getId() == ANTHARAS)
  619. {
  620. if (!zone.isCharacterInZone(attacker) || (getStatus() != IN_FIGHT))
  621. {
  622. _log.warning(getClass().getSimpleName() + ": Player " + attacker.getName() + " attacked Antharas in invalid conditions!");
  623. attacker.teleToLocation(80464, 152294, -3534);
  624. }
  625. if ((attacker.getMountType() == MountType.STRIDER) && !attacker.isAffectedBySkill(ANTH_ANTI_STRIDER.getSkillId()))
  626. {
  627. if (npc.checkDoCastConditions(ANTH_ANTI_STRIDER.getSkill()))
  628. {
  629. npc.setTarget(attacker);
  630. npc.doCast(ANTH_ANTI_STRIDER.getSkill());
  631. }
  632. }
  633. if (skill == null)
  634. {
  635. refreshAiParams(attacker, (damage * 1000));
  636. }
  637. else if (npc.getCurrentHp() < (npc.getMaxHp() * 0.25))
  638. {
  639. refreshAiParams(attacker, ((damage / 3) * 100));
  640. }
  641. else if (npc.getCurrentHp() < (npc.getMaxHp() * 0.5))
  642. {
  643. refreshAiParams(attacker, (damage * 20));
  644. }
  645. else if (npc.getCurrentHp() < (npc.getMaxHp() * 0.75))
  646. {
  647. refreshAiParams(attacker, (damage * 10));
  648. }
  649. else
  650. {
  651. refreshAiParams(attacker, ((damage / 3) * 20));
  652. }
  653. manageSkills(npc);
  654. }
  655. return super.onAttack(npc, attacker, damage, isSummon, skill);
  656. }
  657. @Override
  658. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  659. {
  660. if (zone.isCharacterInZone(killer))
  661. {
  662. if (npc.getId() == ANTHARAS)
  663. {
  664. _antharas = null;
  665. notifyEvent("DESPAWN_MINIONS", null, null);
  666. zone.broadcastPacket(new SpecialCamera(npc, 1200, 20, -10, 0, 10000, 13000, 0, 0, 0, 0, 0));
  667. zone.broadcastPacket(new PlaySound("BS01_D"));
  668. addSpawn(CUBE, 177615, 114941, -7709, 0, false, 900000);
  669. long respawnTime = (Config.ANTHARAS_SPAWN_INTERVAL + getRandom(-Config.ANTHARAS_SPAWN_RANDOM, Config.ANTHARAS_SPAWN_RANDOM)) * 3600000;
  670. setRespawn(respawnTime);
  671. startQuestTimer("CLEAR_STATUS", respawnTime, null, null);
  672. cancelQuestTimer("SET_REGEN", npc, null);
  673. cancelQuestTimer("CHECK_ATTACK", npc, null);
  674. cancelQuestTimer("SPAWN_MINION", npc, null);
  675. startQuestTimer("CLEAR_ZONE", 900000, null, null);
  676. setStatus(DEAD);
  677. }
  678. else
  679. {
  680. _minionCount--;
  681. }
  682. }
  683. return super.onKill(npc, killer, isSummon);
  684. }
  685. @Override
  686. public void onMoveFinished(L2Npc npc)
  687. {
  688. npc.doCast(DISPEL_BOM.getSkill());
  689. npc.doDie(null);
  690. }
  691. @Override
  692. public String onSpawn(L2Npc npc)
  693. {
  694. if (npc.getId() == ANTHARAS)
  695. {
  696. cancelQuestTimer("SET_REGEN", npc, null);
  697. startQuestTimer("SET_REGEN", 60000, npc, null);
  698. ((L2Attackable) npc).setOnKillDelay(0);
  699. }
  700. else
  701. {
  702. for (int i = 1; i <= 6; i++)
  703. {
  704. final int x = npc.getTemplate().getParameters().getInt("suicide" + i + "_x");
  705. final int y = npc.getTemplate().getParameters().getInt("suicide" + i + "_y");
  706. final L2Attackable bomber = (L2Attackable) addSpawn(BOMBER, npc.getX(), npc.getY(), npc.getZ(), 0, true, 15000, true);
  707. bomber.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(x, y, npc.getZ()));
  708. }
  709. npc.deleteMe();
  710. }
  711. return super.onSpawn(npc);
  712. }
  713. @Override
  714. public String onSpellFinished(L2Npc npc, L2PcInstance player, Skill skill)
  715. {
  716. if ((skill.getId() == ANTH_FEAR.getSkillId()) || (skill.getId() == ANTH_FEAR_SHORT.getSkillId()))
  717. {
  718. startQuestTimer("TID_USED_FEAR", 7000, npc, null);
  719. }
  720. startQuestTimer("MANAGE_SKILL", 1000, npc, null);
  721. return super.onSpellFinished(npc, player, skill);
  722. }
  723. @Override
  724. public boolean unload(boolean removeFromList)
  725. {
  726. if (_antharas != null)
  727. {
  728. _antharas.deleteMe();
  729. _antharas = null;
  730. }
  731. return super.unload(removeFromList);
  732. }
  733. private int getStatus()
  734. {
  735. return GrandBossManager.getInstance().getBossStatus(ANTHARAS);
  736. }
  737. private void addBoss(L2GrandBossInstance grandboss)
  738. {
  739. GrandBossManager.getInstance().addBoss(grandboss);
  740. }
  741. private void setStatus(int status)
  742. {
  743. GrandBossManager.getInstance().setBossStatus(ANTHARAS, status);
  744. }
  745. private void setRespawn(long respawnTime)
  746. {
  747. GrandBossManager.getInstance().getStatsSet(ANTHARAS).set("respawn_time", (System.currentTimeMillis() + respawnTime));
  748. }
  749. private final void refreshAiParams(L2PcInstance attacker, int damage)
  750. {
  751. if ((attacker_1 != null) && (attacker == attacker_1))
  752. {
  753. if (attacker_1_hate < (damage + 1000))
  754. {
  755. attacker_1_hate = damage + getRandom(3000);
  756. }
  757. }
  758. else if ((attacker_2 != null) && (attacker == attacker_2))
  759. {
  760. if (attacker_2_hate < (damage + 1000))
  761. {
  762. attacker_2_hate = damage + getRandom(3000);
  763. }
  764. }
  765. else if ((attacker_3 != null) && (attacker == attacker_3))
  766. {
  767. if (attacker_3_hate < (damage + 1000))
  768. {
  769. attacker_3_hate = damage + getRandom(3000);
  770. }
  771. }
  772. else
  773. {
  774. final int i1 = Util.min(attacker_1_hate, attacker_2_hate, attacker_3_hate);
  775. if (attacker_1_hate == i1)
  776. {
  777. attacker_1_hate = damage + getRandom(3000);
  778. attacker_1 = attacker;
  779. }
  780. else if (attacker_2_hate == i1)
  781. {
  782. attacker_2_hate = damage + getRandom(3000);
  783. attacker_2 = attacker;
  784. }
  785. else if (attacker_3_hate == i1)
  786. {
  787. attacker_3_hate = damage + getRandom(3000);
  788. attacker_3 = attacker;
  789. }
  790. }
  791. }
  792. private void manageSkills(L2Npc npc)
  793. {
  794. if (npc.isCastingNow() || npc.isCoreAIDisabled() || !npc.isInCombat())
  795. {
  796. return;
  797. }
  798. int i1 = 0;
  799. int i2 = 0;
  800. L2PcInstance c2 = null;
  801. if ((attacker_1 == null) || (npc.calculateDistance(attacker_1, true, false) > 9000) || attacker_1.isDead())
  802. {
  803. attacker_1_hate = 0;
  804. }
  805. if ((attacker_2 == null) || (npc.calculateDistance(attacker_2, true, false) > 9000) || attacker_2.isDead())
  806. {
  807. attacker_2_hate = 0;
  808. }
  809. if ((attacker_3 == null) || (npc.calculateDistance(attacker_3, true, false) > 9000) || attacker_3.isDead())
  810. {
  811. attacker_3_hate = 0;
  812. }
  813. if (attacker_1_hate > attacker_2_hate)
  814. {
  815. i1 = 2;
  816. i2 = attacker_1_hate;
  817. c2 = attacker_1;
  818. }
  819. else if (attacker_2_hate > 0)
  820. {
  821. i1 = 3;
  822. i2 = attacker_2_hate;
  823. c2 = attacker_2;
  824. }
  825. if (attacker_3_hate > i2)
  826. {
  827. i1 = 4;
  828. i2 = attacker_3_hate;
  829. c2 = attacker_3;
  830. }
  831. if (i2 > 0)
  832. {
  833. if (getRandom(100) < 70)
  834. {
  835. switch (i1)
  836. {
  837. case 2:
  838. {
  839. attacker_1_hate = 500;
  840. break;
  841. }
  842. case 3:
  843. {
  844. attacker_2_hate = 500;
  845. break;
  846. }
  847. case 4:
  848. {
  849. attacker_3_hate = 500;
  850. break;
  851. }
  852. }
  853. }
  854. final double distance_c2 = npc.calculateDistance(c2, true, false);
  855. final double direction_c2 = npc.calculateDirectionTo(c2);
  856. SkillHolder skillToCast = null;
  857. if (npc.getCurrentHp() < (npc.getMaxHp() * 0.25))
  858. {
  859. if (getRandom(100) < 30)
  860. {
  861. npc.setTarget(c2);
  862. skillToCast = ANTH_MOUTH;
  863. }
  864. else if ((getRandom(100) < 80) && (((distance_c2 < 1423) && (direction_c2 < 188) && (direction_c2 > 172)) || ((distance_c2 < 802) && (direction_c2 < 194) && (direction_c2 > 166))))
  865. {
  866. skillToCast = ANTH_TAIL;
  867. }
  868. else if ((getRandom(100) < 40) && (((distance_c2 < 850) && (direction_c2 < 210) && (direction_c2 > 150)) || ((distance_c2 < 425) && (direction_c2 < 270) && (direction_c2 > 90))))
  869. {
  870. skillToCast = ANTH_DEBUFF;
  871. }
  872. else if ((getRandom(100) < 10) && (distance_c2 < 1100))
  873. {
  874. skillToCast = ANTH_JUMP;
  875. }
  876. else if (getRandom(100) < 10)
  877. {
  878. npc.setTarget(c2);
  879. skillToCast = ANTH_METEOR;
  880. }
  881. else if (getRandom(100) < 6)
  882. {
  883. npc.setTarget(c2);
  884. skillToCast = ANTH_BREATH;
  885. }
  886. else if (getRandomBoolean())
  887. {
  888. npc.setTarget(c2);
  889. skillToCast = ANTH_NORM_ATTACK_EX;
  890. }
  891. else if (getRandom(100) < 5)
  892. {
  893. npc.setTarget(c2);
  894. skillToCast = getRandomBoolean() ? ANTH_FEAR : ANTH_FEAR_SHORT;
  895. }
  896. else
  897. {
  898. npc.setTarget(c2);
  899. skillToCast = ANTH_NORM_ATTACK;
  900. }
  901. }
  902. else if (npc.getCurrentHp() < (npc.getMaxHp() * 0.5))
  903. {
  904. if ((getRandom(100) < 80) && (((distance_c2 < 1423) && (direction_c2 < 188) && (direction_c2 > 172)) || ((distance_c2 < 802) && (direction_c2 < 194) && (direction_c2 > 166))))
  905. {
  906. skillToCast = ANTH_TAIL;
  907. }
  908. else if ((getRandom(100) < 40) && (((distance_c2 < 850) && (direction_c2 < 210) && (direction_c2 > 150)) || ((distance_c2 < 425) && (direction_c2 < 270) && (direction_c2 > 90))))
  909. {
  910. skillToCast = ANTH_DEBUFF;
  911. }
  912. else if ((getRandom(100) < 10) && (distance_c2 < 1100))
  913. {
  914. skillToCast = ANTH_JUMP;
  915. }
  916. else if (getRandom(100) < 7)
  917. {
  918. npc.setTarget(c2);
  919. skillToCast = ANTH_METEOR;
  920. }
  921. else if (getRandom(100) < 6)
  922. {
  923. npc.setTarget(c2);
  924. skillToCast = ANTH_BREATH;
  925. }
  926. else if (getRandomBoolean())
  927. {
  928. npc.setTarget(c2);
  929. skillToCast = ANTH_NORM_ATTACK_EX;
  930. }
  931. else if (getRandom(100) < 5)
  932. {
  933. npc.setTarget(c2);
  934. skillToCast = getRandomBoolean() ? ANTH_FEAR : ANTH_FEAR_SHORT;
  935. }
  936. else
  937. {
  938. npc.setTarget(c2);
  939. skillToCast = ANTH_NORM_ATTACK;
  940. }
  941. }
  942. else if (npc.getCurrentHp() < (npc.getMaxHp() * 0.75))
  943. {
  944. if ((getRandom(100) < 80) && (((distance_c2 < 1423) && (direction_c2 < 188) && (direction_c2 > 172)) || ((distance_c2 < 802) && (direction_c2 < 194) && (direction_c2 > 166))))
  945. {
  946. skillToCast = ANTH_TAIL;
  947. }
  948. else if ((getRandom(100) < 10) && (distance_c2 < 1100))
  949. {
  950. skillToCast = ANTH_JUMP;
  951. }
  952. else if (getRandom(100) < 5)
  953. {
  954. npc.setTarget(c2);
  955. skillToCast = ANTH_METEOR;
  956. }
  957. else if (getRandom(100) < 6)
  958. {
  959. npc.setTarget(c2);
  960. skillToCast = ANTH_BREATH;
  961. }
  962. else if (getRandomBoolean())
  963. {
  964. npc.setTarget(c2);
  965. skillToCast = ANTH_NORM_ATTACK_EX;
  966. }
  967. else if (getRandom(100) < 5)
  968. {
  969. npc.setTarget(c2);
  970. skillToCast = getRandomBoolean() ? ANTH_FEAR : ANTH_FEAR_SHORT;
  971. }
  972. else
  973. {
  974. npc.setTarget(c2);
  975. skillToCast = ANTH_NORM_ATTACK;
  976. }
  977. }
  978. else if ((getRandom(100) < 80) && (((distance_c2 < 1423) && (direction_c2 < 188) && (direction_c2 > 172)) || ((distance_c2 < 802) && (direction_c2 < 194) && (direction_c2 > 166))))
  979. {
  980. skillToCast = ANTH_TAIL;
  981. }
  982. else if (getRandom(100) < 3)
  983. {
  984. npc.setTarget(c2);
  985. skillToCast = ANTH_METEOR;
  986. }
  987. else if (getRandom(100) < 6)
  988. {
  989. npc.setTarget(c2);
  990. skillToCast = ANTH_BREATH;
  991. }
  992. else if (getRandomBoolean())
  993. {
  994. npc.setTarget(c2);
  995. skillToCast = ANTH_NORM_ATTACK_EX;
  996. }
  997. else if (getRandom(100) < 5)
  998. {
  999. npc.setTarget(c2);
  1000. skillToCast = getRandomBoolean() ? ANTH_FEAR : ANTH_FEAR_SHORT;
  1001. }
  1002. else
  1003. {
  1004. npc.setTarget(c2);
  1005. skillToCast = ANTH_NORM_ATTACK;
  1006. }
  1007. if ((skillToCast != null) && npc.checkDoCastConditions(skillToCast.getSkill()))
  1008. {
  1009. npc.doCast(skillToCast.getSkill());
  1010. }
  1011. }
  1012. }
  1013. public static void main(String[] args)
  1014. {
  1015. new Antharas();
  1016. }
  1017. }