SecretArea.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 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.entity.Instance;
  25. import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
  26. import com.l2jserver.gameserver.model.quest.Quest;
  27. import com.l2jserver.gameserver.network.SystemMessageId;
  28. /**
  29. * Secret Area in the Keucereus Fortress instance zone.
  30. * @author Gladicek
  31. */
  32. public final class SecretArea extends Quest
  33. {
  34. private static final int INSTANCE_ID = 117;
  35. // TODO Unharcode htmls.
  36. private static final String _ENTER = "<html><head><body>Soldier Ginby:<br>Hurry! Come back before anybody sees you!</body></html>";
  37. private static final String _EXIT = "<html><head><body>Shilen Priest Lelrikia:<br>Doomed creature, either you obey the power of Shilen or you fight.Regardless of your decision, the shadow of death will not simply fade away...</body></html>";
  38. private static final int GINBY = 32566;
  39. private static final int LELRIKIA = 32567;
  40. private static final int ENTER = 0;
  41. private static final int EXIT = 1;
  42. private static final Location[] TELEPORTS =
  43. {
  44. new Location(-23758, -8959, -5384),
  45. new Location(-185057, 242821, 1576)
  46. };
  47. private SecretArea()
  48. {
  49. super(-1, SecretArea.class.getSimpleName(), "instances");
  50. addStartNpc(GINBY);
  51. addTalkId(GINBY);
  52. addTalkId(LELRIKIA);
  53. }
  54. protected void enterInstance(L2PcInstance player)
  55. {
  56. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  57. if (world != null)
  58. {
  59. if (world.getInstanceId() != INSTANCE_ID)
  60. {
  61. player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
  62. return;
  63. }
  64. Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
  65. if (inst != null)
  66. {
  67. teleportPlayer(player, TELEPORTS[ENTER], world.getInstanceId());
  68. }
  69. }
  70. else
  71. {
  72. final int instanceId = InstanceManager.getInstance().createDynamicInstance("SecretArea.xml");
  73. world = new InstanceWorld();
  74. world.setInstanceId(INSTANCE_ID);
  75. world.setTemplateId(instanceId);
  76. world.setStatus(0);
  77. InstanceManager.getInstance().addWorld(world);
  78. world.addAllowed(player.getObjectId());
  79. teleportPlayer(player, TELEPORTS[ENTER], instanceId);
  80. }
  81. }
  82. @Override
  83. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  84. {
  85. String htmltext = getNoQuestMsg(player);
  86. if ((npc.getId() == GINBY) && event.equalsIgnoreCase("enter"))
  87. {
  88. enterInstance(player);
  89. return _ENTER;
  90. }
  91. else if ((npc.getId() == LELRIKIA) && event.equalsIgnoreCase("exit"))
  92. {
  93. teleportPlayer(player, TELEPORTS[EXIT], 0);
  94. return _EXIT;
  95. }
  96. return htmltext;
  97. }
  98. public static void main(String[] args)
  99. {
  100. new SecretArea();
  101. }
  102. }