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