SecretArea.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (C) 2004-2014 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package gracia.instances.SecretArea;
  20. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  21. import com.l2jserver.gameserver.model.Location;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
  25. import com.l2jserver.gameserver.model.quest.Quest;
  26. import com.l2jserver.gameserver.network.SystemMessageId;
  27. /**
  28. * Secret Area in the Keucereus Fortress instance zone.
  29. * @author Gladicek
  30. */
  31. public final class SecretArea extends Quest
  32. {
  33. protected class SAWorld extends InstanceWorld
  34. {
  35. }
  36. private static final int TEMPLATE_ID = 117;
  37. private static final int GINBY = 32566;
  38. private static final int LELRIKIA = 32567;
  39. private static final int ENTER = 0;
  40. private static final int EXIT = 1;
  41. private static final Location[] TELEPORTS =
  42. {
  43. new Location(-23758, -8959, -5384),
  44. new Location(-185057, 242821, 1576)
  45. };
  46. public SecretArea()
  47. {
  48. super(-1, SecretArea.class.getSimpleName(), "gracia/instances");
  49. addStartNpc(GINBY);
  50. addTalkId(GINBY);
  51. addTalkId(LELRIKIA);
  52. }
  53. protected void enterInstance(L2PcInstance player)
  54. {
  55. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  56. if (world != null)
  57. {
  58. if (world instanceof SAWorld)
  59. {
  60. teleportPlayer(player, TELEPORTS[ENTER], world.getInstanceId());
  61. return;
  62. }
  63. player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
  64. return;
  65. }
  66. world = new SAWorld();
  67. world.setInstanceId(InstanceManager.getInstance().createDynamicInstance("SecretArea.xml"));
  68. world.setTemplateId(TEMPLATE_ID);
  69. world.addAllowed(player.getObjectId());
  70. world.setStatus(0);
  71. InstanceManager.getInstance().addWorld(world);
  72. teleportPlayer(player, TELEPORTS[ENTER], world.getInstanceId());
  73. }
  74. @Override
  75. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  76. {
  77. String htmltext = getNoQuestMsg(player);
  78. if ((npc.getId() == GINBY) && event.equalsIgnoreCase("enter"))
  79. {
  80. enterInstance(player);
  81. return "32566-01.html";
  82. }
  83. else if ((npc.getId() == LELRIKIA) && event.equalsIgnoreCase("exit"))
  84. {
  85. teleportPlayer(player, TELEPORTS[EXIT], 0);
  86. return "32567-01.html";
  87. }
  88. return htmltext;
  89. }
  90. }