Guest User

Zaken Ai

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