Keltas.java 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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.actor.L2Npc;
  20. import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.quest.Quest;
  23. import com.l2jserver.gameserver.network.NpcStringId;
  24. import com.l2jserver.gameserver.network.clientpackets.Say2;
  25. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  26. /**
  27. * Manages Darion's Enforcer's and Darion's Executioner spawn/despawn
  28. * @author GKR
  29. */
  30. public class Keltas extends Quest
  31. {
  32. private static final int KELTAS = 22341;
  33. private static final int ENFORCER = 22342;
  34. private static final int EXECUTIONER = 22343;
  35. private L2MonsterInstance spawnedKeltas = null;
  36. private final List<L2Spawn> spawnedMonsters;
  37. private static final int[][] ENFORCER_SPAWN_POINTS =
  38. {
  39. {
  40. -24540, 251404, -3320
  41. },
  42. {
  43. -24100, 252578, -3060
  44. },
  45. {
  46. -24607, 252443, -3074
  47. },
  48. {
  49. -23962, 252041, -3275
  50. },
  51. {
  52. -24381, 252132, -3090
  53. },
  54. {
  55. -23652, 251838, -3370
  56. },
  57. {
  58. -23838, 252603, -3095
  59. },
  60. {
  61. -23257, 251671, -3360
  62. },
  63. {
  64. -27127, 251106, -3523
  65. },
  66. {
  67. -27118, 251203, -3523
  68. },
  69. {
  70. -27052, 251205, -3523
  71. },
  72. {
  73. -26999, 250818, -3523
  74. },
  75. {
  76. -29613, 252888, -3523
  77. },
  78. {
  79. -29765, 253009, -3523
  80. },
  81. {
  82. -29594, 252570, -3523
  83. },
  84. {
  85. -29770, 252658, -3523
  86. },
  87. {
  88. -27816, 252008, -3527
  89. },
  90. {
  91. -27930, 252011, -3523
  92. },
  93. {
  94. -28702, 251986, -3523
  95. },
  96. {
  97. -27357, 251987, -3527
  98. },
  99. {
  100. -28859, 251081, -3527
  101. },
  102. {
  103. -28607, 250397, -3523
  104. },
  105. {
  106. -28801, 250462, -3523
  107. },
  108. {
  109. -29123, 250387, -3472
  110. },
  111. {
  112. -25376, 252368, -3257
  113. },
  114. {
  115. -25376, 252208, -3257
  116. }
  117. };
  118. private static final int[][] EXECUTIONER_SPAWN_POINTS =
  119. {
  120. {
  121. -24419, 251395, -3340
  122. },
  123. {
  124. -24912, 252160, -3310
  125. },
  126. {
  127. -25027, 251941, -3300
  128. },
  129. {
  130. -24127, 252657, -3058
  131. },
  132. {
  133. -25120, 252372, -3270
  134. },
  135. {
  136. -24456, 252651, -3060
  137. },
  138. {
  139. -24844, 251614, -3295
  140. },
  141. {
  142. -28675, 252008, -3523
  143. },
  144. {
  145. -27943, 251238, -3523
  146. },
  147. {
  148. -27827, 251984, -3523
  149. },
  150. {
  151. -27276, 251995, -3523
  152. },
  153. {
  154. -28769, 251955, -3523
  155. },
  156. {
  157. -27969, 251073, -3523
  158. },
  159. {
  160. -27233, 250938, -3523
  161. },
  162. {
  163. -26835, 250914, -3523
  164. },
  165. {
  166. -26802, 251276, -3523
  167. },
  168. {
  169. -29671, 252781, -3527
  170. },
  171. {
  172. -29536, 252831, -3523
  173. },
  174. {
  175. -29419, 253214, -3523
  176. },
  177. {
  178. -27923, 251965, -3523
  179. },
  180. {
  181. -28499, 251882, -3527
  182. },
  183. {
  184. -28194, 251915, -3523
  185. },
  186. {
  187. -28358, 251078, -3527
  188. },
  189. {
  190. -28580, 251071, -3527
  191. },
  192. {
  193. -28492, 250704, -3523
  194. }
  195. };
  196. private void spawnMinions()
  197. {
  198. for (int[] pos : ENFORCER_SPAWN_POINTS)
  199. {
  200. L2MonsterInstance minion = (L2MonsterInstance) addSpawn(ENFORCER, pos[0], pos[1], pos[2], 0, false, 0, false);
  201. minion.getSpawn().setRespawnDelay(60);
  202. minion.getSpawn().setAmount(1);
  203. minion.getSpawn().startRespawn();
  204. spawnedMonsters.add(minion.getSpawn());
  205. }
  206. for (int[] pos : EXECUTIONER_SPAWN_POINTS)
  207. {
  208. L2MonsterInstance minion = (L2MonsterInstance) addSpawn(EXECUTIONER, pos[0], pos[1], pos[2], 0, false, 0, false);
  209. minion.getSpawn().setRespawnDelay(80);
  210. minion.getSpawn().setAmount(1);
  211. minion.getSpawn().startRespawn();
  212. spawnedMonsters.add(minion.getSpawn());
  213. }
  214. }
  215. private void despawnMinions()
  216. {
  217. if ((spawnedMonsters == null) || spawnedMonsters.isEmpty())
  218. {
  219. return;
  220. }
  221. for (L2Spawn spawn : spawnedMonsters)
  222. {
  223. spawn.stopRespawn();
  224. L2Npc minion = spawn.getLastSpawn();
  225. if ((minion != null) && !minion.isDead())
  226. {
  227. minion.deleteMe();
  228. }
  229. }
  230. spawnedMonsters.clear();
  231. }
  232. @Override
  233. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  234. {
  235. if (event.equalsIgnoreCase("despawn"))
  236. {
  237. if ((spawnedKeltas != null) && !spawnedKeltas.isDead())
  238. {
  239. spawnedKeltas.broadcastPacket(new NpcSay(spawnedKeltas.getObjectId(), Say2.SHOUT, spawnedKeltas.getNpcId(), NpcStringId.THAT_IS_IT_FOR_TODAYLETS_RETREAT_EVERYONE_PULL_BACK));
  240. spawnedKeltas.deleteMe();
  241. spawnedKeltas.getSpawn().decreaseCount(spawnedKeltas);
  242. despawnMinions();
  243. }
  244. }
  245. return null;
  246. }
  247. @Override
  248. public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet)
  249. {
  250. cancelQuestTimers("despawn");
  251. despawnMinions();
  252. return super.onKill(npc, killer, isPet);
  253. }
  254. @Override
  255. public final String onSpawn(L2Npc npc)
  256. {
  257. if (!npc.isTeleporting())
  258. {
  259. spawnedKeltas = (L2MonsterInstance) npc;
  260. npc.broadcastPacket(new NpcSay(spawnedKeltas.getObjectId(), Say2.SHOUT, spawnedKeltas.getNpcId(), NpcStringId.GUYS_SHOW_THEM_OUR_POWER));
  261. spawnMinions();
  262. startQuestTimer("despawn", 1800000, null, null);
  263. }
  264. return super.onSpawn(npc);
  265. }
  266. public Keltas(int id, String name, String descr)
  267. {
  268. super(id, name, descr);
  269. addKillId(KELTAS);
  270. addSpawnId(KELTAS);
  271. spawnedMonsters = new FastList<L2Spawn>();
  272. }
  273. public static void main(String[] args)
  274. {
  275. new Keltas(-1, "keltas", "ai");
  276. }
  277. }