Skill that heals user and deals damage?

Hi, i'm new, how can i make a skill that deals damage x3 to all enemies and heals once by 10% only who used the skill?
I tried using this formula:

for (var i=0; i < $gameParty.members().length; i+=1) $gameParty.members()[i].gainHp(Math.round($gameParty.members()[i].mhp * 0.10)); a.atk * 2.5 - b.def * 2

but that heals the attacker by 10% for EVERY attack, i just want this to happen 1 time when you use the skill, i really hope there's a solution on that! :/


..should i make a switch that cures who uses the skill? How could i do this? I don't know what to do ;-;

Thanks to anyone who will help :3
My JavaScript isn’t great in this situation but some solutions that come to mind:

1) Heal the user by 3 or 4 percent each time the attack triggers. It won’t be an even 10 but close enough.

2) Action Sequences from Visustella Battle Core will let you do exactly what you want, if you’re familiar with how to use it.
A different approach could be to give the user a state that heals 10% and wears off at end of turn. Or heal the user if they don't have a state that does nothing but wears off at end of turn.

for (var i=0; i < $gameParty.members().length; i+=1) $gameParty.members().gainHp(Math.round($gameParty.members().mhp * 0.10))
I could be wrong, but I feel like there might be an easier way to heal the user;

a.gainHp(a.mhp / 10); [damage]

That should shorten it, unless I misunderstand who is supposed to be healed.
Yeah, I dunno why you're looping when you only want to heal one person. kirb's formula will do exactly what you want.

The skill itself should have a scope of All Enemies, and your "damage x3" doesn't really mean anything - you make the damage formula be whatever you want.
What I was assuming was that the skill would activate 3 times (or the formula will) and putting that formula in would heal the user 30%. He mentioned attacking 3 times and then healing the user 10%. Again, I could be wrong. I really like the invisible state idea!if you make it 1 action long it should immediately heal.

Now that I look at the original formula again…wouldn’t the for loop run x amount of times and the damage run only once?
Alright guys i finally got time to answer, thank y'all for the help :3, tho i just want the user to heal once upon pressing the attack button and never again, if i try to use Kirb's formula it will heal 3 times and attack 3 times, i just want it to heal 1 time and attack 3 times, is there a way or a plugin to do that? Thanks again guys
You were already given solutions for that. Have the attack apply a state to the user which heals them at the end of the turn; or use action sequences to do it during the skill.
if i try to use Kirb's formula it will heal 3 times and attack 3 times
The formula was just cleaning things up, it wouldn't have any change on what you were doing. Try this instead;

a.isStateAffected(stateId) ? a.gainHp(a.mhp / 10); a.addState(stateId); [damage]

Then make a state that does nothing but wear off at end of turn and replace "stateid" with the number of that state. What this will do is check if you have the state, heal you if you don't, then add the state regardless (because it doesn't stack and does nothing if it could), and finally deals damage. The invisible state will wear off before you get your next turn.

It's entirely possible I got some syntax wrong, the following link is amazing for this;
You were already given solutions for that. Have the attack apply a state to the user which heals them at the end of the turn; or use action sequences to do it during the skill.
Alright, tysm, i did it! If anyone wants to know, i used this formula to make it work, using a state:


if (!a.isStateAffected(15)) a.addState(15); a.atk * 2.5 - b.def * 2

(you can just modify the "15" to the number of the state you want to apply)
Alright, tysm, i did it! If anyone wants to know, i used this formula to make it work, using a state:


if (!a.isStateAffected(15)) a.addState(15); a.atk * 2.5 - b.def * 2

(you can just modify the "15" to the number of the state you want to apply)
Awesome! Note that you don't need to check if they don't have the state, either way they will have it and lose it at end of turn.
Awesome! Note that you don't need to check if they don't have the state, either way they will have it and lose it at end of turn.
Thanks for the tip! I'll fix that in my formula ^-^

Original thread: https://forums.rpgmakerweb.com/threads/skill-that-heals-user-and-deals-damage.142901/