GiftOfVitality.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 events.GiftOfVitality;
  16. import com.l2jserver.gameserver.datatables.SkillTable;
  17. import com.l2jserver.gameserver.model.actor.L2Npc;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. import com.l2jserver.gameserver.model.event.LongTimeEvent;
  20. import com.l2jserver.gameserver.model.quest.QuestState;
  21. import com.l2jserver.gameserver.model.quest.State;
  22. import com.l2jserver.gameserver.network.SystemMessageId;
  23. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  24. /**
  25. * Gift of Vitality event AI.
  26. * @author Gnacik
  27. */
  28. public class GiftOfVitality extends LongTimeEvent
  29. {
  30. // Reuse between buffs
  31. private static final int HOURS = 5;
  32. // NPC
  33. private static final int JACK = 4306;
  34. public GiftOfVitality(int questId, String name, String descr)
  35. {
  36. super(questId, name, descr);
  37. addStartNpc(JACK);
  38. addFirstTalkId(JACK);
  39. addTalkId(JACK);
  40. }
  41. @Override
  42. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  43. {
  44. String htmltext = event;
  45. QuestState st = player.getQuestState(getName());
  46. if (event.equalsIgnoreCase("vitality"))
  47. {
  48. long _reuse = 0;
  49. String _streuse = st.get("reuse");
  50. if (_streuse != null)
  51. {
  52. _reuse = Long.parseLong(_streuse);
  53. }
  54. if (_reuse > System.currentTimeMillis())
  55. {
  56. long remainingTime = (_reuse - System.currentTimeMillis()) / 1000;
  57. int hours = (int) (remainingTime / 3600);
  58. int minutes = (int) ((remainingTime % 3600) / 60);
  59. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.AVAILABLE_AFTER_S1_S2_HOURS_S3_MINUTES);
  60. sm.addSkillName(23179);
  61. sm.addNumber(hours);
  62. sm.addNumber(minutes);
  63. player.sendPacket(sm);
  64. htmltext = "4306-notime.htm";
  65. }
  66. else
  67. {
  68. npc.setTarget(player);
  69. // Gift of Vitality
  70. npc.doCast(SkillTable.getInstance().getInfo(23179, 1));
  71. st.setState(State.STARTED);
  72. st.set("reuse", String.valueOf(System.currentTimeMillis() + (HOURS * 3600000)));
  73. htmltext = "4306-okvitality.htm";
  74. }
  75. }
  76. else if (event.equalsIgnoreCase("memories_player"))
  77. {
  78. if (player.getLevel() < 76)
  79. {
  80. htmltext = "4306-nolevel.htm";
  81. }
  82. else
  83. {
  84. npc.setTarget(player);
  85. npc.doCast(SkillTable.getInstance().getInfo(5627, 1)); // Wind Walk
  86. npc.doCast(SkillTable.getInstance().getInfo(5628, 1)); // Shield
  87. npc.doCast(SkillTable.getInstance().getInfo(5637, 1)); // Magic Barrier
  88. if (player.isMageClass())
  89. {
  90. npc.doCast(SkillTable.getInstance().getInfo(5633, 1)); // Bless the Soul
  91. npc.doCast(SkillTable.getInstance().getInfo(5634, 1)); // Acumen
  92. npc.doCast(SkillTable.getInstance().getInfo(5635, 1)); // Concentration
  93. npc.doCast(SkillTable.getInstance().getInfo(5636, 1)); // Empower
  94. }
  95. else
  96. {
  97. npc.doCast(SkillTable.getInstance().getInfo(5629, 1)); // Bless the Body
  98. npc.doCast(SkillTable.getInstance().getInfo(5630, 1)); // Vampiric Rage
  99. npc.doCast(SkillTable.getInstance().getInfo(5631, 1)); // Regeneration
  100. npc.doCast(SkillTable.getInstance().getInfo(5632, 1)); // Haste
  101. }
  102. htmltext = "4306-okbuff.htm";
  103. }
  104. }
  105. else if (event.equalsIgnoreCase("memories_summon"))
  106. {
  107. if (player.getLevel() < 76)
  108. {
  109. htmltext = "4306-nolevel.htm";
  110. }
  111. else if (!player.hasSummon() || !player.getSummon().isServitor())
  112. {
  113. htmltext = "4306-nosummon.htm";
  114. }
  115. else
  116. {
  117. npc.setTarget(player.getSummon());
  118. npc.doCast(SkillTable.getInstance().getInfo(5627, 1)); // Wind Walk
  119. npc.doCast(SkillTable.getInstance().getInfo(5628, 1)); // Shield
  120. npc.doCast(SkillTable.getInstance().getInfo(5637, 1)); // Magic Barrier
  121. npc.doCast(SkillTable.getInstance().getInfo(5629, 1)); // Bless the Body
  122. npc.doCast(SkillTable.getInstance().getInfo(5633, 1)); // Bless the Soul
  123. npc.doCast(SkillTable.getInstance().getInfo(5630, 1)); // Vampiric Rage
  124. npc.doCast(SkillTable.getInstance().getInfo(5634, 1)); // Acumen
  125. npc.doCast(SkillTable.getInstance().getInfo(5631, 1)); // Regeneration
  126. npc.doCast(SkillTable.getInstance().getInfo(5635, 1)); // Concentration
  127. npc.doCast(SkillTable.getInstance().getInfo(5632, 1)); // Haste
  128. npc.doCast(SkillTable.getInstance().getInfo(5636, 1)); // Empower
  129. htmltext = "4306-okbuff.htm";
  130. }
  131. }
  132. return htmltext;
  133. }
  134. @Override
  135. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  136. {
  137. if (player.getQuestState(getName()) == null)
  138. {
  139. newQuestState(player);
  140. }
  141. return "4306.htm";
  142. }
  143. public static void main(String[] args)
  144. {
  145. new GiftOfVitality(-1, GiftOfVitality.class.getSimpleName(), "events");
  146. }
  147. }