Making a skill that targets an ally and harms all enemies.

As the title says, I'm looking for a way to make an ability where youtarget an ally but also affect enemies. The one I had in mind specifically is a skill that heals an ally and cleanse them from harmful status effects, then deal damage to all enemies equal to 30% of the ally's HP after they were healed. Optional would be to also deal damage based on how many status effects were cleansed.

Is this possible to do? I have all of the Yanfly plugins, especially Target Core. But Target Core doesn't have an option for targetting one ally and all enemies at the same time. So how do I do this?
You can use Action sequencing to do this.
Action Sequence huh? Hmm, I haven't really used action sequences for this purpose before. Not sure how to do that.
Action Sequence huh? Hmm, I haven't really used action sequences for this purpose before. Not sure how to do that.

It looks like the documentation for Action Sequences is here: https://www.yanfly.moe/wiki/Category:Action_Sequences_(MV)

It mentions in the section on targeting that we can use "target" to refer to the target of the skill, and "all enemies" to refer to all enemies, which sound like the things we'll want to use in this case.

So we can use the "ACTION EFFECT: target" sequence to run the effect from our skill, and store the right amount in a variable. If we have our skill do the heal with a damage formula something like $gameVariables.setValue(4, (0.3*a.mat)); a.mat , that will carry out that part. Then we'll want to do an "HP -VARIABLE 4: all enemies, show" on the enemies to reduce their HP. I think that would work?
Action sequencing does way more than make cool animations.

You'd make your skill target 1 ally HP recovery damage formula, then in your sequence you could:
Code:
action effect //Does your skill's action effect. Heal/dmg/any other effects like adding/removing states
EVAL: user.opponentsUnit().aliveMembers().forEach(e => { e.gainHp(-target.hp * 0.3); e.startDamagePopup(); }); //this will dmg all alive enemies with 30% of the current HP of whoever you healed and start a damage popup for it.
Now this is the bare minimum and you'll likely add some effects and timings and whatnot.

Adding more damage based on states removed is a little more complex and out of my paygrade I'm afraid, but there are plenty of more skilled people here than I who can help out too.
Action sequencing does way more than make cool animations.

You'd make your skill target 1 ally HP recovery damage formula, then in your sequence you could:
Code:
action effect //Does your skill's action effect. Heal/dmg/any other effects like adding/removing states
EVAL: user.opponentsUnit().aliveMembers().forEach(e => { e.gainHp(-target.hp * 0.3); e.startDamagePopup(); }); //this will dmg all alive enemies with 30% of the current HP of whoever you healed and start a damage popup for it.
Now this is the bare minimum and you'll likely add some effects and timings and whatnot.

Adding more damage based on states removed is a little more complex and out of my paygrade I'm afraid, but there are plenty of more skilled people here than I who can help out too.
So I went and did what you asked and I encountered several issues.
  1. The cast animation seem to play twice after the first time the animation play and takes effect on the allied target
  2. The damage looks like... the one shown on the image below (it doesn't even play the hit sfx), while the target gets healed a second time.
  3. If the enemies die to it, they don't play any death sound or disappear. They just stay there and the victory music plays.
1772265309620.png

Did I do smth wrong with the Action Sequence? It's been awhile since I've used them in my games. Here's what I had assembled for this spell:
Code:
<Setup Action>
display action
immotal: target, true
perform start
wait for movement
cast animation
wait for animation
</Setup Action>
<Target Action>
perform action
motion spell: user
action animation
wait for animation
action effect
EVAL: user.opponentsUnit().aliveMembers().forEach(e => { e.gainHp(-target.hp * 0.3); e.startDamagePopup(); })
death break
</Target Action>
<Finish Action>
immortal: targets, false
clear battle log
perform finish
wait for movement
</Finish Action>

Also I want to attach an element to the damage part of the spell. How do I do that?
So I went and did what you asked and I encountered several issues.
  1. The cast animation seem to play twice after the first time the animation play and takes effect on the allied target
  2. The damage looks like... the one shown on the image below (it doesn't even play the hit sfx), while the target gets healed a second time.
  3. If the enemies die to it, they don't play any death sound or disappear. They just stay there and the victory music plays.
View attachment 361756
Did I do smth wrong with the Action Sequence? It's been awhile since I've used them in my games. Here's what I had assembled for this spell:
Code:
<Setup Action>
display action
immotal: target, true
perform start
wait for movement
cast animation
wait for animation
</Setup Action>
<Target Action>
perform action
motion spell: user
action animation
wait for animation
action effect
EVAL: user.opponentsUnit().aliveMembers().forEach(e => { e.gainHp(-target.hp * 0.3); e.startDamagePopup(); })
death break
</Target Action>
<Finish Action>
immortal: targets, false
clear battle log
perform finish
wait for movement
</Finish Action>

Also I want to attach an element to the damage part of the spell. How do I do that?
Well that's just because you set up the action sequence and skill wrong. I wasn't aware how little you knew about the plugins. You also have typos in your sequence.

There's no need to do a perform action, immediately followed by a motion command. Perform action already does the motion specified in the weapon.

Death break at this position does nothing because there's nothing to skip and you certainly don't want the finish action to skip if you got stuff like clear battle log and immortal: targets, false in there.

The hit sounds/animations don't play on a gainHP eval because it's not technically a "hit". You'll have to add those to the sequence yourself.
In any case, try this:
Code:
<Setup Action>
display action
immortal: target, true
perform start
wait for movement
cast animation
wait for animation
</Setup Action>

<Target Action>
perform action
action animation
wait for animation
action effect
se: your hit sound name, volume, pitch
EVAL: $gameTroop.aliveMembers().forEach(e=>e.startAnimation(animation_ID,false,0));
EVAL: user.opponentsUnit().aliveMembers().forEach(e => { e.gainHp(-target.hp * 0.3); e.startDamagePopup(); })
EVAL: $gameTroop.members().forEach(e=>{if(e.isDead())e.performCollapse();});
wait for animation
</Target Action>

<Finish Action>
immortal: targets, false
clear battle log
perform finish
wait for movement
</Finish Action>

This is certainly a more involved way of doing it than what the previous poster had suggested, although they did have some wrong stuff in there. It's not possible to attach an element to this because the code in this sequence is not a regular hit, it reduces the enemy HP directly with the specified formula, since you never said anything about needing that.

Edit: I'm not sure what's up with your damage numbers here. It doesn't do that on my end when testing.



It doesn't show a casting animation for me because I'm not using them, so maybe see if my sequence still does it.
Well that's just because you set up the action sequence and skill wrong. I wasn't aware how little you knew about the plugins. You also have typos in your sequence.

There's no need to do a perform action, immediately followed by a motion command. Perform action already does the motion specified in the weapon.

Death break at this position does nothing because there's nothing to skip and you certainly don't want the finish action to skip if you got stuff like clear battle log and immortal: targets, false in there.

The hit sounds/animations don't play on a gainHP eval because it's not technically a "hit". You'll have to add those to the sequence yourself.
In any case, try this:
Code:
<Setup Action>
display action
immortal: target, true
perform start
wait for movement
cast animation
wait for animation
</Setup Action>

<Target Action>
perform action
action animation
wait for animation
action effect
se: your hit sound name, volume, pitch
EVAL: $gameTroop.aliveMembers().forEach(e=>e.startAnimation(animation_ID,false,0));
EVAL: user.opponentsUnit().aliveMembers().forEach(e => { e.gainHp(-target.hp * 0.3); e.startDamagePopup(); })
EVAL: $gameTroop.members().forEach(e=>{if(e.isDead())e.performCollapse();});
wait for animation
</Target Action>

<Finish Action>
immortal: targets, false
clear battle log
perform finish
wait for movement
</Finish Action>

This is certainly a more involved way of doing it than what the previous poster had suggested, although they did have some wrong stuff in there. It's not possible to attach an element to this because the code in this sequence is not a regular hit, it reduces the enemy HP directly with the specified formula, since you never said anything about needing that.

Edit: I'm not sure what's up with your damage numbers here. It doesn't do that on my end when testing.



It doesn't show a casting animation for me because I'm not using them, so maybe see if my sequence still does it.

Sorry about that. I haven't really tinkered around the Action Sequence plugin for a very long time. The most recent game I'm making barely uses it besides making sure the user does the correct animation for weapon-based skills. Not to mention real life being busy.

The code I used was from an old, discontinued project of mine, which I also copied from somewhere in the forums to do a simple basic action sequence. I tried a simplified sequence consisting only a Target Action but it still does the same thing, though at one point all it did is heal the target ally twice and not deal damage which is why I pulled the old code to see if smth would change.

Anyhow, thank you so much for these suggestions. I'll try testing them out later and see if it works in my end.

EDIT: Could the weird damage numbers be due to the heal formula on the formula section? For context, I made the skill heal for a.mat * 3. Here's a screenshot for reference.

1772285687280.png


Also I went to test your new sequence and it worked but the weird numbers still pop up.
Could the weird damage numbers be due to the heal formula on the formula section?
the cause of that is normally because of a decimal value. you need to round your numbers. its done automatically by damage dealt with a formula but gainHp doesnt do it for you
I've finally figured out how to fix the double casting issue! I simply gave an animation to the second cast (which I must've forgotten to add back then).

The issue still remains about the damage looking all too weird.

the cause of that is normally because of a decimal value. you need to round your numbers. its done automatically by damage dealt with a formula but gainHp doesnt do it for you

So do I just use a flat number or how do I do it with the other guy's given formula? The damage has to be 30% of the healed ally's remaining HP.

EDIT: I also have Yanfly's Damage Core plugin. Any way that can be used for the formula?
when you use gainHp, you bypass the damage formula. anything the damage core will do will by bypassed by such a call.

use
Code:
EVAL: user.opponentsUnit().aliveMembers().forEach(e => { e.gainHp(Math.ceil(-target.hp * 0.3)); e.startDamagePopup(); })
when you use gainHp, you bypass the damage formula. anything the damage core will do will by bypassed by such a call.

use
Code:
EVAL: user.opponentsUnit().aliveMembers().forEach(e => { e.gainHp(Math.ceil(-target.hp * 0.3)); e.startDamagePopup(); })
Yoo, that worked! Thanks so much for the help.

Original thread: https://forums.rpgmakerweb.com/threads/making-a-skill-that-targets-an-ally-and-harms-all-enemies.182653/