EffectSilentMove.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 com.l2jserver.gameserver.skills.effects;
  16. import com.l2jserver.gameserver.model.CharEffectList;
  17. import com.l2jserver.gameserver.model.L2Effect;
  18. import com.l2jserver.gameserver.network.SystemMessageId;
  19. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  20. import com.l2jserver.gameserver.skills.Env;
  21. import com.l2jserver.gameserver.templates.effects.EffectTemplate;
  22. import com.l2jserver.gameserver.templates.skills.L2EffectType;
  23. import com.l2jserver.gameserver.templates.skills.L2SkillType;
  24. public class EffectSilentMove extends L2Effect
  25. {
  26. public EffectSilentMove(Env env, EffectTemplate template)
  27. {
  28. super(env, template);
  29. }
  30. // Special constructor to steal this effect
  31. public EffectSilentMove(Env env, L2Effect effect)
  32. {
  33. super(env, effect);
  34. }
  35. /**
  36. *
  37. * @see com.l2jserver.gameserver.model.L2Effect#effectCanBeStolen()
  38. */
  39. @Override
  40. protected boolean effectCanBeStolen()
  41. {
  42. return true;
  43. }
  44. /**
  45. *
  46. * @see com.l2jserver.gameserver.model.L2Effect#onStart()
  47. */
  48. @Override
  49. public boolean onStart()
  50. {
  51. super.onStart();
  52. return true;
  53. }
  54. /**
  55. *
  56. * @see com.l2jserver.gameserver.model.L2Effect#onExit()
  57. */
  58. @Override
  59. public void onExit()
  60. {
  61. super.onExit();
  62. }
  63. /**
  64. *
  65. * @see com.l2jserver.gameserver.model.L2Effect#getEffectType()
  66. */
  67. @Override
  68. public L2EffectType getEffectType()
  69. {
  70. return L2EffectType.SILENT_MOVE;
  71. }
  72. /**
  73. *
  74. * @see com.l2jserver.gameserver.model.L2Effect#onActionTime()
  75. */
  76. @Override
  77. public boolean onActionTime()
  78. {
  79. // Only cont skills shouldn't end
  80. if (getSkill().getSkillType() != L2SkillType.CONT)
  81. return false;
  82. if (getEffected().isDead())
  83. return false;
  84. double manaDam = calc();
  85. if (manaDam > getEffected().getCurrentMp())
  86. {
  87. getEffected().sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SKILL_REMOVED_DUE_LACK_MP));
  88. return false;
  89. }
  90. getEffected().reduceCurrentMp(manaDam);
  91. return true;
  92. }
  93. /* (non-Javadoc)
  94. * @see com.l2jserver.gameserver.model.L2Effect#getEffectFlags()
  95. */
  96. @Override
  97. public int getEffectFlags()
  98. {
  99. return CharEffectList.EFFECT_FLAG_SILENT_MOVE;
  100. }
  101. }