Slaves.java 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 hellbound.AI;
  20. import java.util.List;
  21. import ai.npc.AbstractNpcAI;
  22. import com.l2jserver.gameserver.ai.CtrlIntention;
  23. import com.l2jserver.gameserver.model.Location;
  24. import com.l2jserver.gameserver.model.actor.L2Npc;
  25. import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
  26. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  27. import com.l2jserver.gameserver.network.NpcStringId;
  28. import com.l2jserver.gameserver.network.clientpackets.Say2;
  29. import com.l2jserver.gameserver.taskmanager.DecayTaskManager;
  30. import hellbound.HellboundEngine;
  31. /**
  32. * Hellbound Slaves AI.
  33. * @author DS
  34. */
  35. public final class Slaves extends AbstractNpcAI
  36. {
  37. // NPCs
  38. private static final int[] MASTERS =
  39. {
  40. 22320, // Junior Watchman
  41. 22321, // Junior Summoner
  42. };
  43. // Locations
  44. private static final Location MOVE_TO = new Location(-25451, 252291, -3252, 3500);
  45. // Misc
  46. private static final int TRUST_REWARD = 10;
  47. public Slaves()
  48. {
  49. super(Slaves.class.getSimpleName(), "hellbound/AI");
  50. addSpawnId(MASTERS);
  51. addKillId(MASTERS);
  52. }
  53. @Override
  54. public final String onSpawn(L2Npc npc)
  55. {
  56. ((L2MonsterInstance) npc).enableMinions(HellboundEngine.getInstance().getLevel() < 5);
  57. ((L2MonsterInstance) npc).setOnKillDelay(1000);
  58. return super.onSpawn(npc);
  59. }
  60. @Override
  61. public final String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  62. {
  63. if (((L2MonsterInstance) npc).getMinionList() != null)
  64. {
  65. final List<L2MonsterInstance> slaves = ((L2MonsterInstance) npc).getMinionList().getSpawnedMinions();
  66. if ((slaves != null) && !slaves.isEmpty())
  67. {
  68. for (L2MonsterInstance slave : slaves)
  69. {
  70. if ((slave == null) || slave.isDead())
  71. {
  72. continue;
  73. }
  74. slave.clearAggroList();
  75. slave.abortAttack();
  76. slave.abortCast();
  77. broadcastNpcSay(slave, Say2.NPC_ALL, NpcStringId.THANK_YOU_FOR_SAVING_ME_FROM_THE_CLUTCHES_OF_EVIL);
  78. if ((HellboundEngine.getInstance().getLevel() >= 1) && (HellboundEngine.getInstance().getLevel() <= 2))
  79. {
  80. HellboundEngine.getInstance().updateTrust(TRUST_REWARD, false);
  81. }
  82. slave.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, MOVE_TO);
  83. DecayTaskManager.getInstance().add(slave);
  84. }
  85. }
  86. }
  87. return super.onKill(npc, killer, isSummon);
  88. }
  89. }