Keltas.java 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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 ai.individual;
  20. import java.util.List;
  21. import javolution.util.FastList;
  22. import ai.npc.AbstractNpcAI;
  23. import com.l2jserver.gameserver.model.L2Spawn;
  24. import com.l2jserver.gameserver.model.Location;
  25. import com.l2jserver.gameserver.model.actor.L2Npc;
  26. import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
  27. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  28. import com.l2jserver.gameserver.network.NpcStringId;
  29. import com.l2jserver.gameserver.network.clientpackets.Say2;
  30. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  31. /**
  32. * Manages Darion's Enforcer's and Darion's Executioner spawn/despawn
  33. * @author GKR
  34. */
  35. public final class Keltas extends AbstractNpcAI
  36. {
  37. private static final int KELTAS = 22341;
  38. private static final int ENFORCER = 22342;
  39. private static final int EXECUTIONER = 22343;
  40. private L2MonsterInstance _spawnedKeltas = null;
  41. private final List<L2Spawn> _spawnedMonsters;
  42. private static final Location[] ENFORCER_SPAWN_POINTS =
  43. {
  44. new Location(-24540, 251404, -3320),
  45. new Location(-24100, 252578, -3060),
  46. new Location(-24607, 252443, -3074),
  47. new Location(-23962, 252041, -3275),
  48. new Location(-24381, 252132, -3090),
  49. new Location(-23652, 251838, -3370),
  50. new Location(-23838, 252603, -3095),
  51. new Location(-23257, 251671, -3360),
  52. new Location(-27127, 251106, -3523),
  53. new Location(-27118, 251203, -3523),
  54. new Location(-27052, 251205, -3523),
  55. new Location(-26999, 250818, -3523),
  56. new Location(-29613, 252888, -3523),
  57. new Location(-29765, 253009, -3523),
  58. new Location(-29594, 252570, -3523),
  59. new Location(-29770, 252658, -3523),
  60. new Location(-27816, 252008, -3527),
  61. new Location(-27930, 252011, -3523),
  62. new Location(-28702, 251986, -3523),
  63. new Location(-27357, 251987, -3527),
  64. new Location(-28859, 251081, -3527),
  65. new Location(-28607, 250397, -3523),
  66. new Location(-28801, 250462, -3523),
  67. new Location(-29123, 250387, -3472),
  68. new Location(-25376, 252368, -3257),
  69. new Location(-25376, 252208, -3257)
  70. };
  71. private static final Location[] EXECUTIONER_SPAWN_POINTS =
  72. {
  73. new Location(-24419, 251395, -3340),
  74. new Location(-24912, 252160, -3310),
  75. new Location(-25027, 251941, -3300),
  76. new Location(-24127, 252657, -3058),
  77. new Location(-25120, 252372, -3270),
  78. new Location(-24456, 252651, -3060),
  79. new Location(-24844, 251614, -3295),
  80. new Location(-28675, 252008, -3523),
  81. new Location(-27943, 251238, -3523),
  82. new Location(-27827, 251984, -3523),
  83. new Location(-27276, 251995, -3523),
  84. new Location(-28769, 251955, -3523),
  85. new Location(-27969, 251073, -3523),
  86. new Location(-27233, 250938, -3523),
  87. new Location(-26835, 250914, -3523),
  88. new Location(-26802, 251276, -3523),
  89. new Location(-29671, 252781, -3527),
  90. new Location(-29536, 252831, -3523),
  91. new Location(-29419, 253214, -3523),
  92. new Location(-27923, 251965, -3523),
  93. new Location(-28499, 251882, -3527),
  94. new Location(-28194, 251915, -3523),
  95. new Location(-28358, 251078, -3527),
  96. new Location(-28580, 251071, -3527),
  97. new Location(-28492, 250704, -3523)
  98. };
  99. private Keltas()
  100. {
  101. super(Keltas.class.getSimpleName(), "ai/individual");
  102. addKillId(KELTAS);
  103. addSpawnId(KELTAS);
  104. _spawnedMonsters = new FastList<>();
  105. }
  106. private void spawnMinions()
  107. {
  108. for (Location loc : ENFORCER_SPAWN_POINTS)
  109. {
  110. L2MonsterInstance minion = (L2MonsterInstance) addSpawn(ENFORCER, loc, false, 0, false);
  111. minion.getSpawn().setRespawnDelay(60);
  112. minion.getSpawn().setAmount(1);
  113. minion.getSpawn().startRespawn();
  114. _spawnedMonsters.add(minion.getSpawn());
  115. }
  116. for (Location loc : EXECUTIONER_SPAWN_POINTS)
  117. {
  118. L2MonsterInstance minion = (L2MonsterInstance) addSpawn(EXECUTIONER, loc, false, 0, false);
  119. minion.getSpawn().setRespawnDelay(80);
  120. minion.getSpawn().setAmount(1);
  121. minion.getSpawn().startRespawn();
  122. _spawnedMonsters.add(minion.getSpawn());
  123. }
  124. }
  125. private void despawnMinions()
  126. {
  127. if ((_spawnedMonsters == null) || _spawnedMonsters.isEmpty())
  128. {
  129. return;
  130. }
  131. for (L2Spawn spawn : _spawnedMonsters)
  132. {
  133. spawn.stopRespawn();
  134. L2Npc minion = spawn.getLastSpawn();
  135. if ((minion != null) && !minion.isDead())
  136. {
  137. minion.deleteMe();
  138. }
  139. }
  140. _spawnedMonsters.clear();
  141. }
  142. @Override
  143. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  144. {
  145. if (event.equalsIgnoreCase("despawn"))
  146. {
  147. if ((_spawnedKeltas != null) && !_spawnedKeltas.isDead())
  148. {
  149. _spawnedKeltas.broadcastPacket(new NpcSay(_spawnedKeltas.getObjectId(), Say2.NPC_SHOUT, _spawnedKeltas.getId(), NpcStringId.THAT_IS_IT_FOR_TODAYLETS_RETREAT_EVERYONE_PULL_BACK));
  150. _spawnedKeltas.deleteMe();
  151. _spawnedKeltas.getSpawn().decreaseCount(_spawnedKeltas);
  152. despawnMinions();
  153. }
  154. }
  155. return null;
  156. }
  157. @Override
  158. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  159. {
  160. cancelQuestTimers("despawn");
  161. despawnMinions();
  162. return super.onKill(npc, killer, isSummon);
  163. }
  164. @Override
  165. public final String onSpawn(L2Npc npc)
  166. {
  167. if (!npc.isTeleporting())
  168. {
  169. _spawnedKeltas = (L2MonsterInstance) npc;
  170. npc.broadcastPacket(new NpcSay(_spawnedKeltas.getObjectId(), Say2.NPC_SHOUT, _spawnedKeltas.getId(), NpcStringId.GUYS_SHOW_THEM_OUR_POWER));
  171. spawnMinions();
  172. startQuestTimer("despawn", 1800000, null, null);
  173. }
  174. return super.onSpawn(npc);
  175. }
  176. public static void main(String[] args)
  177. {
  178. new Keltas();
  179. }
  180. }