FairyTrees.java 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright (C) 2004-2015 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.group_template;
  20. import ai.npc.AbstractNpcAI;
  21. import com.l2jserver.gameserver.model.actor.L2Npc;
  22. import com.l2jserver.gameserver.model.actor.L2Playable;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.holders.SkillHolder;
  25. /**
  26. * Fairy Trees AI.
  27. * @author Charus
  28. */
  29. public class FairyTrees extends AbstractNpcAI
  30. {
  31. // NPC
  32. private static final int SOUL_GUARDIAN = 27189; // Soul of Tree Guardian
  33. private static final int[] MOBS =
  34. {
  35. 27185, // Fairy Tree of Wind
  36. 27186, // Fairy Tree of Star
  37. 27187, // Fairy Tree of Twilight
  38. 27188, // Fairy Tree of Abyss
  39. };
  40. // Skill
  41. private static SkillHolder VENOMOUS_POISON = new SkillHolder(4243, 1); // Venomous Poison
  42. // Misc
  43. private static final int MIN_DISTANCE = 1500;
  44. private FairyTrees()
  45. {
  46. super(FairyTrees.class.getSimpleName(), "ai/group_template");
  47. addKillId(MOBS);
  48. addSpawnId(MOBS);
  49. }
  50. @Override
  51. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  52. {
  53. if (npc.calculateDistance(killer, true, false) <= MIN_DISTANCE)
  54. {
  55. for (int i = 0; i < 20; i++)
  56. {
  57. final L2Npc guardian = addSpawn(SOUL_GUARDIAN, npc, false, 30000);
  58. final L2Playable attacker = isSummon ? killer.getSummon() : killer;
  59. addAttackPlayerDesire(guardian, attacker);
  60. if (getRandomBoolean())
  61. {
  62. guardian.setTarget(attacker);
  63. guardian.doCast(VENOMOUS_POISON.getSkill());
  64. }
  65. }
  66. }
  67. return super.onKill(npc, killer, isSummon);
  68. }
  69. @Override
  70. public String onSpawn(L2Npc npc)
  71. {
  72. npc.setIsNoRndWalk(true);
  73. npc.setIsImmobilized(true);
  74. return super.onSpawn(npc);
  75. }
  76. public static void main(String[] args)
  77. {
  78. new FairyTrees();
  79. }
  80. }