GiantsCave.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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.model.actor.L2Attackable;
  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. /**
  28. * Giant's Cave AI.
  29. * @author Gnacik, St3eT
  30. */
  31. public final class GiantsCave extends AbstractNpcAI
  32. {
  33. // NPC
  34. private static final int[] SCOUTS =
  35. {
  36. 22668, // Gamlin (Scout)
  37. 22669, // Leogul (Scout)
  38. };
  39. private GiantsCave()
  40. {
  41. super(GiantsCave.class.getSimpleName(), "ai/group_template");
  42. addAttackId(SCOUTS);
  43. addAggroRangeEnterId(SCOUTS);
  44. }
  45. @Override
  46. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  47. {
  48. if (event.equals("ATTACK") && (player != null) && (npc != null) && !npc.isDead())
  49. {
  50. if (npc.getId() == SCOUTS[0]) // Gamlin
  51. {
  52. broadcastNpcSay(npc, Say2.NPC_SHOUT, NpcStringId._INTRUDER_DETECTED);
  53. }
  54. else
  55. {
  56. broadcastNpcSay(npc, Say2.NPC_SHOUT, NpcStringId.OH_GIANTS_AN_INTRUDER_HAS_BEEN_DISCOVERED);
  57. }
  58. for (L2Character characters : npc.getKnownList().getKnownCharactersInRadius(450))
  59. {
  60. if ((characters != null) && (characters.isAttackable()) && (getRandomBoolean()))
  61. {
  62. L2Attackable monster = (L2Attackable) characters;
  63. attackPlayer(monster, player);
  64. }
  65. }
  66. }
  67. else if (event.equals("CLEAR") && (npc != null) && !npc.isDead())
  68. {
  69. npc.setScriptValue(0);
  70. }
  71. return super.onAdvEvent(event, npc, player);
  72. }
  73. @Override
  74. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon)
  75. {
  76. if (npc.isScriptValue(0))
  77. {
  78. npc.setScriptValue(1);
  79. startQuestTimer("ATTACK", 6000, npc, attacker);
  80. startQuestTimer("CLEAR", 120000, npc, null);
  81. }
  82. return super.onAttack(npc, attacker, damage, isSummon);
  83. }
  84. @Override
  85. public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isSummon)
  86. {
  87. if (npc.isScriptValue(0))
  88. {
  89. npc.setScriptValue(1);
  90. if (getRandomBoolean())
  91. {
  92. broadcastNpcSay(npc, Say2.NPC_ALL, NpcStringId.YOU_GUYS_ARE_DETECTED);
  93. }
  94. else
  95. {
  96. broadcastNpcSay(npc, Say2.NPC_ALL, NpcStringId.WHAT_KIND_OF_CREATURES_ARE_YOU);
  97. }
  98. startQuestTimer("ATTACK", 6000, npc, player);
  99. startQuestTimer("CLEAR", 120000, npc, null);
  100. }
  101. return super.onAggroRangeEnter(npc, player, isSummon);
  102. }
  103. public static void main(String[] args)
  104. {
  105. new GiantsCave();
  106. }
  107. }