MV Looking for help developing a battle mechanic (Aftershock)

Hello,


I'm looking to implement a mechanic into my battle system that I call Aftershock. I'll explain how I'm trying to make it function, and I'll also explain how I would not like it to function.

First, the basic premise is that when a condition is met such as state affliction, when the target takes damage, they will then cause an Aftershock that damages those around it for a lesser amount. I would also like this to be possible for healing so that every time a target receives a heal, other party members receive about 60% of the primary target's healing. Essentially, it goes like this.
1) Use a skill on an enemy that causes the Aftershock state.
2) Whenever that enemy takes damage from, say, a physical attack, or a blunt attack, or an electric attack, or whichever element is chosen, it will then ricochet and deal, say, 60% of that damage to each other enemy (but not hitting itself that second time). It would be preferable if I could make it so that only single target attacks can trigger this, rather than AOE attacks. I would also like it to trigger multiple times if the target is struck multiple times via Yanfly Action sequence.

I get the feeling that Yanfly's counter plugin will come in handy here, but can't quite get it right since countering with all allies means the main target will also be affected by that second hit.

Here is how I would not like it to function; I don't want to use an AOE plugin to turn single target attacks into aoe attacks. It's very important that the aftershock happens in response to a single target attack, rather than simply transforming the single target attack into an all enemies attack.

It's a bit late so I can't think of much more, but I'll drop a TLDR below
E1.................. P1
E2.................. P2
E3.................. P3
E4................... P4

>P3 inflicts Aftershock to E2
>P1 attacks E2 with a physical attack for 100 damage
>E2 takes 100 damage, triggering aftershock
>E1, E3, E4 each take 60 damage, but E2 does not take an additional 60 damage

Same idea in reverse for healing.

I know this is super specific so I'll completely understand if I'm unable to reach a conclusion.
I don't have every nuance figured out since I haven't had much time this morning to play with it before work, but I believe I've solved this once I discovered the existence of Yanfly's Target plugin in addition to critical control. Somehow glanced over target control dozens of times without seeing the application for it. I don't want to delete this just yet, but I'd say this is 85% solved.

Original thread: https://forums.rpgmakerweb.com/threads/looking-for-help-developing-a-battle-mechanic-aftershock.127325/