CpDam.java 2.7 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.model.L2Object;
  18. import com.l2jserver.gameserver.model.ShotType;
  19. import com.l2jserver.gameserver.model.actor.L2Character;
  20. import com.l2jserver.gameserver.model.skills.L2Skill;
  21. import com.l2jserver.gameserver.model.skills.L2SkillType;
  22. import com.l2jserver.gameserver.model.stats.Env;
  23. import com.l2jserver.gameserver.model.stats.Formulas;
  24. public class CpDam implements ISkillHandler
  25. {
  26. private static final L2SkillType[] SKILL_IDS =
  27. {
  28. L2SkillType.CPDAM
  29. };
  30. @Override
  31. public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
  32. {
  33. if (activeChar.isAlikeDead())
  34. {
  35. return;
  36. }
  37. boolean ss = skill.isPhysical() && activeChar.isChargedShot(ShotType.SOULSHOTS);
  38. boolean sps = skill.isMagic() && activeChar.isChargedShot(ShotType.SPIRITSHOTS);
  39. boolean bss = skill.isMagic() && activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS);
  40. for (L2Character target : (L2Character[]) targets)
  41. {
  42. if (activeChar.isPlayer() && target.isPlayer() && target.getActingPlayer().isFakeDeath())
  43. {
  44. target.stopFakeDeath(true);
  45. }
  46. else if (target.isDead() || target.isInvul())
  47. {
  48. continue;
  49. }
  50. byte shld = Formulas.calcShldUse(activeChar, target, skill);
  51. int damage = (int) (target.getCurrentCp() - (target.getCurrentCp() - skill.getPower()));
  52. // Manage attack or cast break of the target (calculating rate, sending message...)
  53. if (!target.isRaid() && Formulas.calcAtkBreak(target, damage))
  54. {
  55. target.breakAttack();
  56. target.breakCast();
  57. }
  58. skill.getEffects(activeChar, target, new Env(shld, ss, sps, bss));
  59. activeChar.sendDamageMessage(target, damage, false, false, false);
  60. target.setCurrentCp(target.getCurrentCp() - damage);
  61. }
  62. activeChar.setChargedShot(bss ? ShotType.BLESSED_SPIRITSHOTS : ShotType.SPIRITSHOTS, false);
  63. }
  64. @Override
  65. public L2SkillType[] getSkillIds()
  66. {
  67. return SKILL_IDS;
  68. }
  69. }