GiantsCave.java 3.2 KB

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