Zaken.java 38 KB

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