Zaken.java 37 KB

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