Drain user and heal ally skill

Greetings,

So I've been trying to figure out how to create a skill that causes the user to lose 15% of their health and heal another and equal amount to the life lost. If this would kill the user then the skill can not be used.

I believe this is possible and I don't think a plugin is needed. Can this all be done with a damage formula or is script needed?

Ill be interested to hear opinions or solutions. Thanks in advance.
You should be definitely able to do it using your skill formula box.
  1. Set your skill to be a healing skill so that you can target the ally you want to heal
  2. In your formula box use
    Code:
    r = (a.mhp * 15) / 100; a.gainHp(-1*r); r
    If you want to use caster's current HP instead of maximum hp you can use
    Code:
    (a.hp * 15) / 100
    This prevents the caster from dying.
  3. Set the value to be a fixed value if you want to transfer the exact same amount (no variance at all).
I didn't test this but it should theoretically work.
If you want to use 15% of the user's maximum HP and still prevent them from dying, you can try this:
Code:
Math.min(a.mhp * 15 / 100, a.hp - 1)
which takes the smaller value between 15% of maximum HP, or all current HP - 1.
The above replies should work, but I notice you mentioned this:
If this would kill the user then the skill can not be used.
...and I think that would require a plugin. 😅

Assuming it doesn't conflict with anything you're currently using, Yanfly's Skill Core should work here. Set the skill to Recover HP, target 1 Ally, and give it a formula along the lines of:
Code:
a.mhp * 0.15
Then, to specify the HP cost, add this notetag to the skill's notebox:
Code:
<HP Cost: 15%>
The plugin should then not only prevent you from using this skill if you don't have enough HP, but also display the HP cost (by default in red text) where you'd normally see the MP/TP cost. ^_^
I want to thank all of you for the many different view points. I already have Yanfly's Skill Core so that seems a simple solution, If I have any problems I'll try:

r = (a.hp * 15) / 100; a.gainHp(-1*r); r

I also want to say that the RPG Maker community is really friendly and helpful. I'm really enjoying being a part of it. You each responded so fast! Thank you all again.

Original thread: https://forums.rpgmakerweb.com/threads/drain-user-and-heal-ally-skill.95581/