CastleWarehouse.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.CastleWarehouse;
  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 Warehouse Keeper AI.
  25. * @author malyelfik
  26. */
  27. public final class CastleWarehouse extends AbstractNpcAI
  28. {
  29. // NPCs
  30. private static final int[] NPCS =
  31. {
  32. 35099, // Warehouse Keeper (Gludio)
  33. 35141, // Warehouse Keeper (Dion)
  34. 35183, // Warehouse Keeper (Giran)
  35. 35225, // Warehouse Keeper (Oren)
  36. 35273, // Warehouse Keeper (Aden)
  37. 35315, // Warehouse Keeper (Inadril)
  38. 35362, // Warehouse Keeper (Goddard)
  39. 35508, // Warehouse Keeper (Rune)
  40. 35554, // Warehouse Keeper (Schuttgart)
  41. };
  42. // Items
  43. private static final int BLOOD_OATH = 9910;
  44. private static final int BLOOD_ALLIANCE = 9911;
  45. private CastleWarehouse()
  46. {
  47. super(CastleWarehouse.class.getSimpleName(), "ai/npc");
  48. addStartNpc(NPCS);
  49. addTalkId(NPCS);
  50. addFirstTalkId(NPCS);
  51. }
  52. @Override
  53. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  54. {
  55. String htmltext = event;
  56. switch (event)
  57. {
  58. case "warehouse-01.html":
  59. case "warehouse-02.html":
  60. case "warehouse-03.html":
  61. break;
  62. case "warehouse-04.html":
  63. htmltext = (!npc.isMyLord(player)) ? "warehouse-no.html" : getHtm(player.getHtmlPrefix(), "warehouse-04.html").replace("%blood%", Integer.toString(player.getClan().getBloodAllianceCount()));
  64. break;
  65. case "Receive":
  66. if (!npc.isMyLord(player))
  67. {
  68. htmltext = "warehouse-no.html";
  69. }
  70. else if (player.getClan().getBloodAllianceCount() == 0)
  71. {
  72. htmltext = "warehouse-05.html";
  73. }
  74. else
  75. {
  76. giveItems(player, BLOOD_ALLIANCE, player.getClan().getBloodAllianceCount());
  77. player.getClan().resetBloodAllianceCount();
  78. htmltext = "warehouse-06.html";
  79. }
  80. break;
  81. case "Exchange":
  82. if (!npc.isMyLord(player))
  83. {
  84. htmltext = "warehouse-no.html";
  85. }
  86. else if (!hasQuestItems(player, BLOOD_ALLIANCE))
  87. {
  88. htmltext = "warehouse-08.html";
  89. }
  90. else
  91. {
  92. takeItems(player, BLOOD_ALLIANCE, 1);
  93. giveItems(player, BLOOD_OATH, 30);
  94. htmltext = "warehouse-07.html";
  95. }
  96. break;
  97. default:
  98. htmltext = null;
  99. break;
  100. }
  101. return htmltext;
  102. }
  103. @Override
  104. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  105. {
  106. return "warehouse-01.html";
  107. }
  108. public static void main(String[] args)
  109. {
  110. new CastleWarehouse();
  111. }
  112. }