EffectSilentMove.java 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 net.sf.l2j.gameserver.skills.effects;
  16. import net.sf.l2j.gameserver.model.L2Character;
  17. import net.sf.l2j.gameserver.model.L2Effect;
  18. import net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance;
  19. import net.sf.l2j.gameserver.network.SystemMessageId;
  20. import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  21. import net.sf.l2j.gameserver.skills.Env;
  22. import net.sf.l2j.gameserver.templates.L2SkillType;
  23. final class EffectSilentMove extends L2Effect
  24. {
  25. public EffectSilentMove(Env env, EffectTemplate template)
  26. {
  27. super(env, template);
  28. }
  29. /**
  30. *
  31. * @see net.sf.l2j.gameserver.model.L2Effect#onStart()
  32. */
  33. @Override
  34. public void onStart()
  35. {
  36. super.onStart();
  37. L2Character effected = getEffected();
  38. if (effected instanceof L2PlayableInstance)
  39. ((L2PlayableInstance) effected).setSilentMoving(true);
  40. }
  41. /**
  42. *
  43. * @see net.sf.l2j.gameserver.model.L2Effect#onExit()
  44. */
  45. @Override
  46. public void onExit()
  47. {
  48. super.onExit();
  49. L2Character effected = getEffected();
  50. if (effected instanceof L2PlayableInstance)
  51. ((L2PlayableInstance) effected).setSilentMoving(false);
  52. }
  53. /**
  54. *
  55. * @see net.sf.l2j.gameserver.model.L2Effect#getEffectType()
  56. */
  57. @Override
  58. public EffectType getEffectType()
  59. {
  60. return EffectType.SILENT_MOVE;
  61. }
  62. /**
  63. *
  64. * @see net.sf.l2j.gameserver.model.L2Effect#onActionTime()
  65. */
  66. @Override
  67. public boolean onActionTime()
  68. {
  69. // Only cont skills shouldn't end
  70. if (getSkill().getSkillType() != L2SkillType.CONT)
  71. return false;
  72. if (getEffected().isDead())
  73. return false;
  74. double manaDam = calc();
  75. if (manaDam > getEffected().getCurrentMp())
  76. {
  77. SystemMessage sm = new SystemMessage(SystemMessageId.SKILL_REMOVED_DUE_LACK_MP);
  78. getEffected().sendPacket(sm);
  79. return false;
  80. }
  81. getEffected().reduceCurrentMp(manaDam);
  82. return true;
  83. }
  84. }