ZealotOfShilen.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 gracia.AI.NPC.ZealotOfShilen;
  20. import ai.npc.AbstractNpcAI;
  21. import com.l2jserver.gameserver.ai.CtrlIntention;
  22. import com.l2jserver.gameserver.model.actor.L2Attackable;
  23. import com.l2jserver.gameserver.model.actor.L2Character;
  24. import com.l2jserver.gameserver.model.actor.L2Npc;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. /**
  27. * Zealot of Shilen AI.
  28. * @author nonom
  29. */
  30. public final class ZealotOfShilen extends AbstractNpcAI
  31. {
  32. // NPCs
  33. private static final int ZEALOT = 18782;
  34. private static final int[] GUARDS =
  35. {
  36. 32628,
  37. 32629
  38. };
  39. public ZealotOfShilen()
  40. {
  41. super(ZealotOfShilen.class.getSimpleName(), "gracia/AI/NPC");
  42. addSpawnId(ZEALOT);
  43. addSpawnId(GUARDS);
  44. addFirstTalkId(GUARDS);
  45. }
  46. @Override
  47. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  48. {
  49. if (npc == null)
  50. {
  51. return null;
  52. }
  53. startQuestTimer("WATCHING", 10000, npc, null, true);
  54. if (event.equalsIgnoreCase("WATCHING") && !npc.isAttackingNow())
  55. {
  56. for (L2Character character : npc.getKnownList().getKnownCharacters())
  57. {
  58. if (character.isMonster() && !character.isDead() && !((L2Attackable) character).isDecayed())
  59. {
  60. npc.setRunning();
  61. ((L2Attackable) npc).addDamageHate(character, 0, 999);
  62. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, character, null);
  63. }
  64. }
  65. }
  66. return null;
  67. }
  68. @Override
  69. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  70. {
  71. return (npc.isAttackingNow()) ? "32628-01.html" : npc.getId() + ".html";
  72. }
  73. @Override
  74. public String onSpawn(L2Npc npc)
  75. {
  76. if (npc.getId() == ZEALOT)
  77. {
  78. npc.setIsNoRndWalk(true);
  79. }
  80. else
  81. {
  82. npc.setIsInvul(true);
  83. ((L2Attackable) npc).setCanReturnToSpawnPoint(false);
  84. startQuestTimer("WATCHING", 10000, npc, null, true);
  85. }
  86. return super.onSpawn(npc);
  87. }
  88. }