BlackJudge.java 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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.BlackJudge;
  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.model.itemcontainer.Inventory;
  24. import com.l2jserver.gameserver.network.SystemMessageId;
  25. import com.l2jserver.gameserver.network.serverpackets.EtcStatusUpdate;
  26. /**
  27. * Black Judge AI.
  28. * @author St3eT
  29. */
  30. public class BlackJudge extends AbstractNpcAI
  31. {
  32. // NPC
  33. private static final int BLACK_JUDGE = 30981;
  34. // Misc
  35. // @formatter:off
  36. private static final int[] COSTS =
  37. {
  38. 3600, 8640, 25200, 50400, 86400, 144000
  39. };
  40. // @formatter:on
  41. private BlackJudge()
  42. {
  43. super(BlackJudge.class.getSimpleName(), "ai/npc");
  44. addStartNpc(BLACK_JUDGE);
  45. addTalkId(BLACK_JUDGE);
  46. addFirstTalkId(BLACK_JUDGE);
  47. }
  48. @Override
  49. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  50. {
  51. String htmltext = null;
  52. final int level = ((player.getExpertiseLevel() < 5) ? player.getExpertiseLevel() : 5);
  53. switch (event)
  54. {
  55. case "remove_info":
  56. {
  57. htmltext = "30981-0" + (level + 1) + ".html";
  58. break;
  59. }
  60. case "remove_dp":
  61. {
  62. if (player.getDeathPenaltyBuffLevel() > 0)
  63. {
  64. int cost = COSTS[level];
  65. if (player.getAdena() >= cost)
  66. {
  67. takeItems(player, Inventory.ADENA_ID, cost);
  68. player.setDeathPenaltyBuffLevel(player.getDeathPenaltyBuffLevel() - 1);
  69. player.sendPacket(SystemMessageId.DEATH_PENALTY_LIFTED);
  70. player.sendPacket(new EtcStatusUpdate(player));
  71. }
  72. else
  73. {
  74. htmltext = "30981-07.html";
  75. }
  76. }
  77. else
  78. {
  79. htmltext = "30981-08.html";
  80. }
  81. break;
  82. }
  83. }
  84. return htmltext;
  85. }
  86. public static void main(String[] args)
  87. {
  88. new BlackJudge();
  89. }
  90. }