TowerOfInfinitum.java 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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.AI.Zones.TowerOfInfinitum;
  20. import hellbound.HellboundEngine;
  21. import java.util.HashMap;
  22. import java.util.Map;
  23. import ai.npc.AbstractNpcAI;
  24. import com.l2jserver.gameserver.model.L2Party;
  25. import com.l2jserver.gameserver.model.Location;
  26. import com.l2jserver.gameserver.model.actor.L2Npc;
  27. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  28. import com.l2jserver.gameserver.util.Util;
  29. /**
  30. * Tower Of Infinitum.
  31. * @author GKR
  32. */
  33. public final class TowerOfInfinitum extends AbstractNpcAI
  34. {
  35. // NPCs
  36. private static final int JERIAN = 32302;
  37. private static final int GK_FIRST = 32745;
  38. private static final int GK_LAST = 32752;
  39. // Skills
  40. private static final int PASS_SKILL = 2357;
  41. // Misc
  42. private static final Map<Integer, Location[]> TELE_COORDS = new HashMap<>();
  43. static
  44. {
  45. TELE_COORDS.put(32745, new Location[]
  46. {
  47. new Location(-22208, 277122, -13376),
  48. null
  49. });
  50. TELE_COORDS.put(32746, new Location[]
  51. {
  52. new Location(-22208, 277106, -11648),
  53. new Location(-22208, 277074, -15040)
  54. });
  55. TELE_COORDS.put(32747, new Location[]
  56. {
  57. new Location(-22208, 277120, -9920),
  58. new Location(-22208, 277120, -13376)
  59. });
  60. TELE_COORDS.put(32748, new Location[]
  61. {
  62. new Location(-19024, 277126, -8256),
  63. new Location(-22208, 277106, -11648)
  64. });
  65. TELE_COORDS.put(32749, new Location[]
  66. {
  67. new Location(-19024, 277106, -9920),
  68. new Location(-22208, 277122, -9920)
  69. });
  70. TELE_COORDS.put(32750, new Location[]
  71. {
  72. new Location(-19008, 277100, -11648),
  73. new Location(-19024, 277122, -8256)
  74. });
  75. TELE_COORDS.put(32751, new Location[]
  76. {
  77. new Location(-19008, 277100, -13376),
  78. new Location(-19008, 277106, -9920)
  79. });
  80. TELE_COORDS.put(32752, new Location[]
  81. {
  82. new Location(14602, 283179, -7500),
  83. new Location(-19008, 277100, -11648)
  84. });
  85. }
  86. public TowerOfInfinitum()
  87. {
  88. super(TowerOfInfinitum.class.getSimpleName(), "hellbound/AI/Zones");
  89. addStartNpc(JERIAN);
  90. addTalkId(JERIAN);
  91. for (int i = GK_FIRST; i <= GK_LAST; i++)
  92. {
  93. addStartNpc(i);
  94. addTalkId(i);
  95. }
  96. }
  97. private static final Location ENTER_LOCATION = new Location(-22204, 277056, -15023);
  98. @Override
  99. public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  100. {
  101. String htmltext = event;
  102. final int npcId = npc.getId();
  103. if (event.equalsIgnoreCase("enter") && (npcId == JERIAN))
  104. {
  105. if (HellboundEngine.getInstance().getLevel() >= 11)
  106. {
  107. L2Party party = player.getParty();
  108. if ((party != null) && (party.getLeaderObjectId() == player.getObjectId()))
  109. {
  110. for (L2PcInstance partyMember : party.getMembers())
  111. {
  112. if (!Util.checkIfInRange(300, partyMember, npc, true) || !partyMember.isAffectedBySkill(PASS_SKILL))
  113. {
  114. return "32302-02.htm";
  115. }
  116. }
  117. for (L2PcInstance partyMember : party.getMembers())
  118. {
  119. partyMember.teleToLocation(ENTER_LOCATION, true);
  120. }
  121. htmltext = null;
  122. }
  123. else
  124. {
  125. htmltext = "32302-02a.htm";
  126. }
  127. }
  128. else
  129. {
  130. htmltext = "32302-02b.htm";
  131. }
  132. }
  133. else if ((event.equalsIgnoreCase("up") || event.equalsIgnoreCase("down")) && (npcId >= GK_FIRST) && (npcId <= GK_LAST))
  134. {
  135. final int direction = event.equalsIgnoreCase("up") ? 0 : 1;
  136. final L2Party party = player.getParty();
  137. if (party == null)
  138. {
  139. htmltext = "gk-noparty.htm";
  140. }
  141. else if (!party.isLeader(player))
  142. {
  143. htmltext = "gk-noreq.htm";
  144. }
  145. else
  146. {
  147. for (L2PcInstance partyMember : party.getMembers())
  148. {
  149. if (!Util.checkIfInRange(1000, partyMember, npc, false) || (Math.abs(partyMember.getZ() - npc.getZ()) > 100))
  150. {
  151. return "gk-noreq.htm";
  152. }
  153. }
  154. final Location tele = TELE_COORDS.get(npcId)[direction];
  155. if (tele != null)
  156. {
  157. for (L2PcInstance partyMember : party.getMembers())
  158. {
  159. partyMember.teleToLocation(tele, true);
  160. }
  161. }
  162. htmltext = null;
  163. }
  164. }
  165. return htmltext;
  166. }
  167. }