EngineerLekon.java 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package vehicles.EngineerLekon;
  16. import com.l2jserver.gameserver.instancemanager.AirShipManager;
  17. import com.l2jserver.gameserver.model.actor.L2Npc;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. import com.l2jserver.gameserver.model.quest.Quest;
  20. import com.l2jserver.gameserver.network.SystemMessageId;
  21. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  22. public class EngineerLekon extends Quest
  23. {
  24. private static final int LEKON = 32557;
  25. private static final int LICENSE = 13559;
  26. private static final int STARSTONE = 13277;
  27. private static final int LICENSE_COST = 10;
  28. private static final SystemMessage SM_NEED_CLANLVL5 = SystemMessage.getSystemMessage(SystemMessageId.THE_AIRSHIP_NEED_CLANLVL_5_TO_SUMMON);
  29. private static final SystemMessage SM_NO_PRIVS = SystemMessage.getSystemMessage(SystemMessageId.THE_AIRSHIP_NO_PRIVILEGES);
  30. private static final SystemMessage SM_LICENSE_ALREADY_ACQUIRED = SystemMessage.getSystemMessage(SystemMessageId.THE_AIRSHIP_SUMMON_LICENSE_ALREADY_ACQUIRED);
  31. @Override
  32. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  33. {
  34. if ("license".equalsIgnoreCase(event))
  35. {
  36. if (player.getClan() == null || player.getClan().getLevel() < 5)
  37. {
  38. player.sendPacket(SM_NEED_CLANLVL5);
  39. return null;
  40. }
  41. if (!player.isClanLeader())
  42. {
  43. player.sendPacket(SM_NO_PRIVS);
  44. return null;
  45. }
  46. if (AirShipManager.getInstance().hasAirShipLicense(player.getClanId()))
  47. {
  48. player.sendPacket(SM_LICENSE_ALREADY_ACQUIRED);
  49. return null;
  50. }
  51. if (player.getInventory().getItemByItemId(LICENSE) != null)
  52. {
  53. player.sendPacket(SM_LICENSE_ALREADY_ACQUIRED);
  54. return null;
  55. }
  56. if (!player.destroyItemByItemId("AirShipLicense", STARSTONE, LICENSE_COST, npc, true))
  57. return null;
  58. player.addItem("AirShipLicense", LICENSE, 1, npc, true);
  59. return null;
  60. }
  61. return event;
  62. }
  63. @Override
  64. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  65. {
  66. if (player.getQuestState(getName()) == null)
  67. newQuestState(player);
  68. return npc.getNpcId() + ".htm";
  69. }
  70. public EngineerLekon(int questId, String name, String descr)
  71. {
  72. super(questId, name, descr);
  73. addStartNpc(LEKON);
  74. addFirstTalkId(LEKON);
  75. addTalkId(LEKON);
  76. }
  77. public static void main(String[] args)
  78. {
  79. new EngineerLekon(-1, EngineerLekon.class.getSimpleName(), "vehicles");
  80. }
  81. }