L2SkillCharge.java 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 net.sf.l2j.gameserver.skills.l2skills;
  16. import net.sf.l2j.gameserver.model.L2Object;
  17. import net.sf.l2j.gameserver.model.L2Skill;
  18. import net.sf.l2j.gameserver.model.actor.L2Character;
  19. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  20. import net.sf.l2j.gameserver.network.SystemMessageId;
  21. import net.sf.l2j.gameserver.network.serverpackets.EtcStatusUpdate;
  22. import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  23. import net.sf.l2j.gameserver.skills.effects.EffectCharge;
  24. import net.sf.l2j.gameserver.templates.StatsSet;
  25. public class L2SkillCharge extends L2Skill {
  26. public L2SkillCharge(StatsSet set)
  27. {
  28. super(set);
  29. }
  30. @Override
  31. public void useSkill(L2Character caster, L2Object[] targets)
  32. {
  33. if (caster.isAlikeDead())
  34. return;
  35. // get the effect
  36. EffectCharge effect = (EffectCharge) caster.getFirstEffect(this);
  37. if (effect != null)
  38. {
  39. if (effect.numCharges < getNumCharges())
  40. {
  41. effect.numCharges++;
  42. if (caster instanceof L2PcInstance)
  43. {
  44. caster.sendPacket(new EtcStatusUpdate((L2PcInstance)caster));
  45. SystemMessage sm = new SystemMessage(SystemMessageId.FORCE_INCREASED_TO_S1);
  46. sm.addNumber(effect.numCharges);
  47. caster.sendPacket(sm);
  48. }
  49. }
  50. else
  51. {
  52. SystemMessage sm = new SystemMessage(SystemMessageId.FORCE_MAXIMUM);
  53. caster.sendPacket(sm);
  54. }
  55. return;
  56. }
  57. getEffects(caster, caster);
  58. //effect self :]
  59. //L2Effect seffect = caster.getEffect(getId());
  60. //TODO ?? this is always null due to a return in the if block above!
  61. //if (effect != null && seffect.isSelfEffect())
  62. //{
  63. //Replace old effect with new one.
  64. // seffect.exit();
  65. //}
  66. // cast self effect if any
  67. getEffectsSelf(caster);
  68. }
  69. }