PlainsOfDion.java 3.1 KB

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