Baium.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package ai.individual;
  16. import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_FOLLOW;
  17. import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
  18. import java.util.ArrayList;
  19. import java.util.Collection;
  20. import java.util.List;
  21. import java.util.logging.Level;
  22. import javolution.util.FastList;
  23. import ai.group_template.L2AttackableAIScript;
  24. import com.l2jserver.Config;
  25. import com.l2jserver.gameserver.GeoData;
  26. import com.l2jserver.gameserver.ThreadPoolManager;
  27. import com.l2jserver.gameserver.datatables.SkillTable;
  28. import com.l2jserver.gameserver.instancemanager.GrandBossManager;
  29. import com.l2jserver.gameserver.model.L2Effect;
  30. import com.l2jserver.gameserver.model.L2Object;
  31. import com.l2jserver.gameserver.model.L2Skill;
  32. import com.l2jserver.gameserver.model.actor.L2Character;
  33. import com.l2jserver.gameserver.model.actor.L2Npc;
  34. import com.l2jserver.gameserver.model.actor.L2Playable;
  35. import com.l2jserver.gameserver.model.actor.instance.L2DecoyInstance;
  36. import com.l2jserver.gameserver.model.actor.instance.L2GrandBossInstance;
  37. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  38. import com.l2jserver.gameserver.model.quest.QuestTimer;
  39. import com.l2jserver.gameserver.model.zone.type.L2BossZone;
  40. import com.l2jserver.gameserver.network.serverpackets.Earthquake;
  41. import com.l2jserver.gameserver.network.serverpackets.MoveToPawn;
  42. import com.l2jserver.gameserver.network.serverpackets.PlaySound;
  43. import com.l2jserver.gameserver.network.serverpackets.SocialAction;
  44. import com.l2jserver.gameserver.templates.StatsSet;
  45. import com.l2jserver.gameserver.util.Util;
  46. import com.l2jserver.util.Rnd;
  47. /**
  48. * Baium AI
  49. *
  50. * Note1: if the server gets rebooted while players are still fighting Baium, there is no lock, but
  51. * players also lose their ability to wake baium up. However, should another person
  52. * enter the room and wake him up, the players who had stayed inside may join the raid.
  53. * This can be helpful for players who became victims of a reboot (they only need 1 new player to
  54. * enter and wake up baium) and is not too exploitable since any player wishing to exploit it
  55. * would have to suffer 5 days of being parked in an empty room.
  56. * Note2: Neither version of Baium should be a permanent spawn. This script is fully capable of
  57. * spawning the statue-version when the lock expires and switching it to the mob version promptly.
  58. *
  59. * Additional notes ( source http://aleenaresron.blogspot.com/2006_08_01_archive.html ):
  60. * * Baium only first respawns five days after his last death. And from those five days he will
  61. * respawn within 1-8 hours of his last death. So, you have to know his last time of death.
  62. * * If by some freak chance you are the only one in Baium's chamber and NO ONE comes in
  63. * [ha, ha] you or someone else will have to wake Baium. There is a good chance that Baium
  64. * will automatically kill whoever wakes him. There are some people that have been able to
  65. * wake him and not die, however if you've already gone through the trouble of getting the
  66. * bloody fabric and camped him out and researched his spawn time, are you willing to take that
  67. * chance that you'll wake him and not be able to finish your quest? Doubtful.
  68. * [ this powerful attack vs the player who wakes him up is NOT yet implemented here]
  69. * * once someone starts attacking Baium no one else can port into the chamber where he is.
  70. * Unlike with the other raid bosses, you can just show up at any time as long as you are there
  71. * when they die. Not true with Baium. Once he gets attacked, the port to Baium closes. byebye,
  72. * see you in 5 days. If nobody attacks baium for 30 minutes, he auto-despawns and unlocks the
  73. * vortex
  74. *
  75. * @author Fulminus version 0.1
  76. */
  77. public class Baium extends L2AttackableAIScript
  78. {
  79. private L2Character _target;
  80. private L2Skill _skill;
  81. private static final int STONE_BAIUM = 29025;
  82. private static final int ANGELIC_VORTEX = 31862;
  83. private static final int LIVE_BAIUM = 29020;
  84. private static final int ARCHANGEL = 29021;
  85. //Baium status tracking
  86. private static final byte ASLEEP = 0; // baium is in the stone version, waiting to be woken up. Entry is unlocked
  87. private static final byte AWAKE = 1; // baium is awake and fighting. Entry is locked.
  88. private static final byte DEAD = 2; // baium has been killed and has not yet spawned. Entry is locked
  89. // fixed archangel spawnloc
  90. private final static int ANGEL_LOCATION[][] =
  91. {
  92. { 114239, 17168, 10080, 63544 },
  93. { 115780, 15564, 10080, 13620 },
  94. { 114880, 16236, 10080, 5400 },
  95. { 115168, 17200, 10080, 0 },
  96. { 115792, 16608, 10080, 0 },
  97. };
  98. private long _LastAttackVsBaiumTime = 0;
  99. private List<L2Npc> _Minions = new ArrayList<L2Npc>(5);
  100. private L2BossZone _Zone;
  101. public Baium (int questId, String name, String descr)
  102. {
  103. super(questId, name, descr);
  104. int[] mob = {LIVE_BAIUM};
  105. this.registerMobs(mob);
  106. // Quest NPC starter initialization
  107. addStartNpc(STONE_BAIUM);
  108. addStartNpc(ANGELIC_VORTEX);
  109. addTalkId(STONE_BAIUM);
  110. addTalkId(ANGELIC_VORTEX);
  111. _Zone = GrandBossManager.getInstance().getZone(113100,14500,10077);
  112. StatsSet info = GrandBossManager.getInstance().getStatsSet(LIVE_BAIUM);
  113. int status = GrandBossManager.getInstance().getBossStatus(LIVE_BAIUM);
  114. if (status == DEAD)
  115. {
  116. // load the unlock date and time for baium from DB
  117. long temp = (info.getLong("respawn_time") - System.currentTimeMillis());
  118. if (temp > 0)
  119. {
  120. // the unlock time has not yet expired. Mark Baium as currently locked (dead). Setup a timer
  121. // to fire at the correct time (calculate the time between now and the unlock time,
  122. // setup a timer to fire after that many msec)
  123. startQuestTimer("baium_unlock", temp, null, null);
  124. }
  125. else
  126. {
  127. // the time has already expired while the server was offline. Delete the saved time and
  128. // immediately spawn the stone-baium. Also the state need not be changed from ASLEEP
  129. addSpawn(STONE_BAIUM,116033,17447,10104,40188,false,0);
  130. GrandBossManager.getInstance().setBossStatus(LIVE_BAIUM,ASLEEP);
  131. }
  132. }
  133. else if (status == AWAKE)
  134. {
  135. int loc_x = info.getInteger("loc_x");
  136. int loc_y = info.getInteger("loc_y");
  137. int loc_z = info.getInteger("loc_z");
  138. int heading = info.getInteger("heading");
  139. final int hp = info.getInteger("currentHP");
  140. final int mp = info.getInteger("currentMP");
  141. L2GrandBossInstance baium = (L2GrandBossInstance) addSpawn(LIVE_BAIUM,loc_x,loc_y,loc_z,heading,false,0);
  142. GrandBossManager.getInstance().addBoss(baium);
  143. final L2Npc _baium = baium;
  144. ThreadPoolManager.getInstance().scheduleGeneral(new Runnable() {
  145. public void run()
  146. {
  147. try
  148. {
  149. _baium.setCurrentHpMp(hp,mp);
  150. _baium.setIsInvul(true);
  151. _baium.setIsImmobilized(true);
  152. _baium.setRunning();
  153. _baium.broadcastPacket(new SocialAction(_baium.getObjectId(),2));
  154. startQuestTimer("baium_wakeup",15000, _baium, null);
  155. }
  156. catch (Exception e)
  157. {
  158. e.printStackTrace();
  159. }
  160. }
  161. },100L);
  162. }
  163. else
  164. addSpawn(STONE_BAIUM,116033,17447,10104,40188,false,0);
  165. }
  166. @Override
  167. public String onAdvEvent (String event, L2Npc npc, L2PcInstance player)
  168. {
  169. if (event.equalsIgnoreCase("baium_unlock"))
  170. {
  171. GrandBossManager.getInstance().setBossStatus(LIVE_BAIUM,ASLEEP);
  172. addSpawn(STONE_BAIUM,116033,17447,10104,40188,false,0);
  173. }
  174. else if (event.equalsIgnoreCase("skill_range") && npc != null)
  175. {
  176. callSkillAI(npc);
  177. }
  178. else if (event.equalsIgnoreCase("clean_player"))
  179. {
  180. _target = getRandomTarget(npc);
  181. }
  182. else if (event.equalsIgnoreCase("baium_wakeup") && npc != null)
  183. {
  184. if (npc.getNpcId() == LIVE_BAIUM)
  185. {
  186. npc.broadcastPacket(new SocialAction(npc.getObjectId(),1));
  187. npc.broadcastPacket(new Earthquake(npc.getX(), npc.getY(), npc.getZ(),40,5));
  188. // start monitoring baium's inactivity
  189. _LastAttackVsBaiumTime = System.currentTimeMillis();
  190. startQuestTimer("baium_despawn", 60000, npc, null, true);
  191. startQuestTimer("skill_range", 500, npc, null, true);
  192. final L2Npc baium = npc;
  193. ThreadPoolManager.getInstance().scheduleGeneral(new Runnable() {
  194. public void run()
  195. {
  196. try
  197. {
  198. baium.setIsInvul(false);
  199. baium.setIsImmobilized(false);
  200. for (L2Npc minion : _Minions)
  201. minion.setShowSummonAnimation(false);
  202. }
  203. catch (Exception e)
  204. {
  205. _log.log(Level.WARNING, "", e);
  206. }
  207. }
  208. },11100L);
  209. // TODO: the person who woke baium up should be knocked across the room, onto a wall, and
  210. // lose massive amounts of HP.
  211. for (int i = 0; i < ANGEL_LOCATION.length; i++)
  212. {
  213. L2Npc angel = addSpawn(ARCHANGEL, ANGEL_LOCATION[i][0], ANGEL_LOCATION[i][1], ANGEL_LOCATION[i][2], ANGEL_LOCATION[i][3], false, 0, true);
  214. angel.setIsInvul(true);
  215. _Minions.add(angel);
  216. }
  217. }
  218. // despawn the live baium after 30 minutes of inactivity
  219. // also check if the players are cheating, having pulled Baium outside his zone...
  220. }
  221. else if (event.equalsIgnoreCase("baium_despawn") && npc != null)
  222. {
  223. if (npc.getNpcId() == LIVE_BAIUM)
  224. {
  225. // just in case the zone reference has been lost (somehow...), restore the reference
  226. if (_Zone == null)
  227. _Zone = GrandBossManager.getInstance().getZone(113100,14500,10077);
  228. if (_LastAttackVsBaiumTime + 1800000 < System.currentTimeMillis())
  229. {
  230. npc.deleteMe(); // despawn the live-baium
  231. for (L2Npc minion : _Minions)
  232. if (minion != null)
  233. {
  234. minion.getSpawn().stopRespawn();
  235. minion.deleteMe();
  236. }
  237. _Minions.clear();
  238. addSpawn(STONE_BAIUM,116033,17447,10104,40188,false,0); // spawn stone-baium
  239. GrandBossManager.getInstance().setBossStatus(LIVE_BAIUM,ASLEEP); // mark that Baium is not awake any more
  240. _Zone.oustAllPlayers();
  241. cancelQuestTimer("baium_despawn", npc, null);
  242. }
  243. else if ((_LastAttackVsBaiumTime + 300000 < System.currentTimeMillis()) && npc.getCurrentHp() < ( ( npc.getMaxHp() * 3 ) / 4.0 ))
  244. {
  245. npc.setIsCastingNow(false); //just in case
  246. npc.setTarget(npc);
  247. npc.doCast(SkillTable.getInstance().getInfo(4135,1));
  248. npc.setIsCastingNow(true);
  249. }
  250. else if (!_Zone.isInsideZone(npc))
  251. npc.teleToLocation(116033,17447,10104);
  252. }
  253. }
  254. return super.onAdvEvent(event, npc, player);
  255. }
  256. @Override
  257. public String onTalk(L2Npc npc,L2PcInstance player)
  258. {
  259. int npcId = npc.getNpcId();
  260. String htmltext = "";
  261. if (_Zone == null)
  262. _Zone = GrandBossManager.getInstance().getZone(113100,14500,10077);
  263. if (_Zone == null)
  264. return "<html><body>Angelic Vortex:<br>You may not enter while admin disabled this zone</body></html>";
  265. if (npcId == STONE_BAIUM && GrandBossManager.getInstance().getBossStatus(LIVE_BAIUM) == ASLEEP)
  266. {
  267. if (_Zone.isPlayerAllowed(player))
  268. {
  269. // once Baium is awaken, no more people may enter until he dies, the server reboots, or
  270. // 30 minutes pass with no attacks made against Baium.
  271. GrandBossManager.getInstance().setBossStatus(LIVE_BAIUM,AWAKE);
  272. npc.deleteMe();
  273. L2GrandBossInstance baium = (L2GrandBossInstance) addSpawn(LIVE_BAIUM, npc, true);
  274. GrandBossManager.getInstance().addBoss(baium);
  275. final L2Npc _baium = baium;
  276. ThreadPoolManager.getInstance().scheduleGeneral(new Runnable() {
  277. public void run()
  278. {
  279. try
  280. {
  281. _baium.setIsInvul(true);
  282. _baium.setRunning();
  283. _baium.broadcastPacket(new SocialAction(_baium.getObjectId(),2));
  284. startQuestTimer("baium_wakeup",15000, _baium, null);
  285. _baium.setShowSummonAnimation(false);
  286. }
  287. catch (Throwable e)
  288. {
  289. _log.log(Level.WARNING, "", e);
  290. }
  291. }
  292. },100L);
  293. }
  294. else
  295. htmltext = "Conditions are not right to wake up Baium";
  296. }
  297. else if (npcId == ANGELIC_VORTEX)
  298. {
  299. if (player.isFlying())
  300. {
  301. //print "Player "+player.getName()+" attempted to enter Baium's lair while flying!";
  302. return "<html><body>Angelic Vortex:<br>You may not enter while flying a wyvern</body></html>";
  303. }
  304. if (GrandBossManager.getInstance().getBossStatus(LIVE_BAIUM) == ASLEEP
  305. && player.getQuestState("baium").getQuestItemsCount(4295) > 0) // bloody fabric
  306. {
  307. player.getQuestState("baium").takeItems(4295,1);
  308. // allow entry for the player for the next 30 secs (more than enough time for the TP to happen)
  309. // Note: this just means 30secs to get in, no limits on how long it takes before we get out.
  310. _Zone.allowPlayerEntry(player,30);
  311. player.teleToLocation(113100,14500,10077);
  312. }
  313. else
  314. npc.showChatWindow(player, 1);
  315. }
  316. return htmltext;
  317. }
  318. @Override
  319. public String onSpellFinished(L2Npc npc, L2PcInstance player, L2Skill skill)
  320. {
  321. if (npc.isInvul())
  322. {
  323. npc.getAI().setIntention(AI_INTENTION_IDLE);
  324. return null;
  325. }
  326. else if (npc.getNpcId() == LIVE_BAIUM && !npc.isInvul())
  327. {
  328. callSkillAI(npc);
  329. }
  330. return super.onSpellFinished(npc, player, skill);
  331. }
  332. @Override
  333. public String onSpawn(L2Npc npc)
  334. {
  335. npc.disableCoreAI(true);
  336. return super.onSpawn(npc);
  337. }
  338. @Override
  339. public String onAttack (L2Npc npc, L2PcInstance attacker, int damage, boolean isPet)
  340. {
  341. if (!_Zone.isInsideZone(attacker))
  342. {
  343. attacker.reduceCurrentHp(attacker.getCurrentHp(),attacker,false,false, null);
  344. return super.onAttack(npc, attacker, damage, isPet);
  345. }
  346. if (npc.isInvul())
  347. {
  348. npc.getAI().setIntention(AI_INTENTION_IDLE);
  349. return super.onAttack(npc, attacker, damage, isPet);
  350. }
  351. else if (npc.getNpcId() == LIVE_BAIUM && !npc.isInvul())
  352. {
  353. if (attacker.getMountType() == 1)
  354. {
  355. int sk_4258 = 0;
  356. L2Effect[] effects = attacker.getAllEffects();
  357. if (effects != null && effects.length != 0)
  358. {
  359. for (L2Effect e : effects)
  360. {
  361. if (e.getSkill().getId() == 4258)
  362. sk_4258 = 1;
  363. }
  364. }
  365. if (sk_4258 == 0)
  366. {
  367. npc.setTarget(attacker);
  368. npc.doCast(SkillTable.getInstance().getInfo(4258,1));
  369. }
  370. }
  371. // update a variable with the last action against baium
  372. _LastAttackVsBaiumTime = System.currentTimeMillis();
  373. callSkillAI(npc);
  374. }
  375. return super.onAttack(npc, attacker, damage, isPet);
  376. }
  377. @Override
  378. public String onKill (L2Npc npc, L2PcInstance killer, boolean isPet)
  379. {
  380. cancelQuestTimer("baium_despawn", npc, null);
  381. npc.broadcastPacket(new PlaySound(1, "BS01_D", 1, npc.getObjectId(), npc.getX(), npc.getY(), npc.getZ()));
  382. // spawn the "Teleportation Cubic" for 15 minutes (to allow players to exit the lair)
  383. addSpawn(29055,115203,16620,10078,0,false,900000); ////should we teleport everyone out if the cubic despawns??
  384. // "lock" baium for 5 days and 1 to 8 hours [i.e. 432,000,000 + 1*3,600,000 + random-less-than(8*3,600,000) millisecs]
  385. long respawnTime = (long)Config.Interval_Of_Baium_Spawn + Rnd.get(Config.Random_Of_Baium_Spawn);
  386. GrandBossManager.getInstance().setBossStatus(LIVE_BAIUM,DEAD);
  387. startQuestTimer("baium_unlock", respawnTime, null, null);
  388. // also save the respawn time so that the info is maintained past reboots
  389. StatsSet info = GrandBossManager.getInstance().getStatsSet(LIVE_BAIUM);
  390. info.set("respawn_time",(System.currentTimeMillis()) + respawnTime);
  391. GrandBossManager.getInstance().setStatsSet(LIVE_BAIUM,info);
  392. for (L2Npc minion : _Minions)
  393. if (minion != null)
  394. {
  395. minion.getSpawn().stopRespawn();
  396. minion.deleteMe();
  397. }
  398. _Minions.clear();
  399. if (getQuestTimer("skill_range", npc, null) != null)
  400. getQuestTimer("skill_range", npc, null).cancel();
  401. return super.onKill(npc,killer,isPet);
  402. }
  403. public L2Character getRandomTarget(L2Npc npc)
  404. {
  405. FastList<L2Character> result = FastList.newInstance();
  406. Collection<L2Object> objs = npc.getKnownList().getKnownObjects().values();
  407. {
  408. for (L2Object obj : objs)
  409. {
  410. if (obj instanceof L2Playable || obj instanceof L2DecoyInstance)
  411. {
  412. if (obj instanceof L2PcInstance)
  413. {
  414. if (((L2PcInstance) obj).getAppearance().getInvisible())
  415. continue;
  416. }
  417. if (((L2Character) obj).getZ() < ( npc.getZ() - 100 ) && ((L2Character) obj).getZ() > ( npc.getZ() + 100 )
  418. || !(GeoData.getInstance().canSeeTarget(((L2Character) obj).getX(), ((L2Character) obj).getY(), ((L2Character) obj).getZ(), npc.getX(), npc.getY(), npc.getZ())))
  419. continue;
  420. }
  421. if (obj instanceof L2Playable || obj instanceof L2DecoyInstance)
  422. {
  423. if (Util.checkIfInRange(9000, npc, obj, true) && !((L2Character) obj).isDead())
  424. result.add((L2Character) obj);
  425. }
  426. }
  427. }
  428. if (result.isEmpty())
  429. {
  430. for (L2Npc minion : _Minions)
  431. if (minion != null)
  432. result.add(minion);
  433. }
  434. if (result.isEmpty())
  435. {
  436. FastList.recycle(result);
  437. return null;
  438. }
  439. Object[] characters = result.toArray();
  440. QuestTimer timer = getQuestTimer("clean_player", npc, null);
  441. if (timer != null)
  442. timer.cancel();
  443. startQuestTimer("clean_player", 20000, npc, null);
  444. L2Character target = (L2Character) characters[Rnd.get(characters.length)];
  445. FastList.recycle(result);
  446. return target;
  447. }
  448. public synchronized void callSkillAI(L2Npc npc)
  449. {
  450. if (npc.isInvul() || npc.isCastingNow()) return;
  451. if (_target == null || _target.isDead() || !(_Zone.isInsideZone(_target)))
  452. {
  453. _target = getRandomTarget(npc);
  454. if (_target != null)
  455. _skill = SkillTable.getInstance().getInfo(getRandomSkill(npc),1);
  456. }
  457. L2Character target = _target;
  458. L2Skill skill = _skill;
  459. if (skill == null)
  460. skill = SkillTable.getInstance().getInfo(getRandomSkill(npc),1);
  461. if (target == null || target.isDead() || !(_Zone.isInsideZone(target)))
  462. {
  463. npc.setIsCastingNow(false);
  464. return;
  465. }
  466. if (Util.checkIfInRange(skill.getCastRange(), npc, target, true))
  467. {
  468. npc.getAI().setIntention(AI_INTENTION_IDLE);
  469. npc.setTarget(target);
  470. npc.setIsCastingNow(true);
  471. _target = null;
  472. _skill = null;
  473. if (getDist(skill.getCastRange()) > 0)
  474. npc.broadcastPacket(new MoveToPawn(npc,target,getDist(skill.getCastRange())));
  475. try
  476. {
  477. Thread.sleep(1000);
  478. npc.stopMove(null);
  479. npc.doCast(skill);
  480. }
  481. catch (Exception e)
  482. {e.printStackTrace();}
  483. }
  484. else
  485. {
  486. npc.getAI().setIntention(AI_INTENTION_FOLLOW, target, null);
  487. npc.setIsCastingNow(false);
  488. }
  489. }
  490. public int getRandomSkill(L2Npc npc)
  491. {
  492. int skill;
  493. if( npc.getCurrentHp() > ( ( npc.getMaxHp() * 3 ) / 4.0 ) )
  494. {
  495. if( Rnd.get(100) < 10 )
  496. skill = 4128;
  497. else if( Rnd.get(100) < 10 )
  498. skill = 4129;
  499. else
  500. skill = 4127;
  501. }
  502. else if( npc.getCurrentHp() > ( ( npc.getMaxHp() * 2 ) / 4.0) )
  503. {
  504. if( Rnd.get(100) < 10 )
  505. skill = 4131;
  506. else if( Rnd.get(100) < 10 )
  507. skill = 4128;
  508. else if( Rnd.get(100) < 10 )
  509. skill = 4129;
  510. else
  511. skill = 4127;
  512. }
  513. else if( npc.getCurrentHp() > ( ( npc.getMaxHp() * 1 ) / 4.0 ) )
  514. {
  515. if( Rnd.get(100) < 10 )
  516. skill = 4130;
  517. else if( Rnd.get(100) < 10 )
  518. skill = 4131;
  519. else if( Rnd.get(100) < 10 )
  520. skill = 4128;
  521. else if( Rnd.get(100) < 10 )
  522. skill = 4129;
  523. else
  524. skill = 4127;
  525. }
  526. else if( Rnd.get(100) < 10 )
  527. skill = 4130;
  528. else if( Rnd.get(100) < 10 )
  529. skill = 4131;
  530. else if( Rnd.get(100) < 10 )
  531. skill = 4128;
  532. else if( Rnd.get(100) < 10 )
  533. skill = 4129;
  534. else
  535. skill = 4127;
  536. return skill;
  537. }
  538. @Override
  539. public String onSkillSee (L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet)
  540. {
  541. if (npc.isInvul())
  542. {
  543. npc.getAI().setIntention(AI_INTENTION_IDLE);
  544. return null;
  545. }
  546. npc.setTarget(caster);
  547. return super.onSkillSee(npc, caster, skill, targets, isPet);
  548. }
  549. public int getDist(int range)
  550. {
  551. int dist = 0;
  552. switch(range)
  553. {
  554. case -1:
  555. break;
  556. case 100:
  557. dist = 85;
  558. break;
  559. default:
  560. dist = range-85;
  561. break;
  562. }
  563. return dist;
  564. }
  565. public static void main(String[] args)
  566. {
  567. // Quest class and state definition
  568. new Baium(-1, "baium", "ai");
  569. }
  570. }