How to heal the party when using a damage-dealing attack?

I've got a magic attack set up to call a Common Event. The magic attack deals damage to all enemies. I'd like it to then also heal the entire party. However, I have two problems with this:

- I don't know how to check which actors are currently in the battle. I'm using Yanfly's Party script, so technically I can have more than 4 actors in the party. How do I know which 4 are the ones in the battle?

- When using "Change HP" on an actor, they don't get a damage popup. How can I add one?
Well, I think we can try an approach using a sort of "fake skill" combined with some coding:

• In the database creates a fake skill like that:
Spoiler
upload_2017-7-31_13-16-13.png

• SCOPE 1 ALLY;
• NO MP COST (Or if you want set it);
• IN BATTLE;
• EFFECT --> Set as effect the recovery of HP (100% or what you want);
• ANIMATION: Set your animation;
• MESSAGE: Set a message for the log (Maybe something not related to the user of the skill!)
• NO TP GAINING (Or if you want you can set a value)

In your common event, set this script:

Code:
var party = $gameParty.battleMembers().filter(function(member) { return member.isAlive() });
party.forEach(function(member) {
var action = new Game_Action(member, true)
action.setSkill(skillId)
return action.apply(member) })
BattleManager.refreshStatus();
party.forEach(function(member) { member.startDamagePopup() })
SceneManager._scene._logWindow.startAction(BattleManager.actor(), action, party)
SceneManager._scene._logWindow.clear()

So, you will create a var where you store all the battleMembers and in particular filtering the one alive;
For each of them you create a new action that will use the fake skill you created;
We will push the damage popup for the recovery;
Update the log window!
You don't need it to be so complicated. If you have Yanfly Skill Core, you can do this instead (no need to call a common event either):

Code:
<Post-Damage Eval>
var heal = VALUE; // Replace with how much hp you want to heal

var members = $gameParty.battleMembers();

for (var i = 0; i < members.length; i++) {
var ally = members[i];
if (ally.isDead()) continue;
ally.gainHp(heal);
ally.startDamagePopup();
ally.clearResult();
}
</Post-Damage Eval>
@Naveed Oh, yeah! I forget about the skill core lol ! Good try! 😂
Thanks, guys! Both work like a charm. Very useful to learn this. 🙂
Im not sure if i am writing to the right spot. I have been looking for some help for this specific subject but slightly different version of it. I hesitated to open a post about it also hesitated to write here because last message was years ago but here it goes. I started using the code Naveed provided with skill core and it works like a charm but its for all party members. I have little to no skill on coding. Im still getting the grasp of it. How can i make this code work for one random ally and also another one for just the user. Im trying to make variations of this healing method for a class all together but couldnt do it. Thanks in advance.
@Rhestael This is one helluva necropost. You gotta make your own thread instead of posting in one that's been dormant since 2017.
I hesitated to open a post about it
Why? That's what the forum is for. Make a thread, tell us what you're trying to accomplish.
@Rhestael , please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.

And…it’s always better to start your own support thread since, not only has so much time passed this one may have lowered relevancy, but also because your project is your own project so the application may vary. We should also avoid hijacking someone’s support thread (not that this one is being used anymore, but it’s a bad practice).

I would make your own thread but link back to old ones in searches if they provide deeper context for your support query.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-heal-the-party-when-using-a-damage-dealing-attack.82046/