Slaves.java 3.2 KB

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