Advertisement
Plim

Untitled

Jul 5th, 2011
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.49 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.    
  54.     private Quest antharasAI()
  55.     {
  56.         return QuestManager.getInstance().getQuest("antharas");
  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.                 if (valakasAI() != null)
  136.                 {
  137.                     int status = GrandBossManager.getInstance().getBossStatus(29028);
  138.                    
  139.                     if (status == 0 || status == 1)
  140.                     {
  141.                         if (playerCount >= 200)
  142.                             htmltext = "31385-03.htm";
  143.                        
  144.                         else if (st.getInt("allowEnter") == 1)
  145.                         {
  146.                             st.unset("allowEnter");
  147.                             L2BossZone zone = GrandBossManager.getInstance().getZone(212852, -114842, -1632);
  148.                            
  149.                             if (zone != null)
  150.                                 zone.allowPlayerEntry(player, 30);
  151.                            
  152.                             player.teleToLocation(204328 + Rnd.get(600), -111874 + Rnd.get(600), 70);
  153.                            
  154.                             playerCount++;
  155.                            
  156.                             if (status == 0)
  157.                             {
  158.                                 L2GrandBossInstance valakas = GrandBossManager.getInstance().getBoss(29028);
  159.                                 valakasAI().startQuestTimer("1001", Config.Valakas_Wait_Time, valakas, null);
  160.                                 GrandBossManager.getInstance().setBossStatus(29028, 1);
  161.                             }
  162.                         }
  163.                        
  164.                         else
  165.                             htmltext = "31385-04.htm";
  166.                     }
  167.                     else if (status == 2)
  168.                         htmltext = "31385-02.htm";
  169.                     else
  170.                         htmltext = "31385-01.htm";
  171.                 }
  172.                
  173.                 else
  174.                     htmltext = "31385-01.htm";
  175.                 break;
  176.            
  177.             case 31384:
  178.                 DoorTable.getInstance().getDoor(24210004).openMe();
  179.                 break;
  180.            
  181.             case 31686:
  182.                 DoorTable.getInstance().getDoor(24210006).openMe();
  183.                 break;
  184.            
  185.             case 31687:
  186.                 DoorTable.getInstance().getDoor(24210005).openMe();
  187.                 break;
  188.            
  189.             case 31540:
  190.                 if (playerCount < 50)
  191.                     htmltext = "31540-01.htm";
  192.                
  193.                 else if (playerCount < 100)
  194.                     htmltext = "31540-02.htm";
  195.                
  196.                 else if (playerCount < 150)
  197.                     htmltext = "31540-03.htm";
  198.                
  199.                 else if (playerCount < 200)
  200.                     htmltext = "31540-04.htm";
  201.                
  202.                 else
  203.                     htmltext = "31540-05.htm";
  204.                 break;
  205.                
  206.             case 31759:
  207.                 player.teleToLocation(150037 + Rnd.get(500), -57720 + Rnd.get(500), -2976);
  208.                 break;
  209.         }
  210.        
  211.         return htmltext;
  212.     }
  213.    
  214.     public GrandBossTeleporters(int questId, String name, String descr)
  215.     {
  216.         super(questId, name, descr);
  217.        
  218.         for (int npcId : NPCs)
  219.         {
  220.             addStartNpc(npcId);
  221.             addTalkId(npcId);
  222.         }
  223.     }
  224.    
  225.     public static void main(String[] args)
  226.     {
  227.         new GrandBossTeleporters(-1, GrandBossTeleporters.class.getSimpleName(), "teleports");
  228.     }
  229. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement