RankuFloor.java 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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.RankuFloor;
  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. * Tower of Infinitum (10th Floor) instance zone.
  34. * @author GKR
  35. */
  36. public final class RankuFloor extends AbstractInstance
  37. {
  38. protected class RFWorld extends InstanceWorld
  39. {
  40. }
  41. // NPCs
  42. private static final int GK_9 = 32752;
  43. private static final int CUBE = 32374;
  44. private static final int RANKU = 25542;
  45. // Item
  46. private static final int SEAL_BREAKER_10 = 15516;
  47. // Locations
  48. private static final Location ENTRY_POINT = new Location(-19008, 277024, -15000);
  49. private static final Location EXIT_POINT = new Location(-19008, 277122, -13376);
  50. // Misc
  51. private static final int TEMPLATE_ID = 143;
  52. private static final int MIN_LV = 78;
  53. public RankuFloor()
  54. {
  55. super(RankuFloor.class.getSimpleName(), "hellbound/Instances");
  56. addStartNpc(GK_9, CUBE);
  57. addTalkId(GK_9, CUBE);
  58. addKillId(RANKU);
  59. }
  60. @Override
  61. public String onTalk(L2Npc npc, L2PcInstance player)
  62. {
  63. String htmltext = null;
  64. if (npc.getId() == GK_9)
  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 RFWorld(), "Ranku.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 RFWorld)
  86. {
  87. teleportPlayer(player, EXIT_POINT, 0);
  88. }
  89. }
  90. return htmltext;
  91. }
  92. @Override
  93. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  94. {
  95. final int instanceId = npc.getInstanceId();
  96. if (instanceId > 0)
  97. {
  98. final Instance inst = InstanceManager.getInstance().getInstance(instanceId);
  99. final InstanceWorld world = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  100. inst.setSpawnLoc(EXIT_POINT);
  101. finishInstance(world);
  102. addSpawn(CUBE, -19056, 278732, -15000, 0, false, 0, false, instanceId);
  103. }
  104. return super.onKill(npc, killer, isSummon);
  105. }
  106. @Override
  107. protected boolean checkConditions(L2PcInstance player)
  108. {
  109. if (player.canOverrideCond(PcCondOverride.INSTANCE_CONDITIONS))
  110. {
  111. return true;
  112. }
  113. final L2Party party = player.getParty();
  114. if ((party == null) || !party.isLeader(player))
  115. {
  116. player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
  117. return false;
  118. }
  119. for (L2PcInstance partyMember : party.getMembers())
  120. {
  121. if (partyMember.getLevel() < MIN_LV)
  122. {
  123. party.broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.C1_S_LEVEL_REQUIREMENT_IS_NOT_SUFFICIENT_AND_CANNOT_BE_ENTERED).addPcName(partyMember));
  124. return false;
  125. }
  126. if (!Util.checkIfInRange(500, player, partyMember, true))
  127. {
  128. party.broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_A_LOCATION_WHICH_CANNOT_BE_ENTERED_THEREFORE_IT_CANNOT_BE_PROCESSED).addPcName(partyMember));
  129. return false;
  130. }
  131. if (InstanceManager.getInstance().getPlayerWorld(player) != null)
  132. {
  133. party.broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_ENTERED_ANOTHER_INSTANT_ZONE_THEREFORE_YOU_CANNOT_ENTER_CORRESPONDING_DUNGEON).addPcName(partyMember));
  134. return false;
  135. }
  136. final Long reenterTime = InstanceManager.getInstance().getInstanceTime(partyMember.getObjectId(), TEMPLATE_ID);
  137. if (System.currentTimeMillis() < reenterTime)
  138. {
  139. party.broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.C1_MAY_NOT_RE_ENTER_YET).addPcName(partyMember));
  140. return false;
  141. }
  142. if (partyMember.getInventory().getInventoryItemCount(SEAL_BREAKER_10, -1, false) < 1)
  143. {
  144. party.broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.C1_S_QUEST_REQUIREMENT_IS_NOT_SUFFICIENT_AND_CANNOT_BE_ENTERED).addPcName(partyMember));
  145. return false;
  146. }
  147. }
  148. return true;
  149. }
  150. @Override
  151. public void onEnterInstance(L2PcInstance player, InstanceWorld world, boolean firstEntrance)
  152. {
  153. if (firstEntrance)
  154. {
  155. if (player.getParty() == null)
  156. {
  157. teleportPlayer(player, ENTRY_POINT, world.getInstanceId());
  158. player.destroyItemByItemId("Quest", SEAL_BREAKER_10, 1, null, true);
  159. world.addAllowed(player.getObjectId());
  160. }
  161. else
  162. {
  163. for (L2PcInstance partyMember : player.getParty().getMembers())
  164. {
  165. teleportPlayer(partyMember, ENTRY_POINT, world.getInstanceId());
  166. partyMember.destroyItemByItemId("Quest", SEAL_BREAKER_10, 1, null, true);
  167. world.addAllowed(partyMember.getObjectId());
  168. }
  169. }
  170. }
  171. else
  172. {
  173. teleportPlayer(player, ENTRY_POINT, world.getInstanceId());
  174. }
  175. }
  176. }