States that absorb % incoming damage first using Yanfly Buff and States Core

Hello....
As the tittle said, I want to make States that the holder will recover some % incoming physical attack damage taken.
I'm using Yanfly Buff and States Core : http://www.yanfly.moe/wiki/Buffs_&_States_Core_(YEP) and using
this script

<Custom React Effect>
if (value > 0 && this.isPhysical()){
var heal = value * 0.3;
target.gainHp(heal);
target.startDamagePopup();
target.startAnimation(41);
value = value * 1;}
</Custom React Effect>

However... the heals comes first.
How to make the heals comes after the damage?

Sorry I don't have knowledge in scripting and still newbie
Try:

<Custom Establish Effect>
if (value > 0 && this.isPhysical()){
var heal = Math.floor(value * 0.3);
user.gainHp(heal);
user.startDamagePopup();
user.startAnimation(41);}
</Custom Establish Effect>


Scratch that, this will trigger when actor strikes opponent and 30% of damage he strikes will heal.

Your code seems to be ok, perhaps you missunderstood something with this plugin.
The heal still happens first using my code

Original thread: https://forums.rpgmakerweb.com/threads/states-that-absorb-incoming-damage-first-using-yanfly-buff-and-states-core.139109/