GeneralDilios.java 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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.individual;
  16. import java.util.ArrayList;
  17. import java.util.List;
  18. import ai.group_template.L2AttackableAIScript;
  19. import com.l2jserver.gameserver.datatables.SpawnTable;
  20. import com.l2jserver.gameserver.model.L2Spawn;
  21. import com.l2jserver.gameserver.model.actor.L2Npc;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.network.NpcStringId;
  24. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  25. import com.l2jserver.util.Rnd;
  26. /**
  27. * Dilios AI
  28. * @author JIV, Sephiroth, Apocalipce
  29. */
  30. public class GeneralDilios extends L2AttackableAIScript
  31. {
  32. private static final int generalId = 32549;
  33. private static final int guardId = 32619;
  34. private L2Npc _general;
  35. private final List<L2Npc> _guards = new ArrayList<L2Npc>();
  36. private static final NpcStringId[] diliosText =
  37. {
  38. NpcStringId.MESSENGER_INFORM_THE_PATRONS_OF_THE_KEUCEREUS_ALLIANCE_BASE_WERE_GATHERING_BRAVE_ADVENTURERS_TO_ATTACK_TIATS_MOUNTED_TROOP_THATS_ROOTED_IN_THE_SEED_OF_DESTRUCTION,
  39. // NpcStringId.MESSENGER_INFORM_THE_PATRONS_OF_THE_KEUCEREUS_ALLIANCE_BASE_THE_SEED_OF_DESTRUCTION_IS_CURRENTLY_SECURED_UNDER_THE_FLAG_OF_THE_KEUCEREUS_ALLIANCE,
  40. // NpcStringId.MESSENGER_INFORM_THE_PATRONS_OF_THE_KEUCEREUS_ALLIANCE_BASE_TIATS_MOUNTED_TROOP_IS_CURRENTLY_TRYING_TO_RETAKE_SEED_OF_DESTRUCTION_COMMIT_ALL_THE_AVAILABLE_REINFORCEMENTS_INTO_SEED_OF_DESTRUCTION,
  41. NpcStringId.MESSENGER_INFORM_THE_BROTHERS_IN_KUCEREUS_CLAN_OUTPOST_BRAVE_ADVENTURERS_WHO_HAVE_CHALLENGED_THE_SEED_OF_INFINITY_ARE_CURRENTLY_INFILTRATING_THE_HALL_OF_EROSION_THROUGH_THE_DEFENSIVELY_WEAK_HALL_OF_SUFFERING,
  42. // NpcStringId.MESSENGER_INFORM_THE_BROTHERS_IN_KUCEREUS_CLAN_OUTPOST_SWEEPING_THE_SEED_OF_INFINITY_IS_CURRENTLY_COMPLETE_TO_THE_HEART_OF_THE_SEED_EKIMUS_IS_BEING_DIRECTLY_ATTACKED_AND_THE_UNDEAD_REMAINING_IN_THE_HALL_OF_SUFFERING_ARE_BEING_ERADICATED,
  43. NpcStringId.MESSENGER_INFORM_THE_PATRONS_OF_THE_KEUCEREUS_ALLIANCE_BASE_THE_SEED_OF_INFINITY_IS_CURRENTLY_SECURED_UNDER_THE_FLAG_OF_THE_KEUCEREUS_ALLIANCE
  44. // NpcStringId.MESSENGER_INFORM_THE_PATRONS_OF_THE_KEUCEREUS_ALLIANCE_BASE_THE_RESURRECTED_UNDEAD_IN_THE_SEED_OF_INFINITY_ARE_POURING_INTO_THE_HALL_OF_SUFFERING_AND_THE_HALL_OF_EROSION
  45. // NpcStringId.MESSENGER_INFORM_THE_BROTHERS_IN_KUCEREUS_CLAN_OUTPOST_EKIMUS_IS_ABOUT_TO_BE_REVIVED_BY_THE_RESURRECTED_UNDEAD_IN_SEED_OF_INFINITY_SEND_ALL_REINFORCEMENTS_TO_THE_HEART_AND_THE_HALL_OF_SUFFERING
  46. };
  47. public GeneralDilios(int questId, String name, String descr)
  48. {
  49. super(questId, name, descr);
  50. findNpcs();
  51. if (_general == null || _guards.isEmpty())
  52. throw new NullPointerException("Cannot find npcs!");
  53. startQuestTimer("command_0", 60000, null, null);
  54. }
  55. public void findNpcs()
  56. {
  57. for (L2Spawn spawn : SpawnTable.getInstance().getSpawnTable())
  58. if (spawn != null)
  59. if (spawn.getNpcid() == generalId)
  60. _general = spawn.getLastSpawn();
  61. else if (spawn.getNpcid() == guardId)
  62. _guards.add(spawn.getLastSpawn());
  63. }
  64. @Override
  65. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  66. {
  67. if (event.startsWith("command_"))
  68. {
  69. int value = Integer.parseInt(event.substring(8));
  70. if (value < 6)
  71. {
  72. _general.broadcastPacket(new NpcSay(_general.getObjectId(), 0, generalId, NpcStringId.STABBING_THREE_TIMES));
  73. startQuestTimer("guard_animation_0", 3400, null, null);
  74. }
  75. else
  76. {
  77. value = -1;
  78. _general.broadcastPacket(new NpcSay(_general.getObjectId(), 1, generalId, diliosText[Rnd.get(diliosText.length)]));
  79. }
  80. startQuestTimer("command_" + (value + 1), 60000, null, null);
  81. }
  82. else if (event.startsWith("guard_animation_"))
  83. {
  84. int value = Integer.parseInt(event.substring(16));
  85. for (L2Npc guard : _guards)
  86. {
  87. guard.broadcastSocialAction(4);
  88. }
  89. if (value < 2)
  90. startQuestTimer("guard_animation_" + (value + 1), 1500, null, null);
  91. }
  92. return super.onAdvEvent(event, npc, player);
  93. }
  94. public static void main(String[] args)
  95. {
  96. new GeneralDilios(-1, "GeneralDilios", "ai");
  97. }
  98. }