Lekon.java 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 gracia.AI.NPC.Lekon;
  20. import ai.npc.AbstractNpcAI;
  21. import com.l2jserver.gameserver.instancemanager.AirShipManager;
  22. import com.l2jserver.gameserver.model.L2Clan;
  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. /**
  27. * Lekon AI.
  28. * @author St3eT
  29. */
  30. public final class Lekon extends AbstractNpcAI
  31. {
  32. // NPCs
  33. private static final int LEKON = 32557;
  34. // Items
  35. private static final int LICENCE = 13559; // Airship Summon License
  36. private static final int STONE = 13277; // Energy Star Stone
  37. // Misc
  38. private static final int MIN_CLAN_LV = 5;
  39. private static final int STONE_COUNT = 10;
  40. public Lekon()
  41. {
  42. super(Lekon.class.getSimpleName(), "gracia/AI/NPC");
  43. addFirstTalkId(LEKON);
  44. addTalkId(LEKON);
  45. addStartNpc(LEKON);
  46. }
  47. @Override
  48. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  49. {
  50. String htmltext = null;
  51. switch (event)
  52. {
  53. case "32557-01.html":
  54. {
  55. htmltext = event;
  56. break;
  57. }
  58. case "licence":
  59. {
  60. final L2Clan clan = player.getClan();
  61. if ((clan == null) || !player.isClanLeader() || (clan.getLevel() < MIN_CLAN_LV))
  62. {
  63. htmltext = "32557-02.html";
  64. }
  65. else if (hasAtLeastOneQuestItem(player, LICENCE))
  66. {
  67. htmltext = "32557-04.html";
  68. }
  69. else if (AirShipManager.getInstance().hasAirShipLicense(clan.getId()))
  70. {
  71. player.sendPacket(SystemMessageId.THE_AIRSHIP_SUMMON_LICENSE_ALREADY_ACQUIRED);
  72. }
  73. else if (getQuestItemsCount(player, STONE) >= STONE_COUNT)
  74. {
  75. takeItems(player, STONE, STONE_COUNT);
  76. giveItems(player, LICENCE, 1);
  77. }
  78. else
  79. {
  80. htmltext = "32557-03.html";
  81. }
  82. break;
  83. }
  84. }
  85. return htmltext;
  86. }
  87. }