RagnaOrcHero.java 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 Hero AI.
  31. * @author Zealar
  32. */
  33. public final class RagnaOrcHero extends AbstractNpcAI
  34. {
  35. private static final int RAGNA_ORC_HERO = 22693;
  36. private RagnaOrcHero()
  37. {
  38. super(RagnaOrcHero.class.getSimpleName(), "ai/individual");
  39. addSpawnId(RAGNA_ORC_HERO);
  40. for (L2Spawn spawn : SpawnTable.getInstance().getSpawns(RAGNA_ORC_HERO))
  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_HERO);
  54. if (Rnd.get(100) < 70)
  55. {
  56. if (template.getParameters().getMinionList("Privates1") != null)
  57. {
  58. for (MinionHolder is : template.getParameters().getMinionList("Privates1"))
  59. {
  60. addMinion((L2MonsterInstance) npc, is.getId());
  61. }
  62. }
  63. }
  64. else
  65. {
  66. if (template.getParameters().getMinionList("Privates2") != null)
  67. {
  68. for (MinionHolder is : template.getParameters().getMinionList("Privates2"))
  69. {
  70. addMinion((L2MonsterInstance) npc, is.getId());
  71. }
  72. }
  73. }
  74. }
  75. }
  76. return super.onSpawn(npc);
  77. }
  78. public static void main(String[] args)
  79. {
  80. new RagnaOrcHero();
  81. }
  82. }