Advertisement
Guest User

IsthinaNormal

a guest
Aug 22nd, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.21 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 version.
  5.  *
  6.  * This program is distributed in the hope that it will be useful, but WITHOUT
  7.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8.  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9.  *
  10.  * You should have received a copy of the GNU General Public License
  11.  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  12.  */
  13. package instances;
  14.  
  15. import java.util.concurrent.atomic.AtomicInteger;
  16.  
  17. import lineage2.commons.threading.RunnableImpl;
  18. import lineage2.gameserver.ThreadPoolManager;
  19. import lineage2.gameserver.instancemanager.WorldStatisticsManager;
  20. import lineage2.gameserver.listener.actor.OnCurrentHpDamageListener;
  21. import lineage2.gameserver.listener.actor.OnDeathListener;
  22. import lineage2.gameserver.listener.zone.OnZoneEnterLeaveListener;
  23. import lineage2.gameserver.model.Creature;
  24. import lineage2.gameserver.model.Player;
  25. import lineage2.gameserver.model.Skill;
  26. import lineage2.gameserver.model.Zone;
  27. import lineage2.gameserver.model.entity.Reflection;
  28. import lineage2.gameserver.model.instances.NpcInstance;
  29. import lineage2.gameserver.model.worldstatistics.CategoryType;
  30. import lineage2.gameserver.network.serverpackets.ExSendUIEvent;
  31. import lineage2.gameserver.network.serverpackets.ExShowScreenMessage;
  32. import lineage2.gameserver.network.serverpackets.ExShowScreenMessage.ScreenMessageAlign;
  33. import lineage2.gameserver.network.serverpackets.ExStartScenePlayer;
  34. import lineage2.gameserver.network.serverpackets.components.NpcString;
  35. import lineage2.gameserver.scripts.Functions;
  36. import lineage2.gameserver.utils.Location;
  37.  
  38. /**
  39.  * @author KilRoy
  40.  */
  41. public class IsthinaNormal extends Reflection
  42. {
  43.     public int ballistaSeconds = 30;
  44.     public long ballistaDamage = 0;
  45.     private static final int Isthina = 29195;
  46.     private static final int Ballista = 19021;
  47.     private static final int Rumiese = 33293;
  48.     private static final int Camera = 18919;
  49.     private final ZoneListener _epicZoneListener = new ZoneListener();
  50.     final DeathListener _deathListener = new DeathListener();
  51.     final CurrentHpListener _currentHpListenerBallista = new CurrentHpListener();
  52.     boolean _entryLocked = false;
  53.     boolean _startLaunched = false;
  54.     boolean _lockedTurn = false;
  55.     final AtomicInteger raidplayers = new AtomicInteger();
  56.    
  57.     @Override
  58.     protected void onCreate()
  59.     {
  60.         super.onCreate();
  61.         getZone("[Isthina_epic]").addListener(_epicZoneListener);
  62.     }
  63.    
  64.     @Override
  65.     protected void onCollapse()
  66.     {
  67.         super.onCollapse();
  68.     }
  69.    
  70.     boolean checkstartCond(int raidplayers)
  71.     {
  72.         return !((raidplayers < getInstancedZone().getMinParty()) || _startLaunched);
  73.     }
  74.    
  75.     public class ZoneListener implements OnZoneEnterLeaveListener
  76.     {
  77.         @Override
  78.         public void onZoneEnter(Zone zone, Creature cha)
  79.         {
  80.             if (_entryLocked)
  81.             {
  82.                 return;
  83.             }
  84.            
  85.             Player player = cha.getPlayer();
  86.             if ((player == null) || !cha.isPlayer())
  87.             {
  88.                 return;
  89.             }
  90.            
  91.             if (checkstartCond(raidplayers.incrementAndGet()))
  92.             {
  93.                 ThreadPoolManager.getInstance().schedule(new StartNormalIsthina(), 15000L);
  94.                 _startLaunched = true;
  95.             }
  96.         }
  97.        
  98.         @Override
  99.         public void onZoneLeave(Zone zone, Creature cha)
  100.         {
  101.         }
  102.     }
  103.    
  104.     private class StartNormalIsthina extends RunnableImpl
  105.     {
  106.         /**
  107.          *
  108.          */
  109.         public StartNormalIsthina()
  110.         {
  111.             // TODO Auto-generated constructor stub
  112.         }
  113.        
  114.         @Override
  115.         public void runImpl()
  116.         {
  117.             _entryLocked = true;
  118.            
  119.             closeDoor(14220100);
  120.             closeDoor(14220101);
  121.            
  122.             NpcInstance isthinaNormal = addSpawnWithoutRespawn(Isthina, new Location(-177125, 147856, -11384, 49140), 0);
  123.             isthinaNormal.addListener(_deathListener);
  124.            
  125.             NpcInstance camera = addSpawnWithoutRespawn(Camera, new Location(-177325, 147856, -11384, 49140), 0);
  126.             camera.setTargetable(false);
  127.            
  128.             for (Player player : getPlayers())
  129.             {
  130.                 player.showQuestMovie(ExStartScenePlayer.SCENE_BOSS_ISTHINA_OPENING);
  131.             }
  132.         }
  133.     }
  134.    
  135.     public class CurrentHpListener implements OnCurrentHpDamageListener
  136.     {
  137.         @Override
  138.         public void onCurrentHpDamage(final Creature actor, final double damage, final Creature attacker, Skill skill)
  139.         {
  140.             if (actor.getNpcId() == Ballista)
  141.             {
  142.                 if (actor.isDead())
  143.                 {
  144.                     return;
  145.                 }
  146.                
  147.                 ballistaDamage += damage;
  148.                
  149.                 ThreadPoolManager.getInstance().schedule(new Runnable()
  150.                 {
  151.                     @Override
  152.                     public void run()
  153.                     {
  154.                         if (actor.isDead())
  155.                         {
  156.                             return;
  157.                         }
  158.                        
  159.                         if (!_lockedTurn && (ballistaSeconds <= 0))
  160.                         {
  161.                             _lockedTurn = true;
  162.                            
  163.                             if (ballistaDamage < actor.getMaxHp())
  164.                             {
  165.                                 double damagePercent = ballistaDamage / 4660000.0;
  166.                                 int rewardId = 0;
  167.                                
  168.                                 if (damagePercent > 0.5)
  169.                                 {
  170.                                     rewardId = 30374;
  171.                                 }
  172.                                 else if (damagePercent > 0.15)
  173.                                 {
  174.                                     rewardId = 30371;
  175.                                 }
  176.                                
  177.                                 Functions.addItem(attacker.getPlayer(), rewardId, 1);
  178.                                 ThreadPoolManager.getInstance().schedule(new IsthinaDeathFinalA(), 10);
  179.                                 actor.removeListener(_currentHpListenerBallista);
  180.                                 WorldStatisticsManager.getInstance().updateStat(attacker.getPlayer(), CategoryType.EPIC_BOSS_KILLS_29195, 1);
  181.                             }
  182.                             else
  183.                             {
  184.                                 ThreadPoolManager.getInstance().schedule(new IsthinaDeathFinalB(), 10);
  185.                                 actor.removeListener(_currentHpListenerBallista);
  186.                                 WorldStatisticsManager.getInstance().updateStat(attacker.getPlayer(), CategoryType.EPIC_BOSS_KILLS_29195, 1);
  187.                             }
  188.                         }
  189.                        
  190.                         int progress = (int) Math.min(6000, (ballistaDamage / 4660000) * 6000);
  191.                         progress -= progress % 60;
  192.                        
  193.                         for (Player player : getPlayers())
  194.                         {
  195.                             player.sendPacket(new ExSendUIEvent(player, 2, ballistaSeconds, progress, 122520, NpcString.NONE2));
  196.                         }
  197.                        
  198.                         ballistaSeconds -= 1;
  199.                     }
  200.                 }, 1000);
  201.             }
  202.         }
  203.     }
  204.    
  205.     private class DeathListener implements OnDeathListener
  206.     {
  207.         /**
  208.          *
  209.          */
  210.         public DeathListener()
  211.         {
  212.             // TODO Auto-generated constructor stub
  213.         }
  214.        
  215.         @Override
  216.         public void onDeath(Creature self, Creature killer)
  217.         {
  218.             if (self.isNpc() && (self.getNpcId() == Isthina))
  219.             {
  220.                 ThreadPoolManager.getInstance().schedule(new IsthinaDeath(), 10);
  221.             }
  222.         }
  223.     }
  224.    
  225.     private class IsthinaDeath extends RunnableImpl
  226.     {
  227.         /**
  228.          *
  229.          */
  230.         public IsthinaDeath()
  231.         {
  232.             // TODO Auto-generated constructor stub
  233.         }
  234.        
  235.         @Override
  236.         public void runImpl()
  237.         {
  238.             for (Player player : getPlayers())
  239.             {
  240.                 player.showQuestMovie(ExStartScenePlayer.SCENE_BOSS_ISTHINA_BRIDGE);
  241.             }
  242.             ThreadPoolManager.getInstance().schedule(new SpawnBallista(), 7200L); // 7.2 secs for movie
  243.         }
  244.     }
  245.    
  246.     private class IsthinaDeathFinalA extends RunnableImpl
  247.     {
  248.         /**
  249.          *
  250.          */
  251.         public IsthinaDeathFinalA()
  252.         {
  253.             // TODO Auto-generated constructor stub
  254.         }
  255.        
  256.         @Override
  257.         public void runImpl()
  258.         {
  259.             setReenterTime(System.currentTimeMillis());
  260.             for (Player player : getPlayers())
  261.             {
  262.                 player.showQuestMovie(ExStartScenePlayer.SCENE_BOSS_ISTHINA_ENDING_A);
  263.             }
  264.             ThreadPoolManager.getInstance().schedule(new FinalAndCollapse(), 23300); // 23.3 secs for movie
  265.             for (NpcInstance n : getNpcs())
  266.             {
  267.                 n.deleteMe();
  268.             }
  269.             openDoor(14220100);
  270.             openDoor(14220101);
  271.         }
  272.     }
  273.    
  274.     private class IsthinaDeathFinalB extends RunnableImpl
  275.     {
  276.         /**
  277.          *
  278.          */
  279.         public IsthinaDeathFinalB()
  280.         {
  281.             // TODO Auto-generated constructor stub
  282.         }
  283.        
  284.         @Override
  285.         public void runImpl()
  286.         {
  287.             setReenterTime(System.currentTimeMillis());
  288.             for (Player player : getPlayers())
  289.             {
  290.                 player.showQuestMovie(ExStartScenePlayer.SCENE_BOSS_ISTHINA_ENDING_B);
  291.             }
  292.             ThreadPoolManager.getInstance().schedule(new FinalAndCollapse(), 22200L); // 22.2 secs for movie
  293.             for (NpcInstance n : getNpcs())
  294.             {
  295.                 n.deleteMe();
  296.             }
  297.             openDoor(14220100);
  298.             openDoor(14220101);
  299.         }
  300.     }
  301.    
  302.     private class FinalAndCollapse extends RunnableImpl
  303.     {
  304.         /**
  305.          *
  306.          */
  307.         public FinalAndCollapse()
  308.         {
  309.             // TODO Auto-generated constructor stub
  310.         }
  311.        
  312.         @Override
  313.         public void runImpl()
  314.         {
  315.             clearReflection(5, true);
  316.             addSpawnWithoutRespawn(Rumiese, new Location(-177125, 147856, -11384, 49140), 0);
  317.         }
  318.     }
  319.    
  320.     private class SpawnBallista extends RunnableImpl
  321.     {
  322.         /**
  323.          *
  324.          */
  325.         public SpawnBallista()
  326.         {
  327.             // TODO Auto-generated constructor stub
  328.         }
  329.        
  330.         @Override
  331.         public void runImpl()
  332.         {
  333.             NpcInstance ballista = addSpawnWithoutRespawn(Ballista, new Location(-177125, 147856, -11384, 49140), 0);
  334.             ballista.block();
  335.             ballista.addListener(_currentHpListenerBallista);
  336.            
  337.             for (Player players : getPlayers())
  338.             {
  339.                 players.sendPacket(new ExShowScreenMessage(NpcString.AFTER_$s1_SECONDS_THE_CHARGING_MAGIC_BALLISTAS_STARTS, 5000, ScreenMessageAlign.TOP_CENTER, false, String.valueOf(1)));
  340.             }
  341.            
  342.             NpcInstance isthinaFinal = addSpawnWithoutRespawn(Isthina, new Location(-177128, 147224, -11414, 16383), 0);
  343.             isthinaFinal.setTargetable(false);
  344.             isthinaFinal.block();
  345.         }
  346.     }
  347. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement