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