HideoutOfTheDawn.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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.HideoutOfTheDawn;
  20. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  21. import com.l2jserver.gameserver.model.Location;
  22. import com.l2jserver.gameserver.model.actor.L2Character;
  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.network.SystemMessageId;
  28. /**
  29. * Hideout of the Dawn instance zone.
  30. * @author Adry_85
  31. */
  32. public final class HideoutOfTheDawn extends Quest
  33. {
  34. protected class HotDWorld extends InstanceWorld
  35. {
  36. long storeTime = 0;
  37. }
  38. private static final int TEMPLATE_ID = 113;
  39. // NPCs
  40. private static final int WOOD = 32593;
  41. private static final int JAINA = 32617;
  42. // Location
  43. private static final Location WOOD_LOC = new Location(-23758, -8959, -5384, 0, 0);
  44. private static final Location JAINA_LOC = new Location(147072, 23743, -1984, 0);
  45. private HideoutOfTheDawn()
  46. {
  47. super(-1, HideoutOfTheDawn.class.getSimpleName(), "instances");
  48. addStartNpc(WOOD);
  49. addTalkId(WOOD, JAINA);
  50. }
  51. @Override
  52. public String onTalk(L2Npc npc, L2PcInstance talker)
  53. {
  54. switch (npc.getId())
  55. {
  56. case WOOD:
  57. {
  58. enterInstance(talker, "HideoutOfTheDawn.xml", WOOD_LOC);
  59. return "32593-01.htm";
  60. }
  61. case JAINA:
  62. {
  63. final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(talker);
  64. world.removeAllowed(talker.getObjectId());
  65. talker.setInstanceId(0);
  66. talker.teleToLocation(JAINA_LOC);
  67. return "32617-01.htm";
  68. }
  69. }
  70. return super.onTalk(npc, talker);
  71. }
  72. protected int enterInstance(L2PcInstance player, String template, Location loc)
  73. {
  74. // check for existing instances for this player
  75. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  76. // existing instance
  77. if (world != null)
  78. {
  79. if (!(world instanceof HotDWorld))
  80. {
  81. player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
  82. return 0;
  83. }
  84. teleportPlayer(player, loc, world.getInstanceId(), false);
  85. removeBuffs(player);
  86. return 0;
  87. }
  88. // New instance
  89. world = new HotDWorld();
  90. world.setInstanceId(InstanceManager.getInstance().createDynamicInstance(template));
  91. world.setTemplateId(TEMPLATE_ID);
  92. world.setStatus(0);
  93. ((HotDWorld) world).storeTime = System.currentTimeMillis();
  94. InstanceManager.getInstance().addWorld(world);
  95. _log.info("Hideout of the Dawn started " + template + " Instance: " + world.getInstanceId() + " created by player: " + player.getName());
  96. // teleport players
  97. teleportPlayer(player, loc, world.getInstanceId(), false);
  98. removeBuffs(player);
  99. world.addAllowed(player.getObjectId());
  100. return world.getInstanceId();
  101. }
  102. private static final void removeBuffs(L2Character ch)
  103. {
  104. ch.stopAllEffectsExceptThoseThatLastThroughDeath();
  105. if (ch.hasSummon())
  106. {
  107. ch.getSummon().stopAllEffectsExceptThoseThatLastThroughDeath();
  108. }
  109. }
  110. public static void main(String[] args)
  111. {
  112. new HideoutOfTheDawn();
  113. }
  114. }