On critical effect - Trying to create a skill with yanfly's plugins

Greetings!
So what I am working on right now is I want a healing spell to have on critical effect. When the healing spell critical heal it will apply a buff (state) that will heal additional hp based on % of the heal that was casted on the target.

So in summery, if a the heal critical healed for 100 it will apply a state that will heal additional 30% of the heal which is 30 for certain amount of turns.

I am still trying to figure out js so I'm still not that good with it.
I'm not a scripter, but I may have a rough solution. You will need Skill Core and Buff & State Core.

1 - Create you healing skill with crit on. Then add it to the eval box:

Code:
<Post-Damage Eval>
if (target.result().critical) {
target.HP_Regen = value;
target.addState(X);
}
</Post-Damage Eval>

2 - Chance X to the ID state of the healing effect.

3 - Create one State with the following code in the eval box:

Code:
<Custom Regenerate Effect>
  // The formula for the regeneration effect. "* 0.3" means 30% of the healing.
  var regen = Math.floor(target.HP_Regen * 0.3);
  // Make the user gain HP.
  user.gainHp(-regen);
  // Show the HP healed.
  user.startDamagePopup();
  // Clear the user's results.
  user.clearResult();
</Custom Regenerate Effect>

4 - The current code heal 30% of the HP healed every turn. You can change it.

As I said, I'm no scripter. Perharps theres a better way to do it.
Edited: oops, I made mistake.

The above looks good! ^_^
Yes! This works!
Thank you so much!

Original thread: https://forums.rpgmakerweb.com/threads/on-critical-effect-trying-to-create-a-skill-with-yanflys-plugins.92480/