ManaHeal.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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.handler.skillhandlers;
  16. import net.sf.l2j.gameserver.handler.ISkillHandler;
  17. import net.sf.l2j.gameserver.model.L2Character;
  18. import net.sf.l2j.gameserver.model.L2Object;
  19. import net.sf.l2j.gameserver.model.L2Skill;
  20. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  21. import net.sf.l2j.gameserver.network.SystemMessageId;
  22. import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
  23. import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  24. import net.sf.l2j.gameserver.skills.Stats;
  25. import net.sf.l2j.gameserver.templates.L2SkillType;
  26. /**
  27. * This class ...
  28. *
  29. * @version $Revision: 1.1.2.2.2.1 $ $Date: 2005/03/02 15:38:36 $
  30. */
  31. public class ManaHeal implements ISkillHandler
  32. {
  33. private static final L2SkillType[] SKILL_IDS =
  34. {
  35. L2SkillType.MANAHEAL,
  36. L2SkillType.MANARECHARGE,
  37. L2SkillType.MANAHEAL_PERCENT
  38. };
  39. /**
  40. *
  41. * @see net.sf.l2j.gameserver.handler.ISkillHandler#useSkill(net.sf.l2j.gameserver.model.L2Character, net.sf.l2j.gameserver.model.L2Skill, net.sf.l2j.gameserver.model.L2Object[])
  42. */
  43. public void useSkill(L2Character actChar, L2Skill skill, L2Object[] targets)
  44. {
  45. L2Character target = null;
  46. for (int index = 0; index < targets.length; index++)
  47. {
  48. target = (L2Character) targets[index];
  49. double mp = skill.getPower();
  50. if (skill.getSkillType() == L2SkillType.MANAHEAL_PERCENT)
  51. {
  52. //double mp = skill.getPower();
  53. mp = target.getMaxMp() * mp / 100.0;
  54. }
  55. else
  56. {
  57. mp = (skill.getSkillType() == L2SkillType.MANARECHARGE) ? target.calcStat(Stats.RECHARGE_MP_RATE, mp, null, null) : mp;
  58. }
  59. //int cLev = activeChar.getLevel();
  60. //hp += skill.getPower()/*+(Math.sqrt(cLev)*cLev)+cLev*/;
  61. target.setLastHealAmount((int) mp);
  62. target.setCurrentMp(mp + target.getCurrentMp());
  63. StatusUpdate sump = new StatusUpdate(target.getObjectId());
  64. sump.addAttribute(StatusUpdate.CUR_MP, (int) target.getCurrentMp());
  65. target.sendPacket(sump);
  66. if (actChar instanceof L2PcInstance && actChar != target)
  67. {
  68. SystemMessage sm = new SystemMessage(SystemMessageId.S2_MP_RESTORED_BY_S1);
  69. sm.addString(actChar.getName());
  70. sm.addNumber((int) mp);
  71. target.sendPacket(sm);
  72. }
  73. else
  74. {
  75. SystemMessage sm = new SystemMessage(SystemMessageId.S1_MP_RESTORED);
  76. sm.addNumber((int) mp);
  77. target.sendPacket(sm);
  78. }
  79. }
  80. }
  81. /**
  82. *
  83. * @see net.sf.l2j.gameserver.handler.ISkillHandler#getSkillIds()
  84. */
  85. public L2SkillType[] getSkillIds()
  86. {
  87. return SKILL_IDS;
  88. }
  89. }