LoveYourGatekeeper.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 events.LoveYourGatekeeper;
  20. import com.l2jserver.gameserver.model.actor.L2Npc;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.event.LongTimeEvent;
  23. import com.l2jserver.gameserver.model.holders.SkillHolder;
  24. import com.l2jserver.gameserver.model.itemcontainer.Inventory;
  25. import com.l2jserver.gameserver.network.SystemMessageId;
  26. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  27. /**
  28. * Love Your Gatekeeper event.
  29. * @author Gladicek
  30. */
  31. public final class LoveYourGatekeeper extends LongTimeEvent
  32. {
  33. // NPC
  34. private static final int GATEKEEPER = 32477;
  35. // Item
  36. private static final int GATEKEEPER_TRANSFORMATION_STICK = 12814;
  37. // Skills
  38. private static SkillHolder TELEPORTER_TRANSFORM = new SkillHolder(5655, 1);
  39. // Misc
  40. private static final int HOURS = 24;
  41. private static final int PRICE = 10000;
  42. private static final String REUSE = LoveYourGatekeeper.class.getSimpleName() + "_reuse";
  43. private LoveYourGatekeeper()
  44. {
  45. super(LoveYourGatekeeper.class.getSimpleName(), "events");
  46. addStartNpc(GATEKEEPER);
  47. addFirstTalkId(GATEKEEPER);
  48. addTalkId(GATEKEEPER);
  49. }
  50. @Override
  51. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  52. {
  53. switch (event)
  54. {
  55. case "transform_stick":
  56. {
  57. if (player.getAdena() >= PRICE)
  58. {
  59. final long reuse = player.getVariables().getLong(REUSE, 0);
  60. if (reuse > System.currentTimeMillis())
  61. {
  62. final long remainingTime = (reuse - System.currentTimeMillis()) / 1000;
  63. final int hours = (int) (remainingTime / 3600);
  64. final int minutes = (int) ((remainingTime % 3600) / 60);
  65. final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.AVAILABLE_AFTER_S1_S2_HOURS_S3_MINUTES);
  66. sm.addItemName(GATEKEEPER_TRANSFORMATION_STICK);
  67. sm.addInt(hours);
  68. sm.addInt(minutes);
  69. player.sendPacket(sm);
  70. }
  71. else
  72. {
  73. takeItems(player, Inventory.ADENA_ID, PRICE);
  74. giveItems(player, GATEKEEPER_TRANSFORMATION_STICK, 1);
  75. player.getVariables().set(REUSE, System.currentTimeMillis() + (HOURS * 3600000));
  76. }
  77. }
  78. else
  79. {
  80. return "32477-3.htm";
  81. }
  82. return null;
  83. }
  84. case "transform":
  85. {
  86. if (!player.isTransformed())
  87. {
  88. player.doCast(TELEPORTER_TRANSFORM.getSkill());
  89. }
  90. return null;
  91. }
  92. }
  93. return event;
  94. }
  95. @Override
  96. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  97. {
  98. return "32477.htm";
  99. }
  100. public static void main(String[] args)
  101. {
  102. new LoveYourGatekeeper();
  103. }
  104. }