JiniaGuildHideout2.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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.JiniaGuildHideout2;
  20. import quests.Q10285_MeetingSirra.Q10285_MeetingSirra;
  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. * Jinia Guild Hideout instance zone.
  31. * @author Adry_85
  32. */
  33. public final class JiniaGuildHideout2 extends Quest
  34. {
  35. protected class JGH2World extends InstanceWorld
  36. {
  37. long storeTime = 0;
  38. }
  39. private static final int TEMPLATE_ID = 141;
  40. // NPC
  41. private static final int RAFFORTY = 32020;
  42. // Location
  43. private static final Location START_LOC = new Location(-23530, -8963, -5413, 0, 0);
  44. private JiniaGuildHideout2()
  45. {
  46. super(-1, JiniaGuildHideout2.class.getSimpleName(), "instances");
  47. addStartNpc(RAFFORTY);
  48. addTalkId(RAFFORTY);
  49. }
  50. @Override
  51. public String onTalk(L2Npc npc, L2PcInstance talker)
  52. {
  53. final QuestState qs = talker.getQuestState(Q10285_MeetingSirra.class.getSimpleName());
  54. if ((qs != null) && qs.isMemoState(1))
  55. {
  56. enterInstance(talker, "JiniaGuildHideout2.xml", START_LOC);
  57. qs.setCond(2, true);
  58. }
  59. return super.onTalk(npc, talker);
  60. }
  61. protected int enterInstance(L2PcInstance player, String template, Location loc)
  62. {
  63. // check for existing instances for this player
  64. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  65. // existing instance
  66. if (world != null)
  67. {
  68. if (!(world instanceof JGH2World))
  69. {
  70. player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
  71. return 0;
  72. }
  73. teleportPlayer(player, loc, world.getInstanceId(), false);
  74. return 0;
  75. }
  76. // New instance
  77. world = new JGH2World();
  78. world.setInstanceId(InstanceManager.getInstance().createDynamicInstance(template));
  79. world.setTemplateId(TEMPLATE_ID);
  80. world.setStatus(0);
  81. ((JGH2World) world).storeTime = System.currentTimeMillis();
  82. InstanceManager.getInstance().addWorld(world);
  83. _log.info("Jinia Guild Hideout started " + template + " Instance: " + world.getInstanceId() + " created by player: " + player.getName());
  84. // teleport players
  85. teleportPlayer(player, loc, world.getInstanceId(), false);
  86. world.addAllowed(player.getObjectId());
  87. return world.getInstanceId();
  88. }
  89. public static void main(String[] args)
  90. {
  91. new JiniaGuildHideout2();
  92. }
  93. }