CastleBlacksmith.java 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.CastleBlacksmith;
  20. import ai.npc.AbstractNpcAI;
  21. import com.l2jserver.gameserver.model.ClanPrivilege;
  22. import com.l2jserver.gameserver.model.PcCondOverride;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. /**
  26. * Castle Blacksmith AI.
  27. * @author malyelfik
  28. */
  29. public final class CastleBlacksmith extends AbstractNpcAI
  30. {
  31. // Blacksmith IDs
  32. private static final int[] NPCS =
  33. {
  34. 35098, // Blacksmith (Gludio)
  35. 35140, // Blacksmith (Dion)
  36. 35182, // Blacksmith (Giran)
  37. 35224, // Blacksmith (Oren)
  38. 35272, // Blacksmith (Aden)
  39. 35314, // Blacksmith (Innadril)
  40. 35361, // Blacksmith (Goddard)
  41. 35507, // Blacksmith (Rune)
  42. 35553, // Blacksmith (Schuttgart)
  43. };
  44. private CastleBlacksmith()
  45. {
  46. super(CastleBlacksmith.class.getSimpleName(), "ai/npc");
  47. addStartNpc(NPCS);
  48. addTalkId(NPCS);
  49. addFirstTalkId(NPCS);
  50. }
  51. private boolean hasRights(L2PcInstance player, L2Npc npc)
  52. {
  53. return player.canOverrideCond(PcCondOverride.CASTLE_CONDITIONS) || npc.isMyLord(player) || ((player.getClanId() == npc.getCastle().getOwnerId()) && player.hasClanPrivilege(ClanPrivilege.CS_MANOR_ADMIN));
  54. }
  55. @Override
  56. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  57. {
  58. return (event.equalsIgnoreCase(npc.getId() + "-02.html") && hasRights(player, npc)) ? event : null;
  59. }
  60. @Override
  61. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  62. {
  63. return (hasRights(player, npc)) ? npc.getId() + "-01.html" : "no.html";
  64. }
  65. public static void main(String[] args)
  66. {
  67. new CastleBlacksmith();
  68. }
  69. }