EngineerLekon.java 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. else
  62. return event;
  63. }
  64. @Override
  65. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  66. {
  67. if (player.getQuestState(getName()) == null)
  68. newQuestState(player);
  69. return npc.getNpcId() + ".htm";
  70. }
  71. public EngineerLekon(int questId, String name, String descr)
  72. {
  73. super(questId, name, descr);
  74. addStartNpc(LEKON);
  75. addFirstTalkId(LEKON);
  76. addTalkId(LEKON);
  77. }
  78. public static void main(String[] args)
  79. {
  80. new EngineerLekon(-1, EngineerLekon.class.getSimpleName(), "vehicles");
  81. }
  82. }