Valakas.java 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  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 java.util.ArrayList;
  17. import java.util.List;
  18. import ai.npc.AbstractNpcAI;
  19. import com.l2jserver.Config;
  20. import com.l2jserver.gameserver.GeoData;
  21. import com.l2jserver.gameserver.ai.CtrlIntention;
  22. import com.l2jserver.gameserver.datatables.SkillTable;
  23. import com.l2jserver.gameserver.instancemanager.GrandBossManager;
  24. import com.l2jserver.gameserver.model.L2CharPosition;
  25. import com.l2jserver.gameserver.model.StatsSet;
  26. import com.l2jserver.gameserver.model.actor.L2Character;
  27. import com.l2jserver.gameserver.model.actor.L2Npc;
  28. import com.l2jserver.gameserver.model.actor.L2Playable;
  29. import com.l2jserver.gameserver.model.actor.instance.L2GrandBossInstance;
  30. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  31. import com.l2jserver.gameserver.model.effects.L2Effect;
  32. import com.l2jserver.gameserver.model.skills.L2Skill;
  33. import com.l2jserver.gameserver.model.zone.type.L2BossZone;
  34. import com.l2jserver.gameserver.network.serverpackets.PlaySound;
  35. import com.l2jserver.gameserver.network.serverpackets.SocialAction;
  36. import com.l2jserver.gameserver.network.serverpackets.SpecialCamera;
  37. import com.l2jserver.gameserver.util.Util;
  38. /**
  39. * Valakas AI
  40. * @author Tryskell
  41. */
  42. public class Valakas extends AbstractNpcAI
  43. {
  44. private long _timeTracker = 0; // Time tracker for last attack on Valakas.
  45. private L2Playable _actualVictim; // Actual target of Valakas.
  46. private static final int VALAKAS = 29028;
  47. // Valakas status.
  48. private static final byte DORMANT = 0; // Valakas is spawned and no one has entered yet. Entry is unlocked.
  49. private static final byte WAITING = 1; // Valakas is spawned and someone has entered, triggering a 30 minute window for additional people to enter. Entry is unlocked.
  50. private static final byte FIGHTING = 2; // Valakas is engaged in battle, annihilating his foes. Entry is locked.
  51. private static final byte DEAD = 3; // Valakas has been killed. Entry is locked.
  52. private static final int[] VALAKAS_REGULAR_SKILLS =
  53. {
  54. 4681,
  55. 4682,
  56. 4683,
  57. 4689
  58. };
  59. private static final int[] VALAKAS_LOWHP_SKILLS =
  60. {
  61. 4681,
  62. 4682,
  63. 4683,
  64. 4689,
  65. 4690
  66. };
  67. private static final int[] VALAKAS_AOE_SKILLS =
  68. {
  69. 4683,
  70. 4684,
  71. 4685,
  72. 4686,
  73. 4688,
  74. 4689,
  75. 4690
  76. };
  77. private static final int _teleportCubeLocation[][] =
  78. {
  79. {
  80. 214880,
  81. -116144,
  82. -1644
  83. },
  84. {
  85. 213696,
  86. -116592,
  87. -1644
  88. },
  89. {
  90. 212112,
  91. -116688,
  92. -1644
  93. },
  94. {
  95. 211184,
  96. -115472,
  97. -1664
  98. },
  99. {
  100. 210336,
  101. -114592,
  102. -1644
  103. },
  104. {
  105. 211360,
  106. -113904,
  107. -1644
  108. },
  109. {
  110. 213152,
  111. -112352,
  112. -1644
  113. },
  114. {
  115. 214032,
  116. -113232,
  117. -1644
  118. },
  119. {
  120. 214752,
  121. -114592,
  122. -1644
  123. },
  124. {
  125. 209824,
  126. -115568,
  127. -1421
  128. },
  129. {
  130. 210528,
  131. -112192,
  132. -1403
  133. },
  134. {
  135. 213120,
  136. -111136,
  137. -1408
  138. },
  139. {
  140. 215184,
  141. -111504,
  142. -1392
  143. },
  144. {
  145. 215456,
  146. -117328,
  147. -1392
  148. },
  149. {
  150. 213200,
  151. -118160,
  152. -1424
  153. }
  154. };
  155. private static L2BossZone ZONE;
  156. private Valakas(String name, String descr)
  157. {
  158. super(name, descr);
  159. registerMobs(VALAKAS);
  160. ZONE = GrandBossManager.getInstance().getZone(212852, -114842, -1632);
  161. final StatsSet info = GrandBossManager.getInstance().getStatsSet(VALAKAS);
  162. final int status = GrandBossManager.getInstance().getBossStatus(VALAKAS);
  163. if (status == DEAD)
  164. {
  165. // load the unlock date and time for valakas from DB
  166. long temp = (info.getLong("respawn_time") - System.currentTimeMillis());
  167. if (temp > 0)
  168. {
  169. // The time has not yet expired. Mark Valakas as currently locked (dead).
  170. startQuestTimer("valakas_unlock", temp, null, null);
  171. }
  172. else
  173. {
  174. // The time has expired while the server was offline. Spawn valakas in his cave as DORMANT.
  175. final L2Npc valakas = addSpawn(VALAKAS, -105200, -253104, -15264, 0, false, 0);
  176. GrandBossManager.getInstance().setBossStatus(VALAKAS, DORMANT);
  177. GrandBossManager.getInstance().addBoss((L2GrandBossInstance) valakas);
  178. valakas.setIsInvul(true);
  179. valakas.setRunning();
  180. valakas.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  181. }
  182. }
  183. else
  184. {
  185. final int loc_x = info.getInteger("loc_x");
  186. final int loc_y = info.getInteger("loc_y");
  187. final int loc_z = info.getInteger("loc_z");
  188. final int heading = info.getInteger("heading");
  189. final int hp = info.getInteger("currentHP");
  190. final int mp = info.getInteger("currentMP");
  191. final L2Npc valakas = addSpawn(VALAKAS, loc_x, loc_y, loc_z, heading, false, 0);
  192. GrandBossManager.getInstance().addBoss((L2GrandBossInstance) valakas);
  193. valakas.setCurrentHpMp(hp, mp);
  194. valakas.setRunning();
  195. // Start timers.
  196. if (status == FIGHTING)
  197. {
  198. // stores current time for inactivity task.
  199. _timeTracker = System.currentTimeMillis();
  200. startQuestTimer("regen_task", 60000, valakas, null, true);
  201. startQuestTimer("skill_task", 2000, valakas, null, true);
  202. }
  203. else
  204. {
  205. valakas.setIsInvul(true);
  206. valakas.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  207. // Start timer to lock entry after 30 minutes
  208. if (status == WAITING)
  209. {
  210. startQuestTimer("beginning", Config.Valakas_Wait_Time, valakas, null);
  211. }
  212. }
  213. }
  214. }
  215. @Override
  216. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  217. {
  218. if (npc != null)
  219. {
  220. if (event.equalsIgnoreCase("beginning"))
  221. {
  222. // Stores current time
  223. _timeTracker = System.currentTimeMillis();
  224. // Teleport Valakas to his lair.
  225. npc.teleToLocation(212852, -114842, -1632);
  226. // Sound + socialAction.
  227. for (L2PcInstance plyr : ZONE.getPlayersInside())
  228. {
  229. plyr.sendPacket(new PlaySound(1, "B03_A", 0, 0, 0, 0, 0));
  230. plyr.sendPacket(new SocialAction(npc.getObjectId(), 3));
  231. }
  232. // Launch the cinematic, and tasks (regen + skill).
  233. startQuestTimer("spawn_1", 1700, npc, null); // 1700
  234. startQuestTimer("spawn_2", 3200, npc, null); // 1500
  235. startQuestTimer("spawn_3", 6500, npc, null); // 3300
  236. startQuestTimer("spawn_4", 9400, npc, null); // 2900
  237. startQuestTimer("spawn_5", 12100, npc, null); // 2700
  238. startQuestTimer("spawn_6", 12430, npc, null); // 330
  239. startQuestTimer("spawn_7", 15430, npc, null); // 3000
  240. startQuestTimer("spawn_8", 16830, npc, null); // 1400
  241. startQuestTimer("spawn_9", 23530, npc, null); // 6700 - end of cinematic
  242. startQuestTimer("spawn_10", 26000, npc, null); // 2500 - AI + unlock
  243. }
  244. // Regeneration && inactivity task
  245. else if (event.equalsIgnoreCase("regen_task"))
  246. {
  247. // Inactivity task - 15min
  248. if (GrandBossManager.getInstance().getBossStatus(VALAKAS) == FIGHTING)
  249. {
  250. if ((_timeTracker + 900000) < System.currentTimeMillis())
  251. {
  252. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  253. npc.teleToLocation(-105200, -253104, -15264);
  254. GrandBossManager.getInstance().setBossStatus(VALAKAS, DORMANT);
  255. npc.setCurrentHpMp(npc.getMaxHp(), npc.getMaxMp());
  256. // Drop all players from the zone.
  257. ZONE.oustAllPlayers();
  258. // Cancel skill_task and regen_task.
  259. cancelQuestTimer("regen_task", npc, null);
  260. cancelQuestTimer("skill_task", npc, null);
  261. return null;
  262. }
  263. }
  264. int lvl = 0;
  265. // Verify if "Valakas Regeneration" skill is active.
  266. final L2Effect[] effects = npc.getAllEffects();
  267. if ((effects != null) && (effects.length != 0))
  268. {
  269. for (L2Effect e : effects)
  270. {
  271. if (e.getSkill().getId() == 4629)
  272. {
  273. lvl = e.getSkill().getLevel();
  274. break;
  275. }
  276. }
  277. }
  278. // Current HPs are inferior to 25% ; apply lvl 4 of regen skill.
  279. if ((npc.getCurrentHp() < (npc.getMaxHp() / 4)) && (lvl != 4))
  280. {
  281. npc.setTarget(npc);
  282. npc.doCast(SkillTable.getInstance().getInfo(4691, 4));
  283. }
  284. // Current HPs are inferior to 50% ; apply lvl 3 of regen skill.
  285. else if ((npc.getCurrentHp() < ((npc.getMaxHp() * 2) / 4.0)) && (lvl != 3))
  286. {
  287. npc.setTarget(npc);
  288. npc.doCast(SkillTable.getInstance().getInfo(4691, 3));
  289. }
  290. // Current HPs are inferior to 75% ; apply lvl 2 of regen skill.
  291. else if ((npc.getCurrentHp() < ((npc.getMaxHp() * 3) / 4.0)) && (lvl != 2))
  292. {
  293. npc.setTarget(npc);
  294. npc.doCast(SkillTable.getInstance().getInfo(4691, 2));
  295. }
  296. // Apply lvl 1.
  297. else if (lvl != 1)
  298. {
  299. npc.setTarget(npc);
  300. npc.doCast(SkillTable.getInstance().getInfo(4691, 1));
  301. }
  302. }
  303. // Spawn cinematic, regen_task and choose of skill.
  304. else if (event.equalsIgnoreCase("spawn_1"))
  305. {
  306. ZONE.broadcastPacket(new SpecialCamera(npc.getObjectId(), 1800, 180, -1, 1500, 10000, 0, 0, 1, 0));
  307. }
  308. else if (event.equalsIgnoreCase("spawn_2"))
  309. {
  310. ZONE.broadcastPacket(new SpecialCamera(npc.getObjectId(), 1300, 180, -5, 3000, 10000, 0, -5, 1, 0));
  311. }
  312. else if (event.equalsIgnoreCase("spawn_3"))
  313. {
  314. ZONE.broadcastPacket(new SpecialCamera(npc.getObjectId(), 500, 180, -8, 600, 10000, 0, 60, 1, 0));
  315. }
  316. else if (event.equalsIgnoreCase("spawn_4"))
  317. {
  318. ZONE.broadcastPacket(new SpecialCamera(npc.getObjectId(), 800, 180, -8, 2700, 10000, 0, 30, 1, 0));
  319. }
  320. else if (event.equalsIgnoreCase("spawn_5"))
  321. {
  322. ZONE.broadcastPacket(new SpecialCamera(npc.getObjectId(), 200, 250, 70, 0, 10000, 30, 80, 1, 0));
  323. }
  324. else if (event.equalsIgnoreCase("spawn_6"))
  325. {
  326. ZONE.broadcastPacket(new SpecialCamera(npc.getObjectId(), 1100, 250, 70, 2500, 10000, 30, 80, 1, 0));
  327. }
  328. else if (event.equalsIgnoreCase("spawn_7"))
  329. {
  330. ZONE.broadcastPacket(new SpecialCamera(npc.getObjectId(), 700, 150, 30, 0, 10000, -10, 60, 1, 0));
  331. }
  332. else if (event.equalsIgnoreCase("spawn_8"))
  333. {
  334. ZONE.broadcastPacket(new SpecialCamera(npc.getObjectId(), 1200, 150, 20, 2900, 10000, -10, 30, 1, 0));
  335. }
  336. else if (event.equalsIgnoreCase("spawn_9"))
  337. {
  338. ZONE.broadcastPacket(new SpecialCamera(npc.getObjectId(), 750, 170, -10, 3400, 4000, 10, -15, 1, 0));
  339. }
  340. else if (event.equalsIgnoreCase("spawn_10"))
  341. {
  342. GrandBossManager.getInstance().setBossStatus(VALAKAS, FIGHTING);
  343. npc.setIsInvul(false);
  344. startQuestTimer("regen_task", 60000, npc, null, true);
  345. startQuestTimer("skill_task", 2000, npc, null, true);
  346. }
  347. // Death cinematic, spawn of Teleport Cubes.
  348. else if (event.equalsIgnoreCase("die_1"))
  349. {
  350. ZONE.broadcastPacket(new SpecialCamera(npc.getObjectId(), 2000, 130, -1, 0, 10000, 0, 0, 1, 1));
  351. }
  352. else if (event.equalsIgnoreCase("die_2"))
  353. {
  354. ZONE.broadcastPacket(new SpecialCamera(npc.getObjectId(), 1100, 210, -5, 3000, 10000, -13, 0, 1, 1));
  355. }
  356. else if (event.equalsIgnoreCase("die_3"))
  357. {
  358. ZONE.broadcastPacket(new SpecialCamera(npc.getObjectId(), 1300, 200, -8, 3000, 10000, 0, 15, 1, 1));
  359. }
  360. else if (event.equalsIgnoreCase("die_4"))
  361. {
  362. ZONE.broadcastPacket(new SpecialCamera(npc.getObjectId(), 1000, 190, 0, 500, 10000, 0, 10, 1, 1));
  363. }
  364. else if (event.equalsIgnoreCase("die_5"))
  365. {
  366. ZONE.broadcastPacket(new SpecialCamera(npc.getObjectId(), 1700, 120, 0, 2500, 10000, 12, 40, 1, 1));
  367. }
  368. else if (event.equalsIgnoreCase("die_6"))
  369. {
  370. ZONE.broadcastPacket(new SpecialCamera(npc.getObjectId(), 1700, 20, 0, 700, 10000, 10, 10, 1, 1));
  371. }
  372. else if (event.equalsIgnoreCase("die_7"))
  373. {
  374. ZONE.broadcastPacket(new SpecialCamera(npc.getObjectId(), 1700, 10, 0, 1000, 10000, 20, 70, 1, 1));
  375. }
  376. else if (event.equalsIgnoreCase("die_8"))
  377. {
  378. ZONE.broadcastPacket(new SpecialCamera(npc.getObjectId(), 1700, 10, 0, 300, 250, 20, -20, 1, 1));
  379. for (int[] element : _teleportCubeLocation)
  380. {
  381. addSpawn(31759, element[0], element[1], element[2], 0, false, 900000);
  382. }
  383. startQuestTimer("remove_players", 900000, null, null);
  384. }
  385. else if (event.equalsIgnoreCase("skill_task"))
  386. {
  387. callSkillAI(npc);
  388. }
  389. }
  390. else
  391. {
  392. if (event.equalsIgnoreCase("valakas_unlock"))
  393. {
  394. final L2Npc valakas = addSpawn(VALAKAS, -105200, -253104, -15264, 32768, false, 0);
  395. GrandBossManager.getInstance().addBoss((L2GrandBossInstance) valakas);
  396. GrandBossManager.getInstance().setBossStatus(VALAKAS, DORMANT);
  397. }
  398. else if (event.equalsIgnoreCase("remove_players"))
  399. {
  400. ZONE.oustAllPlayers();
  401. }
  402. }
  403. return super.onAdvEvent(event, npc, player);
  404. }
  405. @Override
  406. public String onSpawn(L2Npc npc)
  407. {
  408. npc.disableCoreAI(true);
  409. return super.onSpawn(npc);
  410. }
  411. @Override
  412. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isPet)
  413. {
  414. if (!ZONE.isInsideZone(attacker))
  415. {
  416. attacker.doDie(attacker);
  417. return null;
  418. }
  419. if (npc.isInvul())
  420. {
  421. return null;
  422. }
  423. if (GrandBossManager.getInstance().getBossStatus(VALAKAS) != FIGHTING)
  424. {
  425. attacker.teleToLocation(150037, -57255, -2976);
  426. return null;
  427. }
  428. // Debuff strider-mounted players.
  429. if (attacker.getMountType() == 1)
  430. {
  431. final L2Skill skill = SkillTable.getInstance().getInfo(4258, 1);
  432. if (attacker.getFirstEffect(skill) == null)
  433. {
  434. npc.setTarget(attacker);
  435. npc.doCast(skill);
  436. }
  437. }
  438. _timeTracker = System.currentTimeMillis();
  439. return super.onAttack(npc, attacker, damage, isPet);
  440. }
  441. @Override
  442. public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet)
  443. {
  444. // Cancel skill_task and regen_task.
  445. cancelQuestTimer("regen_task", npc, null);
  446. cancelQuestTimer("skill_task", npc, null);
  447. // Launch death animation.
  448. ZONE.broadcastPacket(new PlaySound(1, "B03_D", 0, 0, 0, 0, 0));
  449. startQuestTimer("die_1", 300, npc, null); // 300
  450. startQuestTimer("die_2", 600, npc, null); // 300
  451. startQuestTimer("die_3", 3800, npc, null); // 3200
  452. startQuestTimer("die_4", 8200, npc, null); // 4400
  453. startQuestTimer("die_5", 8700, npc, null); // 500
  454. startQuestTimer("die_6", 13300, npc, null); // 4600
  455. startQuestTimer("die_7", 14000, npc, null); // 700
  456. startQuestTimer("die_8", 16500, npc, null); // 2500
  457. GrandBossManager.getInstance().setBossStatus(VALAKAS, DEAD);
  458. long respawnTime = (long) Config.Interval_Of_Valakas_Spawn + getRandom(Config.Random_Of_Valakas_Spawn);
  459. startQuestTimer("valakas_unlock", respawnTime, null, null);
  460. // also save the respawn time so that the info is maintained past reboots
  461. StatsSet info = GrandBossManager.getInstance().getStatsSet(VALAKAS);
  462. info.set("respawn_time", (System.currentTimeMillis() + respawnTime));
  463. GrandBossManager.getInstance().setStatsSet(VALAKAS, info);
  464. return super.onKill(npc, killer, isPet);
  465. }
  466. @Override
  467. public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isPet)
  468. {
  469. return null;
  470. }
  471. private void callSkillAI(L2Npc npc)
  472. {
  473. if (npc.isInvul() || npc.isCastingNow())
  474. {
  475. return;
  476. }
  477. // Pickup a target if no or dead victim. 10% luck he decides to reconsiders his target.
  478. if ((_actualVictim == null) || _actualVictim.isDead() || !(npc.getKnownList().knowsObject(_actualVictim)) || (getRandom(10) == 0))
  479. {
  480. _actualVictim = getRandomTarget(npc);
  481. }
  482. // If result is still null, Valakas will roam. Don't go deeper in skill AI.
  483. if (_actualVictim == null)
  484. {
  485. if (getRandom(10) == 0)
  486. {
  487. int x = npc.getX();
  488. int y = npc.getY();
  489. int z = npc.getZ();
  490. int posX = x + getRandom(-1400, 1400);
  491. int posY = y + getRandom(-1400, 1400);
  492. if (GeoData.getInstance().canMoveFromToTarget(x, y, z, posX, posY, z, npc.getInstanceId()))
  493. {
  494. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(posX, posY, z, 0));
  495. }
  496. }
  497. return;
  498. }
  499. final L2Skill skill = SkillTable.getInstance().getInfo(getRandomSkill(npc), 1);
  500. // Cast the skill or follow the target.
  501. if (Util.checkIfInRange((skill.getCastRange() < 600) ? 600 : skill.getCastRange(), npc, _actualVictim, true))
  502. {
  503. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  504. npc.setIsCastingNow(true);
  505. npc.setTarget(_actualVictim);
  506. npc.doCast(skill);
  507. }
  508. else
  509. {
  510. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, _actualVictim, null);
  511. npc.setIsCastingNow(false);
  512. }
  513. }
  514. /**
  515. * Pick a random skill.<br>
  516. * Valakas will mostly use utility skills. If Valakas feels surrounded, he will use AoE skills.<br>
  517. * Lower than 50% HPs, he will begin to use Meteor skill.
  518. * @param npc valakas
  519. * @return a usable skillId
  520. */
  521. private int getRandomSkill(L2Npc npc)
  522. {
  523. final int hpRatio = (int) ((npc.getCurrentHp() / npc.getMaxHp()) * 100);
  524. // Valakas Lava Skin is prioritary.
  525. if ((hpRatio < 75) && (getRandom(150) == 0) && (npc.getFirstEffect(4680) == null))
  526. {
  527. return 4680;
  528. }
  529. // Valakas will use mass spells if he feels surrounded.
  530. if (Util.getPlayersCountInRadius(1200, npc, false, false) >= 20)
  531. {
  532. return VALAKAS_AOE_SKILLS[getRandom(VALAKAS_AOE_SKILLS.length)];
  533. }
  534. if (hpRatio > 50)
  535. {
  536. return VALAKAS_REGULAR_SKILLS[getRandom(VALAKAS_REGULAR_SKILLS.length)];
  537. }
  538. return VALAKAS_LOWHP_SKILLS[getRandom(VALAKAS_LOWHP_SKILLS.length)];
  539. }
  540. /**
  541. * Pickup a random L2Playable from the zone, deads targets aren't included.
  542. * @param npc
  543. * @return a random L2Playable.
  544. */
  545. private L2Playable getRandomTarget(L2Npc npc)
  546. {
  547. List<L2Playable> result = new ArrayList<>();
  548. for (L2Character obj : npc.getKnownList().getKnownCharacters())
  549. {
  550. if ((obj == null) || obj.isPet())
  551. {
  552. continue;
  553. }
  554. else if (!obj.isDead() && obj.isPlayable())
  555. {
  556. result.add((L2Playable) obj);
  557. }
  558. }
  559. return (result.isEmpty()) ? null : result.get(getRandom(result.size()));
  560. }
  561. public static void main(String[] args)
  562. {
  563. new Valakas(Valakas.class.getSimpleName(), "ai");
  564. }
  565. }