FleeNpc.java 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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.ai.CtrlIntention;
  22. import com.l2jserver.gameserver.model.Location;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. public final class FleeNpc extends AbstractNpcAI
  26. {
  27. private static final int[] MOBS =
  28. {
  29. 20432,
  30. 22228,
  31. 18150,
  32. 18151,
  33. 18152,
  34. 18153,
  35. 18154,
  36. 18155,
  37. 18156,
  38. 18157
  39. };
  40. private FleeNpc()
  41. {
  42. super(FleeNpc.class.getSimpleName(), "ai/individual");
  43. addAttackId(MOBS);
  44. }
  45. @Override
  46. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon)
  47. {
  48. if ((npc.getId() >= 18150) && (npc.getId() <= 18157))
  49. {
  50. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location((npc.getX() + getRandom(-40, 40)), (npc.getY() + getRandom(-40, 40)), npc.getZ(), npc.getHeading()));
  51. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null, null);
  52. return null;
  53. }
  54. else if ((npc.getId() == 20432) || (npc.getId() == 22228))
  55. {
  56. if (getRandom(3) == 2)
  57. {
  58. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location((npc.getX() + getRandom(-200, 200)), (npc.getY() + getRandom(-200, 200)), npc.getZ(), npc.getHeading()));
  59. }
  60. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null, null);
  61. return null;
  62. }
  63. return super.onAttack(npc, attacker, damage, isSummon);
  64. }
  65. // Register the new Script at the Script System
  66. public static void main(String[] args)
  67. {
  68. new FleeNpc();
  69. }
  70. }