DemonPrinceFloor.java 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. * Copyright (C) 2004-2015 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 hellbound.Instances.DemonPrinceFloor;
  20. import instances.AbstractInstance;
  21. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  22. import com.l2jserver.gameserver.model.L2Party;
  23. import com.l2jserver.gameserver.model.Location;
  24. import com.l2jserver.gameserver.model.PcCondOverride;
  25. import com.l2jserver.gameserver.model.actor.L2Npc;
  26. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  27. import com.l2jserver.gameserver.model.entity.Instance;
  28. import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
  29. import com.l2jserver.gameserver.network.SystemMessageId;
  30. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  31. import com.l2jserver.gameserver.util.Util;
  32. /**
  33. * Demon Prince Floor instance zone.
  34. * @author GKR
  35. */
  36. public final class DemonPrinceFloor extends AbstractInstance
  37. {
  38. protected class DPFWorld extends InstanceWorld
  39. {
  40. }
  41. // NPCs
  42. private static final int GK_4 = 32748;
  43. private static final int CUBE = 32375;
  44. private static final int DEMON_PRINCE = 25540;
  45. // Item
  46. private static final int SEAL_BREAKER_5 = 15515;
  47. // Locations
  48. private static final Location ENTRY_POINT = new Location(-22208, 277056, -8239);
  49. private static final Location EXIT_POINT = new Location(-19024, 277122, -8256);
  50. // Misc
  51. private static final int TEMPLATE_ID = 142;
  52. private static final int MIN_LV = 78;
  53. public DemonPrinceFloor()
  54. {
  55. super(DemonPrinceFloor.class.getSimpleName(), "hellbound/Instances");
  56. addStartNpc(GK_4, CUBE);
  57. addTalkId(GK_4, CUBE);
  58. addKillId(DEMON_PRINCE);
  59. }
  60. @Override
  61. public String onTalk(L2Npc npc, L2PcInstance player)
  62. {
  63. String htmltext = null;
  64. if (npc.getId() == GK_4)
  65. {
  66. if (!player.canOverrideCond(PcCondOverride.INSTANCE_CONDITIONS))
  67. {
  68. if (player.getParty() == null)
  69. {
  70. htmltext = "gk-noparty.htm";
  71. }
  72. else if (!player.getParty().isLeader(player))
  73. {
  74. htmltext = "gk-noleader.htm";
  75. }
  76. }
  77. if (htmltext == null)
  78. {
  79. enterInstance(player, new DPFWorld(), "DemonPrince.xml", TEMPLATE_ID);
  80. }
  81. }
  82. else if (npc.getId() == CUBE)
  83. {
  84. final InstanceWorld world = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  85. if (world instanceof DPFWorld)
  86. {
  87. world.removeAllowed(player.getObjectId());
  88. teleportPlayer(player, EXIT_POINT, 0);
  89. }
  90. }
  91. return htmltext;
  92. }
  93. @Override
  94. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  95. {
  96. final int instanceId = npc.getInstanceId();
  97. if (instanceId > 0)
  98. {
  99. final Instance inst = InstanceManager.getInstance().getInstance(instanceId);
  100. final InstanceWorld world = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  101. inst.setSpawnLoc(EXIT_POINT);
  102. finishInstance(world);
  103. addSpawn(CUBE, -22144, 278744, -8239, 0, false, 0, false, instanceId);
  104. }
  105. return super.onKill(npc, killer, isSummon);
  106. }
  107. @Override
  108. protected boolean checkConditions(L2PcInstance player)
  109. {
  110. if (player.canOverrideCond(PcCondOverride.INSTANCE_CONDITIONS))
  111. {
  112. return true;
  113. }
  114. final L2Party party = player.getParty();
  115. if ((party == null) || !party.isLeader(player))
  116. {
  117. player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
  118. return false;
  119. }
  120. for (L2PcInstance partyMember : party.getMembers())
  121. {
  122. if (partyMember.getLevel() < MIN_LV)
  123. {
  124. party.broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.C1_S_LEVEL_REQUIREMENT_IS_NOT_SUFFICIENT_AND_CANNOT_BE_ENTERED).addPcName(partyMember));
  125. return false;
  126. }
  127. if (!Util.checkIfInRange(500, player, partyMember, true))
  128. {
  129. party.broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_A_LOCATION_WHICH_CANNOT_BE_ENTERED_THEREFORE_IT_CANNOT_BE_PROCESSED).addPcName(partyMember));
  130. return false;
  131. }
  132. if (InstanceManager.getInstance().getPlayerWorld(player) != null)
  133. {
  134. party.broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_ENTERED_ANOTHER_INSTANT_ZONE_THEREFORE_YOU_CANNOT_ENTER_CORRESPONDING_DUNGEON).addPcName(partyMember));
  135. return false;
  136. }
  137. final Long reentertime = InstanceManager.getInstance().getInstanceTime(partyMember.getObjectId(), TEMPLATE_ID);
  138. if (System.currentTimeMillis() < reentertime)
  139. {
  140. party.broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.C1_MAY_NOT_RE_ENTER_YET).addPcName(partyMember));
  141. return false;
  142. }
  143. if (partyMember.getInventory().getInventoryItemCount(SEAL_BREAKER_5, -1, false) < 1)
  144. {
  145. party.broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.C1_S_QUEST_REQUIREMENT_IS_NOT_SUFFICIENT_AND_CANNOT_BE_ENTERED).addPcName(partyMember));
  146. return false;
  147. }
  148. }
  149. return true;
  150. }
  151. @Override
  152. public void onEnterInstance(L2PcInstance player, InstanceWorld world, boolean firstEntrance)
  153. {
  154. if (firstEntrance)
  155. {
  156. if (player.getParty() == null)
  157. {
  158. teleportPlayer(player, ENTRY_POINT, world.getInstanceId());
  159. player.destroyItemByItemId("Quest", SEAL_BREAKER_5, 1, null, true);
  160. world.addAllowed(player.getObjectId());
  161. }
  162. else
  163. {
  164. for (L2PcInstance partyMember : player.getParty().getMembers())
  165. {
  166. teleportPlayer(partyMember, ENTRY_POINT, world.getInstanceId());
  167. partyMember.destroyItemByItemId("Quest", SEAL_BREAKER_5, 1, null, true);
  168. world.addAllowed(partyMember.getObjectId());
  169. }
  170. }
  171. }
  172. else
  173. {
  174. teleportPlayer(player, ENTRY_POINT, world.getInstanceId());
  175. }
  176. }
  177. }