GiantScouts.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 java.util.Collection;
  17. import com.l2jserver.gameserver.GeoData;
  18. import com.l2jserver.gameserver.ai.CtrlIntention;
  19. import com.l2jserver.gameserver.model.L2Object;
  20. import com.l2jserver.gameserver.model.actor.L2Attackable;
  21. import com.l2jserver.gameserver.model.actor.L2Character;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.network.NpcStringId;
  26. import com.l2jserver.gameserver.network.clientpackets.Say2;
  27. import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
  28. public class GiantScouts extends L2AttackableAIScript
  29. {
  30. final private static int _scouts[] = { 22668, 22669 };
  31. public GiantScouts(int questId, String name, String descr)
  32. {
  33. super(questId, name, descr);
  34. registerMobs(_scouts, QuestEventType.ON_AGGRO_RANGE_ENTER);
  35. }
  36. @Override
  37. public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isPet)
  38. {
  39. L2Character target = isPet ? player.getPet() : player;
  40. if(GeoData.getInstance().canSeeTarget(npc, target))
  41. {
  42. if (!npc.isInCombat() && npc.getTarget() == null)
  43. npc.broadcastPacket(new CreatureSay(npc.getObjectId(), Say2.SHOUT, npc.getName(), NpcStringId.OH_GIANTS_AN_INTRUDER_HAS_BEEN_DISCOVERED));
  44. npc.setTarget(target);
  45. npc.setRunning();
  46. ((L2Attackable) npc).addDamageHate(target, 0, 999);
  47. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
  48. // Notify clan
  49. Collection<L2Object> objs = npc.getKnownList().getKnownObjects().values();
  50. for(L2Object obj : objs)
  51. {
  52. if (obj != null)
  53. {
  54. if (obj instanceof L2MonsterInstance)
  55. {
  56. L2MonsterInstance monster = (L2MonsterInstance) obj;
  57. if (( npc.getClan() != null && monster.getClan() != null) && monster.getClan().equals(npc.getClan()) && GeoData.getInstance().canSeeTarget(npc, monster))
  58. {
  59. monster.setTarget(target);
  60. monster.setRunning();
  61. monster.addDamageHate(target, 0, 999);
  62. monster.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
  63. }
  64. }
  65. }
  66. }
  67. }
  68. return super.onAggroRangeEnter(npc, player, isPet);
  69. }
  70. public static void main(String[] args)
  71. {
  72. new GiantScouts(-1, "GiantScouts", "ai");
  73. }
  74. }