ClanTrader.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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.ClanTrader;
  20. import ai.npc.AbstractNpcAI;
  21. import com.l2jserver.Config;
  22. import com.l2jserver.gameserver.model.ClanPrivilege;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.network.SystemMessageId;
  26. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  27. /**
  28. * Clan Trader AI.
  29. * @author St3eT
  30. */
  31. public final class ClanTrader extends AbstractNpcAI
  32. {
  33. // Npc
  34. private static final int[] CLAN_TRADER =
  35. {
  36. 32024, // Mulia
  37. 32025, // Ilia
  38. };
  39. // Items
  40. private static final int BLOOD_ALLIANCE = 9911; // Blood Alliance
  41. private static final int BLOOD_ALLIANCE_COUNT = 1; // Blood Alliance Count
  42. private static final int BLOOD_OATH = 9910; // Blood Oath
  43. private static final int BLOOD_OATH_COUNT = 10; // Blood Oath Count
  44. private static final int KNIGHTS_EPAULETTE = 9912; // Knight's Epaulette
  45. private static final int KNIGHTS_EPAULETTE_COUNT = 100; // Knight's Epaulette Count
  46. private ClanTrader()
  47. {
  48. super(ClanTrader.class.getSimpleName(), "ai/npc");
  49. addStartNpc(CLAN_TRADER);
  50. addTalkId(CLAN_TRADER);
  51. addFirstTalkId(CLAN_TRADER);
  52. }
  53. private String giveReputation(L2Npc npc, L2PcInstance player, int count, int itemId, int itemCount)
  54. {
  55. if (getQuestItemsCount(player, itemId) >= itemCount)
  56. {
  57. takeItems(player, itemId, itemCount);
  58. player.getClan().addReputationScore(count, true);
  59. final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_ADDED_S1S_POINTS_TO_REPUTATION_SCORE);
  60. sm.addInt(count);
  61. player.sendPacket(sm);
  62. return npc.getId() + "-04.html";
  63. }
  64. return npc.getId() + "-03.html";
  65. }
  66. @Override
  67. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  68. {
  69. String htmltext = null;
  70. switch (event)
  71. {
  72. case "32024.html":
  73. case "32024-02.html":
  74. case "32025.html":
  75. case "32025-02.html":
  76. {
  77. htmltext = event;
  78. break;
  79. }
  80. case "repinfo":
  81. {
  82. htmltext = (player.getClan().getLevel() > 4) ? npc.getId() + "-02.html" : npc.getId() + "-05.html";
  83. break;
  84. }
  85. case "exchange-ba":
  86. {
  87. htmltext = giveReputation(npc, player, Config.BLOODALLIANCE_POINTS, BLOOD_ALLIANCE, BLOOD_ALLIANCE_COUNT);
  88. break;
  89. }
  90. case "exchange-bo":
  91. {
  92. htmltext = giveReputation(npc, player, Config.BLOODOATH_POINTS, BLOOD_OATH, BLOOD_OATH_COUNT);
  93. break;
  94. }
  95. case "exchange-ke":
  96. {
  97. htmltext = giveReputation(npc, player, Config.KNIGHTSEPAULETTE_POINTS, KNIGHTS_EPAULETTE, KNIGHTS_EPAULETTE_COUNT);
  98. break;
  99. }
  100. }
  101. return htmltext;
  102. }
  103. @Override
  104. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  105. {
  106. if (player.isClanLeader() || player.hasClanPrivilege(ClanPrivilege.CL_TROOPS_FAME))
  107. {
  108. return npc.getId() + ".html";
  109. }
  110. return npc.getId() + "-01.html";
  111. }
  112. public static void main(String[] args)
  113. {
  114. new ClanTrader();
  115. }
  116. }