SecretArea.java 4.3 KB

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