Zaken.java 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063
  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.instancemanager.GrandBossManager;
  28. import com.l2jserver.gameserver.model.L2Object;
  29. import com.l2jserver.gameserver.model.StatsSet;
  30. import com.l2jserver.gameserver.model.actor.L2Attackable;
  31. import com.l2jserver.gameserver.model.actor.L2Character;
  32. import com.l2jserver.gameserver.model.actor.L2Npc;
  33. import com.l2jserver.gameserver.model.actor.instance.L2GrandBossInstance;
  34. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  35. import com.l2jserver.gameserver.model.effects.L2Effect;
  36. import com.l2jserver.gameserver.model.skills.L2Skill;
  37. import com.l2jserver.gameserver.model.zone.type.L2BossZone;
  38. import com.l2jserver.gameserver.network.serverpackets.PlaySound;
  39. /**
  40. * Zaken AI
  41. */
  42. public class Zaken extends AbstractNpcAI
  43. {
  44. private int _1001 = 0; // used for first cancel of QuestTimer "1001"
  45. private int _ai0 = 0; // used for zaken coords updater
  46. private int _ai1 = 0; // used for X coord tracking for non-random teleporting in zaken's self teleport skill
  47. private int _ai2 = 0; // used for Y coord tracking for non-random teleporting in zaken's self teleport skill
  48. private int _ai3 = 0; // used for Z coord tracking for non-random teleporting in zaken's self teleport skill
  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.getInteger("loc_x");
  191. int loc_y = info.getInteger("loc_y");
  192. int loc_z = info.getInteger("loc_z");
  193. int heading = info.getInteger("heading");
  194. int hp = info.getInteger("currentHP");
  195. int mp = info.getInteger("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. _ai1 = npc.getX();
  212. _ai2 = npc.getY();
  213. _ai3 = npc.getZ();
  214. _quest0 = 0;
  215. _quest1 = 0;
  216. _quest2 = 3;
  217. if (_Zone == null)
  218. {
  219. _log.warning("Zaken AI failed to load, missing zone for Zaken");
  220. return;
  221. }
  222. if (_Zone.isInsideZone(npc))
  223. {
  224. _ai4 = 1;
  225. startQuestTimer("1003", 1700, null, null, true);
  226. }
  227. _1001 = 1;
  228. startQuestTimer("1001", 1000, npc, null, true); // buffs,random teleports
  229. }
  230. @Override
  231. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  232. {
  233. int status = GrandBossManager.getInstance().getBossStatus(ZAKEN);
  234. if ((status == DEAD) && !event.equalsIgnoreCase("zaken_unlock"))
  235. {
  236. return super.onAdvEvent(event, npc, player);
  237. }
  238. if (event.equalsIgnoreCase("1001"))
  239. {
  240. if (_1001 == 1)
  241. {
  242. _1001 = 0;
  243. cancelQuestTimer("1001", npc, null);
  244. }
  245. int sk_4223 = 0;
  246. int sk_4227 = 0;
  247. L2Effect[] effects = npc.getAllEffects();
  248. if ((effects != null) && (effects.length != 0))
  249. {
  250. for (L2Effect e : effects)
  251. {
  252. if (e.getSkill().getId() == 4227)
  253. {
  254. sk_4227 = 1;
  255. }
  256. if (e.getSkill().getId() == 4223)
  257. {
  258. sk_4223 = 1;
  259. }
  260. }
  261. }
  262. if (getTimeHour() < 5)
  263. {
  264. if (sk_4223 == 1) // use night face if zaken have day face
  265. {
  266. npc.setTarget(npc);
  267. npc.doCast(SkillTable.getInstance().getInfo(4224, 1));
  268. _ai1 = npc.getX();
  269. _ai2 = npc.getY();
  270. _ai3 = npc.getZ();
  271. }
  272. if (sk_4227 == 0) // use zaken regeneration
  273. {
  274. npc.setTarget(npc);
  275. npc.doCast(SkillTable.getInstance().getInfo(4227, 1));
  276. }
  277. if ((npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ATTACK) && (_ai0 == 0))
  278. {
  279. int i0 = 0;
  280. int i1 = 1;
  281. if (((L2Attackable) npc).getMostHated() != null)
  282. {
  283. if ((((((L2Attackable) npc).getMostHated().getX() - _ai1) * (((L2Attackable) npc).getMostHated().getX() - _ai1)) + ((((L2Attackable) npc).getMostHated().getY() - _ai2) * (((L2Attackable) npc).getMostHated().getY() - _ai2))) > (1500 * 1500))
  284. {
  285. i0 = 1;
  286. }
  287. else
  288. {
  289. i0 = 0;
  290. }
  291. if (i0 == 0)
  292. {
  293. i1 = 0;
  294. }
  295. if (_quest0 > 0)
  296. {
  297. if (c_quest0 == null)
  298. {
  299. i0 = 0;
  300. }
  301. else if ((((c_quest0.getX() - _ai1) * (c_quest0.getX() - _ai1)) + ((c_quest0.getY() - _ai2) * (c_quest0.getY() - _ai2))) > (1500 * 1500))
  302. {
  303. i0 = 1;
  304. }
  305. else
  306. {
  307. i0 = 0;
  308. }
  309. if (i0 == 0)
  310. {
  311. i1 = 0;
  312. }
  313. }
  314. if (_quest0 > 1)
  315. {
  316. if (c_quest1 == null)
  317. {
  318. i0 = 0;
  319. }
  320. else if ((((c_quest1.getX() - _ai1) * (c_quest1.getX() - _ai1)) + ((c_quest1.getY() - _ai2) * (c_quest1.getY() - _ai2))) > (1500 * 1500))
  321. {
  322. i0 = 1;
  323. }
  324. else
  325. {
  326. i0 = 0;
  327. }
  328. if (i0 == 0)
  329. {
  330. i1 = 0;
  331. }
  332. }
  333. if (_quest0 > 2)
  334. {
  335. if (c_quest2 == null)
  336. {
  337. i0 = 0;
  338. }
  339. else if ((((c_quest2.getX() - _ai1) * (c_quest2.getX() - _ai1)) + ((c_quest2.getY() - _ai2) * (c_quest2.getY() - _ai2))) > (1500 * 1500))
  340. {
  341. i0 = 1;
  342. }
  343. else
  344. {
  345. i0 = 0;
  346. }
  347. if (i0 == 0)
  348. {
  349. i1 = 0;
  350. }
  351. }
  352. if (_quest0 > 3)
  353. {
  354. if (c_quest3 == null)
  355. {
  356. i0 = 0;
  357. }
  358. else if ((((c_quest3.getX() - _ai1) * (c_quest3.getX() - _ai1)) + ((c_quest3.getY() - _ai2) * (c_quest3.getY() - _ai2))) > (1500 * 1500))
  359. {
  360. i0 = 1;
  361. }
  362. else
  363. {
  364. i0 = 0;
  365. }
  366. if (i0 == 0)
  367. {
  368. i1 = 0;
  369. }
  370. }
  371. if (_quest0 > 4)
  372. {
  373. if (c_quest4 == null)
  374. {
  375. i0 = 0;
  376. }
  377. else if ((((c_quest4.getX() - _ai1) * (c_quest4.getX() - _ai1)) + ((c_quest4.getY() - _ai2) * (c_quest4.getY() - _ai2))) > (1500 * 1500))
  378. {
  379. i0 = 1;
  380. }
  381. else
  382. {
  383. i0 = 0;
  384. }
  385. if (i0 == 0)
  386. {
  387. i1 = 0;
  388. }
  389. }
  390. if (i1 == 1)
  391. {
  392. _quest0 = 0;
  393. int i2 = getRandom(15);
  394. _ai1 = Xcoords[i2] + getRandom(650);
  395. _ai2 = Ycoords[i2] + getRandom(650);
  396. _ai3 = Zcoords[i2];
  397. npc.setTarget(npc);
  398. npc.doCast(SkillTable.getInstance().getInfo(4222, 1));
  399. }
  400. }
  401. }
  402. if ((getRandom(20) < 1) && (_ai0 == 0))
  403. {
  404. _ai1 = npc.getX();
  405. _ai2 = npc.getY();
  406. _ai3 = npc.getZ();
  407. }
  408. L2Character c_ai0 = null;
  409. if ((npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ATTACK) && (_quest1 == 0))
  410. {
  411. if (((L2Attackable) npc).getMostHated() != null)
  412. {
  413. c_ai0 = ((L2Attackable) npc).getMostHated();
  414. _quest1 = 1;
  415. }
  416. }
  417. else if ((npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ATTACK) && (_quest1 != 0))
  418. {
  419. if (((L2Attackable) npc).getMostHated() != null)
  420. {
  421. if (c_ai0 == ((L2Attackable) npc).getMostHated())
  422. {
  423. _quest1 = (_quest1 + 1);
  424. }
  425. else
  426. {
  427. _quest1 = 1;
  428. c_ai0 = ((L2Attackable) npc).getMostHated();
  429. }
  430. }
  431. }
  432. if (npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE)
  433. {
  434. _quest1 = 0;
  435. }
  436. if (_quest1 > 5)
  437. {
  438. ((L2Attackable) npc).stopHating(c_ai0);
  439. L2Character nextTarget = ((L2Attackable) npc).getMostHated();
  440. if (nextTarget != null)
  441. {
  442. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, nextTarget);
  443. }
  444. _quest1 = 0;
  445. }
  446. }
  447. else if (sk_4223 == 0) // use day face if not night time
  448. {
  449. npc.setTarget(npc);
  450. npc.doCast(SkillTable.getInstance().getInfo(4223, 1));
  451. _quest2 = 3;
  452. }
  453. if (sk_4227 == 1) // when switching to day time, cancel zaken night regen
  454. {
  455. npc.setTarget(npc);
  456. npc.doCast(SkillTable.getInstance().getInfo(4242, 1));
  457. }
  458. if (getRandom(40) < 1)
  459. {
  460. int i2 = getRandom(15);
  461. _ai1 = Xcoords[i2] + getRandom(650);
  462. _ai2 = Ycoords[i2] + getRandom(650);
  463. _ai3 = Zcoords[i2];
  464. npc.setTarget(npc);
  465. npc.doCast(SkillTable.getInstance().getInfo(4222, 1));
  466. }
  467. startQuestTimer("1001", 30000, npc, null, true);
  468. }
  469. if (event.equalsIgnoreCase("1002"))
  470. {
  471. _quest0 = 0;
  472. npc.doCast(SkillTable.getInstance().getInfo(4222, 1));
  473. _ai0 = 0;
  474. }
  475. if (event.equalsIgnoreCase("1003"))
  476. {
  477. if (_ai4 == 1)
  478. {
  479. int rr = getRandom(15);
  480. ((L2Attackable) addSpawn(pirates_zombie_captain_b, Xcoords[rr] + getRandom(650), Ycoords[rr] + getRandom(650), Zcoords[rr], getRandom(65536), false, 0)).setIsRaidMinion(true);
  481. _ai4 = 2;
  482. }
  483. else if (_ai4 == 2)
  484. {
  485. int rr = getRandom(15);
  486. ((L2Attackable) addSpawn(doll_blader_b, Xcoords[rr] + getRandom(650), Ycoords[rr] + getRandom(650), Zcoords[rr], getRandom(65536), false, 0)).setIsRaidMinion(true);
  487. _ai4 = 3;
  488. }
  489. else if (_ai4 == 3)
  490. {
  491. ((L2Attackable) addSpawn(vale_master_b, Xcoords[getRandom(15)] + getRandom(650), Ycoords[getRandom(15)] + getRandom(650), Zcoords[getRandom(15)], getRandom(65536), false, 0)).setIsRaidMinion(true);
  492. ((L2Attackable) addSpawn(vale_master_b, Xcoords[getRandom(15)] + getRandom(650), Ycoords[getRandom(15)] + getRandom(650), Zcoords[getRandom(15)], getRandom(65536), false, 0)).setIsRaidMinion(true);
  493. _ai4 = 4;
  494. }
  495. else if (_ai4 == 4)
  496. {
  497. ((L2Attackable) addSpawn(pirates_zombie_b, Xcoords[getRandom(15)] + getRandom(650), Ycoords[getRandom(15)] + getRandom(650), Zcoords[getRandom(15)], getRandom(65536), false, 0)).setIsRaidMinion(true);
  498. ((L2Attackable) addSpawn(pirates_zombie_b, Xcoords[getRandom(15)] + getRandom(650), Ycoords[getRandom(15)] + getRandom(650), Zcoords[getRandom(15)], getRandom(65536), false, 0)).setIsRaidMinion(true);
  499. ((L2Attackable) addSpawn(pirates_zombie_b, Xcoords[getRandom(15)] + getRandom(650), Ycoords[getRandom(15)] + getRandom(650), Zcoords[getRandom(15)], getRandom(65536), false, 0)).setIsRaidMinion(true);
  500. ((L2Attackable) addSpawn(pirates_zombie_b, Xcoords[getRandom(15)] + getRandom(650), Ycoords[getRandom(15)] + getRandom(650), Zcoords[getRandom(15)], getRandom(65536), false, 0)).setIsRaidMinion(true);
  501. ((L2Attackable) addSpawn(pirates_zombie_b, Xcoords[getRandom(15)] + getRandom(650), Ycoords[getRandom(15)] + getRandom(650), Zcoords[getRandom(15)], getRandom(65536), false, 0)).setIsRaidMinion(true);
  502. _ai4 = 5;
  503. }
  504. else if (_ai4 == 5)
  505. {
  506. ((L2Attackable) addSpawn(doll_blader_b, 52675, 219371, -3290, getRandom(65536), false, 0)).setIsRaidMinion(true);
  507. ((L2Attackable) addSpawn(doll_blader_b, 52687, 219596, -3368, getRandom(65536), false, 0)).setIsRaidMinion(true);
  508. ((L2Attackable) addSpawn(doll_blader_b, 52672, 219740, -3418, getRandom(65536), false, 0)).setIsRaidMinion(true);
  509. ((L2Attackable) addSpawn(pirates_zombie_b, 52857, 219992, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  510. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 52959, 219997, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  511. ((L2Attackable) addSpawn(vale_master_b, 53381, 220151, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  512. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 54236, 220948, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  513. ((L2Attackable) addSpawn(pirates_zombie_b, 54885, 220144, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  514. ((L2Attackable) addSpawn(pirates_zombie_b, 55264, 219860, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  515. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 55399, 220263, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  516. ((L2Attackable) addSpawn(pirates_zombie_b, 55679, 220129, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  517. ((L2Attackable) addSpawn(vale_master_b, 56276, 220783, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  518. ((L2Attackable) addSpawn(vale_master_b, 57173, 220234, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  519. ((L2Attackable) addSpawn(pirates_zombie_b, 56267, 218826, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  520. ((L2Attackable) addSpawn(doll_blader_b, 56294, 219482, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  521. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 56094, 219113, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  522. ((L2Attackable) addSpawn(doll_blader_b, 56364, 218967, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  523. ((L2Attackable) addSpawn(pirates_zombie_b, 57113, 218079, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  524. ((L2Attackable) addSpawn(doll_blader_b, 56186, 217153, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  525. ((L2Attackable) addSpawn(pirates_zombie_b, 55440, 218081, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  526. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 55202, 217940, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  527. ((L2Attackable) addSpawn(pirates_zombie_b, 55225, 218236, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  528. ((L2Attackable) addSpawn(pirates_zombie_b, 54973, 218075, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  529. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 53412, 218077, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  530. ((L2Attackable) addSpawn(vale_master_b, 54226, 218797, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  531. ((L2Attackable) addSpawn(vale_master_b, 54394, 219067, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  532. ((L2Attackable) addSpawn(pirates_zombie_b, 54139, 219253, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  533. ((L2Attackable) addSpawn(doll_blader_b, 54262, 219480, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  534. _ai4 = 6;
  535. }
  536. else if (_ai4 == 6)
  537. {
  538. ((L2Attackable) addSpawn(pirates_zombie_b, 53412, 218077, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  539. ((L2Attackable) addSpawn(vale_master_b, 54413, 217132, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  540. ((L2Attackable) addSpawn(doll_blader_b, 54841, 217132, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  541. ((L2Attackable) addSpawn(doll_blader_b, 55372, 217128, -3343, getRandom(65536), false, 0)).setIsRaidMinion(true);
  542. ((L2Attackable) addSpawn(doll_blader_b, 55893, 217122, -3488, getRandom(65536), false, 0)).setIsRaidMinion(true);
  543. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 56282, 217237, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  544. ((L2Attackable) addSpawn(vale_master_b, 56963, 218080, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  545. ((L2Attackable) addSpawn(pirates_zombie_b, 56267, 218826, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  546. ((L2Attackable) addSpawn(doll_blader_b, 56294, 219482, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  547. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 56094, 219113, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  548. ((L2Attackable) addSpawn(doll_blader_b, 56364, 218967, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  549. ((L2Attackable) addSpawn(vale_master_b, 56276, 220783, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  550. ((L2Attackable) addSpawn(vale_master_b, 57173, 220234, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  551. ((L2Attackable) addSpawn(pirates_zombie_b, 54885, 220144, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  552. ((L2Attackable) addSpawn(pirates_zombie_b, 55264, 219860, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  553. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 55399, 220263, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  554. ((L2Attackable) addSpawn(pirates_zombie_b, 55679, 220129, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  555. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 54236, 220948, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  556. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 54464, 219095, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  557. ((L2Attackable) addSpawn(vale_master_b, 54226, 218797, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  558. ((L2Attackable) addSpawn(vale_master_b, 54394, 219067, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  559. ((L2Attackable) addSpawn(pirates_zombie_b, 54139, 219253, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  560. ((L2Attackable) addSpawn(doll_blader_b, 54262, 219480, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  561. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 53412, 218077, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  562. ((L2Attackable) addSpawn(pirates_zombie_b, 55440, 218081, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  563. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 55202, 217940, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  564. ((L2Attackable) addSpawn(pirates_zombie_b, 55225, 218236, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  565. ((L2Attackable) addSpawn(pirates_zombie_b, 54973, 218075, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  566. _ai4 = 7;
  567. }
  568. else if (_ai4 == 7)
  569. {
  570. ((L2Attackable) addSpawn(pirates_zombie_b, 54228, 217504, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  571. ((L2Attackable) addSpawn(vale_master_b, 54181, 217168, -3216, getRandom(65536), false, 0)).setIsRaidMinion(true);
  572. ((L2Attackable) addSpawn(doll_blader_b, 54714, 217123, -3168, getRandom(65536), false, 0)).setIsRaidMinion(true);
  573. ((L2Attackable) addSpawn(doll_blader_b, 55298, 217127, -3073, getRandom(65536), false, 0)).setIsRaidMinion(true);
  574. ((L2Attackable) addSpawn(doll_blader_b, 55787, 217130, -2993, getRandom(65536), false, 0)).setIsRaidMinion(true);
  575. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 56284, 217216, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  576. ((L2Attackable) addSpawn(vale_master_b, 56963, 218080, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  577. ((L2Attackable) addSpawn(pirates_zombie_b, 56267, 218826, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  578. ((L2Attackable) addSpawn(doll_blader_b, 56294, 219482, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  579. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 56094, 219113, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  580. ((L2Attackable) addSpawn(doll_blader_b, 56364, 218967, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  581. ((L2Attackable) addSpawn(vale_master_b, 56276, 220783, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  582. ((L2Attackable) addSpawn(vale_master_b, 57173, 220234, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  583. ((L2Attackable) addSpawn(pirates_zombie_b, 54885, 220144, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  584. ((L2Attackable) addSpawn(pirates_zombie_b, 55264, 219860, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  585. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 55399, 220263, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  586. ((L2Attackable) addSpawn(pirates_zombie_b, 55679, 220129, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  587. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 54236, 220948, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  588. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 54464, 219095, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  589. ((L2Attackable) addSpawn(vale_master_b, 54226, 218797, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  590. ((L2Attackable) addSpawn(vale_master_b, 54394, 219067, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  591. ((L2Attackable) addSpawn(pirates_zombie_b, 54139, 219253, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  592. ((L2Attackable) addSpawn(doll_blader_b, 54262, 219480, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  593. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 53412, 218077, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  594. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 54280, 217200, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  595. ((L2Attackable) addSpawn(pirates_zombie_b, 55440, 218081, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  596. ((L2Attackable) addSpawn(pirates_zombie_captain_b, 55202, 217940, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  597. ((L2Attackable) addSpawn(pirates_zombie_b, 55225, 218236, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  598. ((L2Attackable) addSpawn(pirates_zombie_b, 54973, 218075, -2944, getRandom(65536), false, 0)).setIsRaidMinion(true);
  599. _ai4 = 8;
  600. cancelQuestTimer("1003", null, null);
  601. }
  602. }
  603. else if (event.equalsIgnoreCase("zaken_unlock"))
  604. {
  605. L2GrandBossInstance zaken = (L2GrandBossInstance) addSpawn(ZAKEN, 55312, 219168, -3223, 0, false, 0);
  606. GrandBossManager.getInstance().setBossStatus(ZAKEN, ALIVE);
  607. spawnBoss(zaken);
  608. }
  609. else if (event.equalsIgnoreCase("CreateOnePrivateEx"))
  610. {
  611. ((L2Attackable) addSpawn(npc.getNpcId(), npc.getX(), npc.getY(), npc.getZ(), 0, false, 0)).setIsRaidMinion(true);
  612. }
  613. return super.onAdvEvent(event, npc, player);
  614. }
  615. @Override
  616. public String onFactionCall(L2Npc npc, L2Npc caller, L2PcInstance attacker, boolean isPet)
  617. {
  618. if ((caller == null) || (npc == null))
  619. {
  620. return super.onFactionCall(npc, caller, attacker, isPet);
  621. }
  622. int npcId = npc.getNpcId();
  623. int callerId = caller.getNpcId();
  624. if ((getTimeHour() < 5) && (callerId != ZAKEN) && (npcId == ZAKEN))
  625. {
  626. int damage = 0; // well damage required :x
  627. if ((npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE) && (_ai0 == 0) && (damage < 10) && (getRandom((30 * 15)) < 1))// todo - damage missing
  628. {
  629. _ai0 = 1;
  630. _ai1 = caller.getX();
  631. _ai2 = caller.getY();
  632. _ai3 = caller.getZ();
  633. startQuestTimer("1002", 300, caller, null);
  634. }
  635. }
  636. return super.onFactionCall(npc, caller, attacker, isPet);
  637. }
  638. @Override
  639. public String onSpellFinished(L2Npc npc, L2PcInstance player, L2Skill skill)
  640. {
  641. if (npc.getNpcId() == ZAKEN)
  642. {
  643. int skillId = skill.getId();
  644. if (skillId == 4222)
  645. {
  646. npc.teleToLocation(_ai1, _ai2, _ai3);
  647. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  648. }
  649. else if (skillId == 4216)
  650. {
  651. int i1 = getRandom(15);
  652. player.teleToLocation(Xcoords[i1] + getRandom(650), Ycoords[i1] + getRandom(650), Zcoords[i1]);
  653. ((L2Attackable) npc).stopHating(player);
  654. L2Character nextTarget = ((L2Attackable) npc).getMostHated();
  655. if (nextTarget != null)
  656. {
  657. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, nextTarget);
  658. }
  659. }
  660. else if (skillId == 4217)
  661. {
  662. int i0 = 0;
  663. int i1 = getRandom(15);
  664. player.teleToLocation(Xcoords[i1] + getRandom(650), Ycoords[i1] + getRandom(650), Zcoords[i1]);
  665. ((L2Attackable) npc).stopHating(player);
  666. if ((c_quest0 != null) && (_quest0 > 0) && (c_quest0 != player) && (c_quest0.getZ() > (player.getZ() - 100)) && (c_quest0.getZ() < (player.getZ() + 100)))
  667. {
  668. if ((((c_quest0.getX() - player.getX()) * (c_quest0.getX() - player.getX())) + ((c_quest0.getY() - player.getY()) * (c_quest0.getY() - player.getY()))) > (250 * 250))
  669. {
  670. i0 = 1;
  671. }
  672. else
  673. {
  674. i0 = 0;
  675. }
  676. if (i0 == 0)
  677. {
  678. i1 = getRandom(15);
  679. c_quest0.teleToLocation(Xcoords[i1] + getRandom(650), Ycoords[i1] + getRandom(650), Zcoords[i1]);
  680. ((L2Attackable) npc).stopHating(c_quest0);
  681. }
  682. }
  683. if ((c_quest1 != null) && (_quest0 > 1) && (c_quest1 != player) && (c_quest1.getZ() > (player.getZ() - 100)) && (c_quest1.getZ() < (player.getZ() + 100)))
  684. {
  685. if ((((c_quest1.getX() - player.getX()) * (c_quest1.getX() - player.getX())) + ((c_quest1.getY() - player.getY()) * (c_quest1.getY() - player.getY()))) > (250 * 250))
  686. {
  687. i0 = 1;
  688. }
  689. else
  690. {
  691. i0 = 0;
  692. }
  693. if (i0 == 0)
  694. {
  695. i1 = getRandom(15);
  696. c_quest1.teleToLocation(Xcoords[i1] + getRandom(650), Ycoords[i1] + getRandom(650), Zcoords[i1]);
  697. ((L2Attackable) npc).stopHating(c_quest1);
  698. }
  699. }
  700. if ((c_quest2 != null) && (_quest0 > 2) && (c_quest2 != player) && (c_quest2.getZ() > (player.getZ() - 100)) && (c_quest2.getZ() < (player.getZ() + 100)))
  701. {
  702. if ((((c_quest2.getX() - player.getX()) * (c_quest2.getX() - player.getX())) + ((c_quest2.getY() - player.getY()) * (c_quest2.getY() - player.getY()))) > (250 * 250))
  703. {
  704. i0 = 1;
  705. }
  706. else
  707. {
  708. i0 = 0;
  709. }
  710. if (i0 == 0)
  711. {
  712. i1 = getRandom(15);
  713. c_quest2.teleToLocation(Xcoords[i1] + getRandom(650), Ycoords[i1] + getRandom(650), Zcoords[i1]);
  714. ((L2Attackable) npc).stopHating(c_quest2);
  715. }
  716. }
  717. if ((c_quest3 != null) && (_quest0 > 3) && (c_quest3 != player) && (c_quest3.getZ() > (player.getZ() - 100)) && (c_quest3.getZ() < (player.getZ() + 100)))
  718. {
  719. if ((((c_quest3.getX() - player.getX()) * (c_quest3.getX() - player.getX())) + ((c_quest3.getY() - player.getY()) * (c_quest3.getY() - player.getY()))) > (250 * 250))
  720. {
  721. i0 = 1;
  722. }
  723. else
  724. {
  725. i0 = 0;
  726. }
  727. if (i0 == 0)
  728. {
  729. i1 = getRandom(15);
  730. c_quest3.teleToLocation(Xcoords[i1] + getRandom(650), Ycoords[i1] + getRandom(650), Zcoords[i1]);
  731. ((L2Attackable) npc).stopHating(c_quest3);
  732. }
  733. }
  734. if ((c_quest4 != null) && (_quest0 > 4) && (c_quest4 != player) && (c_quest4.getZ() > (player.getZ() - 100)) && (c_quest4.getZ() < (player.getZ() + 100)))
  735. {
  736. if ((((c_quest4.getX() - player.getX()) * (c_quest4.getX() - player.getX())) + ((c_quest4.getY() - player.getY()) * (c_quest4.getY() - player.getY()))) > (250 * 250))
  737. {
  738. i0 = 1;
  739. }
  740. else
  741. {
  742. i0 = 0;
  743. }
  744. if (i0 == 0)
  745. {
  746. i1 = getRandom(15);
  747. c_quest4.teleToLocation(Xcoords[i1] + getRandom(650), Ycoords[i1] + getRandom(650), Zcoords[i1]);
  748. ((L2Attackable) npc).stopHating(c_quest4);
  749. }
  750. }
  751. L2Character nextTarget = ((L2Attackable) npc).getMostHated();
  752. if (nextTarget != null)
  753. {
  754. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, nextTarget);
  755. }
  756. }
  757. }
  758. return super.onSpellFinished(npc, player, skill);
  759. }
  760. @Override
  761. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isPet)
  762. {
  763. int npcId = npc.getNpcId();
  764. if (npcId == ZAKEN)
  765. {
  766. if (attacker.getMountType() == 1)
  767. {
  768. int sk_4258 = 0;
  769. L2Effect[] effects = attacker.getAllEffects();
  770. if ((effects != null) && (effects.length != 0))
  771. {
  772. for (L2Effect e : effects)
  773. {
  774. if (e.getSkill().getId() == 4258)
  775. {
  776. sk_4258 = 1;
  777. }
  778. }
  779. }
  780. if (sk_4258 == 0)
  781. {
  782. npc.setTarget(attacker);
  783. npc.doCast(SkillTable.getInstance().getInfo(4258, 1));
  784. }
  785. }
  786. L2Character originalAttacker = isPet ? attacker.getSummon() : attacker;
  787. int hate = (int) (((damage / npc.getMaxHp()) / 0.05) * 20000);
  788. ((L2Attackable) npc).addDamageHate(originalAttacker, 0, hate);
  789. if (getRandom(10) < 1)
  790. {
  791. int i0 = getRandom((15 * 15));
  792. if (i0 < 1)
  793. {
  794. npc.setTarget(attacker);
  795. npc.doCast(SkillTable.getInstance().getInfo(4216, 1));
  796. }
  797. else if (i0 < 2)
  798. {
  799. npc.setTarget(attacker);
  800. npc.doCast(SkillTable.getInstance().getInfo(4217, 1));
  801. }
  802. else if (i0 < 4)
  803. {
  804. npc.setTarget(attacker);
  805. npc.doCast(SkillTable.getInstance().getInfo(4219, 1));
  806. }
  807. else if (i0 < 8)
  808. {
  809. npc.setTarget(attacker);
  810. npc.doCast(SkillTable.getInstance().getInfo(4218, 1));
  811. }
  812. else if (i0 < 15)
  813. {
  814. for (L2Character character : npc.getKnownList().getKnownCharactersInRadius(100))
  815. {
  816. if (character != attacker)
  817. {
  818. continue;
  819. }
  820. if (attacker != ((L2Attackable) npc).getMostHated())
  821. {
  822. npc.setTarget(attacker);
  823. npc.doCast(SkillTable.getInstance().getInfo(4221, 1));
  824. }
  825. }
  826. }
  827. if (getRandom(2) < 1)
  828. {
  829. if (attacker == ((L2Attackable) npc).getMostHated())
  830. {
  831. npc.setTarget(attacker);
  832. npc.doCast(SkillTable.getInstance().getInfo(4220, 1));
  833. }
  834. }
  835. }
  836. if (getTimeHour() < 5)
  837. {
  838. }
  839. else if (npc.getCurrentHp() < ((npc.getMaxHp() * _quest2) / 4.0))
  840. {
  841. _quest2 = (_quest2 - 1);
  842. int i2 = getRandom(15);
  843. _ai1 = Xcoords[i2] + getRandom(650);
  844. _ai2 = Ycoords[i2] + getRandom(650);
  845. _ai3 = Zcoords[i2];
  846. npc.setTarget(npc);
  847. npc.doCast(SkillTable.getInstance().getInfo(4222, 1));
  848. }
  849. }
  850. return super.onAttack(npc, attacker, damage, isPet);
  851. }
  852. @Override
  853. public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet)
  854. {
  855. int npcId = npc.getNpcId();
  856. if (npcId == ZAKEN)
  857. {
  858. npc.broadcastPacket(new PlaySound(1, "BS02_D", 1, npc.getObjectId(), npc.getX(), npc.getY(), npc.getZ()));
  859. GrandBossManager.getInstance().setBossStatus(ZAKEN, DEAD);
  860. // Calculate Min and Max respawn times randomly.
  861. long respawnTime = getRandom((Config.Interval_Of_Zaken_Spawn - Config.Random_Of_Zaken_Spawn), (Config.Interval_Of_Zaken_Spawn + Config.Random_Of_Zaken_Spawn));
  862. startQuestTimer("zaken_unlock", respawnTime, null, null);
  863. cancelQuestTimer("1001", npc, null);
  864. cancelQuestTimer("1003", npc, null);
  865. // also save the respawn time so that the info is maintained past reboots
  866. StatsSet info = GrandBossManager.getInstance().getStatsSet(ZAKEN);
  867. info.set("respawn_time", System.currentTimeMillis() + respawnTime);
  868. GrandBossManager.getInstance().setStatsSet(ZAKEN, info);
  869. }
  870. else if (GrandBossManager.getInstance().getBossStatus(ZAKEN) == ALIVE)
  871. {
  872. if (npcId != ZAKEN)
  873. {
  874. startQuestTimer("CreateOnePrivateEx", ((30 + getRandom(60)) * 1000), npc, null);
  875. }
  876. }
  877. return super.onKill(npc, killer, isPet);
  878. }
  879. @Override
  880. public String onSkillSee(L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet)
  881. {
  882. int npcId = npc.getNpcId();
  883. if (npcId == ZAKEN)
  884. {
  885. if (skill.getAggroPoints() > 0)
  886. {
  887. ((L2Attackable) npc).addDamageHate(caster, 0, (((skill.getAggroPoints() / npc.getMaxHp()) * 10) * 150));
  888. }
  889. if (getRandom(12) < 1)
  890. {
  891. int i0 = getRandom((15 * 15));
  892. if (i0 < 1)
  893. {
  894. npc.setTarget(caster);
  895. npc.doCast(SkillTable.getInstance().getInfo(4216, 1));
  896. }
  897. else if (i0 < 2)
  898. {
  899. npc.setTarget(caster);
  900. npc.doCast(SkillTable.getInstance().getInfo(4217, 1));
  901. }
  902. else if (i0 < 4)
  903. {
  904. npc.setTarget(caster);
  905. npc.doCast(SkillTable.getInstance().getInfo(4219, 1));
  906. }
  907. else if (i0 < 8)
  908. {
  909. npc.setTarget(caster);
  910. npc.doCast(SkillTable.getInstance().getInfo(4218, 1));
  911. }
  912. else if (i0 < 15)
  913. {
  914. for (L2Character character : npc.getKnownList().getKnownCharactersInRadius(100))
  915. {
  916. if (character != caster)
  917. {
  918. continue;
  919. }
  920. if (caster != ((L2Attackable) npc).getMostHated())
  921. {
  922. npc.setTarget(caster);
  923. npc.doCast(SkillTable.getInstance().getInfo(4221, 1));
  924. }
  925. }
  926. }
  927. if (getRandom(2) < 1)
  928. {
  929. if (caster == ((L2Attackable) npc).getMostHated())
  930. {
  931. npc.setTarget(caster);
  932. npc.doCast(SkillTable.getInstance().getInfo(4220, 1));
  933. }
  934. }
  935. }
  936. }
  937. return super.onSkillSee(npc, caster, skill, targets, isPet);
  938. }
  939. @Override
  940. public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isPet)
  941. {
  942. int npcId = npc.getNpcId();
  943. if (npcId == ZAKEN)
  944. {
  945. if (_Zone.isInsideZone(npc))
  946. {
  947. L2Character target = isPet ? player.getSummon() : player;
  948. ((L2Attackable) npc).addDamageHate(target, 1, 200);
  949. }
  950. if ((player.getZ() > (npc.getZ() - 100)) && (player.getZ() < (npc.getZ() + 100)))
  951. {
  952. if ((_quest0 < 5) && (getRandom(3) < 1))
  953. {
  954. if (_quest0 == 0)
  955. {
  956. c_quest0 = player;
  957. }
  958. else if (_quest0 == 1)
  959. {
  960. c_quest1 = player;
  961. }
  962. else if (_quest0 == 2)
  963. {
  964. c_quest2 = player;
  965. }
  966. else if (_quest0 == 3)
  967. {
  968. c_quest3 = player;
  969. }
  970. else if (_quest0 == 4)
  971. {
  972. c_quest4 = player;
  973. }
  974. _quest0++;
  975. }
  976. if (getRandom(15) < 1)
  977. {
  978. int i0 = getRandom((15 * 15));
  979. if (i0 < 1)
  980. {
  981. npc.setTarget(player);
  982. npc.doCast(SkillTable.getInstance().getInfo(4216, 1));
  983. }
  984. else if (i0 < 2)
  985. {
  986. npc.setTarget(player);
  987. npc.doCast(SkillTable.getInstance().getInfo(4217, 1));
  988. }
  989. else if (i0 < 4)
  990. {
  991. npc.setTarget(player);
  992. npc.doCast(SkillTable.getInstance().getInfo(4219, 1));
  993. }
  994. else if (i0 < 8)
  995. {
  996. npc.setTarget(player);
  997. npc.doCast(SkillTable.getInstance().getInfo(4218, 1));
  998. }
  999. else if (i0 < 15)
  1000. {
  1001. for (L2Character character : npc.getKnownList().getKnownCharactersInRadius(100))
  1002. {
  1003. if (character != player)
  1004. {
  1005. continue;
  1006. }
  1007. if (player != ((L2Attackable) npc).getMostHated())
  1008. {
  1009. npc.setTarget(player);
  1010. npc.doCast(SkillTable.getInstance().getInfo(4221, 1));
  1011. }
  1012. }
  1013. }
  1014. if (getRandom(2) < 1)
  1015. {
  1016. if (player == ((L2Attackable) npc).getMostHated())
  1017. {
  1018. npc.setTarget(player);
  1019. npc.doCast(SkillTable.getInstance().getInfo(4220, 1));
  1020. }
  1021. }
  1022. }
  1023. }
  1024. }
  1025. return super.onAggroRangeEnter(npc, player, isPet);
  1026. }
  1027. public int getTimeHour()
  1028. {
  1029. return (GameTimeController.getInstance().getGameTime() / 60) % 24;
  1030. }
  1031. public static void main(String[] args)
  1032. {
  1033. new Zaken(Zaken.class.getSimpleName(), "ai");
  1034. }
  1035. }