Guest User

GrandBossTeleport.java

a guest
Jul 30th, 2016
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 net.sf.l2j.gameserver.scripting.scripts.teleports;
  16.  
  17. import java.util.List;
  18.  
  19. import net.sf.l2j.Config;
  20. import net.sf.l2j.commons.random.Rnd;
  21. import net.sf.l2j.gameserver.datatables.DoorTable;
  22. import net.sf.l2j.gameserver.instancemanager.GrandBossManager;
  23. import net.sf.l2j.gameserver.model.Location;
  24. import net.sf.l2j.gameserver.model.actor.L2Npc;
  25. import net.sf.l2j.gameserver.model.actor.instance.L2GrandBossInstance;
  26. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  27. import net.sf.l2j.gameserver.model.zone.type.L2BossZone;
  28. import net.sf.l2j.gameserver.scripting.Quest;
  29. import net.sf.l2j.gameserver.scripting.QuestState;
  30. import net.sf.l2j.gameserver.scripting.ScriptManager;
  31. import net.sf.l2j.gameserver.scripting.scripts.ai.individual.Antharas;
  32. import net.sf.l2j.gameserver.scripting.scripts.ai.individual.Baium;
  33. import net.sf.l2j.gameserver.scripting.scripts.ai.individual.Sailren;
  34. import net.sf.l2j.gameserver.scripting.scripts.ai.individual.Valakas;
  35. import net.sf.l2j.gameserver.util.Util;
  36.  
  37. /**
  38.  * This script leads behavior of multiple bosses teleporters.
  39.  * <ul>
  40.  * <li>13001, Heart of Warding : Teleport into Lair of Antharas</li>
  41.  * <li>29055, Teleportation Cubic : Teleport out of Baium zone</li>
  42.  * <li>31859, Teleportation Cubic : Teleport out of Lair of Antharas</li>
  43.  * <li>31384, Gatekeeper of Fire Dragon : Opening some doors</li>
  44.  * <li>31385, Heart of Volcano : Teleport into Lair of Valakas</li>
  45.  * <li>31540, Watcher of Valakas Klein : Teleport into Hall of Flames</li>
  46.  * <li>31686, Gatekeeper of Fire Dragon : Opens doors to Heart of Volcano</li>
  47.  * <li>31687, Gatekeeper of Fire Dragon : Opens doors to Heart of Volcano</li>
  48.  * <li>31759, Teleportation Cubic : Teleport out of Lair of Valakas</li>
  49.  * <li>31862, Angelic Vortex : Baium Teleport (3 different HTMs according of situation)</li>
  50.  * <li>32107, Teleportation Cubic : Teleport out of Sailren Nest</li>
  51.  * <li>32109, Shilen's Stone Statue : Teleport to Sailren Nest</li>
  52.  * </ul>
  53.  * @author Plim, original python script by Emperorc
  54.  */
  55. public class GrandBossTeleporters extends Quest
  56. {
  57.     private static final String qn = "GrandBossTeleporters";
  58.    
  59.     private static final Location baiumTeleIn = new Location(113100, 14500, 10077);
  60.     private static final Location[] baiumTeleOut =
  61.     {
  62.         new Location(108784, 16000, -4928),
  63.         new Location(113824, 10448, -5164),
  64.         new Location(115488, 22096, -5168)
  65.     };
  66.    
  67.     private static final Location sailrenTeleIn = new Location(27333, -6835, -1970);
  68.     private static final Location[] sailrenTeleOut =
  69.     {
  70.         new Location(10610, -24035, -3676),
  71.         new Location(10703, -24041, -3673),
  72.         new Location(10769, -24107, -3672)
  73.     };
  74.    
  75.     private static int _valakasPlayersCount = 0;
  76.    
  77.     public GrandBossTeleporters()
  78.     {
  79.         super(-1, "teleports");
  80.        
  81.         addFirstTalkId(29055, 31862);
  82.         addStartNpc(13001, 29055, 31859, 31384, 31385, 31540, 31686, 31687, 31759, 31862, 32107, 32109);
  83.         addTalkId(13001, 29055, 31859, 31384, 31385, 31540, 31686, 31687, 31759, 31862, 32107, 32109);
  84.     }
  85.    
  86.     @Override
  87.     public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  88.     {
  89.         String htmltext = "";
  90.         QuestState st = player.getQuestState(qn);
  91.         if (st == null)
  92.             st = newQuestState(player);
  93.        
  94.         if (event.equalsIgnoreCase("baium"))
  95.         {
  96.             // Player is mounted on a wyvern, cancel it.
  97.             if (player.isFlying())
  98.                 htmltext = "31862-05.htm";
  99.             // Player hasn't blooded fabric, cancel it.
  100.             else if (!st.hasQuestItems(4295))
  101.                 htmltext = "31862-03.htm";
  102.             // All is ok, take the item and teleport the player inside.
  103.             else
  104.             {
  105.                 st.takeItems(4295, 1);
  106.                
  107.                 // allow entry for the player for the next 30 secs.
  108.                 GrandBossManager.getInstance().getZoneById(110002).allowPlayerEntry(player, 30);
  109.                 player.teleToLocation(baiumTeleIn, 0);
  110.             }
  111.         }
  112.         else if (event.equalsIgnoreCase("baium_story"))
  113.             htmltext = "31862-02.htm";
  114.         else if (event.equalsIgnoreCase("baium_exit"))
  115.             player.teleToLocation(baiumTeleOut[Rnd.get(baiumTeleOut.length)], 100);
  116.         else if (event.equalsIgnoreCase("31540"))
  117.         {
  118.             if (st.hasQuestItems(7267))
  119.             {
  120.                 st.takeItems(7267, 1);
  121.                 player.teleToLocation(183813, -115157, -3303, 0);
  122.                 st.set("allowEnter", "1");
  123.             }
  124.             else
  125.                 htmltext = "31540-06.htm";
  126.         }
  127.         return htmltext;
  128.     }
  129.    
  130.     @Override
  131.     public String onFirstTalk(L2Npc npc, L2PcInstance player)
  132.     {
  133.         String htmltext = "";
  134.         QuestState st = player.getQuestState(qn);
  135.         if (st == null)
  136.             st = newQuestState(player);
  137.        
  138.         switch (npc.getNpcId())
  139.         {
  140.             case 29055:
  141.                 htmltext = "29055-01.htm";
  142.                 break;
  143.            
  144.             case 31862:
  145.                 final int status = GrandBossManager.getInstance().getBossStatus(29020);
  146.                 if (status == Baium.AWAKE)
  147.                     htmltext = "31862-01.htm";
  148.                 else if (status == Baium.DEAD)
  149.                     htmltext = "31862-04.htm";
  150.                 else
  151.                     htmltext = "31862-00.htm";
  152.                 break;
  153.         }
  154.        
  155.         return htmltext;
  156.     }
  157.    
  158.     @Override
  159.     public String onTalk(L2Npc npc, L2PcInstance player)
  160.     {
  161.         String htmltext = "";
  162.         QuestState st = player.getQuestState(getName());
  163.         if (st == null)
  164.             return null;
  165.        
  166.         int status;
  167.         switch (npc.getNpcId())
  168.         {
  169.             case 13001:
  170.                 status = GrandBossManager.getInstance().getBossStatus(Antharas.ANTHARAS);
  171.                 if (status == Antharas.FIGHTING)
  172.                     htmltext = "13001-02.htm";
  173.                 else if (status == Antharas.DEAD)
  174.                     htmltext = "13001-01.htm";
  175.                 else if (status == Antharas.DORMANT || status == Antharas.WAITING)
  176.                 {
  177.                     if (st.hasQuestItems(3865))
  178.                     {
  179.                         st.takeItems(3865, 1);
  180.                         GrandBossManager.getInstance().getZoneById(110001).allowPlayerEntry(player, 30);
  181.                        
  182.                         player.teleToLocation(175300 + Rnd.get(-350, 350), 115180 + Rnd.get(-1000, 1000), -7709, 0);
  183.                        
  184.                         if (status == Antharas.DORMANT)
  185.                         {
  186.                             GrandBossManager.getInstance().setBossStatus(Antharas.ANTHARAS, Antharas.WAITING);
  187.                             ScriptManager.getInstance().getQuest("Antharas").startQuestTimer("beginning", Config.WAIT_TIME_ANTHARAS, null, null, false);
  188.                         }
  189.                     }
  190.                     else
  191.                         htmltext = "13001-03.htm";
  192.                 }
  193.                 break;
  194.            
  195.             case 31859:
  196.                 player.teleToLocation(79800 + Rnd.get(600), 151200 + Rnd.get(1100), -3534, 0);
  197.                 break;
  198.            
  199.             case 31385:
  200.                 status = GrandBossManager.getInstance().getBossStatus(Valakas.VALAKAS);
  201.                 if (status == 0 || status == 1)
  202.                 {
  203.                     if (_valakasPlayersCount >= 200)
  204.                         htmltext = "31385-03.htm";
  205.                     else if (st.getInt("allowEnter") == 1)
  206.                     {
  207.                         st.unset("allowEnter");
  208.                         GrandBossManager.getInstance().getZoneById(110010).allowPlayerEntry(player, 30);
  209.                        
  210.                         player.teleToLocation(204328, -111874, 70, 300);
  211.                        
  212.                         _valakasPlayersCount++;
  213.                        
  214.                         if (status == 0)
  215.                         {
  216.                             L2GrandBossInstance valakas = GrandBossManager.getInstance().getBoss(Valakas.VALAKAS);
  217.                             GrandBossManager.getInstance().setBossStatus(Valakas.VALAKAS, 1);
  218.                             ScriptManager.getInstance().getQuest("Valakas").startQuestTimer("beginning", Config.WAIT_TIME_VALAKAS, valakas, null, false);
  219.                         }
  220.                     }
  221.                     else
  222.                         htmltext = "31385-04.htm";
  223.                 }
  224.                 else if (status == 2)
  225.                     htmltext = "31385-02.htm";
  226.                 else
  227.                     htmltext = "31385-01.htm";
  228.                 break;
  229.            
  230.             case 31384:
  231.                 DoorTable.getInstance().getDoor(24210004).openMe();
  232.                 break;
  233.            
  234.             case 31686:
  235.                 DoorTable.getInstance().getDoor(24210006).openMe();
  236.                 break;
  237.            
  238.             case 31687:
  239.                 DoorTable.getInstance().getDoor(24210005).openMe();
  240.                 break;
  241.            
  242.             case 31540:
  243.                 if (_valakasPlayersCount < 50)
  244.                     htmltext = "31540-01.htm";
  245.                 else if (_valakasPlayersCount < 100)
  246.                     htmltext = "31540-02.htm";
  247.                 else if (_valakasPlayersCount < 150)
  248.                     htmltext = "31540-03.htm";
  249.                 else if (_valakasPlayersCount < 200)
  250.                     htmltext = "31540-04.htm";
  251.                 else
  252.                     htmltext = "31540-05.htm";
  253.                 break;
  254.            
  255.             case 31759:
  256.                 player.teleToLocation(150037, -57720, -2976, 250);
  257.                 break;
  258.            
  259.             case 32107:
  260.                 player.teleToLocation(sailrenTeleOut[Rnd.get(sailrenTeleOut.length)], 100);
  261.                 break;
  262.            
  263.             case 32109:
  264.                 if (!player.isInParty())
  265.                     htmltext = "32109-03.htm";
  266.                 else if (!player.getParty().isLeader(player))
  267.                     htmltext = "32109-01.htm";
  268.                 else
  269.                 {
  270.                     if (st.hasQuestItems(8784))
  271.                     {
  272.                         status = GrandBossManager.getInstance().getBossStatus(Sailren.SAILREN);
  273.                         if (status == Sailren.DORMANT)
  274.                         {
  275.                             final List<L2PcInstance> party = player.getParty().getPartyMembers();
  276.                            
  277.                             // Check players conditions.
  278.                             for (L2PcInstance member : party)
  279.                             {
  280.                                 if (member.getLevel() < 70)
  281.                                     return "32109-06.htm";
  282.                                
  283.                                 if (!Util.checkIfInRange(1000, player, member, true))
  284.                                     return "32109-07.htm";
  285.                             }
  286.                            
  287.                             // Take item from party leader.
  288.                             st.takeItems(8784, 1);
  289.                            
  290.                             final L2BossZone nest = GrandBossManager.getInstance().getZoneById(110015);
  291.                            
  292.                             // Teleport players.
  293.                             for (L2PcInstance member : party)
  294.                             {
  295.                                 if (nest != null)
  296.                                 {
  297.                                     nest.allowPlayerEntry(member, 30);
  298.                                     member.teleToLocation(sailrenTeleIn, 100);
  299.                                 }
  300.                             }
  301.                             GrandBossManager.getInstance().setBossStatus(Sailren.SAILREN, Sailren.FIGHTING);
  302.                             ScriptManager.getInstance().getQuest("Sailren").startQuestTimer("beginning", 60000, null, null, false);
  303.                         }
  304.                         else if (status == Sailren.DEAD)
  305.                             htmltext = "32109-04.htm";
  306.                         else
  307.                             htmltext = "32109-05.htm";
  308.                     }
  309.                     else
  310.                         htmltext = "32109-02.htm";
  311.                 }
  312.                 break;
  313.         }
  314.        
  315.         return htmltext;
  316.     }
  317. }
Add Comment
Please, Sign In to add comment