ElcadiasTent.java 4.1 KB

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