SinWardens.java 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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.Map;
  21. import javolution.util.FastMap;
  22. import ai.npc.AbstractNpcAI;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.network.NpcStringId;
  27. import com.l2jserver.gameserver.network.clientpackets.Say2;
  28. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  29. /**
  30. * Manages Sin Wardens disappearing and chat.
  31. * @author GKR
  32. */
  33. public final class SinWardens extends AbstractNpcAI
  34. {
  35. private static final int[] SIN_WARDEN_MINIONS =
  36. {
  37. 22424,
  38. 22425,
  39. 22426,
  40. 22427,
  41. 22428,
  42. 22429,
  43. 22430,
  44. 22432,
  45. 22433,
  46. 22434,
  47. 22435,
  48. 22436,
  49. 22437,
  50. 22438
  51. };
  52. private final Map<Integer, Integer> killedMinionsCount = new FastMap<>();
  53. private SinWardens()
  54. {
  55. super(SinWardens.class.getSimpleName(), "ai/individual");
  56. addKillId(SIN_WARDEN_MINIONS);
  57. }
  58. @Override
  59. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  60. {
  61. if (npc.isMinion())
  62. {
  63. L2MonsterInstance master = ((L2MonsterInstance) npc).getLeader();
  64. if ((master != null) && !master.isDead())
  65. {
  66. int killedCount = killedMinionsCount.containsKey(master.getObjectId()) ? killedMinionsCount.get(master.getObjectId()) : 0;
  67. killedCount++;
  68. if ((killedCount) == 5)
  69. {
  70. master.broadcastPacket(new NpcSay(master.getObjectId(), Say2.NPC_ALL, master.getId(), NpcStringId.WE_MIGHT_NEED_NEW_SLAVES_ILL_BE_BACK_SOON_SO_WAIT));
  71. master.doDie(killer);
  72. killedMinionsCount.remove(master.getObjectId());
  73. }
  74. else
  75. {
  76. killedMinionsCount.put(master.getObjectId(), killedCount);
  77. }
  78. }
  79. }
  80. return super.onKill(npc, killer, isSummon);
  81. }
  82. public static void main(String[] args)
  83. {
  84. new SinWardens();
  85. }
  86. }