SecretArea.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. ** @author Gladicek Secret Area in the Keucereus Fortress (For Quest 10272 Light Fragment)
  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. private class SecretAreaWorld extends InstanceWorld
  44. {
  45. }
  46. private void teleportPlayer(L2PcInstance player, Location loc, int instanceId)
  47. {
  48. player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  49. player.setInstanceId(instanceId);
  50. player.teleToLocation(loc, false);
  51. if (player.getPet() != null)
  52. {
  53. player.getPet().getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  54. player.getPet().setInstanceId(instanceId);
  55. player.getPet().teleToLocation(loc, false);
  56. }
  57. }
  58. protected void enterInstance(L2PcInstance player)
  59. {
  60. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  61. if (world != null)
  62. {
  63. if (!(world instanceof SecretAreaWorld))
  64. {
  65. player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
  66. return;
  67. }
  68. Instance inst = InstanceManager.getInstance().getInstance(world.instanceId);
  69. if (inst != null)
  70. {
  71. teleportPlayer(player, TELEPORTS[ENTER], world.instanceId);
  72. }
  73. }
  74. else
  75. {
  76. final int instanceId = InstanceManager.getInstance().createDynamicInstance("SecretArea.xml");
  77. world = new SecretAreaWorld();
  78. world.instanceId = instanceId;
  79. world.templateId = INSTANCE_ID;
  80. world.status = 0;
  81. InstanceManager.getInstance().addWorld(world);
  82. world.allowed.add(player.getObjectId());
  83. teleportPlayer(player, TELEPORTS[ENTER], instanceId);
  84. }
  85. }
  86. @Override
  87. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  88. {
  89. String htmltext = getNoQuestMsg(player);
  90. QuestState st = player.getQuestState(qn);
  91. if (st == null)
  92. st = newQuestState(player);
  93. if (npc.getNpcId() == GINBY && event.equalsIgnoreCase("enter"))
  94. {
  95. enterInstance(player);
  96. return _ENTER;
  97. }
  98. else if (npc.getNpcId() == LELRIKIA && event.equalsIgnoreCase("exit"))
  99. {
  100. teleportPlayer(player, TELEPORTS[EXIT], 0);
  101. return _EXIT;
  102. }
  103. return htmltext;
  104. }
  105. public SecretArea(int questId, String name, String descr)
  106. {
  107. super(questId, name, descr);
  108. addStartNpc(GINBY);
  109. addTalkId(GINBY);
  110. addTalkId(LELRIKIA);
  111. }
  112. public static void main(String[] args)
  113. {
  114. new SecretArea(-1, qn, "instances");
  115. }
  116. }