SinWardens.java 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.Map;
  17. import javolution.util.FastMap;
  18. import ai.group_template.L2AttackableAIScript;
  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.network.NpcStringId;
  23. import com.l2jserver.gameserver.network.clientpackets.Say2;
  24. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  25. /**
  26. * Manages Sin Wardens disappearing and chat
  27. * @author GKR
  28. */
  29. public class SinWardens extends L2AttackableAIScript
  30. {
  31. private static final int[] SIN_WARDEN_MINIONS =
  32. {
  33. 22424, 22425, 22426, 22427, 22428, 22429, 22430, 22432, 22433, 22434, 22435, 22436, 22437, 22438
  34. };
  35. private final Map<Integer, Integer> killedMinionsCount = new FastMap<Integer, Integer>();
  36. @Override
  37. public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet)
  38. {
  39. if (npc.isMinion())
  40. {
  41. L2MonsterInstance master = ((L2MonsterInstance) npc).getLeader();
  42. if ((master != null) && !master.isDead())
  43. {
  44. int killedCount = killedMinionsCount.containsKey(master.getObjectId()) ? killedMinionsCount.get(master.getObjectId()) : 0;
  45. killedCount++;
  46. if ((killedCount) == 5)
  47. {
  48. master.broadcastPacket(new NpcSay(master.getObjectId(), Say2.ALL, master.getNpcId(), NpcStringId.WE_MIGHT_NEED_NEW_SLAVES_ILL_BE_BACK_SOON_SO_WAIT));
  49. master.doDie(killer);
  50. killedMinionsCount.remove(master.getObjectId());
  51. }
  52. else
  53. {
  54. killedMinionsCount.put(master.getObjectId(), killedCount);
  55. }
  56. }
  57. }
  58. return super.onKill(npc, killer, isPet);
  59. }
  60. public SinWardens(int id, String name, String descr)
  61. {
  62. super(id, name, descr);
  63. for (int monsterId : SIN_WARDEN_MINIONS)
  64. {
  65. addKillId(monsterId);
  66. }
  67. }
  68. public static void main(String[] args)
  69. {
  70. new SinWardens(-1, "SinWardens", "ai");
  71. }
  72. }