GraveRobbers.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 ai.npc.AbstractNpcAI;
  21. import com.l2jserver.gameserver.datatables.SpawnTable;
  22. import com.l2jserver.gameserver.model.L2Spawn;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
  25. import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
  26. import com.l2jserver.gameserver.model.holders.MinionHolder;
  27. import com.l2jserver.util.Rnd;
  28. /**
  29. * Grove Robber's AI.<br>
  30. * <ul>
  31. * <li>Grove Robber Summoner</li>
  32. * <li>Grove Robber Megician</li>
  33. * </ul>
  34. * @author Zealar
  35. */
  36. public final class GraveRobbers extends AbstractNpcAI
  37. {
  38. private static final int GRAVE_ROBBER_SUMMONER = 22678;
  39. private static final int GRAVE_ROBBER_MEGICIAN = 22679;
  40. private GraveRobbers()
  41. {
  42. super(GraveRobbers.class.getSimpleName(), "ai/individual");
  43. addSpawnId(GRAVE_ROBBER_SUMMONER, GRAVE_ROBBER_MEGICIAN);
  44. for (L2Spawn spawn : SpawnTable.getInstance().getSpawns(GRAVE_ROBBER_MEGICIAN))
  45. {
  46. onSpawn(spawn.getLastSpawn());
  47. }
  48. }
  49. @Override
  50. public String onSpawn(L2Npc npc)
  51. {
  52. if (npc instanceof L2MonsterInstance)
  53. {
  54. if (!((L2MonsterInstance) npc).hasMinions())
  55. {
  56. L2NpcTemplate template = npc.getTemplate();
  57. if (Rnd.get(2) == 0)
  58. {
  59. if (template.getParameters().getMinionList("Privates1") != null)
  60. {
  61. for (MinionHolder is : template.getParameters().getMinionList("Privates1"))
  62. {
  63. addMinion((L2MonsterInstance) npc, is.getId());
  64. }
  65. }
  66. }
  67. else
  68. {
  69. if (template.getParameters().getMinionList("Privates2") != null)
  70. {
  71. for (MinionHolder is : template.getParameters().getMinionList("Privates2"))
  72. {
  73. addMinion((L2MonsterInstance) npc, is.getId());
  74. }
  75. }
  76. }
  77. }
  78. }
  79. return super.onSpawn(npc);
  80. }
  81. public static void main(String[] args)
  82. {
  83. new GraveRobbers();
  84. }
  85. }