Advertisement
Plim

GrandBossTeleporters.java

Apr 27th, 2011
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.53 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 teleports.GrandBossTeleporters;
  16.  
  17. import ai.individual.Antharas;
  18.  
  19. import com.l2jserver.Config;
  20. import com.l2jserver.gameserver.datatables.DoorTable;
  21. import com.l2jserver.gameserver.instancemanager.GrandBossManager;
  22. import com.l2jserver.gameserver.instancemanager.QuestManager;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2GrandBossInstance;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.model.quest.Quest;
  27. import com.l2jserver.gameserver.model.quest.QuestState;
  28. import com.l2jserver.gameserver.model.zone.type.L2BossZone;
  29. import com.l2jserver.util.Rnd;
  30.  
  31. /**
  32.  * @author Plim
  33.  * Original python script by Emperorc
  34.  */
  35. public class GrandBossTeleporters extends Quest
  36. {
  37.     private static final int[] NPCs =
  38.     {
  39.         13001, //Heart of Warding : Teleport into Lair of Antharas
  40.         31859, //Teleportation Cubic : Teleport out of Lair of Antharas
  41.         31384, //Gatekeeper of Fire Dragon : Opening some doors
  42.         31385, //Heart of Volcano : Teleport into Lair of Valakas
  43.         31540, //Watcher of Valakas Klein : Teleport into Hall of Flames
  44.         31686, //Gatekeeper of Fire Dragon : Opens doors to Heart of Volcano
  45.         31687, //Gatekeeper of Fire Dragon : Opens doors to Heart of Volcano
  46.         31759 //Teleportation Cubic : Teleport out of Lair of Valakas
  47.     };
  48.      
  49.     private Quest valakasAI()
  50.     {
  51.         return QuestManager.getInstance().getQuest("valakas");
  52.     }
  53.     private Quest antharasAI()
  54.     {
  55.         return QuestManager.getInstance().getQuest("antharas");
  56.     }
  57.  
  58.    
  59.     private static int playerCount = 0;
  60.    
  61.     @Override
  62.     public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  63.     {
  64.         String htmltext = "";
  65.         QuestState st = player.getQuestState(getName());
  66.        
  67.         if (st == null)
  68.             st = newQuestState(player);
  69.        
  70.         if (st.getQuestItemsCount(7267) > 0)
  71.         {
  72.             st.takeItems(7267, 1);
  73.             player.teleToLocation(183813, -115157, -3303);
  74.             st.set("allowEnter", "1");
  75.         }
  76.        
  77.         else
  78.             htmltext = "31540-06.htm";
  79.        
  80.         return htmltext;
  81.     }
  82.    
  83.     @Override
  84.     public String onTalk(L2Npc npc, L2PcInstance player)
  85.     {
  86.         String htmltext = "";
  87.         QuestState st = player.getQuestState(getName());
  88.        
  89.         if (st == null)
  90.             return null;
  91.        
  92.         switch (npc.getNpcId())
  93.         {
  94.             case 13001:
  95.                 if (antharasAI() != null)
  96.                 {
  97.                     int status = GrandBossManager.getInstance().getBossStatus(29019);
  98.                     int statusW = GrandBossManager.getInstance().getBossStatus(29066);
  99.                     int statusN = GrandBossManager.getInstance().getBossStatus(29067);
  100.                     int statusS = GrandBossManager.getInstance().getBossStatus(29068);
  101.                    
  102.                     if (status == 2 || statusW == 2 || statusN == 2 || statusS == 2)
  103.                         htmltext = "13001-02.htm";
  104.                    
  105.                     else if (status == 3 || statusW == 3 || statusN == 3 || statusS == 3)
  106.                         htmltext = "13001-01.htm";
  107.                    
  108.                     else if (status == 0 || status == 1) //If entrance to see Antharas is unlocked (he is Dormant or Waiting)               }
  109.                     {
  110.                         if (st.getQuestItemsCount(3865) > 0)
  111.                         {
  112.                             st.takeItems(3865, 1);
  113.                             L2BossZone zone = GrandBossManager.getInstance().getZone(179700, 113800, -7709);
  114.                            
  115.                             if (zone != null)
  116.                                 zone.allowPlayerEntry(player, 30);
  117.                            
  118.                             player.teleToLocation(179700 + Rnd.get(700), 113800 + Rnd.get(2100), -7709);
  119.                            
  120.                             if (status == 0)
  121.                                 ((Antharas) antharasAI()).setAntharasSpawnTask();
  122.                         }
  123.                        
  124.                         else
  125.                             htmltext = "13001-03.htm";
  126.                     }
  127.                 }
  128.                 break;
  129.            
  130.             case 31859:
  131.                 player.teleToLocation(79800 + Rnd.get(600), 151200 + Rnd.get(1100), -3534);
  132.                 break;
  133.            
  134.             case 31385:
  135.                 htmltext = "31385-01.htm";
  136.                 if (valakasAI() != null)
  137.                 {
  138.                     int status = GrandBossManager.getInstance().getBossStatus(29028);
  139.                    
  140.                     if (status == 0 || status == 1)
  141.                     {
  142.                         if (playerCount >= 200)
  143.                             htmltext = "31385-03.htm";
  144.                        
  145.                         else if (st.getInt("allowEnter") == 1)
  146.                         {
  147.                             st.unset("allowEnter");
  148.                             L2BossZone zone = GrandBossManager.getInstance().getZone(212852, -114842, -1632);
  149.                            
  150.                             if (zone != null)
  151.                                 zone.allowPlayerEntry(player, 30);
  152.                            
  153.                             player.teleToLocation(204328 + Rnd.get(600), -111874 + Rnd.get(600), 70);
  154.                            
  155.                             playerCount++;
  156.                            
  157.                             if (status == 0)
  158.                             {
  159.                                 L2GrandBossInstance valakas = GrandBossManager.getInstance().getBoss(29028);
  160.                                 valakasAI().startQuestTimer("1001", Config.Valakas_Wait_Time, valakas, null);
  161.                                 GrandBossManager.getInstance().setBossStatus(29028, 1);
  162.                             }
  163.                         }
  164.                        
  165.                         else
  166.                             htmltext = "31385-04.htm";
  167.                     }
  168.                    
  169.                     else if (status == 2)
  170.                         htmltext = "31385-02.htm";
  171.                    
  172.                     else
  173.                         htmltext = "31385-01.htm";
  174.                 }
  175.                
  176.                 else
  177.                     htmltext = "31385-01.htm";
  178.                 break;
  179.            
  180.             case 31384:
  181.                 DoorTable.getInstance().getDoor(24210004).openMe();
  182.                 break;
  183.            
  184.             case 31686:
  185.                 DoorTable.getInstance().getDoor(24210006).openMe();
  186.                 break;
  187.            
  188.             case 31687:
  189.                 DoorTable.getInstance().getDoor(24210005).openMe();
  190.                 break;
  191.            
  192.             case 31540:
  193.                 if (playerCount < 50)
  194.                     htmltext = "31540-01.htm";
  195.                
  196.                 else if (playerCount < 100)
  197.                     htmltext = "31540-02.htm";
  198.                
  199.                 else if (playerCount < 150)
  200.                     htmltext = "31540-03.htm";
  201.                
  202.                 else if (playerCount < 200)
  203.                     htmltext = "31540-04.htm";
  204.                
  205.                 else
  206.                     htmltext = "31540-05.htm";
  207.                 break;
  208.                
  209.             case 31759:
  210.                 player.teleToLocation(150037 + Rnd.get(500), -57720 + Rnd.get(500), -2976);
  211.                 break;
  212.         }
  213.        
  214.         return htmltext;
  215.     }
  216.    
  217.     public GrandBossTeleporters(int questId, String name, String descr)
  218.     {
  219.         super(questId, name, descr);
  220.        
  221.         for (int npcId : NPCs)
  222.         {
  223.             addStartNpc(npcId);
  224.             addTalkId(npcId);
  225.         }
  226.     }
  227.    
  228.     public static void main(String[] args)
  229.     {
  230.         new GrandBossTeleporters(-1, GrandBossTeleporters.class.getSimpleName(), "teleports");
  231.     }
  232. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement