CpDamPercent.java 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (C) 2004-2013 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package handlers.skillhandlers;
  20. import com.l2jserver.gameserver.handler.ISkillHandler;
  21. import com.l2jserver.gameserver.model.L2Object;
  22. import com.l2jserver.gameserver.model.ShotType;
  23. import com.l2jserver.gameserver.model.actor.L2Character;
  24. import com.l2jserver.gameserver.model.skills.L2Skill;
  25. import com.l2jserver.gameserver.model.skills.L2SkillType;
  26. import com.l2jserver.gameserver.model.stats.Env;
  27. import com.l2jserver.gameserver.model.stats.Formulas;
  28. public class CpDamPercent implements ISkillHandler
  29. {
  30. private static final L2SkillType[] SKILL_IDS =
  31. {
  32. L2SkillType.CPDAMPERCENT
  33. };
  34. @Override
  35. public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
  36. {
  37. if (activeChar.isAlikeDead())
  38. {
  39. return;
  40. }
  41. boolean ss = skill.useSoulShot() && activeChar.isChargedShot(ShotType.SOULSHOTS);
  42. boolean sps = skill.useSpiritShot() && activeChar.isChargedShot(ShotType.SPIRITSHOTS);
  43. boolean bss = skill.useSpiritShot() && activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS);
  44. for (L2Character target : (L2Character[]) targets)
  45. {
  46. if (activeChar.isPlayer() && target.isPlayer() && target.getActingPlayer().isFakeDeath())
  47. {
  48. target.stopFakeDeath(true);
  49. }
  50. else if (target.isDead() || target.isInvul())
  51. {
  52. continue;
  53. }
  54. byte shld = Formulas.calcShldUse(activeChar, target, skill);
  55. int damage = (int) (target.getCurrentCp() * (skill.getPower() / 100));
  56. // Manage attack or cast break of the target (calculating rate, sending message...)
  57. if (!target.isRaid() && Formulas.calcAtkBreak(target, damage))
  58. {
  59. target.breakAttack();
  60. target.breakCast();
  61. }
  62. skill.getEffects(activeChar, target, new Env(shld, ss, sps, bss));
  63. activeChar.sendDamageMessage(target, damage, false, false, false);
  64. target.setCurrentCp(target.getCurrentCp() - damage);
  65. }
  66. activeChar.setChargedShot(bss ? ShotType.BLESSED_SPIRITSHOTS : ShotType.SPIRITSHOTS, false);
  67. }
  68. @Override
  69. public L2SkillType[] getSkillIds()
  70. {
  71. return SKILL_IDS;
  72. }
  73. }