SecretArea.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright (C) 2004-2013 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 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. protected void enterInstance(L2PcInstance player)
  48. {
  49. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  50. if (world != null)
  51. {
  52. if (world.getInstanceId() != INSTANCE_ID)
  53. {
  54. player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
  55. return;
  56. }
  57. Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
  58. if (inst != null)
  59. {
  60. teleportPlayer(player, TELEPORTS[ENTER], world.getInstanceId());
  61. }
  62. }
  63. else
  64. {
  65. final int instanceId = InstanceManager.getInstance().createDynamicInstance("SecretArea.xml");
  66. world = new InstanceWorld();
  67. world.setInstanceId(INSTANCE_ID);
  68. world.setTemplateId(instanceId);
  69. world.setStatus(0);
  70. InstanceManager.getInstance().addWorld(world);
  71. world.addAllowed(player.getObjectId());
  72. teleportPlayer(player, TELEPORTS[ENTER], instanceId);
  73. }
  74. }
  75. @Override
  76. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  77. {
  78. String htmltext = getNoQuestMsg(player);
  79. if ((npc.getId() == GINBY) && event.equalsIgnoreCase("enter"))
  80. {
  81. enterInstance(player);
  82. return _ENTER;
  83. }
  84. else if ((npc.getId() == LELRIKIA) && event.equalsIgnoreCase("exit"))
  85. {
  86. teleportPlayer(player, TELEPORTS[EXIT], 0);
  87. return _EXIT;
  88. }
  89. return htmltext;
  90. }
  91. public SecretArea(int questId, String name, String descr)
  92. {
  93. super(questId, name, descr);
  94. addStartNpc(GINBY);
  95. addTalkId(GINBY);
  96. addTalkId(LELRIKIA);
  97. }
  98. public static void main(String[] args)
  99. {
  100. new SecretArea(-1, SecretArea.class.getSimpleName(), "instances");
  101. }
  102. }