Zaken.java 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951
  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.actor.L2Attackable;
  29. import com.l2jserver.gameserver.model.actor.L2Character;
  30. import com.l2jserver.gameserver.model.actor.L2Npc;
  31. import com.l2jserver.gameserver.model.actor.instance.L2GrandBossInstance;
  32. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  33. import com.l2jserver.gameserver.model.zone.type.L2BossZone;
  34. import com.l2jserver.gameserver.network.serverpackets.PlaySound;
  35. import com.l2jserver.gameserver.templates.StatsSet;
  36. import com.l2jserver.util.Rnd;
  37. /**
  38. * Zaken AI
  39. *
  40. */
  41. public class Zaken extends L2AttackableAIScript
  42. {
  43. protected static final Logger log = Logger.getLogger(Zaken.class.getName());
  44. private int _1001 = 0; // used for first cancel of QuestTimer "1001"
  45. private int _ai0 = 0; // used for zaken coords updater
  46. private int _ai1 = 0; // used for X coord tracking for non-random teleporting in zaken's self teleport skill
  47. private int _ai2 = 0; // used for Y coord tracking for non-random teleporting in zaken's self teleport skill
  48. private int _ai3 = 0; // used for Z coord tracking for non-random teleporting in zaken's self teleport skill
  49. private int _ai4 = 0; // used for spawning minions cycles
  50. private int _quest0 = 0; // used for teleporting progress
  51. private int _quest1 = 0; // used for most hated players progress
  52. private int _quest2 = 0; // used for zaken HP check for teleport
  53. private L2PcInstance c_quest0 = null; // 1st player used for area teleport
  54. private L2PcInstance c_quest1 = null; // 2nd player used for area teleport
  55. private L2PcInstance c_quest2 = null; // 3rd player used for area teleport
  56. private L2PcInstance c_quest3 = null; // 4th player used for area teleport
  57. private L2PcInstance c_quest4 = null; // 5th player used for area teleport
  58. private static final int ZAKEN = 29022;
  59. private static final int doll_blader_b = 29023;
  60. private static final int vale_master_b = 29024;
  61. private static final int pirates_zombie_captain_b = 29026;
  62. private static final int pirates_zombie_b = 29027;
  63. private static final int[] Xcoords =
  64. {
  65. 53950, 55980, 54950, 55970, 53930, 55970, 55980, 54960, 53950, 53930, 55970, 55980, 54960, 53950, 53930
  66. };
  67. private static final int[] Ycoords =
  68. {
  69. 219860, 219820, 218790, 217770, 217760, 217770, 219920, 218790, 219860, 217760, 217770, 219920, 218790, 219860, 217760
  70. };
  71. private static final int[] Zcoords =
  72. {
  73. -3488, -3488, -3488, -3488, -3488, -3216, -3216, -3216, -3216, -3216, -2944, -2944, -2944, -2944, -2944
  74. };
  75. //ZAKEN Status Tracking :
  76. private static final byte ALIVE = 0; //Zaken is spawned.
  77. private static final byte DEAD = 1; //Zaken has been killed.
  78. private static L2BossZone _Zone;
  79. public Zaken(int questId, String name, String descr)
  80. {
  81. super(questId, name, descr);
  82. // Zaken doors handling
  83. ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable()
  84. {
  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. public void run()
  95. {
  96. try
  97. {
  98. DoorTable.getInstance().getDoor(21240006).closeMe();
  99. }
  100. catch (Throwable e)
  101. {
  102. log.warning("Cannot close door ID: 21240006 " + e);
  103. }
  104. }
  105. }, 300000L);
  106. }
  107. }
  108. catch (Throwable e)
  109. {
  110. log.warning("Cannot open door ID: 21240006 " + e);
  111. }
  112. }
  113. }, 2000L, 600000L);
  114. int[] mobs =
  115. {
  116. ZAKEN, doll_blader_b, vale_master_b, pirates_zombie_captain_b, pirates_zombie_b
  117. };
  118. registerMobs(mobs);
  119. _Zone = GrandBossManager.getInstance().getZone(55312, 219168, -3223);
  120. StatsSet info = GrandBossManager.getInstance().getStatsSet(ZAKEN);
  121. int status = GrandBossManager.getInstance().getBossStatus(ZAKEN);
  122. if (status == DEAD)
  123. {
  124. // load the unlock date and time for zaken from DB
  125. long temp = info.getLong("respawn_time") - System.currentTimeMillis();
  126. // if zaken is locked until a certain time, mark it so and start the unlock timer
  127. // the unlock time has not yet expired.
  128. if (temp > 0)
  129. startQuestTimer("zaken_unlock", temp, null, null);
  130. else
  131. {
  132. // the time has already expired while the server was offline. Immediately spawn zaken.
  133. L2GrandBossInstance zaken = (L2GrandBossInstance) addSpawn(ZAKEN, 55312, 219168, -3223, 0, false, 0);
  134. GrandBossManager.getInstance().setBossStatus(ZAKEN, ALIVE);
  135. spawnBoss(zaken);
  136. }
  137. }
  138. else
  139. {
  140. int loc_x = info.getInteger("loc_x");
  141. int loc_y = info.getInteger("loc_y");
  142. int loc_z = info.getInteger("loc_z");
  143. int heading = info.getInteger("heading");
  144. int hp = info.getInteger("currentHP");
  145. int mp = info.getInteger("currentMP");
  146. L2GrandBossInstance zaken = (L2GrandBossInstance) addSpawn(ZAKEN, loc_x, loc_y, loc_z, heading, false, 0);
  147. zaken.setCurrentHpMp(hp, mp);
  148. spawnBoss(zaken);
  149. }
  150. }
  151. public void spawnBoss(L2GrandBossInstance npc)
  152. {
  153. if (npc == null)
  154. {
  155. log.warning("Zaken AI failed to load, missing Zaken in grandboss_data.sql");
  156. return;
  157. }
  158. GrandBossManager.getInstance().addBoss(npc);
  159. npc.broadcastPacket(new PlaySound(1, "BS01_A", 1, npc.getObjectId(), npc.getX(), npc.getY(), npc.getZ()));
  160. _ai0 = 0;
  161. _ai1 = npc.getX();
  162. _ai2 = npc.getY();
  163. _ai3 = npc.getZ();
  164. _quest0 = 0;
  165. _quest1 = 0;
  166. _quest2 = 3;
  167. if (_Zone == null)
  168. {
  169. log.warning("Zaken AI failed to load, missing zone for Zaken");
  170. return;
  171. }
  172. if (_Zone.isInsideZone(npc))
  173. {
  174. _ai4 = 1;
  175. startQuestTimer("1003", 1700, null, null, true);
  176. }
  177. _1001 = 1;
  178. startQuestTimer("1001", 1000, npc, null, true); //buffs,random teleports
  179. }
  180. @Override
  181. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  182. {
  183. int status = GrandBossManager.getInstance().getBossStatus(ZAKEN);
  184. if (status == DEAD && !event.equalsIgnoreCase("zaken_unlock"))
  185. return super.onAdvEvent(event, npc, player);
  186. if (event.equalsIgnoreCase("1001"))
  187. {
  188. if (_1001 == 1)
  189. {
  190. _1001 = 0;
  191. cancelQuestTimer("1001", npc, null);
  192. }
  193. int sk_4223 = 0;
  194. int sk_4227 = 0;
  195. L2Effect[] effects = npc.getAllEffects();
  196. if (effects != null && effects.length != 0)
  197. {
  198. for (L2Effect e : effects)
  199. {
  200. if (e.getSkill().getId() == 4227)
  201. {
  202. sk_4227 = 1;
  203. }
  204. if (e.getSkill().getId() == 4223)
  205. {
  206. sk_4223 = 1;
  207. }
  208. }
  209. }
  210. if (getTimeHour() < 5)
  211. {
  212. if (sk_4223 == 1) //use night face if zaken have day face
  213. {
  214. npc.setTarget(npc);
  215. npc.doCast(SkillTable.getInstance().getInfo(4224, 1));
  216. _ai1 = npc.getX();
  217. _ai2 = npc.getY();
  218. _ai3 = npc.getZ();
  219. }
  220. if (sk_4227 == 0) //use zaken regeneration
  221. {
  222. npc.setTarget(npc);
  223. npc.doCast(SkillTable.getInstance().getInfo(4227, 1));
  224. }
  225. if (npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ATTACK && _ai0 == 0)
  226. {
  227. int i0 = 0;
  228. int i1 = 1;
  229. if (((L2Attackable) npc).getMostHated() != null)
  230. {
  231. if ((((((L2Attackable) npc).getMostHated().getX() - _ai1) * (((L2Attackable) npc).getMostHated().getX() - _ai1)) + ((((L2Attackable) npc).getMostHated().getY() - _ai2) * (((L2Attackable) npc)
  232. .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. else if (npc.getCurrentHp() < ((npc.getMaxHp() * _quest2) / 4.0))
  732. {
  733. _quest2 = (_quest2 - 1);
  734. int i2 = Rnd.get(15);
  735. _ai1 = Xcoords[i2] + Rnd.get(650);
  736. _ai2 = Ycoords[i2] + Rnd.get(650);
  737. _ai3 = Zcoords[i2];
  738. npc.setTarget(npc);
  739. npc.doCast(SkillTable.getInstance().getInfo(4222, 1));
  740. }
  741. }
  742. return super.onAttack(npc, attacker, damage, isPet);
  743. }
  744. @Override
  745. public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet)
  746. {
  747. int npcId = npc.getNpcId();
  748. if (npcId == ZAKEN)
  749. {
  750. npc.broadcastPacket(new PlaySound(1, "BS02_D", 1, npc.getObjectId(), npc.getX(), npc.getY(), npc.getZ()));
  751. GrandBossManager.getInstance().setBossStatus(ZAKEN, DEAD);
  752. //time is 36hour +/- 17hour
  753. long respawnTime = (long) Config.Interval_Of_Zaken_Spawn + Rnd.get(Config.Random_Of_Zaken_Spawn);
  754. startQuestTimer("zaken_unlock", respawnTime, null, null);
  755. cancelQuestTimer("1001", npc, null);
  756. cancelQuestTimer("1003", npc, null);
  757. // also save the respawn time so that the info is maintained past reboots
  758. StatsSet info = GrandBossManager.getInstance().getStatsSet(ZAKEN);
  759. info.set("respawn_time", System.currentTimeMillis() + respawnTime);
  760. GrandBossManager.getInstance().setStatsSet(ZAKEN, info);
  761. }
  762. else if (GrandBossManager.getInstance().getBossStatus(ZAKEN) == ALIVE)
  763. {
  764. if (npcId != ZAKEN)
  765. {
  766. startQuestTimer("CreateOnePrivateEx", ((30 + Rnd.get(60)) * 1000), npc, null);
  767. }
  768. }
  769. return super.onKill(npc, killer, isPet);
  770. }
  771. @Override
  772. public String onSkillSee(L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet)
  773. {
  774. int npcId = npc.getNpcId();
  775. if (npcId == ZAKEN)
  776. {
  777. if (skill.getAggroPoints() > 0)
  778. {
  779. ((L2Attackable) npc).addDamageHate(caster, 0, (((skill.getAggroPoints() / npc.getMaxHp()) * 10) * 150));
  780. }
  781. if (Rnd.get(12) < 1)
  782. {
  783. int i0 = Rnd.get((15 * 15));
  784. if (i0 < 1)
  785. {
  786. npc.setTarget(caster);
  787. npc.doCast(SkillTable.getInstance().getInfo(4216, 1));
  788. }
  789. else if (i0 < 2)
  790. {
  791. npc.setTarget(caster);
  792. npc.doCast(SkillTable.getInstance().getInfo(4217, 1));
  793. }
  794. else if (i0 < 4)
  795. {
  796. npc.setTarget(caster);
  797. npc.doCast(SkillTable.getInstance().getInfo(4219, 1));
  798. }
  799. else if (i0 < 8)
  800. {
  801. npc.setTarget(caster);
  802. npc.doCast(SkillTable.getInstance().getInfo(4218, 1));
  803. }
  804. else if (i0 < 15)
  805. {
  806. for (L2Character character : npc.getKnownList().getKnownCharactersInRadius(100))
  807. {
  808. if (character != caster)
  809. continue;
  810. if (caster != ((L2Attackable) npc).getMostHated())
  811. {
  812. npc.setTarget(caster);
  813. npc.doCast(SkillTable.getInstance().getInfo(4221, 1));
  814. }
  815. }
  816. }
  817. if (Rnd.get(2) < 1)
  818. {
  819. if (caster == ((L2Attackable) npc).getMostHated())
  820. {
  821. npc.setTarget(caster);
  822. npc.doCast(SkillTable.getInstance().getInfo(4220, 1));
  823. }
  824. }
  825. }
  826. }
  827. return super.onSkillSee(npc, caster, skill, targets, isPet);
  828. }
  829. @Override
  830. public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isPet)
  831. {
  832. int npcId = npc.getNpcId();
  833. if (npcId == ZAKEN)
  834. {
  835. if (_Zone.isInsideZone(npc))
  836. {
  837. L2Character target = isPet ? player.getPet() : player;
  838. ((L2Attackable) npc).addDamageHate(target, 1, 200);
  839. }
  840. if (player.getZ() > (npc.getZ() - 100) && player.getZ() < (npc.getZ() + 100))
  841. {
  842. if (_quest0 < 5 && Rnd.get(3) < 1)
  843. {
  844. if (_quest0 == 0)
  845. {
  846. c_quest0 = player;
  847. }
  848. else if (_quest0 == 1)
  849. {
  850. c_quest1 = player;
  851. }
  852. else if (_quest0 == 2)
  853. {
  854. c_quest2 = player;
  855. }
  856. else if (_quest0 == 3)
  857. {
  858. c_quest3 = player;
  859. }
  860. else if (_quest0 == 4)
  861. {
  862. c_quest4 = player;
  863. }
  864. _quest0++;
  865. }
  866. if (Rnd.get(15) < 1)
  867. {
  868. int i0 = Rnd.get((15 * 15));
  869. if (i0 < 1)
  870. {
  871. npc.setTarget(player);
  872. npc.doCast(SkillTable.getInstance().getInfo(4216, 1));
  873. }
  874. else if (i0 < 2)
  875. {
  876. npc.setTarget(player);
  877. npc.doCast(SkillTable.getInstance().getInfo(4217, 1));
  878. }
  879. else if (i0 < 4)
  880. {
  881. npc.setTarget(player);
  882. npc.doCast(SkillTable.getInstance().getInfo(4219, 1));
  883. }
  884. else if (i0 < 8)
  885. {
  886. npc.setTarget(player);
  887. npc.doCast(SkillTable.getInstance().getInfo(4218, 1));
  888. }
  889. else if (i0 < 15)
  890. {
  891. for (L2Character character : npc.getKnownList().getKnownCharactersInRadius(100))
  892. {
  893. if (character != player)
  894. continue;
  895. if (player != ((L2Attackable) npc).getMostHated())
  896. {
  897. npc.setTarget(player);
  898. npc.doCast(SkillTable.getInstance().getInfo(4221, 1));
  899. }
  900. }
  901. }
  902. if (Rnd.get(2) < 1)
  903. {
  904. if (player == ((L2Attackable) npc).getMostHated())
  905. {
  906. npc.setTarget(player);
  907. npc.doCast(SkillTable.getInstance().getInfo(4220, 1));
  908. }
  909. }
  910. }
  911. }
  912. }
  913. return super.onAggroRangeEnter(npc, player, isPet);
  914. }
  915. public int getTimeHour()
  916. {
  917. return (GameTimeController.getInstance().getGameTime() / 60) % 24;
  918. }
  919. public static void main(String[] args)
  920. {
  921. // now call the constructor (starts up the ai)
  922. new Zaken(-1, "zaken", "ai");
  923. }
  924. }