EffectSilentMove.java 2.8 KB

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