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