FairyTrees.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package ai.group_template;
  16. import com.l2jserver.gameserver.ai.CtrlIntention;
  17. import com.l2jserver.gameserver.datatables.SkillTable;
  18. import com.l2jserver.gameserver.model.L2Skill;
  19. import com.l2jserver.gameserver.model.actor.L2Attackable;
  20. import com.l2jserver.gameserver.model.actor.L2Character;
  21. import com.l2jserver.gameserver.model.actor.instance.L2NpcInstance;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.util.Util;
  24. import com.l2jserver.util.Rnd;
  25. public class FairyTrees extends L2AttackableAIScript
  26. {
  27. private static final int[] mobs = { 27185, 27186, 27187, 27188 };
  28. public FairyTrees(int questId, String name, String descr)
  29. {
  30. super(questId, name, descr);
  31. this.registerMobs(mobs, QuestEventType.ON_KILL);
  32. super.addSpawnId(27189);
  33. }
  34. public String onKill (L2NpcInstance npc, L2PcInstance killer, boolean isPet)
  35. {
  36. int npcId = npc.getNpcId();
  37. if (Util.contains(mobs, npcId))
  38. {
  39. for (int i = 0; i < 20; i++)
  40. {
  41. L2Attackable newNpc = (L2Attackable) addSpawn(27189, npc.getX(), npc.getY(), npc.getZ(), 0, false, 30000);
  42. L2Character originalKiller = isPet ? killer.getPet() : killer;
  43. newNpc.setRunning();
  44. newNpc.addDamageHate(originalKiller, 0, 999);
  45. newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalKiller);
  46. if (Rnd.get(1, 2) == 1)
  47. {
  48. L2Skill skill = SkillTable.getInstance().getInfo(4243, 1);
  49. if (skill != null && originalKiller != null)
  50. skill.getEffects(newNpc, originalKiller);
  51. }
  52. }
  53. }
  54. return super.onKill(npc, killer, isPet);
  55. }
  56. public static void main(String[] args)
  57. {
  58. new FairyTrees(-1, "fairy_trees", "ai");
  59. }
  60. }