Zaken.java 38 KB

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