EffectSilentMove.java 2.2 KB

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