CombatPointHeal.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 handlers.skillhandlers;
  16. import com.l2jserver.gameserver.handler.ISkillHandler;
  17. import com.l2jserver.gameserver.handler.SkillHandler;
  18. import com.l2jserver.gameserver.model.L2Object;
  19. import com.l2jserver.gameserver.model.L2Skill;
  20. import com.l2jserver.gameserver.model.actor.L2Character;
  21. import com.l2jserver.gameserver.network.SystemMessageId;
  22. import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
  23. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  24. import com.l2jserver.gameserver.templates.skills.L2SkillType;
  25. /**
  26. * This class ...
  27. *
  28. * @version $Revision: 1.1.2.2.2.1 $ $Date: 2005/03/02 15:38:36 $
  29. */
  30. public class CombatPointHeal implements ISkillHandler
  31. {
  32. private static final L2SkillType[] SKILL_IDS =
  33. {
  34. L2SkillType.COMBATPOINTHEAL
  35. };
  36. /**
  37. *
  38. * @see com.l2jserver.gameserver.handler.ISkillHandler#useSkill(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.L2Skill, com.l2jserver.gameserver.model.L2Object[])
  39. */
  40. @Override
  41. public void useSkill(L2Character actChar, L2Skill skill, L2Object[] targets)
  42. {
  43. //check for other effects
  44. ISkillHandler handler = SkillHandler.getInstance().getHandler(L2SkillType.BUFF);
  45. if (handler != null)
  46. handler.useSkill(actChar, skill, targets);
  47. for (L2Character target: (L2Character[]) targets)
  48. {
  49. if (target.isInvul())
  50. continue;
  51. double cp = skill.getPower();
  52. cp = Math.min(cp, target.getMaxRecoverableCp() - target.getCurrentCp());
  53. // Prevent negative amounts
  54. if (cp < 0)
  55. cp = 0;
  56. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CP_WILL_BE_RESTORED);
  57. sm.addNumber((int) cp);
  58. target.sendPacket(sm);
  59. target.setCurrentCp(cp + target.getCurrentCp());
  60. StatusUpdate sump = new StatusUpdate(target);
  61. sump.addAttribute(StatusUpdate.CUR_CP, (int) target.getCurrentCp());
  62. target.sendPacket(sump);
  63. }
  64. }
  65. @Override
  66. public L2SkillType[] getSkillIds()
  67. {
  68. return SKILL_IDS;
  69. }
  70. }