Advertisement
Guest User

Zaken - L2

a guest
Jan 15th, 2017
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 23.18 KB | None | 0 0
  1. import com.sun.corba.se.spi.orbutil.threadpool.ThreadPoolManager;
  2.  
  3. import net.sf.l2j.commons.random.Rnd;
  4.  
  5. import net.sf.l2j.Config;
  6. import net.sf.l2j.gameserver.ai.CtrlIntention;
  7. import net.sf.l2j.gameserver.datatables.DoorTable;
  8. import net.sf.l2j.gameserver.datatables.SkillTable;
  9. import net.sf.l2j.gameserver.datatables.SkillTable.FrequentSkill;
  10. import net.sf.l2j.gameserver.instancemanager.GrandBossManager;
  11. import net.sf.l2j.gameserver.model.L2Object;
  12. import net.sf.l2j.gameserver.model.L2Skill;
  13. import net.sf.l2j.gameserver.model.actor.L2Attackable;
  14. import net.sf.l2j.gameserver.model.actor.L2Character;
  15. import net.sf.l2j.gameserver.model.actor.L2Npc;
  16. import net.sf.l2j.gameserver.model.actor.L2Playable;
  17. import net.sf.l2j.gameserver.model.actor.instance.L2GrandBossInstance;
  18. import net.sf.l2j.gameserver.model.actor.instance.L2MonsterInstance;
  19. import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
  20. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  21. import net.sf.l2j.gameserver.model.zone.type.L2BossZone;
  22. import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  23. import net.sf.l2j.gameserver.network.serverpackets.PlaySound;
  24. import net.sf.l2j.gameserver.scripting.scripts.ai.L2AttackableAIScript;
  25. import net.sf.l2j.gameserver.templates.StatsSet;
  26. import net.sf.l2j.gameserver.util.Util;
  27.  
  28. import net.sf.l2j.commons.concurrent.ThreadPool;
  29. public class Zaken extends L2AttackableAIScript
  30. {
  31. private static final L2GrandBossInstance _zakenLair = GrandBossManager.getInstance().getBoss(110000);
  32. private L2Object TARGET;
  33. private int _minionStatus = 0; // used for spawning minions cycles
  34. private int hate = 0; // used for most hated players progress
  35. private static final int[] Xcoords =
  36. {
  37. 53950,
  38. 55980,
  39. 54950,
  40. 55970,
  41. 53930,
  42. 55970,
  43. 55980,
  44. 54960,
  45. 53950,
  46. 53930,
  47. 55970,
  48. 55980,
  49. 54960,
  50. 53950,
  51. 53930
  52. };
  53.  
  54. private static final int[] Ycoords =
  55. {
  56. 219860,
  57. 219820,
  58. 218790,
  59. 217770,
  60. 217760,
  61. 217770,
  62. 219920,
  63. 218790,
  64. 219860,
  65. 217760,
  66. 217770,
  67. 219920,
  68. 218790,
  69. 219860,
  70. 217760
  71. };
  72.  
  73. private static final int[] Zcoords =
  74. {
  75. -3488,
  76. -3488,
  77. -3488,
  78. -3488,
  79. -3488,
  80. -3216,
  81. -3216,
  82. -3216,
  83. -3216,
  84. -3216,
  85. -2944,
  86. -2944,
  87. -2944,
  88. -2944,
  89. -2944
  90. };
  91.  
  92. //Skills
  93. private static final int TELEPORT = 4216;
  94. private static final int MASS_TELEPORT = 4217;
  95. private static final int DRAIN = 4218;
  96. private static final int HOLD = 4219;
  97. private static final int DUAL_ATTACK = 4220;
  98. private static final int MASS_DUAL_ATTACK = 4221;
  99. private static final int SELF_TELEPORT = 4222;
  100. private static final int NIGHT_TO_DAY = 4223;
  101. private static final int DAY_TO_NIGHT = 4224;
  102. private static final int REGEN_NIGHT = 4227;
  103. private static final int REGEN_DAY = 4242;
  104.  
  105. //Boss
  106. private static final int ZAKEN = 29022;
  107.  
  108. //Minions
  109. private static final int DOLLBLADER = 29023;
  110. private static final int VALEMASTER = 29024;
  111. private static final int PIRATECAPTAIN = 29026;
  112. private static final int PIRATEZOMBIE = 29027;
  113.  
  114. // ZAKEN Status Tracking :
  115. private static final byte ALIVE = 0; // Zaken is spawned.
  116. private static final byte DEAD = 1; // Zaken has been killed.
  117.  
  118. public Zaken(String name, String descr)
  119. {
  120. super(name);
  121.  
  122. ThreadPool.scheduleAtFixedRate(new Runnable()
  123. {
  124. @Override
  125. public void run()
  126. {
  127. try
  128. {
  129. if (GetTimeHour() == 0)
  130. {
  131. DoorTable.getInstance().getDoor(21240006).openMe();
  132. ThreadPool.schedule(new Runnable()
  133. {
  134. @Override
  135. public void run()
  136. {
  137. try
  138. {
  139. DoorTable.getInstance().getDoor(21240006).closeMe();
  140. }
  141. catch (Throwable e)
  142. {
  143. _log.warning("Cannot close door ID: 21240006 " + e);
  144. }
  145. }
  146. }, 300000L);
  147. }
  148. }
  149. catch (Throwable e)
  150. {
  151. _log.warning("Cannot open door ID: 21240006 " + e);
  152. }
  153. }
  154. }, 2000L, 600000L);
  155.  
  156. int[] mobs =
  157. {
  158. ZAKEN,
  159. DOLLBLADER,
  160. VALEMASTER,
  161. PIRATECAPTAIN,
  162. PIRATEZOMBIE
  163. };
  164. registerMobs(mobs);
  165.  
  166.  
  167. final StatsSet info = GrandBossManager.getInstance().getStatsSet(ZAKEN);
  168. final 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. startQuestTimer("zaken_unlock", temp, null, null, false);
  177. else
  178. {
  179. // the time has already expired while the server was offline. Immediately spawn zaken.
  180. int i1 = Rnd.get(15);
  181.  
  182. L2GrandBossInstance zaken = (L2GrandBossInstance) addSpawn(ZAKEN, Xcoords[i1] + Rnd.get(650), Ycoords[i1] + Rnd.get(650), Zcoords[i1], i1, false, 0, false);
  183.  
  184. GrandBossManager.getInstance().setBossStatus(ZAKEN, ALIVE);
  185. spawnBoss(zaken);
  186. int X = zaken.getX();
  187. int Y = zaken.getY();
  188. int Z = zaken.getZ();
  189. _log.config("Zaken: Current in X: " + X + " Y: " + Y + " Z: " + Z + ".");
  190. }
  191. }
  192. else
  193. {
  194. int i1 = Rnd.get(15);
  195. int hp = info.getInteger("currentHP");
  196. int mp = info.getInteger("currentMP");
  197. L2GrandBossInstance zaken = (L2GrandBossInstance) addSpawn(ZAKEN, Xcoords[i1] + Rnd.get(650), Ycoords[i1] + Rnd.get(650), Zcoords[i1], i1, false, 0, false);
  198. zaken.setCurrentHpMp(hp, mp);
  199. spawnBoss(zaken);
  200. int X = zaken.getX();
  201. int Y = zaken.getY();
  202. int Z = zaken.getZ();
  203. _log.config("Zaken: Current in X: " + X + " Y: " + Y + " Z: " + Z + ".");
  204. }
  205. }
  206.  
  207. /**
  208. * @param mobs
  209. */
  210. private void registerMobs(int[] mobs)
  211. {
  212. // TODO Auto-generated method stub
  213.  
  214. }
  215.  
  216. public void spawnBoss(L2GrandBossInstance npc)
  217. {
  218. if (npc == null)
  219. {
  220. _log.warning("Zaken AI failed to load, missing Zaken in grandboss_data.sql");
  221. return;
  222. }
  223.  
  224. GrandBossManager.getInstance().addBoss(npc);
  225.  
  226. npc.broadcastPacket(new PlaySound(1, "BS01_A", 1, npc.getObjectId(), npc.getX(), npc.getY(), npc.getZ()));
  227. hate = 0;
  228.  
  229. if (_zakenLair == null)
  230. {
  231. _log.warning("Zaken AI failed to load, missing zone for Zaken");
  232. return;
  233. }
  234. if (_zakenLair.isInsideZone(npc))
  235. {
  236. _minionStatus = 1;
  237. startQuestTimer("minion_cycle", 1700, null, null, true);
  238. }
  239.  
  240. startQuestTimer("timer", 1000, npc, null, false);
  241. }
  242.  
  243. @Override
  244. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  245. {
  246. int status = GrandBossManager.getInstance().getBossStatus(ZAKEN);
  247. if ((status == DEAD) && !event.equalsIgnoreCase("zaken_unlock"))
  248. return super.onAdvEvent(event, npc, player);
  249.  
  250. if (event.equalsIgnoreCase("timer"))
  251. {
  252. if (GetTimeHour() < 5)
  253. {
  254. L2Skill skill = SkillTable.getInstance().getInfo(DAY_TO_NIGHT, 1);
  255. if (npc.getFirstEffect(skill) == null)
  256. {
  257. npc.setTarget(npc);
  258. npc.doCast(SkillTable.getInstance().getInfo(DAY_TO_NIGHT, 1));
  259. npc.doCast(SkillTable.getInstance().getInfo(REGEN_NIGHT, 1));
  260. }
  261. }
  262. else if(GetTimeHour() > 5)
  263. {
  264. L2Skill skill = SkillTable.getInstance().getInfo(NIGHT_TO_DAY, 1);
  265. if (npc.getFirstEffect(skill) == null)
  266. {
  267. npc.setTarget(npc);
  268. npc.doCast(SkillTable.getInstance().getInfo(NIGHT_TO_DAY, 1));
  269. npc.doCast(SkillTable.getInstance().getInfo(REGEN_DAY, 1));
  270. }
  271. }
  272.  
  273. L2Character _mostHated = null;
  274. if ((npc.getAI().getIntention() == CtrlIntention.ATTACK) && (hate == 0))
  275. {
  276. if (((L2Attackable) npc).getMostHated() != null)
  277. {
  278. _mostHated = ((L2Attackable) npc).getMostHated();
  279. hate = 1;
  280. }
  281. }
  282. else if ((npc.getAI().getIntention() == CtrlIntention.ATTACK) && (hate != 0))
  283. {
  284. if (((L2Attackable) npc).getMostHated() != null)
  285. {
  286. if (_mostHated == ((L2Attackable) npc).getMostHated())
  287. hate = hate + 1;
  288. else
  289. {
  290. hate = 1;
  291. _mostHated = ((L2Attackable) npc).getMostHated();
  292. }
  293. }
  294. }
  295.  
  296. if (npc.getAI().getIntention() == CtrlIntention.IDLE)
  297. {
  298. hate = 0;
  299. }
  300.  
  301. if (hate > 5)
  302. {
  303. ((L2Attackable) npc).stopHating(_mostHated);
  304. L2Character nextTarget = ((L2Attackable) npc).getMostHated();
  305. if (nextTarget != null)
  306. npc.getAI().setIntention(CtrlIntention.ATTACK, nextTarget);
  307.  
  308. hate = 0;
  309. }
  310.  
  311. if (Rnd.get(40) < 1)
  312. {
  313. npc.doCast(SkillTable.getInstance().getInfo(SELF_TELEPORT, 1));
  314. }
  315.  
  316. startQuestTimer("timer", 30000, npc, null, true);
  317. }
  318.  
  319. if (event.equalsIgnoreCase("minion_cycle"))
  320. {
  321. if (_minionStatus == 1)
  322. {
  323. int rr = Rnd.get(15);
  324. addSpawn(PIRATECAPTAIN, Xcoords[rr] + Rnd.get(650), Ycoords[rr] + Rnd.get(650), Zcoords[rr], Rnd.get(65536), false, 0, true);
  325. _minionStatus = 2;
  326. }
  327. else if (_minionStatus == 2)
  328. {
  329. int rr = Rnd.get(15);
  330. addSpawn(DOLLBLADER, Xcoords[rr] + Rnd.get(650), Ycoords[rr] + Rnd.get(650), Zcoords[rr], Rnd.get(65536), false, 0, true);
  331. _minionStatus = 3;
  332. }
  333. else if (_minionStatus == 3)
  334. {
  335. addSpawn(VALEMASTER, Xcoords[Rnd.get(15)] + Rnd.get(650), Ycoords[Rnd.get(15)] + Rnd.get(650), Zcoords[Rnd.get(15)], Rnd.get(65536), false, 0, true);
  336. addSpawn(VALEMASTER, Xcoords[Rnd.get(15)] + Rnd.get(650), Ycoords[Rnd.get(15)] + Rnd.get(650), Zcoords[Rnd.get(15)], Rnd.get(65536), false, 0, true);
  337. _minionStatus = 4;
  338. }
  339. else if (_minionStatus == 4)
  340. {
  341. addSpawn(PIRATEZOMBIE, Xcoords[Rnd.get(15)] + Rnd.get(650), Ycoords[Rnd.get(15)] + Rnd.get(650), Zcoords[Rnd.get(15)], Rnd.get(65536), false, 0, true);
  342. addSpawn(PIRATEZOMBIE, Xcoords[Rnd.get(15)] + Rnd.get(650), Ycoords[Rnd.get(15)] + Rnd.get(650), Zcoords[Rnd.get(15)], Rnd.get(65536), false, 0, true);
  343. addSpawn(PIRATEZOMBIE, Xcoords[Rnd.get(15)] + Rnd.get(650), Ycoords[Rnd.get(15)] + Rnd.get(650), Zcoords[Rnd.get(15)], Rnd.get(65536), false, 0, true);
  344. addSpawn(PIRATEZOMBIE, Xcoords[Rnd.get(15)] + Rnd.get(650), Ycoords[Rnd.get(15)] + Rnd.get(650), Zcoords[Rnd.get(15)], Rnd.get(65536), false, 0, true);
  345. addSpawn(PIRATEZOMBIE, Xcoords[Rnd.get(15)] + Rnd.get(650), Ycoords[Rnd.get(15)] + Rnd.get(650), Zcoords[Rnd.get(15)], Rnd.get(65536), false, 0, true);
  346. _minionStatus = 5;
  347. }
  348. else if (_minionStatus == 5)
  349. {
  350. addSpawn(DOLLBLADER, 52675, 219371, -3290, Rnd.get(65536), false, 0, true);
  351. addSpawn(DOLLBLADER, 52687, 219596, -3368, Rnd.get(65536), false, 0, true);
  352. addSpawn(DOLLBLADER, 52672, 219740, -3418, Rnd.get(65536), false, 0, true);
  353. addSpawn(PIRATEZOMBIE, 52857, 219992, -3488, Rnd.get(65536), false, 0, true);
  354. addSpawn(PIRATECAPTAIN, 52959, 219997, -3488, Rnd.get(65536), false, 0, true);
  355. addSpawn(VALEMASTER, 53381, 220151, -3488, Rnd.get(65536), false, 0, true);
  356. addSpawn(PIRATECAPTAIN, 54236, 220948, -3488, Rnd.get(65536), false, 0, true);
  357. addSpawn(PIRATEZOMBIE, 54885, 220144, -3488, Rnd.get(65536), false, 0, true);
  358. addSpawn(PIRATEZOMBIE, 55264, 219860, -3488, Rnd.get(65536), false, 0, true);
  359. addSpawn(PIRATECAPTAIN, 55399, 220263, -3488, Rnd.get(65536), false, 0, true);
  360. addSpawn(PIRATEZOMBIE, 55679, 220129, -3488, Rnd.get(65536), false, 0, true);
  361. addSpawn(VALEMASTER, 56276, 220783, -3488, Rnd.get(65536), false, 0, true);
  362. addSpawn(VALEMASTER, 57173, 220234, -3488, Rnd.get(65536), false, 0, true);
  363. addSpawn(PIRATEZOMBIE, 56267, 218826, -3488, Rnd.get(65536), false, 0, true);
  364. addSpawn(DOLLBLADER, 56294, 219482, -3488, Rnd.get(65536), false, 0, true);
  365. addSpawn(PIRATECAPTAIN, 56094, 219113, -3488, Rnd.get(65536), false, 0, true);
  366. addSpawn(DOLLBLADER, 56364, 218967, -3488, Rnd.get(65536), false, 0, true);
  367. addSpawn(PIRATEZOMBIE, 57113, 218079, -3488, Rnd.get(65536), false, 0, true);
  368. addSpawn(DOLLBLADER, 56186, 217153, -3488, Rnd.get(65536), false, 0, true);
  369. addSpawn(PIRATEZOMBIE, 55440, 218081, -3488, Rnd.get(65536), false, 0, true);
  370. addSpawn(PIRATECAPTAIN, 55202, 217940, -3488, Rnd.get(65536), false, 0, true);
  371. addSpawn(PIRATEZOMBIE, 55225, 218236, -3488, Rnd.get(65536), false, 0, true);
  372. addSpawn(PIRATEZOMBIE, 54973, 218075, -3488, Rnd.get(65536), false, 0, true);
  373. addSpawn(PIRATECAPTAIN, 53412, 218077, -3488, Rnd.get(65536), false, 0, true);
  374. addSpawn(VALEMASTER, 54226, 218797, -3488, Rnd.get(65536), false, 0, true);
  375. addSpawn(VALEMASTER, 54394, 219067, -3488, Rnd.get(65536), false, 0, true);
  376. addSpawn(PIRATEZOMBIE, 54139, 219253, -3488, Rnd.get(65536), false, 0, true);
  377. addSpawn(DOLLBLADER, 54262, 219480, -3488, Rnd.get(65536), false, 0, true);
  378. _minionStatus = 6;
  379. }
  380. else if (_minionStatus == 6)
  381. {
  382. addSpawn(PIRATEZOMBIE, 53412, 218077, -3488, Rnd.get(65536), false, 0, true);
  383. addSpawn(VALEMASTER, 54413, 217132, -3488, Rnd.get(65536), false, 0, true);
  384. addSpawn(DOLLBLADER, 54841, 217132, -3488, Rnd.get(65536), false, 0, true);
  385. addSpawn(DOLLBLADER, 55372, 217128, -3343, Rnd.get(65536), false, 0, true);
  386. addSpawn(DOLLBLADER, 55893, 217122, -3488, Rnd.get(65536), false, 0, true);
  387. addSpawn(PIRATECAPTAIN, 56282, 217237, -3216, Rnd.get(65536), false, 0, true);
  388. addSpawn(VALEMASTER, 56963, 218080, -3216, Rnd.get(65536), false, 0, true);
  389. addSpawn(PIRATEZOMBIE, 56267, 218826, -3216, Rnd.get(65536), false, 0, true);
  390. addSpawn(DOLLBLADER, 56294, 219482, -3216, Rnd.get(65536), false, 0, true);
  391. addSpawn(PIRATECAPTAIN, 56094, 219113, -3216, Rnd.get(65536), false, 0, true);
  392. addSpawn(DOLLBLADER, 56364, 218967, -3216, Rnd.get(65536), false, 0, true);
  393. addSpawn(VALEMASTER, 56276, 220783, -3216, Rnd.get(65536), false, 0, true);
  394. addSpawn(VALEMASTER, 57173, 220234, -3216, Rnd.get(65536), false, 0, true);
  395. addSpawn(PIRATEZOMBIE, 54885, 220144, -3216, Rnd.get(65536), false, 0, true);
  396. addSpawn(PIRATEZOMBIE, 55264, 219860, -3216, Rnd.get(65536), false, 0, true);
  397. addSpawn(PIRATECAPTAIN, 55399, 220263, -3216, Rnd.get(65536), false, 0, true);
  398. addSpawn(PIRATEZOMBIE, 55679, 220129, -3216, Rnd.get(65536), false, 0, true);
  399. addSpawn(PIRATECAPTAIN, 54236, 220948, -3216, Rnd.get(65536), false, 0, true);
  400. addSpawn(PIRATECAPTAIN, 54464, 219095, -3216, Rnd.get(65536), false, 0, true);
  401. addSpawn(VALEMASTER, 54226, 218797, -3216, Rnd.get(65536), false, 0, true);
  402. addSpawn(VALEMASTER, 54394, 219067, -3216, Rnd.get(65536), false, 0, true);
  403. addSpawn(PIRATEZOMBIE, 54139, 219253, -3216, Rnd.get(65536), false, 0, true);
  404. addSpawn(DOLLBLADER, 54262, 219480, -3216, Rnd.get(65536), false, 0, true);
  405. addSpawn(PIRATECAPTAIN, 53412, 218077, -3216, Rnd.get(65536), false, 0, true);
  406. addSpawn(PIRATEZOMBIE, 55440, 218081, -3216, Rnd.get(65536), false, 0, true);
  407. addSpawn(PIRATECAPTAIN, 55202, 217940, -3216, Rnd.get(65536), false, 0, true);
  408. addSpawn(PIRATEZOMBIE, 55225, 218236, -3216, Rnd.get(65536), false, 0, true);
  409. addSpawn(PIRATEZOMBIE, 54973, 218075, -3216, Rnd.get(65536), false, 0, true);
  410. _minionStatus = 7;
  411. }
  412. else if (_minionStatus == 7)
  413. {
  414. addSpawn(PIRATEZOMBIE, 54228, 217504, -3216, Rnd.get(65536), false, 0, true);
  415. addSpawn(VALEMASTER, 54181, 217168, -3216, Rnd.get(65536), false, 0, true);
  416. addSpawn(DOLLBLADER, 54714, 217123, -3168, Rnd.get(65536), false, 0, true);
  417. addSpawn(DOLLBLADER, 55298, 217127, -3073, Rnd.get(65536), false, 0, true);
  418. addSpawn(DOLLBLADER, 55787, 217130, -2993, Rnd.get(65536), false, 0, true);
  419. addSpawn(PIRATECAPTAIN, 56284, 217216, -2944, Rnd.get(65536), false, 0, true);
  420. addSpawn(VALEMASTER, 56963, 218080, -2944, Rnd.get(65536), false, 0, true);
  421. addSpawn(PIRATEZOMBIE, 56267, 218826, -2944, Rnd.get(65536), false, 0, true);
  422. addSpawn(DOLLBLADER, 56294, 219482, -2944, Rnd.get(65536), false, 0, true);
  423. addSpawn(PIRATECAPTAIN, 56094, 219113, -2944, Rnd.get(65536), false, 0, true);
  424. addSpawn(DOLLBLADER, 56364, 218967, -2944, Rnd.get(65536), false, 0, true);
  425. addSpawn(VALEMASTER, 56276, 220783, -2944, Rnd.get(65536), false, 0, true);
  426. addSpawn(VALEMASTER, 57173, 220234, -2944, Rnd.get(65536), false, 0, true);
  427. addSpawn(PIRATEZOMBIE, 54885, 220144, -2944, Rnd.get(65536), false, 0, true);
  428. addSpawn(PIRATEZOMBIE, 55264, 219860, -2944, Rnd.get(65536), false, 0, true);
  429. addSpawn(PIRATECAPTAIN, 55399, 220263, -2944, Rnd.get(65536), false, 0, true);
  430. addSpawn(PIRATEZOMBIE, 55679, 220129, -2944, Rnd.get(65536), false, 0, true);
  431. addSpawn(PIRATECAPTAIN, 54236, 220948, -2944, Rnd.get(65536), false, 0, true);
  432. addSpawn(PIRATECAPTAIN, 54464, 219095, -2944, Rnd.get(65536), false, 0, true);
  433. addSpawn(VALEMASTER, 54226, 218797, -2944, Rnd.get(65536), false, 0, true);
  434. addSpawn(VALEMASTER, 54394, 219067, -2944, Rnd.get(65536), false, 0, true);
  435. addSpawn(PIRATEZOMBIE, 54139, 219253, -2944, Rnd.get(65536), false, 0, true);
  436. addSpawn(DOLLBLADER, 54262, 219480, -2944, Rnd.get(65536), false, 0, true);
  437. addSpawn(PIRATECAPTAIN, 53412, 218077, -2944, Rnd.get(65536), false, 0, true);
  438. addSpawn(PIRATECAPTAIN, 54280, 217200, -2944, Rnd.get(65536), false, 0, true);
  439. addSpawn(PIRATEZOMBIE, 55440, 218081, -2944, Rnd.get(65536), false, 0, true);
  440. addSpawn(PIRATECAPTAIN, 55202, 217940, -2944, Rnd.get(65536), false, 0, true);
  441. addSpawn(PIRATEZOMBIE, 55225, 218236, -2944, Rnd.get(65536), false, 0, true);
  442. addSpawn(PIRATEZOMBIE, 54973, 218075, -2944, Rnd.get(65536), false, 0, true);
  443. cancelQuestTimer("minion_cycle", null, null);
  444. }
  445. }
  446.  
  447. else if (event.equalsIgnoreCase("zaken_unlock"))
  448. {
  449. int i1 = Rnd.get(15);
  450. L2GrandBossInstance zaken = (L2GrandBossInstance) addSpawn(ZAKEN, Xcoords[i1] + Rnd.get(650), Ycoords[i1] + Rnd.get(650), Zcoords[i1], i1, false, 0, false);
  451.  
  452. GrandBossManager.getInstance().setBossStatus(ZAKEN, ZAKEN);
  453. spawnBoss(zaken);
  454. int X = zaken.getX();
  455. int Y = zaken.getY();
  456. int Z = zaken.getZ();
  457. _log.config("Zaken: Current in X: " + X + " Y: " + Y + " Z: " + Z + ".");
  458. }
  459. else if (event.equalsIgnoreCase("CreateOnePrivateEx"))
  460. addSpawn(npc.getNpcId(), npc.getX(), npc.getY(), npc.getZ(), 0, false, 0, true);
  461.  
  462. return super.onAdvEvent(event, npc, player);
  463. }
  464.  
  465. public String onFactionCall(L2Npc npc, L2NpcInstance caller, L2PcInstance attacker, boolean isPet)
  466. {
  467. if ((caller == null) || (npc == null))
  468. return super.onFactionCall(npc, caller, attacker, isPet);
  469.  
  470. int npcId = npc.getNpcId();
  471. int callerId = caller.getNpcId();
  472.  
  473. if ((GetTimeHour() < 5) && (callerId != ZAKEN) && (npcId == ZAKEN))
  474. {
  475. int damage = 0; // well damage required :X
  476. if ((npc.getAI().getIntention() == CtrlIntention.IDLE) && (damage < 10) && (Rnd.get((30 * 15)) < 1))// todo - damage missing
  477. {
  478. int xx = caller.getX();
  479. int yy = caller.getY();
  480. int zz = caller.getZ();
  481. npc.teleToLocation(xx, yy, zz, Rnd.get(65535));
  482. }
  483. }
  484.  
  485. return super.onFactionCall(npc, caller, attacker, isPet);
  486. }
  487.  
  488. @Override
  489. public String onSpellFinished(L2Npc npc, L2PcInstance player, L2Skill skill)
  490. {
  491. if (npc.getNpcId() == ZAKEN)
  492. {
  493. int skillId = skill.getId();
  494. if (skillId == SELF_TELEPORT)
  495. {
  496. int i1 = Rnd.get(15);
  497. npc.teleToLocation(Xcoords[i1] + Rnd.get(650), Ycoords[i1] + Rnd.get(650), Zcoords[i1], i1);
  498. npc.getAI().setIntention(CtrlIntention.IDLE);
  499. int X = npc.getX();
  500. int Y = npc.getY();
  501. int Z = npc.getZ();
  502. _log.config("Zaken: Current in X: " + X + " Y: " + Y + " Z: " + Z + ".");
  503. }
  504. else if (skillId == TELEPORT)
  505. {
  506. int i1 = Rnd.get(15);
  507. player.teleToLocation(Xcoords[i1] + Rnd.get(650), Ycoords[i1] + Rnd.get(650), Zcoords[i1], i1);
  508. ((L2Attackable) npc).stopHating(player);
  509. L2Character nextTarget = ((L2Attackable) npc).getMostHated();
  510.  
  511. if (nextTarget != null)
  512. npc.getAI().setIntention(CtrlIntention.ATTACK, nextTarget);
  513. }
  514. else if (skillId == MASS_TELEPORT)
  515. {
  516. int i1 = Rnd.get(15);
  517. player.teleToLocation(Xcoords[i1] + Rnd.get(650), Ycoords[i1] + Rnd.get(650), Zcoords[i1], i1);
  518. ((L2Attackable) npc).stopHating(player);
  519.  
  520. for (L2Character character : npc.getStatus().getStatusListener())
  521. {
  522. if ((character != player) && !Util.checkIfInRange(250, player, character, true))
  523. {
  524. int r1 = Rnd.get(15);
  525. character.teleToLocation(Xcoords[r1] + Rnd.get(650), Ycoords[r1] + Rnd.get(650), Zcoords[r1], r1);
  526. ((L2Attackable) npc).stopHating(character);
  527. }
  528. }
  529.  
  530. L2Character nextTarget = ((L2Attackable) npc).getMostHated();
  531. if (nextTarget != null)
  532. npc.getAI().setIntention(CtrlIntention.ATTACK, nextTarget);
  533. }
  534. }
  535.  
  536. return super.onSpellFinished(npc, player, skill);
  537. }
  538.  
  539.  
  540. @Override
  541. public String onSkillSee(L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet)
  542. {
  543. if (skill.getAggroPoints() > 0)
  544. ((L2Attackable) npc).addDamageHate(caster, 0, ((skill.getAggroPoints() / npc.getMaxHp()) * 10 * 150));
  545.  
  546. if (Rnd.get(12) < 1)
  547. {
  548. TARGET = caster;
  549. CallSkills(npc);
  550. }
  551. return super.onSkillSee(npc, caster, skill, targets, isPet);
  552. }
  553.  
  554. @Override
  555. public String onAggro(L2Npc npc, L2PcInstance player, boolean isPet)
  556. {
  557. if (npc == null)
  558. return null;
  559.  
  560. final boolean isMage;
  561. final L2Playable character;
  562. if (isPet)
  563. {
  564. isMage = false;
  565. character = player.getPet();
  566. }
  567. else
  568. {
  569. isMage = player.isMageClass();
  570. character = player;
  571. }
  572.  
  573. if (character == null)
  574. return null;
  575.  
  576. if (!Config.RAID_DISABLE_CURSE && character.getLevel() - npc.getLevel() > 8)
  577. {
  578. L2Skill curse = null;
  579. if (isMage)
  580. {
  581. if (!character.isMuted() && Rnd.get(4) == 0)
  582. curse = FrequentSkill.RAID_CURSE.getSkill();
  583. }
  584. else
  585. {
  586. if (!character.isParalyzed() && Rnd.get(4) == 0)
  587. curse = FrequentSkill.RAID_CURSE2.getSkill();
  588. }
  589.  
  590. if (curse != null)
  591. {
  592. npc.broadcastPacket(new MagicSkillUse(npc, character, curse.getId(), curse.getLevel(), 300, 0));
  593. curse.getEffects(npc, character);
  594. }
  595.  
  596. ((L2Attackable) npc).stopHating(character); // for calling again
  597. return null;
  598. }
  599.  
  600. if (_zakenLair.isInsideZone(npc))
  601. {
  602. L2Character target = isPet ? player.getPet() : player;
  603. ((L2Attackable) npc).addDamageHate(target, 1, 200);
  604. }
  605.  
  606. int npcId = npc.getNpcId();
  607. if (npcId == ZAKEN)
  608. {
  609. if (Rnd.get(15) < 1)
  610. {
  611. TARGET = player;
  612. CallSkills(npc);
  613. }
  614. }
  615.  
  616. return super.onAggro(npc, player, isPet);
  617. }
  618.  
  619. public void CallSkills(L2Npc npc)
  620. {
  621. int chance = Rnd.get(Rnd.get(15) * Rnd.get(15));
  622. npc.setTarget(TARGET);
  623.  
  624. if (chance < 1)
  625. npc.doCast(SkillTable.getInstance().getInfo(TELEPORT, 1));
  626.  
  627. else if (chance < 2)
  628. npc.doCast(SkillTable.getInstance().getInfo(MASS_TELEPORT, 1));
  629.  
  630. else if (chance < 4)
  631. npc.doCast(SkillTable.getInstance().getInfo(HOLD, 1));
  632.  
  633. else if (chance < 8)
  634. npc.doCast(SkillTable.getInstance().getInfo(DRAIN, 1));
  635.  
  636. else if (chance < 15)
  637. npc.doCast(SkillTable.getInstance().getInfo(MASS_DUAL_ATTACK, 1));
  638.  
  639. if (Rnd.get(2) < 1)
  640. {
  641. if (TARGET == ((L2Attackable) npc).getMostHated())
  642. npc.doCast(SkillTable.getInstance().getInfo(DUAL_ATTACK, 1));
  643. }
  644.  
  645. if ((Rnd.get(150) < 2 ) && (GetTimeHour() > 5) && (npc.getCurrentHp() / npc.getMaxHp() < 0.80))
  646. npc.doCast(SkillTable.getInstance().getInfo(SELF_TELEPORT, 1));
  647. }
  648.  
  649. @Override
  650. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isPet, L2Skill skill)
  651. {
  652. int npcId = npc.getNpcId();
  653. if (npcId == ZAKEN)
  654. {
  655. if (attacker.getMountType() == 1)
  656. {
  657. L2Skill skill1 = SkillTable.getInstance().getInfo(4258, 1);
  658. if (attacker.getFirstEffect(skill1) == null)
  659. {
  660. npc.setTarget(attacker);
  661. npc.doCast(skill1);
  662. }
  663. }
  664. L2Character originalAttacker = isPet ? attacker.getPet() : attacker;
  665. int hate = (int) ((damage / npc.getMaxHp() / 0.05) * 20000);
  666. ((L2Attackable) npc).addDamageHate(originalAttacker, 0, hate);
  667.  
  668. if (Rnd.get(10) < 1)
  669. {
  670. TARGET = attacker;
  671. CallSkills(npc);
  672. }
  673. }
  674.  
  675. return super.onAttack(npc, attacker, damage, isPet, skill);
  676. }
  677.  
  678. @Override
  679. public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet)
  680. {
  681. int npcId = npc.getNpcId();
  682.  
  683. if (npcId == ZAKEN)
  684. {
  685. npc.broadcastPacket(new PlaySound(1, "BS02_D", 1, npc.getObjectId(), npc.getX(), npc.getY(), npc.getZ()));
  686.  
  687. GrandBossManager.getInstance().setBossStatus(ZAKEN, ZAKEN);
  688. long respawnTime = (long) Config.SPAWN_INTERVAL_ZAKEN + Rnd.get(Config.RANDOM_SPAWN_TIME_ZAKEN);
  689. startQuestTimer("zaken_unlock", respawnTime, null, null, false);
  690. cancelQuestTimer("timer", npc, null);
  691. cancelQuestTimer("minion_cycle", npc, null);
  692.  
  693. StatsSet info = GrandBossManager.getInstance().getStatsSet(ZAKEN);
  694. info.set("respawn_time", System.currentTimeMillis() + respawnTime);
  695. GrandBossManager.getInstance().setStatsSet(ZAKEN, info);
  696. }
  697. else if (GrandBossManager.getInstance().getBossStatus(ZAKEN) == ALIVE)
  698. {
  699. if (npcId != ZAKEN)
  700. startQuestTimer("CreateOnePrivateEx", ((30 + Rnd.get(60)) * 1000), npc, null, false);
  701. }
  702.  
  703. return super.onKill(npc, killer, isPet);
  704. }
  705.  
  706. public int GetTimeHour()
  707. {
  708. return (GameTimeController.getInstance().getGameTime() / 60) % 24;
  709. }
  710.  
  711. public static void main(String[] args)
  712. {
  713. new Zaken(Zaken.class.getSimpleName(), "ai/individual");
  714. }
  715. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement