Zaken.java 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048
  1. /*
  2. * Copyright (C) 2004-2013 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 ai.npc.AbstractNpcAI;
  21. import com.l2jserver.Config;
  22. import com.l2jserver.gameserver.GameTimeController;
  23. import com.l2jserver.gameserver.ThreadPoolManager;
  24. import com.l2jserver.gameserver.ai.CtrlIntention;
  25. import com.l2jserver.gameserver.datatables.DoorTable;
  26. import com.l2jserver.gameserver.datatables.SkillTable;
  27. import com.l2jserver.gameserver.enums.MountType;
  28. import com.l2jserver.gameserver.instancemanager.GrandBossManager;
  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.L2GrandBossInstance;
  36. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  37. import com.l2jserver.gameserver.model.effects.L2Effect;
  38. import com.l2jserver.gameserver.model.skills.L2Skill;
  39. import com.l2jserver.gameserver.model.zone.type.L2BossZone;
  40. import com.l2jserver.gameserver.network.serverpackets.PlaySound;
  41. /**
  42. * Zaken AI
  43. */
  44. public class Zaken extends AbstractNpcAI
  45. {
  46. private int _1001 = 0; // used for first cancel of QuestTimer "1001"
  47. private int _ai0 = 0; // used for zaken coords updater
  48. private final Location _loc = new Location(0, 0, 0);
  49. private int _ai4 = 0; // used for spawning minions cycles
  50. private int _quest0 = 0; // used for teleporting progress
  51. private int _quest1 = 0; // used for most hated players progress
  52. private int _quest2 = 0; // used for zaken HP check for teleport
  53. private L2PcInstance c_quest0 = null; // 1st player used for area teleport
  54. private L2PcInstance c_quest1 = null; // 2nd player used for area teleport
  55. private L2PcInstance c_quest2 = null; // 3rd player used for area teleport
  56. private L2PcInstance c_quest3 = null; // 4th player used for area teleport
  57. private L2PcInstance c_quest4 = null; // 5th player used for area teleport
  58. private static final int ZAKEN = 29022;
  59. private static final int doll_blader_b = 29023;
  60. private static final int vale_master_b = 29024;
  61. private static final int pirates_zombie_captain_b = 29026;
  62. private static final int pirates_zombie_b = 29027;
  63. private static final int[] Xcoords =
  64. {
  65. 53950,
  66. 55980,
  67. 54950,
  68. 55970,
  69. 53930,
  70. 55970,
  71. 55980,
  72. 54960,
  73. 53950,
  74. 53930,
  75. 55970,
  76. 55980,
  77. 54960,
  78. 53950,
  79. 53930
  80. };
  81. private static final int[] Ycoords =
  82. {
  83. 219860,
  84. 219820,
  85. 218790,
  86. 217770,
  87. 217760,
  88. 217770,
  89. 219920,
  90. 218790,
  91. 219860,
  92. 217760,
  93. 217770,
  94. 219920,
  95. 218790,
  96. 219860,
  97. 217760
  98. };
  99. private static final int[] Zcoords =
  100. {
  101. -3488,
  102. -3488,
  103. -3488,
  104. -3488,
  105. -3488,
  106. -3216,
  107. -3216,
  108. -3216,
  109. -3216,
  110. -3216,
  111. -2944,
  112. -2944,
  113. -2944,
  114. -2944,
  115. -2944
  116. };
  117. // ZAKEN Status Tracking :
  118. private static final byte ALIVE = 0; // Zaken is spawned.
  119. private static final byte DEAD = 1; // Zaken has been killed.
  120. private static L2BossZone _Zone;
  121. private Zaken(String name, String descr)
  122. {
  123. super(name, descr);
  124. // Zaken doors handling
  125. ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable()
  126. {
  127. @Override
  128. public void run()
  129. {
  130. try
  131. {
  132. if (getTimeHour() == 0)
  133. {
  134. DoorTable.getInstance().getDoor(21240006).openMe();
  135. ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  136. {
  137. @Override
  138. public void run()
  139. {
  140. try
  141. {
  142. DoorTable.getInstance().getDoor(21240006).closeMe();
  143. }
  144. catch (Throwable e)
  145. {
  146. _log.warning("Cannot close door ID: 21240006 " + e);
  147. }
  148. }
  149. }, 300000L);
  150. }
  151. }
  152. catch (Throwable e)
  153. {
  154. _log.warning("Cannot open door ID: 21240006 " + e);
  155. }
  156. }
  157. }, 2000L, 600000L);
  158. int[] mobs =
  159. {
  160. ZAKEN,
  161. doll_blader_b,
  162. vale_master_b,
  163. pirates_zombie_captain_b,
  164. pirates_zombie_b
  165. };
  166. registerMobs(mobs);
  167. _Zone = GrandBossManager.getInstance().getZone(55312, 219168, -3223);
  168. StatsSet info = GrandBossManager.getInstance().getStatsSet(ZAKEN);
  169. int status = GrandBossManager.getInstance().getBossStatus(ZAKEN);
  170. if (status == DEAD)
  171. {
  172. // load the unlock date and time for zaken from DB
  173. long temp = info.getLong("respawn_time") - System.currentTimeMillis();
  174. // if zaken is locked until a certain time, mark it so and start the unlock timer
  175. // the unlock time has not yet expired.
  176. if (temp > 0)
  177. {
  178. startQuestTimer("zaken_unlock", temp, null, null);
  179. }
  180. else
  181. {
  182. // the time has already expired while the server was offline. Immediately spawn zaken.
  183. L2GrandBossInstance zaken = (L2GrandBossInstance) addSpawn(ZAKEN, 55312, 219168, -3223, 0, false, 0);
  184. GrandBossManager.getInstance().setBossStatus(ZAKEN, ALIVE);
  185. spawnBoss(zaken);
  186. }
  187. }
  188. else
  189. {
  190. int loc_x = info.getInt("loc_x");
  191. int loc_y = info.getInt("loc_y");
  192. int loc_z = info.getInt("loc_z");
  193. int heading = info.getInt("heading");
  194. int hp = info.getInt("currentHP");
  195. int mp = info.getInt("currentMP");
  196. L2GrandBossInstance zaken = (L2GrandBossInstance) addSpawn(ZAKEN, loc_x, loc_y, loc_z, heading, false, 0);
  197. zaken.setCurrentHpMp(hp, mp);
  198. spawnBoss(zaken);
  199. }
  200. }
  201. public void spawnBoss(L2GrandBossInstance npc)
  202. {
  203. if (npc == null)
  204. {
  205. _log.warning("Zaken AI failed to load, missing Zaken in grandboss_data.sql");
  206. return;
  207. }
  208. GrandBossManager.getInstance().addBoss(npc);
  209. npc.broadcastPacket(new PlaySound(1, "BS01_A", 1, npc.getObjectId(), npc.getX(), npc.getY(), npc.getZ()));
  210. _ai0 = 0;
  211. _loc.setLocation(npc.getLocation());
  212. _quest0 = 0;
  213. _quest1 = 0;
  214. _quest2 = 3;
  215. if (_Zone == null)
  216. {
  217. _log.warning("Zaken AI failed to load, missing zone for Zaken");
  218. return;
  219. }
  220. if (_Zone.isInsideZone(npc))
  221. {
  222. _ai4 = 1;
  223. startQuestTimer("1003", 1700, null, null, true);
  224. }
  225. _1001 = 1;
  226. startQuestTimer("1001", 1000, npc, null, true); // buffs,random teleports
  227. }
  228. @Override
  229. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  230. {
  231. int status = GrandBossManager.getInstance().getBossStatus(ZAKEN);
  232. if ((status == DEAD) && !event.equalsIgnoreCase("zaken_unlock"))
  233. {
  234. return super.onAdvEvent(event, npc, player);
  235. }
  236. if (event.equalsIgnoreCase("1001"))
  237. {
  238. if (_1001 == 1)
  239. {
  240. _1001 = 0;
  241. cancelQuestTimer("1001", npc, null);
  242. }
  243. int sk_4223 = 0;
  244. int sk_4227 = 0;
  245. for (L2Effect e : npc.getAllEffects())
  246. {
  247. if (e.getSkill().getId() == 4227)
  248. {
  249. sk_4227 = 1;
  250. }
  251. if (e.getSkill().getId() == 4223)
  252. {
  253. sk_4223 = 1;
  254. }
  255. }
  256. if (getTimeHour() < 5)
  257. {
  258. if (sk_4223 == 1) // use night face if zaken have day face
  259. {
  260. npc.setTarget(npc);
  261. npc.doCast(SkillTable.getInstance().getInfo(4224, 1));
  262. _loc.setLocation(npc.getLocation());
  263. }
  264. if (sk_4227 == 0) // use zaken regeneration
  265. {
  266. npc.setTarget(npc);
  267. npc.doCast(SkillTable.getInstance().getInfo(4227, 1));
  268. }
  269. if ((npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ATTACK) && (_ai0 == 0))
  270. {
  271. int i0 = 0;
  272. int i1 = 1;
  273. if (((L2Attackable) npc).getMostHated() != null)
  274. {
  275. if ((((((L2Attackable) npc).getMostHated().getX() - _loc.getX()) * (((L2Attackable) npc).getMostHated().getX() - _loc.getX())) + ((((L2Attackable) npc).getMostHated().getY() - _loc.getY()) * (((L2Attackable) npc).getMostHated().getY() - _loc.getY()))) > (1500 * 1500))
  276. {
  277. i0 = 1;
  278. }
  279. else
  280. {
  281. i0 = 0;
  282. }
  283. if (i0 == 0)
  284. {
  285. i1 = 0;
  286. }
  287. if (_quest0 > 0)
  288. {
  289. if (c_quest0 == null)
  290. {
  291. i0 = 0;
  292. }
  293. else if ((((c_quest0.getX() - _loc.getX()) * (c_quest0.getX() - _loc.getX())) + ((c_quest0.getY() - _loc.getY()) * (c_quest0.getY() - _loc.getY()))) > (1500 * 1500))
  294. {
  295. i0 = 1;
  296. }
  297. else
  298. {
  299. i0 = 0;
  300. }
  301. if (i0 == 0)
  302. {
  303. i1 = 0;
  304. }
  305. }
  306. if (_quest0 > 1)
  307. {
  308. if (c_quest1 == null)
  309. {
  310. i0 = 0;
  311. }
  312. else if ((((c_quest1.getX() - _loc.getX()) * (c_quest1.getX() - _loc.getX())) + ((c_quest1.getY() - _loc.getY()) * (c_quest1.getY() - _loc.getY()))) > (1500 * 1500))
  313. {
  314. i0 = 1;
  315. }
  316. else
  317. {
  318. i0 = 0;
  319. }
  320. if (i0 == 0)
  321. {
  322. i1 = 0;
  323. }
  324. }
  325. if (_quest0 > 2)
  326. {
  327. if (c_quest2 == null)
  328. {
  329. i0 = 0;
  330. }
  331. else if ((((c_quest2.getX() - _loc.getX()) * (c_quest2.getX() - _loc.getX())) + ((c_quest2.getY() - _loc.getY()) * (c_quest2.getY() - _loc.getY()))) > (1500 * 1500))
  332. {
  333. i0 = 1;
  334. }
  335. else
  336. {
  337. i0 = 0;
  338. }
  339. if (i0 == 0)
  340. {
  341. i1 = 0;
  342. }
  343. }
  344. if (_quest0 > 3)
  345. {
  346. if (c_quest3 == null)
  347. {
  348. i0 = 0;
  349. }
  350. else if ((((c_quest3.getX() - _loc.getX()) * (c_quest3.getX() - _loc.getX())) + ((c_quest3.getY() - _loc.getY()) * (c_quest3.getY() - _loc.getY()))) > (1500 * 1500))
  351. {
  352. i0 = 1;
  353. }
  354. else
  355. {
  356. i0 = 0;
  357. }
  358. if (i0 == 0)
  359. {
  360. i1 = 0;
  361. }
  362. }
  363. if (_quest0 > 4)
  364. {
  365. if (c_quest4 == null)
  366. {
  367. i0 = 0;
  368. }
  369. else if ((((c_quest4.getX() - _loc.getX()) * (c_quest4.getX() - _loc.getX())) + ((c_quest4.getY() - _loc.getY()) * (c_quest4.getY() - _loc.getY()))) > (1500 * 1500))
  370. {
  371. i0 = 1;
  372. }
  373. else
  374. {
  375. i0 = 0;
  376. }
  377. if (i0 == 0)
  378. {
  379. i1 = 0;
  380. }
  381. }
  382. if (i1 == 1)
  383. {
  384. _quest0 = 0;
  385. int i2 = getRandom(15);
  386. _loc.setX(Xcoords[i2] + getRandom(650));
  387. _loc.setY(Ycoords[i2] + getRandom(650));
  388. _loc.setZ(Zcoords[i2]);
  389. npc.setTarget(npc);
  390. npc.doCast(SkillTable.getInstance().getInfo(4222, 1));
  391. }
  392. }
  393. }
  394. if ((getRandom(20) < 1) && (_ai0 == 0))
  395. {
  396. _loc.setLocation(npc.getLocation());
  397. }
  398. L2Character c_ai0 = null;
  399. if ((npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ATTACK) && (_quest1 == 0))
  400. {
  401. if (((L2Attackable) npc).getMostHated() != null)
  402. {
  403. c_ai0 = ((L2Attackable) npc).getMostHated();
  404. _quest1 = 1;
  405. }
  406. }
  407. else if ((npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ATTACK) && (_quest1 != 0))
  408. {
  409. if (((L2Attackable) npc).getMostHated() != null)
  410. {
  411. if (c_ai0 == ((L2Attackable) npc).getMostHated())
  412. {
  413. _quest1 = (_quest1 + 1);
  414. }
  415. else
  416. {
  417. _quest1 = 1;
  418. c_ai0 = ((L2Attackable) npc).getMostHated();
  419. }
  420. }
  421. }
  422. if (npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE)
  423. {
  424. _quest1 = 0;
  425. }
  426. if (_quest1 > 5)
  427. {
  428. ((L2Attackable) npc).stopHating(c_ai0);
  429. L2Character nextTarget = ((L2Attackable) npc).getMostHated();
  430. if (nextTarget != null)
  431. {
  432. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, nextTarget);
  433. }
  434. _quest1 = 0;
  435. }
  436. }
  437. else if (sk_4223 == 0) // use day face if not night time
  438. {
  439. npc.setTarget(npc);
  440. npc.doCast(SkillTable.getInstance().getInfo(4223, 1));
  441. _quest2 = 3;
  442. }
  443. if (sk_4227 == 1) // when switching to day time, cancel zaken night regen
  444. {
  445. npc.setTarget(npc);
  446. npc.doCast(SkillTable.getInstance().getInfo(4242, 1));
  447. }
  448. if (getRandom(40) < 1)
  449. {
  450. int i2 = getRandom(15);
  451. _loc.setX(Xcoords[i2] + getRandom(650));
  452. _loc.setY(Ycoords[i2] + getRandom(650));
  453. _loc.setZ(Zcoords[i2]);
  454. npc.setTarget(npc);
  455. npc.doCast(SkillTable.getInstance().getInfo(4222, 1));
  456. }
  457. startQuestTimer("1001", 30000, npc, null, true);
  458. }
  459. if (event.equalsIgnoreCase("1002"))
  460. {
  461. _quest0 = 0;
  462. npc.doCast(SkillTable.getInstance().getInfo(4222, 1));
  463. _ai0 = 0;
  464. }
  465. if (event.equalsIgnoreCase("1003"))
  466. {
  467. if (_ai4 == 1)
  468. {
  469. int rr = getRandom(15);
  470. ((L2Attackable) addSpawn(pirates_zombie_captain_b, Xcoords[rr] + getRandom(650), Ycoords[rr] + getRandom(650), Zcoords[rr], getRandom(65536), false, 0)).setIsRaidMinion(true);
  471. _ai4 = 2;
  472. }
  473. else if (_ai4 == 2)
  474. {
  475. int rr = getRandom(15);
  476. ((L2Attackable) addSpawn(doll_blader_b, Xcoords[rr] + getRandom(650), Ycoords[rr] + getRandom(650), Zcoords[rr], getRandom(65536), false, 0)).setIsRaidMinion(true);
  477. _ai4 = 3;
  478. }
  479. else if (_ai4 == 3)
  480. {
  481. ((L2Attackable) addSpawn(vale_master_b, Xcoords[getRandom(15)] + getRandom(650), Ycoords[getRandom(15)] + getRandom(650), Zcoords[getRandom(15)], getRandom(65536), false, 0)).setIsRaidMinion(true);
  482. ((L2Attackable) addSpawn(vale_master_b, Xcoords[getRandom(15)] + getRandom(650), Ycoords[getRandom(15)] + getRandom(650), Zcoords[getRandom(15)], getRandom(65536), false, 0)).setIsRaidMinion(true);
  483. _ai4 = 4;
  484. }
  485. else if (_ai4 == 4)
  486. {
  487. ((L2Attackable) addSpawn(pirates_zombie_b, Xcoords[getRandom(15)] + getRandom(650), Ycoords[getRandom(15)] + getRandom(650), Zcoords[getRandom(15)], getRandom(65536), false, 0)).setIsRaidMinion(true);
  488. ((L2Attackable) addSpawn(pirates_zombie_b, Xcoords[getRandom(15)] + getRandom(650), Ycoords[getRandom(15)] + getRandom(650), Zcoords[getRandom(15)], getRandom(65536), false, 0)).setIsRaidMinion(true);
  489. ((L2Attackable) addSpawn(pirates_zombie_b, Xcoords[getRandom(15)] + getRandom(650), Ycoords[getRandom(15)] + getRandom(650), Zcoords[getRandom(15)], getRandom(65536), false, 0)).setIsRaidMinion(true);
  490. ((L2Attackable) addSpawn(pirates_zombie_b, Xcoords[getRandom(15)] + getRandom(650), Ycoords[getRandom(15)] + getRandom(650), Zcoords[getRandom(15)], getRandom(65536), false, 0)).setIsRaidMinion(true);
  491. ((L2Attackable) addSpawn(pirates_zombie_b, Xcoords[getRandom(15)] + getRandom(650), Ycoords[getRandom(15)] + getRandom(650), Zcoords[getRandom(15)], getRandom(65536), false, 0)).setIsRaidMinion(true);
  492. _ai4 = 5;
  493. }
  494. else if (_ai4 == 5)
  495. {
  496. ((L2Attackable) addSpawn(doll_blader_b, 52675, 219371, -3290, getRandom(65536), false, 0)).setIsRaidMinion(true);
  497. ((L2Attackable) addSpawn(doll_blader_b, 52687, 219596, -3368, getRandom(65536), false, 0)).setIsRaidMinion(true);
  498. ((L2Attackable) addSpawn(doll_blader_b, 52672, 219740, -3418, getRandom(65536), false, 0)).setIsRaidMinion(true);
  499. ((L2Attackable) addSpawn(pirates_zombie_b, 52857, 219992, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  500. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 52959, 219997, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  501. ((L2Attackable) addSpawn(vale_master_b, 53381, 220151, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  502. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 54236, 220948, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  503. ((L2Attackable) addSpawn(pirates_zombie_b, 54885, 220144, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  504. ((L2Attackable) addSpawn(pirates_zombie_b, 55264, 219860, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  505. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 55399, 220263, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  506. ((L2Attackable) addSpawn(pirates_zombie_b, 55679, 220129, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  507. ((L2Attackable) addSpawn(vale_master_b, 56276, 220783, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  508. ((L2Attackable) addSpawn(vale_master_b, 57173, 220234, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  509. ((L2Attackable) addSpawn(pirates_zombie_b, 56267, 218826, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  510. ((L2Attackable) addSpawn(doll_blader_b, 56294, 219482, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  511. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 56094, 219113, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  512. ((L2Attackable) addSpawn(doll_blader_b, 56364, 218967, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  513. ((L2Attackable) addSpawn(pirates_zombie_b, 57113, 218079, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  514. ((L2Attackable) addSpawn(doll_blader_b, 56186, 217153, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  515. ((L2Attackable) addSpawn(pirates_zombie_b, 55440, 218081, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  516. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 55202, 217940, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  517. ((L2Attackable) addSpawn(pirates_zombie_b, 55225, 218236, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  518. ((L2Attackable) addSpawn(pirates_zombie_b, 54973, 218075, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  519. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 53412, 218077, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  520. ((L2Attackable) addSpawn(vale_master_b, 54226, 218797, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  521. ((L2Attackable) addSpawn(vale_master_b, 54394, 219067, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  522. ((L2Attackable) addSpawn(pirates_zombie_b, 54139, 219253, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  523. ((L2Attackable) addSpawn(doll_blader_b, 54262, 219480, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  524. _ai4 = 6;
  525. }
  526. else if (_ai4 == 6)
  527. {
  528. ((L2Attackable) addSpawn(pirates_zombie_b, 53412, 218077, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  529. ((L2Attackable) addSpawn(vale_master_b, 54413, 217132, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  530. ((L2Attackable) addSpawn(doll_blader_b, 54841, 217132, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  531. ((L2Attackable) addSpawn(doll_blader_b, 55372, 217128, -3343, getRandom(65536), false, 0)).setIsRaidMinion(true);
  532. ((L2Attackable) addSpawn(doll_blader_b, 55893, 217122, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  533. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 56282, 217237, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  534. ((L2Attackable) addSpawn(vale_master_b, 56963, 218080, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  535. ((L2Attackable) addSpawn(pirates_zombie_b, 56267, 218826, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  536. ((L2Attackable) addSpawn(doll_blader_b, 56294, 219482, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  537. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 56094, 219113, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  538. ((L2Attackable) addSpawn(doll_blader_b, 56364, 218967, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  539. ((L2Attackable) addSpawn(vale_master_b, 56276, 220783, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  540. ((L2Attackable) addSpawn(vale_master_b, 57173, 220234, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  541. ((L2Attackable) addSpawn(pirates_zombie_b, 54885, 220144, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  542. ((L2Attackable) addSpawn(pirates_zombie_b, 55264, 219860, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  543. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 55399, 220263, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  544. ((L2Attackable) addSpawn(pirates_zombie_b, 55679, 220129, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  545. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 54236, 220948, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  546. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 54464, 219095, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  547. ((L2Attackable) addSpawn(vale_master_b, 54226, 218797, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  548. ((L2Attackable) addSpawn(vale_master_b, 54394, 219067, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  549. ((L2Attackable) addSpawn(pirates_zombie_b, 54139, 219253, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  550. ((L2Attackable) addSpawn(doll_blader_b, 54262, 219480, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  551. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 53412, 218077, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  552. ((L2Attackable) addSpawn(pirates_zombie_b, 55440, 218081, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  553. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 55202, 217940, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  554. ((L2Attackable) addSpawn(pirates_zombie_b, 55225, 218236, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  555. ((L2Attackable) addSpawn(pirates_zombie_b, 54973, 218075, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  556. _ai4 = 7;
  557. }
  558. else if (_ai4 == 7)
  559. {
  560. ((L2Attackable) addSpawn(pirates_zombie_b, 54228, 217504, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  561. ((L2Attackable) addSpawn(vale_master_b, 54181, 217168, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  562. ((L2Attackable) addSpawn(doll_blader_b, 54714, 217123, -3168, getRandom(65536), false, 0)).setIsRaidMinion(true);
  563. ((L2Attackable) addSpawn(doll_blader_b, 55298, 217127, -3073, getRandom(65536), false, 0)).setIsRaidMinion(true);
  564. ((L2Attackable) addSpawn(doll_blader_b, 55787, 217130, -2993, getRandom(65536), false, 0)).setIsRaidMinion(true);
  565. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 56284, 217216, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  566. ((L2Attackable) addSpawn(vale_master_b, 56963, 218080, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  567. ((L2Attackable) addSpawn(pirates_zombie_b, 56267, 218826, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  568. ((L2Attackable) addSpawn(doll_blader_b, 56294, 219482, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  569. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 56094, 219113, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  570. ((L2Attackable) addSpawn(doll_blader_b, 56364, 218967, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  571. ((L2Attackable) addSpawn(vale_master_b, 56276, 220783, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  572. ((L2Attackable) addSpawn(vale_master_b, 57173, 220234, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  573. ((L2Attackable) addSpawn(pirates_zombie_b, 54885, 220144, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  574. ((L2Attackable) addSpawn(pirates_zombie_b, 55264, 219860, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  575. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 55399, 220263, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  576. ((L2Attackable) addSpawn(pirates_zombie_b, 55679, 220129, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  577. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 54236, 220948, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  578. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 54464, 219095, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  579. ((L2Attackable) addSpawn(vale_master_b, 54226, 218797, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  580. ((L2Attackable) addSpawn(vale_master_b, 54394, 219067, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  581. ((L2Attackable) addSpawn(pirates_zombie_b, 54139, 219253, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  582. ((L2Attackable) addSpawn(doll_blader_b, 54262, 219480, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  583. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 53412, 218077, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  584. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 54280, 217200, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  585. ((L2Attackable) addSpawn(pirates_zombie_b, 55440, 218081, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  586. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 55202, 217940, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  587. ((L2Attackable) addSpawn(pirates_zombie_b, 55225, 218236, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  588. ((L2Attackable) addSpawn(pirates_zombie_b, 54973, 218075, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  589. _ai4 = 8;
  590. cancelQuestTimer("1003", null, null);
  591. }
  592. }
  593. else if (event.equalsIgnoreCase("zaken_unlock"))
  594. {
  595. L2GrandBossInstance zaken = (L2GrandBossInstance) addSpawn(ZAKEN, 55312, 219168, -3223, 0, false, 0);
  596. GrandBossManager.getInstance().setBossStatus(ZAKEN, ALIVE);
  597. spawnBoss(zaken);
  598. }
  599. else if (event.equalsIgnoreCase("CreateOnePrivateEx"))
  600. {
  601. ((L2Attackable) addSpawn(npc.getId(), npc.getX(), npc.getY(), npc.getZ(), 0, false, 0)).setIsRaidMinion(true);
  602. }
  603. return super.onAdvEvent(event, npc, player);
  604. }
  605. @Override
  606. public String onFactionCall(L2Npc npc, L2Npc caller, L2PcInstance attacker, boolean isSummon)
  607. {
  608. if ((caller == null) || (npc == null))
  609. {
  610. return super.onFactionCall(npc, caller, attacker, isSummon);
  611. }
  612. int npcId = npc.getId();
  613. int callerId = caller.getId();
  614. if ((getTimeHour() < 5) && (callerId != ZAKEN) && (npcId == ZAKEN))
  615. {
  616. int damage = 0; // well damage required :x
  617. if ((npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE) && (_ai0 == 0) && (damage < 10) && (getRandom((30 * 15)) < 1))// todo - damage missing
  618. {
  619. _ai0 = 1;
  620. _loc.setLocation(caller.getLocation());
  621. startQuestTimer("1002", 300, caller, null);
  622. }
  623. }
  624. return super.onFactionCall(npc, caller, attacker, isSummon);
  625. }
  626. @Override
  627. public String onSpellFinished(L2Npc npc, L2PcInstance player, L2Skill skill)
  628. {
  629. if (npc.getId() == ZAKEN)
  630. {
  631. int skillId = skill.getId();
  632. if (skillId == 4222)
  633. {
  634. npc.teleToLocation(_loc);
  635. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  636. }
  637. else if (skillId == 4216)
  638. {
  639. int i1 = getRandom(15);
  640. player.teleToLocation(new Location(Xcoords[i1] + getRandom(650), Ycoords[i1] + getRandom(650), Zcoords[i1]));
  641. ((L2Attackable) npc).stopHating(player);
  642. L2Character nextTarget = ((L2Attackable) npc).getMostHated();
  643. if (nextTarget != null)
  644. {
  645. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, nextTarget);
  646. }
  647. }
  648. else if (skillId == 4217)
  649. {
  650. int i0 = 0;
  651. int i1 = getRandom(15);
  652. player.teleToLocation(new Location(Xcoords[i1] + getRandom(650), Ycoords[i1] + getRandom(650), Zcoords[i1]));
  653. ((L2Attackable) npc).stopHating(player);
  654. if ((c_quest0 != null) && (_quest0 > 0) && (c_quest0 != player) && (c_quest0.getZ() > (player.getZ() - 100)) && (c_quest0.getZ() < (player.getZ() + 100)))
  655. {
  656. if ((((c_quest0.getX() - player.getX()) * (c_quest0.getX() - player.getX())) + ((c_quest0.getY() - player.getY()) * (c_quest0.getY() - player.getY()))) > (250 * 250))
  657. {
  658. i0 = 1;
  659. }
  660. else
  661. {
  662. i0 = 0;
  663. }
  664. if (i0 == 0)
  665. {
  666. i1 = getRandom(15);
  667. c_quest0.teleToLocation(new Location(Xcoords[i1] + getRandom(650), Ycoords[i1] + getRandom(650), Zcoords[i1]));
  668. ((L2Attackable) npc).stopHating(c_quest0);
  669. }
  670. }
  671. if ((c_quest1 != null) && (_quest0 > 1) && (c_quest1 != player) && (c_quest1.getZ() > (player.getZ() - 100)) && (c_quest1.getZ() < (player.getZ() + 100)))
  672. {
  673. if ((((c_quest1.getX() - player.getX()) * (c_quest1.getX() - player.getX())) + ((c_quest1.getY() - player.getY()) * (c_quest1.getY() - player.getY()))) > (250 * 250))
  674. {
  675. i0 = 1;
  676. }
  677. else
  678. {
  679. i0 = 0;
  680. }
  681. if (i0 == 0)
  682. {
  683. i1 = getRandom(15);
  684. c_quest1.teleToLocation(new Location(Xcoords[i1] + getRandom(650), Ycoords[i1] + getRandom(650), Zcoords[i1]));
  685. ((L2Attackable) npc).stopHating(c_quest1);
  686. }
  687. }
  688. if ((c_quest2 != null) && (_quest0 > 2) && (c_quest2 != player) && (c_quest2.getZ() > (player.getZ() - 100)) && (c_quest2.getZ() < (player.getZ() + 100)))
  689. {
  690. if ((((c_quest2.getX() - player.getX()) * (c_quest2.getX() - player.getX())) + ((c_quest2.getY() - player.getY()) * (c_quest2.getY() - player.getY()))) > (250 * 250))
  691. {
  692. i0 = 1;
  693. }
  694. else
  695. {
  696. i0 = 0;
  697. }
  698. if (i0 == 0)
  699. {
  700. i1 = getRandom(15);
  701. c_quest2.teleToLocation(new Location(Xcoords[i1] + getRandom(650), Ycoords[i1] + getRandom(650), Zcoords[i1]));
  702. ((L2Attackable) npc).stopHating(c_quest2);
  703. }
  704. }
  705. if ((c_quest3 != null) && (_quest0 > 3) && (c_quest3 != player) && (c_quest3.getZ() > (player.getZ() - 100)) && (c_quest3.getZ() < (player.getZ() + 100)))
  706. {
  707. if ((((c_quest3.getX() - player.getX()) * (c_quest3.getX() - player.getX())) + ((c_quest3.getY() - player.getY()) * (c_quest3.getY() - player.getY()))) > (250 * 250))
  708. {
  709. i0 = 1;
  710. }
  711. else
  712. {
  713. i0 = 0;
  714. }
  715. if (i0 == 0)
  716. {
  717. i1 = getRandom(15);
  718. c_quest3.teleToLocation(new Location(Xcoords[i1] + getRandom(650), Ycoords[i1] + getRandom(650), Zcoords[i1]));
  719. ((L2Attackable) npc).stopHating(c_quest3);
  720. }
  721. }
  722. if ((c_quest4 != null) && (_quest0 > 4) && (c_quest4 != player) && (c_quest4.getZ() > (player.getZ() - 100)) && (c_quest4.getZ() < (player.getZ() + 100)))
  723. {
  724. if ((((c_quest4.getX() - player.getX()) * (c_quest4.getX() - player.getX())) + ((c_quest4.getY() - player.getY()) * (c_quest4.getY() - player.getY()))) > (250 * 250))
  725. {
  726. i0 = 1;
  727. }
  728. else
  729. {
  730. i0 = 0;
  731. }
  732. if (i0 == 0)
  733. {
  734. i1 = getRandom(15);
  735. c_quest4.teleToLocation(new Location(Xcoords[i1] + getRandom(650), Ycoords[i1] + getRandom(650), Zcoords[i1]));
  736. ((L2Attackable) npc).stopHating(c_quest4);
  737. }
  738. }
  739. L2Character nextTarget = ((L2Attackable) npc).getMostHated();
  740. if (nextTarget != null)
  741. {
  742. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, nextTarget);
  743. }
  744. }
  745. }
  746. return super.onSpellFinished(npc, player, skill);
  747. }
  748. @Override
  749. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon)
  750. {
  751. int npcId = npc.getId();
  752. if (npcId == ZAKEN)
  753. {
  754. if (attacker.getMountType() == MountType.STRIDER)
  755. {
  756. int sk_4258 = 0;
  757. for (L2Effect e : attacker.getAllEffects())
  758. {
  759. if (e.getSkill().getId() == 4258)
  760. {
  761. sk_4258 = 1;
  762. }
  763. }
  764. if (sk_4258 == 0)
  765. {
  766. npc.setTarget(attacker);
  767. npc.doCast(SkillTable.getInstance().getInfo(4258, 1));
  768. }
  769. }
  770. L2Character originalAttacker = isSummon ? attacker.getSummon() : attacker;
  771. int hate = (int) (((damage / npc.getMaxHp()) / 0.05) * 20000);
  772. ((L2Attackable) npc).addDamageHate(originalAttacker, 0, hate);
  773. if (getRandom(10) < 1)
  774. {
  775. int i0 = getRandom((15 * 15));
  776. if (i0 < 1)
  777. {
  778. npc.setTarget(attacker);
  779. npc.doCast(SkillTable.getInstance().getInfo(4216, 1));
  780. }
  781. else if (i0 < 2)
  782. {
  783. npc.setTarget(attacker);
  784. npc.doCast(SkillTable.getInstance().getInfo(4217, 1));
  785. }
  786. else if (i0 < 4)
  787. {
  788. npc.setTarget(attacker);
  789. npc.doCast(SkillTable.getInstance().getInfo(4219, 1));
  790. }
  791. else if (i0 < 8)
  792. {
  793. npc.setTarget(attacker);
  794. npc.doCast(SkillTable.getInstance().getInfo(4218, 1));
  795. }
  796. else if (i0 < 15)
  797. {
  798. for (L2Character character : npc.getKnownList().getKnownCharactersInRadius(100))
  799. {
  800. if (character != attacker)
  801. {
  802. continue;
  803. }
  804. if (attacker != ((L2Attackable) npc).getMostHated())
  805. {
  806. npc.setTarget(attacker);
  807. npc.doCast(SkillTable.getInstance().getInfo(4221, 1));
  808. }
  809. }
  810. }
  811. if (getRandom(2) < 1)
  812. {
  813. if (attacker == ((L2Attackable) npc).getMostHated())
  814. {
  815. npc.setTarget(attacker);
  816. npc.doCast(SkillTable.getInstance().getInfo(4220, 1));
  817. }
  818. }
  819. }
  820. if (getTimeHour() < 5)
  821. {
  822. }
  823. else if (npc.getCurrentHp() < ((npc.getMaxHp() * _quest2) / 4.0))
  824. {
  825. _quest2 = (_quest2 - 1);
  826. int i2 = getRandom(15);
  827. _loc.setX(Xcoords[i2] + getRandom(650));
  828. _loc.setY(Ycoords[i2] + getRandom(650));
  829. _loc.setZ(Zcoords[i2]);
  830. npc.setTarget(npc);
  831. npc.doCast(SkillTable.getInstance().getInfo(4222, 1));
  832. }
  833. }
  834. return super.onAttack(npc, attacker, damage, isSummon);
  835. }
  836. @Override
  837. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  838. {
  839. int npcId = npc.getId();
  840. if (npcId == ZAKEN)
  841. {
  842. npc.broadcastPacket(new PlaySound(1, "BS02_D", 1, npc.getObjectId(), npc.getX(), npc.getY(), npc.getZ()));
  843. GrandBossManager.getInstance().setBossStatus(ZAKEN, DEAD);
  844. // Calculate Min and Max respawn times randomly.
  845. long respawnTime = Config.ZAKEN_SPAWN_INTERVAL + getRandom(-Config.ZAKEN_SPAWN_RANDOM, Config.ZAKEN_SPAWN_RANDOM);
  846. respawnTime *= 3600000;
  847. startQuestTimer("zaken_unlock", respawnTime, null, null);
  848. cancelQuestTimer("1001", npc, null);
  849. cancelQuestTimer("1003", npc, null);
  850. // also save the respawn time so that the info is maintained past reboots
  851. StatsSet info = GrandBossManager.getInstance().getStatsSet(ZAKEN);
  852. info.set("respawn_time", System.currentTimeMillis() + respawnTime);
  853. GrandBossManager.getInstance().setStatsSet(ZAKEN, info);
  854. }
  855. else if (GrandBossManager.getInstance().getBossStatus(ZAKEN) == ALIVE)
  856. {
  857. if (npcId != ZAKEN)
  858. {
  859. startQuestTimer("CreateOnePrivateEx", ((30 + getRandom(60)) * 1000), npc, null);
  860. }
  861. }
  862. return super.onKill(npc, killer, isSummon);
  863. }
  864. @Override
  865. public String onSkillSee(L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isSummon)
  866. {
  867. int npcId = npc.getId();
  868. if (npcId == ZAKEN)
  869. {
  870. if (skill.getEffectPoint() > 0)
  871. {
  872. ((L2Attackable) npc).addDamageHate(caster, 0, (((skill.getEffectPoint() / npc.getMaxHp()) * 10) * 150));
  873. }
  874. if (getRandom(12) < 1)
  875. {
  876. int i0 = getRandom((15 * 15));
  877. if (i0 < 1)
  878. {
  879. npc.setTarget(caster);
  880. npc.doCast(SkillTable.getInstance().getInfo(4216, 1));
  881. }
  882. else if (i0 < 2)
  883. {
  884. npc.setTarget(caster);
  885. npc.doCast(SkillTable.getInstance().getInfo(4217, 1));
  886. }
  887. else if (i0 < 4)
  888. {
  889. npc.setTarget(caster);
  890. npc.doCast(SkillTable.getInstance().getInfo(4219, 1));
  891. }
  892. else if (i0 < 8)
  893. {
  894. npc.setTarget(caster);
  895. npc.doCast(SkillTable.getInstance().getInfo(4218, 1));
  896. }
  897. else if (i0 < 15)
  898. {
  899. for (L2Character character : npc.getKnownList().getKnownCharactersInRadius(100))
  900. {
  901. if (character != caster)
  902. {
  903. continue;
  904. }
  905. if (caster != ((L2Attackable) npc).getMostHated())
  906. {
  907. npc.setTarget(caster);
  908. npc.doCast(SkillTable.getInstance().getInfo(4221, 1));
  909. }
  910. }
  911. }
  912. if (getRandom(2) < 1)
  913. {
  914. if (caster == ((L2Attackable) npc).getMostHated())
  915. {
  916. npc.setTarget(caster);
  917. npc.doCast(SkillTable.getInstance().getInfo(4220, 1));
  918. }
  919. }
  920. }
  921. }
  922. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  923. }
  924. @Override
  925. public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isSummon)
  926. {
  927. int npcId = npc.getId();
  928. if (npcId == ZAKEN)
  929. {
  930. if (_Zone.isInsideZone(npc))
  931. {
  932. L2Character target = isSummon ? player.getSummon() : player;
  933. ((L2Attackable) npc).addDamageHate(target, 1, 200);
  934. }
  935. if ((player.getZ() > (npc.getZ() - 100)) && (player.getZ() < (npc.getZ() + 100)))
  936. {
  937. if ((_quest0 < 5) && (getRandom(3) < 1))
  938. {
  939. if (_quest0 == 0)
  940. {
  941. c_quest0 = player;
  942. }
  943. else if (_quest0 == 1)
  944. {
  945. c_quest1 = player;
  946. }
  947. else if (_quest0 == 2)
  948. {
  949. c_quest2 = player;
  950. }
  951. else if (_quest0 == 3)
  952. {
  953. c_quest3 = player;
  954. }
  955. else if (_quest0 == 4)
  956. {
  957. c_quest4 = player;
  958. }
  959. _quest0++;
  960. }
  961. if (getRandom(15) < 1)
  962. {
  963. int i0 = getRandom((15 * 15));
  964. if (i0 < 1)
  965. {
  966. npc.setTarget(player);
  967. npc.doCast(SkillTable.getInstance().getInfo(4216, 1));
  968. }
  969. else if (i0 < 2)
  970. {
  971. npc.setTarget(player);
  972. npc.doCast(SkillTable.getInstance().getInfo(4217, 1));
  973. }
  974. else if (i0 < 4)
  975. {
  976. npc.setTarget(player);
  977. npc.doCast(SkillTable.getInstance().getInfo(4219, 1));
  978. }
  979. else if (i0 < 8)
  980. {
  981. npc.setTarget(player);
  982. npc.doCast(SkillTable.getInstance().getInfo(4218, 1));
  983. }
  984. else if (i0 < 15)
  985. {
  986. for (L2Character character : npc.getKnownList().getKnownCharactersInRadius(100))
  987. {
  988. if (character != player)
  989. {
  990. continue;
  991. }
  992. if (player != ((L2Attackable) npc).getMostHated())
  993. {
  994. npc.setTarget(player);
  995. npc.doCast(SkillTable.getInstance().getInfo(4221, 1));
  996. }
  997. }
  998. }
  999. if (getRandom(2) < 1)
  1000. {
  1001. if (player == ((L2Attackable) npc).getMostHated())
  1002. {
  1003. npc.setTarget(player);
  1004. npc.doCast(SkillTable.getInstance().getInfo(4220, 1));
  1005. }
  1006. }
  1007. }
  1008. }
  1009. }
  1010. return super.onAggroRangeEnter(npc, player, isSummon);
  1011. }
  1012. public int getTimeHour()
  1013. {
  1014. return (GameTimeController.getInstance().getGameTime() / 60) % 24;
  1015. }
  1016. public static void main(String[] args)
  1017. {
  1018. new Zaken(Zaken.class.getSimpleName(), "ai");
  1019. }
  1020. }