ElcadiasTent.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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.ElcadiasTent;
  20. import quests.Q10292_SevenSignsGirlOfDoubt.Q10292_SevenSignsGirlOfDoubt;
  21. import quests.Q10293_SevenSignsForbiddenBookOfTheElmoreAdenKingdom.Q10293_SevenSignsForbiddenBookOfTheElmoreAdenKingdom;
  22. import quests.Q10294_SevenSignsToTheMonasteryOfSilence.Q10294_SevenSignsToTheMonasteryOfSilence;
  23. import ai.npc.AbstractNpcAI;
  24. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  25. import com.l2jserver.gameserver.model.Location;
  26. import com.l2jserver.gameserver.model.actor.L2Npc;
  27. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  28. import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
  29. import com.l2jserver.gameserver.model.quest.QuestState;
  30. import com.l2jserver.gameserver.network.SystemMessageId;
  31. /**
  32. * Elcadia's Tent instance zone.
  33. * @author Adry_85
  34. */
  35. public final class ElcadiasTent extends AbstractNpcAI
  36. {
  37. protected class ETWorld extends InstanceWorld
  38. {
  39. }
  40. private static final int TEMPLATE_ID = 158;
  41. // NPCs
  42. private static final int ELCADIA = 32784;
  43. private static final int GRUFF_LOOKING_MAN = 32862;
  44. // Locations
  45. private static final Location START_LOC = new Location(89706, -238074, -9632, 0, 0);
  46. private static final Location EXIT_LOC = new Location(43316, -87986, -2832, 0, 0);
  47. private ElcadiasTent()
  48. {
  49. super(ElcadiasTent.class.getSimpleName(), "instances");
  50. addFirstTalkId(GRUFF_LOOKING_MAN, ELCADIA);
  51. addStartNpc(GRUFF_LOOKING_MAN, ELCADIA);
  52. addTalkId(GRUFF_LOOKING_MAN, ELCADIA);
  53. }
  54. @Override
  55. public String onTalk(L2Npc npc, L2PcInstance talker)
  56. {
  57. if (npc.getId() == GRUFF_LOOKING_MAN)
  58. {
  59. final QuestState GirlOfDoubt = talker.getQuestState(Q10292_SevenSignsGirlOfDoubt.class.getSimpleName());
  60. final QuestState ForbiddenBook = talker.getQuestState(Q10293_SevenSignsForbiddenBookOfTheElmoreAdenKingdom.class.getSimpleName());
  61. final QuestState Monastery = talker.getQuestState(Q10294_SevenSignsToTheMonasteryOfSilence.class.getSimpleName());
  62. if (((GirlOfDoubt != null) && GirlOfDoubt.isStarted()) //
  63. || ((GirlOfDoubt != null) && GirlOfDoubt.isCompleted() && (ForbiddenBook == null)) //
  64. || ((ForbiddenBook != null) && ForbiddenBook.isStarted()) //
  65. || ((ForbiddenBook != null) && ForbiddenBook.isCompleted() && (Monastery == null)))
  66. {
  67. enterInstance(talker, "ElcadiasTent.xml", START_LOC);
  68. }
  69. else
  70. {
  71. return "32862-01.html";
  72. }
  73. }
  74. else
  75. {
  76. final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(talker);
  77. world.removeAllowed(talker.getObjectId());
  78. talker.setInstanceId(0);
  79. talker.teleToLocation(EXIT_LOC);
  80. }
  81. return super.onTalk(npc, talker);
  82. }
  83. private void enterInstance(L2PcInstance player, String template, Location loc)
  84. {
  85. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  86. if (world != null)
  87. {
  88. if (!(world instanceof ETWorld))
  89. {
  90. player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
  91. }
  92. else
  93. {
  94. teleportPlayer(player, loc, world.getInstanceId(), false);
  95. }
  96. }
  97. else
  98. {
  99. // New instance.
  100. world = new ETWorld();
  101. world.setInstanceId(InstanceManager.getInstance().createDynamicInstance(template));
  102. world.setTemplateId(TEMPLATE_ID);
  103. world.setStatus(0);
  104. InstanceManager.getInstance().addWorld(world);
  105. _log.info("Elcadia's Tent started " + template + " Instance: " + world.getInstanceId() + " created by player: " + player.getName());
  106. // Teleport players.
  107. teleportPlayer(player, loc, world.getInstanceId(), false);
  108. world.addAllowed(player.getObjectId());
  109. }
  110. }
  111. public static void main(String[] args)
  112. {
  113. new ElcadiasTent();
  114. }
  115. }