Advertisement
Guest User

Lindvior AI

a guest
Nov 28th, 2016
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 31.71 KB | None | 0 0
  1. package ai.individual.GrandBosses.Lindvior;
  2.  
  3. import ai.group_template.L2AttackableAIScript;
  4. import l2server.Config;
  5. import l2server.gameserver.ThreadPoolManager;
  6. import l2server.gameserver.ai.CtrlIntention;
  7. import l2server.gameserver.datatables.ScenePlayerDataTable;
  8. import l2server.gameserver.datatables.SkillTable;
  9. import l2server.gameserver.datatables.SpawnTable;
  10. import l2server.gameserver.instancemanager.GrandBossManager;
  11. import l2server.gameserver.instancemanager.InstanceManager;
  12. import l2server.gameserver.model.L2Skill;
  13. import l2server.gameserver.model.Location;
  14. import l2server.gameserver.model.actor.L2Character;
  15. import l2server.gameserver.model.actor.L2Npc;
  16. import l2server.gameserver.model.actor.instance.L2GrandBossInstance;
  17. import l2server.gameserver.model.actor.instance.L2MonsterInstance;
  18. import l2server.gameserver.model.actor.instance.L2PcInstance;
  19. import l2server.gameserver.model.quest.QuestTimer;
  20. import l2server.gameserver.model.zone.type.L2BossZone;
  21. import l2server.gameserver.network.serverpackets.*;
  22. import l2server.gameserver.util.Broadcast;
  23. import l2server.gameserver.util.Util;
  24. import l2server.log.Log;
  25. import l2server.util.Rnd;
  26.  
  27. import java.util.ArrayList;
  28. import java.util.HashMap;
  29. import java.util.List;
  30. import java.util.Map;
  31. import java.util.Map.Entry;
  32.  
  33. /**
  34.  * @author LasTravel
  35.  * @author Pere
  36.  *         <p>
  37.  *         Lindvior Boss - Normal Mode
  38.  *         <p>
  39.  *         Source:
  40.  *         - http://www.youtube.com/watch?v=QlHvI54oyJo (Retail part 1)
  41.  *         - http://www.youtube.com/watch?v=9GMk6q4rjys (Retail part 2)
  42.  *         - http://www.youtube.com/watch?v=sVFNT8tdagA (Retail part3)
  43.  *         - http://www.youtube.com/watch?v=vKwf8Jx_Qtc (Retail failed boss)
  44.  *         - http://www.youtube.com/watch?v=dG9OMGGg1ao
  45.  */
  46.  
  47. public class Lindvior extends L2AttackableAIScript
  48. {
  49.     //Quest
  50.     private static final boolean _debug = false;
  51.     private static final String _qn = "Lindvior";
  52.  
  53.     //Id's
  54.     private static final int _npcEnterId = 33881;
  55.     private static final int _generatorId = 19426;
  56.     private static final int _generatorGuard = 19479;
  57.     private static final int _giantCycloneId = 19427;
  58.     private static final int _cycloneId = 25898;
  59.     private static final int _firstFloorLindvior = 25899;
  60.     private static final int _secondFloorLindvior = 29240;
  61.     private static final int _flyLindvior = 19424;
  62.     private static final int[] _lindviorIds = {_firstFloorLindvior, _secondFloorLindvior, _flyLindvior};
  63.     private static final int[] _lynDracoIds = {25895, 25896, 25897, 29241, 29242, 29243};
  64.     private static final int[] _allMinionIds = {
  65.             _lynDracoIds[0],
  66.             _lynDracoIds[1],
  67.             _lynDracoIds[2],
  68.             _lynDracoIds[3],
  69.             _lynDracoIds[4],
  70.             _lynDracoIds[5],
  71.             _cycloneId,
  72.             _giantCycloneId
  73.     };
  74.     private static final int _flyingLindviorAroundZoneId = 19423;
  75.     private static final int _lindviorCameraId = 19428;
  76.     //private static final int _redCircle                   = 19391;
  77.     //private static final int _blueCircle                  = 19392;
  78.     private static final double maxGeneratorDamage = 1500000;
  79.     private static final L2BossZone _bossZone = GrandBossManager.getInstance().getZone(45697, -26269, -1409);
  80.  
  81.     //Effects
  82.     private static final int _allGeneratorsConnectedEffect = 21170110;
  83.     private static final int _redTowerEffect = 21170112;
  84.     private static final int _shieldTowerEffect = 21170100;
  85.     private static final int _generatorEffect_1 = 21170104;
  86.     private static final int _generatorEffect_2 = 21170102;
  87.     private static final int _generatorEffect_3 = 21170106;
  88.     private static final int _generatorEffect_4 = 21170108;
  89.     private static final int _redZoneEffect = 21170120;
  90.  
  91.     //Cords
  92.     private static final Location _enterCords = new Location(46931, -28813, -1406);
  93.  
  94.     //Skills
  95.     //private static final L2Skill _rechargePossible        = SkillTable.getInstance().getInfo(15605, 1);
  96.     //private static final L2Skill _recharge                = SkillTable.getInstance().getInfo(15606, 1);
  97.     private static final L2Skill _takeOff = SkillTable.getInstance().getInfo(15596, 1);
  98.  
  99.     //Vars
  100.     private L2Npc _dummyLindvior;
  101.     private L2Npc _lindviorBoss;
  102.     private Location _bossLocation;
  103.     private static long _LastAction;
  104.     private int _bossStage;
  105.     private Map<L2Npc, Double> _manageGenerators = new HashMap<L2Npc, Double>();
  106.  
  107.     public Lindvior(int questId, String name, String descr)
  108.     {
  109.         super(questId, name, descr);
  110.  
  111.         addTalkId(_npcEnterId);
  112.         addStartNpc(_npcEnterId);
  113.         addSpawnId(_generatorGuard);
  114.         addFirstTalkId(_generatorId);
  115.         addTalkId(_generatorId);
  116.         addStartNpc(_generatorId);
  117.         addSpawnId(_generatorId);
  118.         addAttackId(_generatorId);
  119.  
  120.         for (int a : _allMinionIds)
  121.         {
  122.             addAttackId(a);
  123.             addKillId(a);
  124.         }
  125.  
  126.         for (int a : _lindviorIds)
  127.         {
  128.             addSpellFinishedId(a);
  129.             addAttackId(a);
  130.             addKillId(a);
  131.         }
  132.  
  133.         //Unlock
  134.         startQuestTimer("unlock_lindvior", GrandBossManager.getInstance().getUnlockTime(_secondFloorLindvior), null,
  135.                 null);
  136.     }
  137.  
  138.     @Override
  139.     public String onSpawn(L2Npc npc)
  140.     {
  141.         if (_debug)
  142.         {
  143.             Log.warning(getName() + ": onSpawn: " + npc.getName());
  144.         }
  145.  
  146.         if (npc.getNpcId() == _generatorId)
  147.         {
  148.             npc.disableCoreAI(true);
  149.             npc.setDisplayEffect(1);
  150.             npc.setIsMortal(false);
  151.             npc.setIsInvul(true); //Can't get damage now
  152.         }
  153.  
  154.         if (npc.getNpcId() == _generatorGuard)
  155.         {
  156.             npc.setIsInvul(true);
  157.         }
  158.  
  159.         return super.onSpawn(npc);
  160.     }
  161.  
  162.     @Override
  163.     public String onFirstTalk(L2Npc npc, L2PcInstance player)
  164.     {
  165.         if (_debug)
  166.         {
  167.             Log.warning(getName() + ": onFirstTalk: " + player.getName());
  168.         }
  169.  
  170.         if (npc.getNpcId() == _generatorId)
  171.         {
  172.             if (_bossStage == 1)
  173.             {
  174.                 return npc.getDisplayEffect() == 1 ? "Generator.html" : "GeneratorDone.html";
  175.             }
  176.             else
  177.             {
  178.                 player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, npc);
  179.             }
  180.         }
  181.  
  182.         return super.onFirstTalk(npc, player);
  183.     }
  184.  
  185.     @Override
  186.     public final String onTalk(L2Npc npc, L2PcInstance player)
  187.     {
  188.         if (_debug)
  189.         {
  190.             Log.warning(getName() + ": onTalk: " + player.getName());
  191.         }
  192.  
  193.         int npcId = npc.getNpcId();
  194.         if (npcId == _npcEnterId)
  195.         {
  196.             int lindStatus = GrandBossManager.getInstance().getBossStatus(_secondFloorLindvior);
  197.  
  198.             final List<L2PcInstance> allPlayers = new ArrayList<L2PcInstance>();
  199.             if (lindStatus == GrandBossManager.getInstance().DEAD)
  200.             {
  201.                 return "33881-01.html";
  202.             }
  203.             else
  204.             {
  205.                 if (!_debug)
  206.                 {
  207.                     if (lindStatus == GrandBossManager.getInstance().ALIVE && !InstanceManager.getInstance()
  208.                             .checkInstanceConditions(player, -1, Config.LINDVIOR_MIN_PLAYERS, 200, 95,
  209.                                     Config.MAX_LEVEL))
  210.                     {
  211.                         return null;
  212.                     }
  213.                     else if (lindStatus == GrandBossManager.getInstance().WAITING && !InstanceManager.getInstance()
  214.                             .checkInstanceConditions(player, -1, Config.LINDVIOR_MIN_PLAYERS, 200, 95,
  215.                                     Config.MAX_LEVEL))
  216.                     {
  217.                         return null;
  218.                     }
  219.                     else if (lindStatus == GrandBossManager.getInstance().FIGHTING)
  220.                     {
  221.                         return null;
  222.                     }
  223.                 }
  224.             }
  225.  
  226.             if (lindStatus == GrandBossManager.getInstance().ALIVE)
  227.             {
  228.                 GrandBossManager.getInstance()
  229.                         .setBossStatus(_secondFloorLindvior, GrandBossManager.getInstance().WAITING);
  230.  
  231.                 startQuestTimer("stage_1_start", 1000, null, null);
  232.             }
  233.  
  234.             if (_debug)
  235.             {
  236.                 allPlayers.add(player);
  237.             }
  238.             else
  239.             {
  240.                 allPlayers.addAll(Config.LINDVIOR_MIN_PLAYERS > Config.MAX_MEMBERS_IN_PARTY ||
  241.                         player.getParty().isInCommandChannel() ? player.getParty().getCommandChannel().getMembers() :
  242.                         player.getParty().getPartyMembers());
  243.             }
  244.  
  245.             for (L2PcInstance enterPlayer : allPlayers)
  246.             {
  247.                 if (enterPlayer == null)
  248.                 {
  249.                     continue;
  250.                 }
  251.  
  252.                 _bossZone.allowPlayerEntry(enterPlayer, 7200);
  253.  
  254.                 enterPlayer.sendPacket(new EventTrigger(_redTowerEffect, true));
  255.                 enterPlayer.teleToLocation(_enterCords, true);
  256.             }
  257.         }
  258.  
  259.         return "";
  260.     }
  261.  
  262.     @Override
  263.     public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  264.     {
  265.         if (_debug)
  266.         {
  267.             Log.warning(getName() + ": onAdvEvent: " + event);
  268.         }
  269.  
  270.         if (event.equalsIgnoreCase("unlock_lindvior"))
  271.         {
  272.             L2Npc lindvior = addSpawn(_secondFloorLindvior, -105200, -253104, -15264, 32768, false, 0);
  273.  
  274.             GrandBossManager.getInstance().addBoss((L2GrandBossInstance) lindvior);
  275.             GrandBossManager.getInstance().setBossStatus(_secondFloorLindvior, GrandBossManager.getInstance().ALIVE);
  276.  
  277.             Broadcast.toAllOnlinePlayers(new Earthquake(45697, -26269, -1409, 20, 10));
  278.         }
  279.         else if (event.equalsIgnoreCase("check_activity_task"))
  280.         {
  281.             if (!GrandBossManager.getInstance().isActive(_secondFloorLindvior, _LastAction))
  282.             {
  283.                 notifyEvent("end_lindvior", null, null);
  284.             }
  285.         }
  286.         else if (event.equalsIgnoreCase("stage_1_start"))
  287.         {
  288.             SpawnTable.getInstance().spawnSpecificTable("lindvior_boss");
  289.  
  290.             _bossStage = 1;
  291.  
  292.             _bossZone.sendDelayedPacketToZone(5000,
  293.                     new ExShowScreenMessage(14211701, 0, true, 5000)); //You must activate the 4 Generators.
  294.  
  295.             //Generator guards should broadcast npcStringId 1802366
  296.  
  297.             _dummyLindvior = addSpawn(_lindviorCameraId, 45259, -27115, -638, 41325, false, 0, false);
  298.  
  299.             _LastAction = System.currentTimeMillis();
  300.  
  301.             startQuestTimer("check_activity_task", 60000, null, null, true);
  302.         }
  303.         else if (event.equalsIgnoreCase("stage_1_activate_generator"))
  304.         {
  305.             if (_bossStage == 1)
  306.             {
  307.                 if (npc.getDisplayEffect() == 1) //Orange
  308.                 {
  309.                     npc.setDisplayEffect(2); //Blue
  310.  
  311.                     int generatorEffect = _generatorEffect_1;
  312.                     if (Util.checkIfInRange(500, npc.getX(), npc.getY(), npc.getZ(), 45283, -30372, -1405, false))
  313.                     {
  314.                         generatorEffect = _generatorEffect_2;
  315.                     }
  316.                     else if (Util.checkIfInRange(500, npc.getX(), npc.getY(), npc.getZ(), 45283, -23967, -1405, false))
  317.                     {
  318.                         generatorEffect = _generatorEffect_3;
  319.                     }
  320.                     else if (Util.checkIfInRange(500, npc.getX(), npc.getY(), npc.getZ(), 42086, -27179, -1405, false))
  321.                     {
  322.                         generatorEffect = _generatorEffect_4;
  323.                     }
  324.  
  325.                     _bossZone.broadcastPacket(new EventTrigger(generatorEffect, true));
  326.  
  327.                     _bossZone.broadcastPacket(new Earthquake(npc.getX(), npc.getY(), npc.getZ(), 10, 10));
  328.  
  329.                     synchronized (_manageGenerators)
  330.                     {
  331.                         if (_manageGenerators.size() < 3)
  332.                         {
  333.                             _bossZone.broadcastPacket(new ExShowScreenMessage(14211701, 0, true,
  334.                                     5000)); //You must activate the 4 Generators.
  335.                         }
  336.  
  337.                         if (!_manageGenerators.containsKey(npc))
  338.                         {
  339.                             _manageGenerators.put(npc, (double) 0);
  340.                         }
  341.  
  342.                         if (_manageGenerators.size() == 4)
  343.                         {
  344.                             //All generators are active now
  345.                             //Here the center shield should opens (missing) and Lindvior should appear
  346.                             _bossStage = 2;
  347.  
  348.                             //Spawn the dummy cyclone
  349.                             for (L2Npc generator : _manageGenerators.keySet())
  350.                             {
  351.                                 if (generator == null)
  352.                                 {
  353.                                     continue;
  354.                                 }
  355.  
  356.                                 //Display & invul maybe should be done before the intro movie
  357.                                 generator.setDisplayEffect(1);
  358.                                 generator.setIsInvul(false); //generator now can get damage
  359.                             }
  360.  
  361.                             _bossZone.broadcastPacket(new EventTrigger(_allGeneratorsConnectedEffect, true));
  362.  
  363.                             _bossZone.broadcastPacket(new SocialAction(_dummyLindvior.getObjectId(), 1));
  364.  
  365.                             _bossZone.broadcastPacket(new EventTrigger(_shieldTowerEffect, true));
  366.                             _bossZone.broadcastPacket(new EventTrigger(_redTowerEffect, false));
  367.  
  368.                             startQuestTimer("stage_2_intro_start", 6500, npc, null);
  369.                         }
  370.                     }
  371.                 }
  372.             }
  373.         }
  374.         else if (event.equalsIgnoreCase("stage_2_intro_start"))
  375.         {
  376.             _bossZone.showVidToZone(76);
  377.  
  378.             startQuestTimer("stage_2_start", ScenePlayerDataTable.getInstance().getVideoDuration(76) + 200, npc, null);
  379.         }
  380.         else if (event.equalsIgnoreCase("stage_2_start"))
  381.         {
  382.             _dummyLindvior.deleteMe();
  383.             _dummyLindvior = addSpawn(_flyingLindviorAroundZoneId, 45259, -27115, -638, 41325, false, 0, false);
  384.  
  385.             _bossZone.broadcastPacket(new ExShowScreenMessage(14211702, 0, true, 5000)); //Protect the Generator!
  386.         }
  387.         else if (event.equalsIgnoreCase("stage_2_end"))
  388.         {
  389.             _bossStage = 5;
  390.  
  391.             _bossLocation = new Location(_lindviorBoss.getX(), _lindviorBoss.getY(), _lindviorBoss.getZ(),
  392.                     _lindviorBoss.getHeading());
  393.  
  394.             _lindviorBoss.deleteMe();
  395.  
  396.             startQuestTimer("stage_3_start", 5000, npc, null);
  397.         }
  398.         else if (event.equalsIgnoreCase("stage_3_start"))
  399.         {
  400.             landingLindvior();
  401.         }
  402.         else if (event.equalsIgnoreCase("stage_3_end"))
  403.         {
  404.             _bossStage = 7;
  405.  
  406.             _bossLocation = new Location(_lindviorBoss.getX(), _lindviorBoss.getY(), _lindviorBoss.getZ(),
  407.                     _lindviorBoss.getHeading());
  408.  
  409.             _lindviorBoss.deleteMe();
  410.  
  411.             startQuestTimer("stage_4_start", 5000, npc, null);
  412.         }
  413.         else if (event.equalsIgnoreCase("stage_4_start"))
  414.         {
  415.             landingLindvior();
  416.         }
  417.         else if (event.equalsIgnoreCase("stage_4_end"))
  418.         {
  419.             _bossLocation = new Location(_lindviorBoss.getX(), _lindviorBoss.getY(), _lindviorBoss.getZ(),
  420.                     _lindviorBoss.getHeading());
  421.  
  422.             _lindviorBoss.deleteMe();
  423.  
  424.             startQuestTimer("stage_5_start", 5000, npc, null);
  425.         }
  426.         else if (event.equalsIgnoreCase("stage_5_start"))
  427.         {
  428.             landingLindvior();
  429.         }
  430.         else if (event.equalsIgnoreCase("stage_5_end"))
  431.         {
  432.             _bossLocation = new Location(_lindviorBoss.getX(), _lindviorBoss.getY(), _lindviorBoss.getZ(),
  433.                     _lindviorBoss.getHeading());
  434.  
  435.             _lindviorBoss.deleteMe();
  436.  
  437.             startQuestTimer("stage_6_start", 5000, npc, null);
  438.         }
  439.         else if (event.equalsIgnoreCase("stage_6_start"))
  440.         {
  441.             landingLindvior();
  442.         }
  443.         else if (event.equalsIgnoreCase("spawn_minion_task"))
  444.         {
  445.             if (_lindviorBoss != null && !_lindviorBoss.isDead())
  446.             {
  447.                 if (Rnd.get(100) > 30)
  448.                 {
  449.                     if (_bossStage < 9) //Can spawn Lyns at all stages, less at the last one
  450.                     {
  451.                         spawnMinions(_lindviorBoss, Rnd.get(100) > 50 ? _cycloneId : -1, 1000, 20);
  452.                     }
  453.                     else
  454.                     {
  455.                         spawnMinions(_lindviorBoss, _cycloneId, 1000, 20); //Only Cyclones
  456.                     }
  457.                 }
  458.  
  459.                 //Big Cyclone only at last stage, always
  460.                 if (_bossStage >= 9)
  461.                 {
  462.                     spawnMinions(_lindviorBoss, _giantCycloneId, 1, 2);
  463.                 }
  464.  
  465.                 //Individual Player Cyclone always
  466.                 for (L2PcInstance players : _bossZone.getPlayersInside())
  467.                 {
  468.                     if (players == null)
  469.                     {
  470.                         continue;
  471.                     }
  472.  
  473.                     if (Rnd.get(100) > 40)
  474.                     {
  475.                         spawnMinions(players, _cycloneId, 1, 1);
  476.                     }
  477.                 }
  478.             }
  479.         }
  480.         else if (event.equalsIgnoreCase("cancel_timers"))
  481.         {
  482.             QuestTimer activityTimer = getQuestTimer("check_activity_task", null, null);
  483.             if (activityTimer != null)
  484.             {
  485.                 activityTimer.cancel();
  486.             }
  487.  
  488.             QuestTimer spawnMinionTask = getQuestTimer("spawn_minion_task", null, null);
  489.             if (spawnMinionTask != null)
  490.             {
  491.                 spawnMinionTask.cancel();
  492.             }
  493.         }
  494.         else if (event.equalsIgnoreCase("end_lindvior"))
  495.         {
  496.             notifyEvent("cancel_timers", null, null);
  497.  
  498.             _bossZone.oustAllPlayers();
  499.  
  500.             _manageGenerators.clear();
  501.  
  502.             _bossStage = 0;
  503.  
  504.             SpawnTable.getInstance().despawnSpecificTable("lindvior_boss");
  505.  
  506.             for (L2Npc mob : _bossZone.getNpcsInside())
  507.             {
  508.                 if (mob == null)
  509.                 {
  510.                     continue;
  511.                 }
  512.  
  513.                 mob.getSpawn().stopRespawn();
  514.                 mob.deleteMe();
  515.             }
  516.  
  517.             if (GrandBossManager.getInstance().getBossStatus(_secondFloorLindvior) !=
  518.                     GrandBossManager.getInstance().DEAD)
  519.             {
  520.                 GrandBossManager.getInstance()
  521.                         .setBossStatus(_secondFloorLindvior, GrandBossManager.getInstance().ALIVE);
  522.             }
  523.         }
  524.  
  525.         return super.onAdvEvent(event, npc, player);
  526.     }
  527.  
  528.     private void spawnMinions(L2Character npc, int minionId, int rad, int amount)
  529.     {
  530.         int radius = rad;
  531.         int mobCount = _bossZone.getNpcsInside().size();
  532.         if (mobCount < 70)
  533.         {
  534.             for (int i = 0; i < amount; i++)
  535.             {
  536.                 int x = (int) (radius * Math.cos(i * 0.618));
  537.                 int y = (int) (radius * Math.sin(i * 0.618));
  538.  
  539.                 L2MonsterInstance minion = (L2MonsterInstance) addSpawn(
  540.                         minionId == -1 ? _lynDracoIds[Rnd.get(_lynDracoIds.length)] : minionId, npc.getX() + x,
  541.                         npc.getY() + y, npc.getZ() + 20, -1, false, 0, true, npc.getInstanceId());
  542.                 minion.setIsRunning(true);
  543.  
  544.                 //To be sure
  545.                 if (!_bossZone.isInsideZone(minion))
  546.                 {
  547.                     minion.teleToLocation(npc.getX(), npc.getY(), npc.getZ());
  548.                 }
  549.             }
  550.         }
  551.     }
  552.  
  553.     @Override
  554.     public final String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isPet, L2Skill skill)
  555.     {
  556.         if (_debug)
  557.         {
  558.             Log.warning(getName() + ": onAttack: " + npc.getName());
  559.         }
  560.  
  561.         _LastAction = System.currentTimeMillis();
  562.  
  563.         //Anti BUGGERS
  564.         if (!_bossZone.isInsideZone(attacker)) //Character attacking out of zone
  565.         {
  566.             attacker.doDie(null);
  567.  
  568.             if (_debug)
  569.             {
  570.                 Log.warning(getName() + ": Character: " + attacker.getName() + " attacked: " + npc.getName() +
  571.                         " out of the boss zone!");
  572.             }
  573.         }
  574.  
  575.         if (!_bossZone.isInsideZone(npc)) //Npc moved out of the zone
  576.         {
  577.             int[] randPoint = _bossZone.getZone().getRandomPoint();
  578.             npc.teleToLocation(randPoint[0], randPoint[1], randPoint[2]);
  579.  
  580.             if (_debug)
  581.             {
  582.                 Log.warning(getName() + ": Character: " + attacker.getName() + " attacked: " + npc.getName() +
  583.                         " wich is out of the boss zone!");
  584.             }
  585.         }
  586.  
  587.         if (npc.getNpcId() == _generatorId)
  588.         {
  589.             if (_bossStage == 2)
  590.             {
  591.                 if (npc.getDisplayEffect() == 1)//Charge is Possible
  592.                 {
  593.                     synchronized (_manageGenerators)
  594.                     {
  595.                         if (_manageGenerators.containsKey(npc))
  596.                         {
  597.                             if (_manageGenerators.get(npc) == 0) //First attack
  598.                             {
  599.                                 _manageGenerators.put(npc, (double) damage);
  600.  
  601.                                 _bossZone.broadcastPacket(
  602.                                         new ExShowScreenMessage(14211702, 0, true, 5000)); //Protect the Generator!
  603.  
  604.                                 //Spawn Lyn Dracos
  605.                                 spawnMinions(npc, -1, 600, 7);
  606.                             }
  607.                             else
  608.                             {
  609.                                 //This should be done with one special skill but we will do it with damage....
  610.                                 double generatorDamage =
  611.                                         _manageGenerators.get(npc); //Get the current damage from this generator
  612.                                 double calcDamage = generatorDamage + damage;
  613.  
  614.                                 if (generatorDamage == maxGeneratorDamage)
  615.                                 {
  616.                                     return super.onAttack(npc, attacker, damage, isPet);
  617.                                 }
  618.                                 else
  619.                                 {
  620.                                     if (calcDamage >= maxGeneratorDamage)
  621.                                     {
  622.                                         _manageGenerators.put(npc, maxGeneratorDamage);
  623.  
  624.                                         npc.broadcastPacket(new ExSendUIEvent(5, 120, 120, 16211701),
  625.                                                 1200); //bar with the 100%
  626.  
  627.                                         _bossZone.broadcastPacket(new ExShowScreenMessage(
  628.                                                 "$s1 has charged the cannon!".replace("$s1", attacker.getName()),
  629.                                                 5000)); //$s1 has charged the cannon!
  630.  
  631.                                         int count = 0;
  632.  
  633.                                         for (Entry<L2Npc, Double> generator : _manageGenerators.entrySet())
  634.                                         {
  635.                                             if (generator.getValue() == maxGeneratorDamage)
  636.                                             {
  637.                                                 count++;
  638.                                             }
  639.                                         }
  640.  
  641.                                         if (count == 4)
  642.                                         {
  643.                                             //All generators are charged here
  644.                                             _bossStage = 3;
  645.  
  646.                                             GrandBossManager.getInstance().setBossStatus(_secondFloorLindvior,
  647.                                                     GrandBossManager.getInstance().FIGHTING);
  648.  
  649.                                             _dummyLindvior.deleteMe(); //Delete the flying Lindvior
  650.  
  651.                                             //Lindvior fall to the scenario here
  652.                                             _bossZone.broadcastPacket(
  653.                                                     new Earthquake(npc.getX(), npc.getY(), npc.getZ(), 10, 10));
  654.  
  655.                                             landingLindvior();
  656.  
  657.                                             _bossZone.sendDelayedPacketToZone(5000,
  658.                                                     new ExShowScreenMessage(14211708, 0, true,
  659.                                                             5000)); //Lindvior has fallen from the sky!
  660.  
  661.                                             //Start the minion task
  662.                                             startQuestTimer("spawn_minion_task", 3 * 60000, null, null, true);
  663.  
  664.                                             //At this point all the start instance npcs are deleted
  665.                                             for (L2Character chara : _bossZone.getCharactersInside().values())
  666.                                             {
  667.                                                 if (chara == null || !(chara instanceof L2Npc))
  668.                                                 {
  669.                                                     continue;
  670.                                                 }
  671.  
  672.                                                 if (((L2Npc) chara).getNpcId() != _firstFloorLindvior)
  673.                                                 {
  674.                                                     chara.deleteMe();
  675.                                                 }
  676.                                             }
  677.  
  678.                                             //kick dual box
  679.                                             _bossZone.kickDualBoxes();
  680.                                         }
  681.                                     }
  682.                                     else
  683.                                     {
  684.                                         _manageGenerators.put(npc, calcDamage);
  685.  
  686.                                         double calc = generatorDamage / maxGeneratorDamage * 120;
  687.  
  688.                                         npc.broadcastPacket(new ExSendUIEvent(5, (int) calc, 120, 16211701), 1200);
  689.                                     }
  690.                                 }
  691.                             }
  692.                         }
  693.                     }
  694.                 }
  695.             }
  696.         }
  697.         else if (npc.getNpcId() == _firstFloorLindvior)
  698.         {
  699.             if (_bossStage == 3)
  700.             {
  701.                 if (npc.getCurrentHp() < npc.getMaxHp() * 0.50) //50%
  702.                 {
  703.                     _bossStage = 4;
  704.  
  705.                     takeOffLindvior();
  706.  
  707.                     _bossZone.broadcastPacket(new EventTrigger(_redZoneEffect, true));
  708.                     _bossZone.sendDelayedPacketToZone(15000, new EventTrigger(_redZoneEffect, false));
  709.                     _bossZone.broadcastPacket(new ExShowScreenMessage(14211705, 0, true,
  710.                             5000)); //A fearsome power emanates from Lindvior!
  711.  
  712.                     startQuestTimer("stage_2_end", 4000, npc, null); //TODO
  713.                 }
  714.             }
  715.         }
  716.         else if (npc.getNpcId() == _secondFloorLindvior)
  717.         {
  718.             if (_bossStage == 7)
  719.             {
  720.                 if (npc.getCurrentHp() < npc.getMaxHp() * 0.20) //20%
  721.                 {
  722.                     _bossStage = 8;
  723.  
  724.                     takeOffLindvior();
  725.  
  726.                     startQuestTimer("stage_4_end", 5600, npc, null);
  727.                 }
  728.             }
  729.         }
  730.         else if (npc.getNpcId() == _flyLindvior)
  731.         {
  732.             if (_bossStage == 5)
  733.             {
  734.                 if (npc.getCurrentHp() < npc.getMaxHp() * 0.30) //30%
  735.                 {
  736.                     _bossStage = 6;
  737.  
  738.                     takeOffLindvior();
  739.  
  740.                     startQuestTimer("stage_3_end", 5600, npc, null);
  741.                 }
  742.             }
  743.             else if (_bossStage == 8)
  744.             {
  745.                 if (npc.getCurrentHp() < npc.getMaxHp() * 0.20) //20%
  746.                 {
  747.                     _bossStage = 9;
  748.  
  749.                     takeOffLindvior();
  750.  
  751.                     startQuestTimer("stage_5_end", 5600, npc, null);
  752.                 }
  753.             }
  754.         }
  755.  
  756.         return super.onAttack(npc, attacker, damage, isPet, skill);
  757.     }
  758.  
  759.     private void takeOffLindvior()
  760.     {
  761.         switch (_bossStage)
  762.         {
  763.             case 4:
  764.             case 6:
  765.             case 8:
  766.             case 9:
  767.                 _lindviorBoss.disableCoreAI(true);
  768.                 _lindviorBoss.setIsInvul(true);
  769.                 _lindviorBoss.setTarget(_lindviorBoss);
  770.  
  771.                 if (_lindviorBoss.isCastingNow())
  772.                 {
  773.                     _lindviorBoss.abortCast();
  774.                 }
  775.  
  776.                 _lindviorBoss.doCast(_takeOff);
  777.                 break;
  778.         }
  779.     }
  780.  
  781.     private void landingLindvior()
  782.     {
  783.         switch (_bossStage)
  784.         {
  785.             case 3:
  786.                 _lindviorBoss = addSpawn(_firstFloorLindvior, 47180, -26122, -1407, 48490, false, 0, true);
  787.                 break;
  788.  
  789.             case 5:
  790.             case 8:
  791.                 _lindviorBoss = addSpawn(_flyLindvior, _bossLocation.getX(), _bossLocation.getY(), _bossLocation.getZ(),
  792.                         _bossLocation.getHeading(), false, 0, true);
  793.                 _lindviorBoss.setDisplayEffect(1);
  794.                 _lindviorBoss.setCurrentHp(_lindviorBoss.getMaxHp() * (_bossStage == 5 ? 0.85 : 0.40));
  795.                 break;
  796.  
  797.             case 7:
  798.             case 9:
  799.                 _lindviorBoss =
  800.                         addSpawn(_secondFloorLindvior, _bossLocation.getX(), _bossLocation.getY(), _bossLocation.getZ(),
  801.                                 _bossLocation.getHeading(), false, 0, true);
  802.                 _lindviorBoss.setCurrentHp(_lindviorBoss.getMaxHp() * (_bossStage == 7 ? 0.70 : 0.20));
  803.                 break;
  804.         }
  805.  
  806.         _lindviorBoss.setShowSummonAnimation(false);
  807.     }
  808.  
  809.     @Override
  810.     public String onKill(L2Npc npc, L2PcInstance player, boolean isPet)
  811.     {
  812.         if (_debug)
  813.         {
  814.             Log.warning(getName() + ": onKill: " + npc.getName());
  815.         }
  816.  
  817.         if (npc.getNpcId() == _secondFloorLindvior)
  818.         {
  819.             GrandBossManager.getInstance().notifyBossKilled(_secondFloorLindvior);
  820.  
  821.             notifyEvent("cancel_timers", null, null);
  822.  
  823.             _bossZone.stopWholeZone();
  824.  
  825.             // Start the zone when the cameras ends
  826.             ThreadPoolManager.getInstance().scheduleAi(new Runnable()
  827.             {
  828.                 @Override
  829.                 public void run()
  830.                 {
  831.                     _bossZone.startWholeZone();
  832.                 }
  833.             }, 14000);
  834.  
  835.             startQuestTimer("unlock_lindvior", GrandBossManager.getInstance().getUnlockTime(_secondFloorLindvior), null,
  836.                     null);
  837.             startQuestTimer("end_lindvior", 1800000, null, null);
  838.         }
  839.  
  840.         return super.onKill(npc, player, isPet);
  841.     }
  842.  
  843.     @Override
  844.     public int getOnKillDelay(int npcId)
  845.     {
  846.         return 0;
  847.     }
  848.  
  849.     public static void main(String[] args)
  850.     {
  851.         new Lindvior(-1, _qn, "ai/individual/GrandBosses");
  852.     }
  853. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement