PlainsOfDion.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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.group_template;
  20. import ai.npc.AbstractNpcAI;
  21. import com.l2jserver.gameserver.GeoData;
  22. import com.l2jserver.gameserver.model.actor.L2Character;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.network.NpcStringId;
  27. import com.l2jserver.gameserver.network.clientpackets.Say2;
  28. import com.l2jserver.gameserver.util.Util;
  29. /**
  30. * AI for mobs in Plains of Dion (near Floran Village).
  31. * @author Gladicek
  32. */
  33. public final class PlainsOfDion extends AbstractNpcAI
  34. {
  35. private static final int DELU_LIZARDMEN[] =
  36. {
  37. 21104, // Delu Lizardman Supplier
  38. 21105, // Delu Lizardman Special Agent
  39. 21107, // Delu Lizardman Commander
  40. };
  41. private static final NpcStringId[] MONSTERS_MSG =
  42. {
  43. NpcStringId.S1_HOW_DARE_YOU_INTERRUPT_OUR_FIGHT_HEY_GUYS_HELP,
  44. NpcStringId.S1_HEY_WERE_HAVING_A_DUEL_HERE,
  45. NpcStringId.THE_DUEL_IS_OVER_ATTACK,
  46. NpcStringId.FOUL_KILL_THE_COWARD,
  47. NpcStringId.HOW_DARE_YOU_INTERRUPT_A_SACRED_DUEL_YOU_MUST_BE_TAUGHT_A_LESSON
  48. };
  49. private static final NpcStringId[] MONSTERS_ASSIST_MSG =
  50. {
  51. NpcStringId.DIE_YOU_COWARD,
  52. NpcStringId.KILL_THE_COWARD,
  53. NpcStringId.WHAT_ARE_YOU_LOOKING_AT
  54. };
  55. private PlainsOfDion()
  56. {
  57. super(PlainsOfDion.class.getSimpleName(), "ai/group_template");
  58. addAttackId(DELU_LIZARDMEN);
  59. }
  60. @Override
  61. public String onAttack(L2Npc npc, L2PcInstance player, int damage, boolean isSummon)
  62. {
  63. if (npc.isScriptValue(0))
  64. {
  65. int i = getRandom(5);
  66. if (i < 2)
  67. {
  68. broadcastNpcSay(npc, Say2.NPC_ALL, MONSTERS_MSG[i], player.getName());
  69. }
  70. else
  71. {
  72. broadcastNpcSay(npc, Say2.NPC_ALL, MONSTERS_MSG[i]);
  73. }
  74. for (L2Character obj : npc.getKnownList().getKnownCharactersInRadius(npc.getTemplate().getClanHelpRange()))
  75. {
  76. if (obj.isMonster() && Util.contains(DELU_LIZARDMEN, obj.getId()) && !obj.isAttackingNow() && !obj.isDead() && GeoData.getInstance().canSeeTarget(npc, obj))
  77. {
  78. final L2MonsterInstance monster = (L2MonsterInstance) obj;
  79. attackPlayer(monster, player);
  80. broadcastNpcSay(monster, Say2.NPC_ALL, MONSTERS_ASSIST_MSG[getRandom(3)]);
  81. }
  82. }
  83. npc.setScriptValue(1);
  84. }
  85. return super.onAttack(npc, player, damage, isSummon);
  86. }
  87. public static void main(String[] args)
  88. {
  89. new PlainsOfDion();
  90. }
  91. }