Keltas.java 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package ai.individual;
  16. import java.util.List;
  17. import javolution.util.FastList;
  18. import com.l2jserver.gameserver.model.L2Spawn;
  19. import com.l2jserver.gameserver.model.Location;
  20. import com.l2jserver.gameserver.model.actor.L2Npc;
  21. import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.model.quest.Quest;
  24. import com.l2jserver.gameserver.network.NpcStringId;
  25. import com.l2jserver.gameserver.network.clientpackets.Say2;
  26. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  27. /**
  28. * Manages Darion's Enforcer's and Darion's Executioner spawn/despawn
  29. * @author GKR
  30. */
  31. public class Keltas extends Quest
  32. {
  33. private static final int KELTAS = 22341;
  34. private static final int ENFORCER = 22342;
  35. private static final int EXECUTIONER = 22343;
  36. private L2MonsterInstance spawnedKeltas = null;
  37. private final List<L2Spawn> spawnedMonsters;
  38. private static final Location[] ENFORCER_SPAWN_POINTS =
  39. {
  40. new Location(-24540, 251404, -3320),
  41. new Location(-24100, 252578, -3060),
  42. new Location(-24607, 252443, -3074),
  43. new Location(-23962, 252041, -3275),
  44. new Location(-24381, 252132, -3090),
  45. new Location(-23652, 251838, -3370),
  46. new Location(-23838, 252603, -3095),
  47. new Location(-23257, 251671, -3360),
  48. new Location(-27127, 251106, -3523),
  49. new Location(-27118, 251203, -3523),
  50. new Location(-27052, 251205, -3523),
  51. new Location(-26999, 250818, -3523),
  52. new Location(-29613, 252888, -3523),
  53. new Location(-29765, 253009, -3523),
  54. new Location(-29594, 252570, -3523),
  55. new Location(-29770, 252658, -3523),
  56. new Location(-27816, 252008, -3527),
  57. new Location(-27930, 252011, -3523),
  58. new Location(-28702, 251986, -3523),
  59. new Location(-27357, 251987, -3527),
  60. new Location(-28859, 251081, -3527),
  61. new Location(-28607, 250397, -3523),
  62. new Location(-28801, 250462, -3523),
  63. new Location(-29123, 250387, -3472),
  64. new Location(-25376, 252368, -3257),
  65. new Location(-25376, 252208, -3257)
  66. };
  67. private static final Location[] EXECUTIONER_SPAWN_POINTS =
  68. {
  69. new Location(-24419, 251395, -3340),
  70. new Location(-24912, 252160, -3310),
  71. new Location(-25027, 251941, -3300),
  72. new Location(-24127, 252657, -3058),
  73. new Location(-25120, 252372, -3270),
  74. new Location(-24456, 252651, -3060),
  75. new Location(-24844, 251614, -3295),
  76. new Location(-28675, 252008, -3523),
  77. new Location(-27943, 251238, -3523),
  78. new Location(-27827, 251984, -3523),
  79. new Location(-27276, 251995, -3523),
  80. new Location(-28769, 251955, -3523),
  81. new Location(-27969, 251073, -3523),
  82. new Location(-27233, 250938, -3523),
  83. new Location(-26835, 250914, -3523),
  84. new Location(-26802, 251276, -3523),
  85. new Location(-29671, 252781, -3527),
  86. new Location(-29536, 252831, -3523),
  87. new Location(-29419, 253214, -3523),
  88. new Location(-27923, 251965, -3523),
  89. new Location(-28499, 251882, -3527),
  90. new Location(-28194, 251915, -3523),
  91. new Location(-28358, 251078, -3527),
  92. new Location(-28580, 251071, -3527),
  93. new Location(-28492, 250704, -3523)
  94. };
  95. private void spawnMinions()
  96. {
  97. for (Location loc : ENFORCER_SPAWN_POINTS)
  98. {
  99. L2MonsterInstance minion = (L2MonsterInstance) addSpawn(ENFORCER, loc, false, 0, false);
  100. minion.getSpawn().setRespawnDelay(60);
  101. minion.getSpawn().setAmount(1);
  102. minion.getSpawn().startRespawn();
  103. spawnedMonsters.add(minion.getSpawn());
  104. }
  105. for (Location loc : EXECUTIONER_SPAWN_POINTS)
  106. {
  107. L2MonsterInstance minion = (L2MonsterInstance) addSpawn(EXECUTIONER, loc, false, 0, false);
  108. minion.getSpawn().setRespawnDelay(80);
  109. minion.getSpawn().setAmount(1);
  110. minion.getSpawn().startRespawn();
  111. spawnedMonsters.add(minion.getSpawn());
  112. }
  113. }
  114. private void despawnMinions()
  115. {
  116. if ((spawnedMonsters == null) || spawnedMonsters.isEmpty())
  117. {
  118. return;
  119. }
  120. for (L2Spawn spawn : spawnedMonsters)
  121. {
  122. spawn.stopRespawn();
  123. L2Npc minion = spawn.getLastSpawn();
  124. if ((minion != null) && !minion.isDead())
  125. {
  126. minion.deleteMe();
  127. }
  128. }
  129. spawnedMonsters.clear();
  130. }
  131. @Override
  132. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  133. {
  134. if (event.equalsIgnoreCase("despawn"))
  135. {
  136. if ((spawnedKeltas != null) && !spawnedKeltas.isDead())
  137. {
  138. spawnedKeltas.broadcastPacket(new NpcSay(spawnedKeltas.getObjectId(), Say2.SHOUT, spawnedKeltas.getNpcId(), NpcStringId.THAT_IS_IT_FOR_TODAYLETS_RETREAT_EVERYONE_PULL_BACK));
  139. spawnedKeltas.deleteMe();
  140. spawnedKeltas.getSpawn().decreaseCount(spawnedKeltas);
  141. despawnMinions();
  142. }
  143. }
  144. return null;
  145. }
  146. @Override
  147. public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet)
  148. {
  149. cancelQuestTimers("despawn");
  150. despawnMinions();
  151. return super.onKill(npc, killer, isPet);
  152. }
  153. @Override
  154. public final String onSpawn(L2Npc npc)
  155. {
  156. if (!npc.isTeleporting())
  157. {
  158. spawnedKeltas = (L2MonsterInstance) npc;
  159. npc.broadcastPacket(new NpcSay(spawnedKeltas.getObjectId(), Say2.SHOUT, spawnedKeltas.getNpcId(), NpcStringId.GUYS_SHOW_THEM_OUR_POWER));
  160. spawnMinions();
  161. startQuestTimer("despawn", 1800000, null, null);
  162. }
  163. return super.onSpawn(npc);
  164. }
  165. public Keltas(int id, String name, String descr)
  166. {
  167. super(id, name, descr);
  168. addKillId(KELTAS);
  169. addSpawnId(KELTAS);
  170. spawnedMonsters = new FastList<L2Spawn>();
  171. }
  172. public static void main(String[] args)
  173. {
  174. new Keltas(-1, "keltas", "ai");
  175. }
  176. }