FameManager.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * Copyright (C) 2004-2014 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.FameManager;
  20. import ai.npc.AbstractNpcAI;
  21. import com.l2jserver.gameserver.model.actor.L2Npc;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.network.SystemMessageId;
  24. import com.l2jserver.gameserver.network.serverpackets.UserInfo;
  25. /**
  26. * Fame Manager AI.
  27. * @author St3eT
  28. */
  29. public final class FameManager extends AbstractNpcAI
  30. {
  31. // Npc
  32. private static final int[] FAME_MANAGER =
  33. {
  34. 36479, // Rapidus
  35. 36480, // Scipio
  36. };
  37. // Misc
  38. private static final int MIN_LVL = 40;
  39. private static final int DECREASE_COST = 5000;
  40. private static final int REPUTATION_COST = 1000;
  41. private static final int MIN_CLAN_LVL = 5;
  42. private static final int CLASS_LVL = 2;
  43. private FameManager()
  44. {
  45. super(FameManager.class.getSimpleName(), "ai/npc");
  46. addStartNpc(FAME_MANAGER);
  47. addTalkId(FAME_MANAGER);
  48. addFirstTalkId(FAME_MANAGER);
  49. }
  50. @Override
  51. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  52. {
  53. String htmltext = null;
  54. switch (event)
  55. {
  56. case "36479.html":
  57. case "36479-02.html":
  58. case "36479-07.html":
  59. case "36480.html":
  60. case "36480-02.html":
  61. case "36480-07.html":
  62. {
  63. htmltext = event;
  64. break;
  65. }
  66. case "decreasePk":
  67. {
  68. if (player.getPkKills() > 0)
  69. {
  70. if ((player.getFame() >= DECREASE_COST) && (player.getLevel() >= MIN_LVL) && (player.getClassId().level() >= CLASS_LVL))
  71. {
  72. player.setFame(player.getFame() - DECREASE_COST);
  73. player.setPkKills(player.getPkKills() - 1);
  74. player.sendPacket(new UserInfo(player));
  75. htmltext = npc.getId() + "-06.html";
  76. }
  77. else
  78. {
  79. htmltext = npc.getId() + "-01.html";
  80. }
  81. }
  82. else
  83. {
  84. htmltext = npc.getId() + "-05.html";
  85. }
  86. break;
  87. }
  88. case "clanRep":
  89. {
  90. if ((player.getClan() != null) && (player.getClan().getLevel() >= MIN_CLAN_LVL))
  91. {
  92. if ((player.getFame() >= REPUTATION_COST) && (player.getLevel() >= MIN_LVL) && (player.getClassId().level() >= CLASS_LVL))
  93. {
  94. player.setFame(player.getFame() - REPUTATION_COST);
  95. player.getClan().addReputationScore(50, true);
  96. player.sendPacket(new UserInfo(player));
  97. player.sendPacket(SystemMessageId.ACQUIRED_50_CLAN_FAME_POINTS);
  98. htmltext = npc.getId() + "-04.html";
  99. }
  100. else
  101. {
  102. htmltext = npc.getId() + "-01.html";
  103. }
  104. }
  105. else
  106. {
  107. htmltext = npc.getId() + "-03.html";
  108. }
  109. break;
  110. }
  111. }
  112. return htmltext;
  113. }
  114. @Override
  115. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  116. {
  117. return ((player.getFame() > 0) && (player.getLevel() >= MIN_LVL) && (player.getClassId().level() >= CLASS_LVL)) ? npc.getId() + ".html" : npc.getId() + "-01.html";
  118. }
  119. public static void main(String[] args)
  120. {
  121. new FameManager();
  122. }
  123. }