brounlimited

Zaken AI (Addapted for aCis)

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