Zaken.java 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064
  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 isSummon)
  617. {
  618. if ((caller == null) || (npc == null))
  619. {
  620. return super.onFactionCall(npc, caller, attacker, isSummon);
  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, isSummon);
  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 isSummon)
  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 = isSummon ? 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, isSummon);
  851. }
  852. @Override
  853. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  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 = Config.ZAKEN_SPAWN_INTERVAL + getRandom(-Config.ZAKEN_SPAWN_RANDOM, Config.ZAKEN_SPAWN_RANDOM);
  862. respawnTime *= 3600000;
  863. startQuestTimer("zaken_unlock", respawnTime, null, null);
  864. cancelQuestTimer("1001", npc, null);
  865. cancelQuestTimer("1003", npc, null);
  866. // also save the respawn time so that the info is maintained past reboots
  867. StatsSet info = GrandBossManager.getInstance().getStatsSet(ZAKEN);
  868. info.set("respawn_time", System.currentTimeMillis() + respawnTime);
  869. GrandBossManager.getInstance().setStatsSet(ZAKEN, info);
  870. }
  871. else if (GrandBossManager.getInstance().getBossStatus(ZAKEN) == ALIVE)
  872. {
  873. if (npcId != ZAKEN)
  874. {
  875. startQuestTimer("CreateOnePrivateEx", ((30 + getRandom(60)) * 1000), npc, null);
  876. }
  877. }
  878. return super.onKill(npc, killer, isSummon);
  879. }
  880. @Override
  881. public String onSkillSee(L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isSummon)
  882. {
  883. int npcId = npc.getNpcId();
  884. if (npcId == ZAKEN)
  885. {
  886. if (skill.getAggroPoints() > 0)
  887. {
  888. ((L2Attackable) npc).addDamageHate(caster, 0, (((skill.getAggroPoints() / npc.getMaxHp()) * 10) * 150));
  889. }
  890. if (getRandom(12) < 1)
  891. {
  892. int i0 = getRandom((15 * 15));
  893. if (i0 < 1)
  894. {
  895. npc.setTarget(caster);
  896. npc.doCast(SkillTable.getInstance().getInfo(4216, 1));
  897. }
  898. else if (i0 < 2)
  899. {
  900. npc.setTarget(caster);
  901. npc.doCast(SkillTable.getInstance().getInfo(4217, 1));
  902. }
  903. else if (i0 < 4)
  904. {
  905. npc.setTarget(caster);
  906. npc.doCast(SkillTable.getInstance().getInfo(4219, 1));
  907. }
  908. else if (i0 < 8)
  909. {
  910. npc.setTarget(caster);
  911. npc.doCast(SkillTable.getInstance().getInfo(4218, 1));
  912. }
  913. else if (i0 < 15)
  914. {
  915. for (L2Character character : npc.getKnownList().getKnownCharactersInRadius(100))
  916. {
  917. if (character != caster)
  918. {
  919. continue;
  920. }
  921. if (caster != ((L2Attackable) npc).getMostHated())
  922. {
  923. npc.setTarget(caster);
  924. npc.doCast(SkillTable.getInstance().getInfo(4221, 1));
  925. }
  926. }
  927. }
  928. if (getRandom(2) < 1)
  929. {
  930. if (caster == ((L2Attackable) npc).getMostHated())
  931. {
  932. npc.setTarget(caster);
  933. npc.doCast(SkillTable.getInstance().getInfo(4220, 1));
  934. }
  935. }
  936. }
  937. }
  938. return super.onSkillSee(npc, caster, skill, targets, isSummon);
  939. }
  940. @Override
  941. public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isSummon)
  942. {
  943. int npcId = npc.getNpcId();
  944. if (npcId == ZAKEN)
  945. {
  946. if (_Zone.isInsideZone(npc))
  947. {
  948. L2Character target = isSummon ? player.getSummon() : player;
  949. ((L2Attackable) npc).addDamageHate(target, 1, 200);
  950. }
  951. if ((player.getZ() > (npc.getZ() - 100)) && (player.getZ() < (npc.getZ() + 100)))
  952. {
  953. if ((_quest0 < 5) && (getRandom(3) < 1))
  954. {
  955. if (_quest0 == 0)
  956. {
  957. c_quest0 = player;
  958. }
  959. else if (_quest0 == 1)
  960. {
  961. c_quest1 = player;
  962. }
  963. else if (_quest0 == 2)
  964. {
  965. c_quest2 = player;
  966. }
  967. else if (_quest0 == 3)
  968. {
  969. c_quest3 = player;
  970. }
  971. else if (_quest0 == 4)
  972. {
  973. c_quest4 = player;
  974. }
  975. _quest0++;
  976. }
  977. if (getRandom(15) < 1)
  978. {
  979. int i0 = getRandom((15 * 15));
  980. if (i0 < 1)
  981. {
  982. npc.setTarget(player);
  983. npc.doCast(SkillTable.getInstance().getInfo(4216, 1));
  984. }
  985. else if (i0 < 2)
  986. {
  987. npc.setTarget(player);
  988. npc.doCast(SkillTable.getInstance().getInfo(4217, 1));
  989. }
  990. else if (i0 < 4)
  991. {
  992. npc.setTarget(player);
  993. npc.doCast(SkillTable.getInstance().getInfo(4219, 1));
  994. }
  995. else if (i0 < 8)
  996. {
  997. npc.setTarget(player);
  998. npc.doCast(SkillTable.getInstance().getInfo(4218, 1));
  999. }
  1000. else if (i0 < 15)
  1001. {
  1002. for (L2Character character : npc.getKnownList().getKnownCharactersInRadius(100))
  1003. {
  1004. if (character != player)
  1005. {
  1006. continue;
  1007. }
  1008. if (player != ((L2Attackable) npc).getMostHated())
  1009. {
  1010. npc.setTarget(player);
  1011. npc.doCast(SkillTable.getInstance().getInfo(4221, 1));
  1012. }
  1013. }
  1014. }
  1015. if (getRandom(2) < 1)
  1016. {
  1017. if (player == ((L2Attackable) npc).getMostHated())
  1018. {
  1019. npc.setTarget(player);
  1020. npc.doCast(SkillTable.getInstance().getInfo(4220, 1));
  1021. }
  1022. }
  1023. }
  1024. }
  1025. }
  1026. return super.onAggroRangeEnter(npc, player, isSummon);
  1027. }
  1028. public int getTimeHour()
  1029. {
  1030. return (GameTimeController.getInstance().getGameTime() / 60) % 24;
  1031. }
  1032. public static void main(String[] args)
  1033. {
  1034. new Zaken(Zaken.class.getSimpleName(), "ai");
  1035. }
  1036. }