HideoutOfTheDawn.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * Copyright (C) 2004-2013 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.effects.L2Effect;
  26. import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
  27. import com.l2jserver.gameserver.model.quest.Quest;
  28. import com.l2jserver.gameserver.model.skills.L2Skill;
  29. import com.l2jserver.gameserver.network.SystemMessageId;
  30. /**
  31. * Hideout of the Dawn instance zone.
  32. * @author Adry_85
  33. */
  34. public class HideoutOfTheDawn extends Quest
  35. {
  36. protected class HotDWorld extends InstanceWorld
  37. {
  38. long storeTime = 0;
  39. }
  40. private static final int INSTANCEID = 113;
  41. // NPCs
  42. private static final int WOOD = 32593;
  43. private static final int JAINA = 32617;
  44. // Location
  45. private static final Location WOOD_LOC = new Location(-23758, -8959, -5384, 0, 0);
  46. private static final Location JAINA_LOC = new Location(147072, 23743, -1984, 0);
  47. public HideoutOfTheDawn(int questId, String name, String descr)
  48. {
  49. super(questId, name, descr);
  50. addStartNpc(WOOD);
  51. addTalkId(WOOD, JAINA);
  52. }
  53. @Override
  54. public String onTalk(L2Npc npc, L2PcInstance talker)
  55. {
  56. switch (npc.getNpcId())
  57. {
  58. case WOOD:
  59. {
  60. enterInstance(talker, "HideoutOfTheDawn.xml", WOOD_LOC);
  61. return "32593-01.htm";
  62. }
  63. case JAINA:
  64. {
  65. final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(talker);
  66. world.removeAllowed(talker.getObjectId());
  67. talker.setInstanceId(0);
  68. talker.teleToLocation(JAINA_LOC, 0);
  69. return "32617-01.htm";
  70. }
  71. }
  72. return super.onTalk(npc, talker);
  73. }
  74. protected int enterInstance(L2PcInstance player, String template, Location loc)
  75. {
  76. // check for existing instances for this player
  77. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  78. // existing instance
  79. if (world != null)
  80. {
  81. if (!(world instanceof HotDWorld))
  82. {
  83. player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
  84. return 0;
  85. }
  86. teleportPlayer(player, loc, world.getInstanceId(), false);
  87. removeBuffs(player);
  88. return 0;
  89. }
  90. // New instance
  91. world = new HotDWorld();
  92. world.setInstanceId(InstanceManager.getInstance().createDynamicInstance(template));
  93. world.setTemplateId(INSTANCEID);
  94. world.setStatus(0);
  95. ((HotDWorld) world).storeTime = System.currentTimeMillis();
  96. InstanceManager.getInstance().addWorld(world);
  97. _log.info("SevenSign started " + template + " Instance: " + world.getInstanceId() + " created by player: " + player.getName());
  98. // teleport players
  99. teleportPlayer(player, loc, world.getInstanceId(), false);
  100. removeBuffs(player);
  101. world.addAllowed(player.getObjectId());
  102. return world.getInstanceId();
  103. }
  104. private static final void removeBuffs(L2Character ch)
  105. {
  106. for (L2Effect e : ch.getAllEffects())
  107. {
  108. if (e == null)
  109. {
  110. continue;
  111. }
  112. L2Skill skill = e.getSkill();
  113. if (skill.isDebuff() || skill.isStayAfterDeath())
  114. {
  115. continue;
  116. }
  117. e.exit();
  118. }
  119. if (ch.getSummon() != null)
  120. {
  121. for (L2Effect e : ch.getSummon().getAllEffects())
  122. {
  123. if (e == null)
  124. {
  125. continue;
  126. }
  127. L2Skill skill = e.getSkill();
  128. if (skill.isDebuff() || skill.isStayAfterDeath())
  129. {
  130. continue;
  131. }
  132. e.exit();
  133. }
  134. }
  135. }
  136. public static void main(String[] args)
  137. {
  138. new HideoutOfTheDawn(-1, HideoutOfTheDawn.class.getSimpleName(), "instances");
  139. }
  140. }