CombatPointHeal.java 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. public void useSkill(L2Character actChar, L2Skill skill, L2Object[] targets)
  41. {
  42. //check for other effects
  43. ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(L2SkillType.BUFF);
  44. if (handler != null)
  45. handler.useSkill(actChar, skill, targets);
  46. for (L2Character target: (L2Character[]) targets)
  47. {
  48. if (target.isInvul())
  49. continue;
  50. double cp = skill.getPower();
  51. cp = Math.min(cp, target.getMaxRecoverableCp() - target.getCurrentCp());
  52. // Prevent negative amounts
  53. if (cp < 0)
  54. cp = 0;
  55. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CP_WILL_BE_RESTORED);
  56. sm.addNumber((int) cp);
  57. target.sendPacket(sm);
  58. target.setCurrentCp(cp + target.getCurrentCp());
  59. StatusUpdate sump = new StatusUpdate(target);
  60. sump.addAttribute(StatusUpdate.CUR_CP, (int) target.getCurrentCp());
  61. target.sendPacket(sump);
  62. }
  63. }
  64. public L2SkillType[] getSkillIds()
  65. {
  66. return SKILL_IDS;
  67. }
  68. }