SecretArea.java 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 instances.SecretArea;
  16. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  17. import com.l2jserver.gameserver.instancemanager.InstanceManager.InstanceWorld;
  18. import com.l2jserver.gameserver.model.Location;
  19. import com.l2jserver.gameserver.model.actor.L2Npc;
  20. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  21. import com.l2jserver.gameserver.model.entity.Instance;
  22. import com.l2jserver.gameserver.model.quest.Quest;
  23. import com.l2jserver.gameserver.model.quest.QuestState;
  24. import com.l2jserver.gameserver.network.SystemMessageId;
  25. /**
  26. * Secret Area in the Keucereus Fortress (For Quest 10272 Light Fragment)
  27. ** @author Gladicek
  28. */
  29. public class SecretArea extends Quest
  30. {
  31. private static final String qn = "SecretArea";
  32. private static final int INSTANCE_ID = 117;
  33. private static final String _ENTER = "<html><head><body>Soldier Ginby:<br>Hurry! Come back before anybody sees you!</body></html>";
  34. 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>";
  35. private static final int GINBY = 32566;
  36. private static final int LELRIKIA = 32567;
  37. private static final int ENTER = 0;
  38. private static final int EXIT = 1;
  39. private static final Location[] TELEPORTS =
  40. {
  41. new Location(-23758, -8959, -5384), new Location(-185057, 242821, 1576)
  42. };
  43. protected class SecretAreaWorld extends InstanceWorld
  44. {
  45. }
  46. private void teleportPlayer(L2PcInstance player, Location loc, int instanceId)
  47. {
  48. player.setInstanceId(instanceId);
  49. player.teleToLocation(loc, false);
  50. }
  51. protected void enterInstance(L2PcInstance player)
  52. {
  53. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  54. if (world != null)
  55. {
  56. if (!(world instanceof SecretAreaWorld))
  57. {
  58. player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
  59. return;
  60. }
  61. Instance inst = InstanceManager.getInstance().getInstance(world.instanceId);
  62. if (inst != null)
  63. {
  64. teleportPlayer(player, TELEPORTS[ENTER], world.instanceId);
  65. }
  66. }
  67. else
  68. {
  69. final int instanceId = InstanceManager.getInstance().createDynamicInstance("SecretArea.xml");
  70. world = new SecretAreaWorld();
  71. world.instanceId = instanceId;
  72. world.templateId = INSTANCE_ID;
  73. world.status = 0;
  74. InstanceManager.getInstance().addWorld(world);
  75. world.allowed.add(player.getObjectId());
  76. teleportPlayer(player, TELEPORTS[ENTER], instanceId);
  77. }
  78. }
  79. @Override
  80. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  81. {
  82. String htmltext = getNoQuestMsg(player);
  83. QuestState st = player.getQuestState(qn);
  84. if (st == null)
  85. st = newQuestState(player);
  86. if (npc.getNpcId() == GINBY && event.equalsIgnoreCase("enter"))
  87. {
  88. enterInstance(player);
  89. return _ENTER;
  90. }
  91. else if (npc.getNpcId() == LELRIKIA && event.equalsIgnoreCase("exit"))
  92. {
  93. teleportPlayer(player, TELEPORTS[EXIT], 0);
  94. return _EXIT;
  95. }
  96. return htmltext;
  97. }
  98. public SecretArea(int questId, String name, String descr)
  99. {
  100. super(questId, name, descr);
  101. addStartNpc(GINBY);
  102. addTalkId(GINBY);
  103. addTalkId(LELRIKIA);
  104. }
  105. public static void main(String[] args)
  106. {
  107. new SecretArea(-1, qn, "instances");
  108. }
  109. }