PavelArchaic.java 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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.model.actor.L2Attackable;
  18. import com.l2jserver.gameserver.model.actor.L2Npc;
  19. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  20. import com.l2jserver.gameserver.util.Util;
  21. import com.l2jserver.util.Rnd;
  22. /**
  23. ** @author Gnacik
  24. */
  25. public class PavelArchaic extends L2AttackableAIScript
  26. {
  27. private static final int[] _mobs1 = { 22801, 22804 };
  28. private static final int[] _mobs2 = { 18917 };
  29. @Override
  30. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isPet)
  31. {
  32. if (!npc.isDead() && Util.contains(_mobs2, npc.getNpcId()))
  33. {
  34. npc.doDie(attacker);
  35. if (Rnd.get(100) < 40)
  36. {
  37. L2Attackable _golem1 = (L2Attackable) addSpawn(22801, npc.getX(), npc.getY(), npc.getZ(), npc.getHeading(), false, 0);
  38. attackPlayer(_golem1, attacker);
  39. L2Attackable _golem2 = (L2Attackable) addSpawn(22804, npc.getX(), npc.getY(), npc.getZ(), npc.getHeading(), false, 0);
  40. attackPlayer(_golem2, attacker);
  41. }
  42. }
  43. return super.onAttack(npc, attacker, damage, isPet);
  44. }
  45. @Override
  46. public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet)
  47. {
  48. if (Util.contains(_mobs1, npc.getNpcId()))
  49. {
  50. L2Attackable _golem = (L2Attackable) addSpawn(npc.getNpcId() + 1, npc.getX(), npc.getY(), npc.getZ(), npc.getHeading(), false, 0);
  51. attackPlayer(_golem, killer);
  52. }
  53. return super.onKill(npc, killer, isPet);
  54. }
  55. private void attackPlayer(L2Attackable npc, L2PcInstance player)
  56. {
  57. npc.setIsRunning(true);
  58. npc.addDamageHate(player, 0, 999);
  59. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player);
  60. }
  61. public PavelArchaic(int questId, String name, String descr)
  62. {
  63. super(questId, name, descr);
  64. registerMobs(_mobs1, QuestEventType.ON_KILL);
  65. registerMobs(_mobs2, QuestEventType.ON_ATTACK);
  66. }
  67. public static void main(String[] args)
  68. {
  69. new PavelArchaic(-1, "PavelArchaic", "ai");
  70. }
  71. }