Zaken.java 38 KB

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