CastleSiegeManager.java 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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.npc.CastleSiegeManager;
  20. import ai.npc.AbstractNpcAI;
  21. import com.l2jserver.gameserver.model.actor.L2Npc;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. /**
  24. * Castle Siege Manager AI.
  25. * @author St3eT
  26. */
  27. public final class CastleSiegeManager extends AbstractNpcAI
  28. {
  29. // NPCs
  30. private static final int[] SIEGE_MANAGER =
  31. {
  32. 35104, // Gludio Castle
  33. 35146, // Dion Castle
  34. 35188, // Giran Castle
  35. 35232, // Oren Castle
  36. 35278, // Aden Castle
  37. 35320, // Innadril Castle
  38. 35367, // Goddard Castle
  39. 35513, // Rune Castle
  40. 35559, // Schuttgard Castle
  41. 35639, // Fortress of the Dead
  42. 35420, // Devastated Castle
  43. };
  44. private CastleSiegeManager()
  45. {
  46. super(CastleSiegeManager.class.getSimpleName(), "ai/npc");
  47. addFirstTalkId(SIEGE_MANAGER);
  48. }
  49. @Override
  50. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  51. {
  52. String htmltext = null;
  53. if (player.isClanLeader() && (player.getClanId() == npc.getCastle().getOwnerId()))
  54. {
  55. if (isInSiege(npc))
  56. {
  57. htmltext = "CastleSiegeManager.html";
  58. }
  59. else
  60. {
  61. htmltext = "CastleSiegeManager-01.html";
  62. }
  63. }
  64. else if (isInSiege(npc))
  65. {
  66. htmltext = "CastleSiegeManager-02.html";
  67. }
  68. else
  69. {
  70. if (npc.getConquerableHall() != null)
  71. {
  72. npc.getConquerableHall().showSiegeInfo(player);
  73. }
  74. else
  75. {
  76. npc.getCastle().getSiege().listRegisterClan(player);
  77. }
  78. }
  79. return htmltext;
  80. }
  81. private boolean isInSiege(L2Npc npc)
  82. {
  83. if ((npc.getConquerableHall() != null) && npc.getConquerableHall().isInSiege())
  84. {
  85. return true;
  86. }
  87. else if (npc.getCastle().getSiege().isInProgress())
  88. {
  89. return true;
  90. }
  91. return false;
  92. }
  93. public static void main(String[] args)
  94. {
  95. new CastleSiegeManager();
  96. }
  97. }