Recoil Damage State

Hey there. I have a bit of a headscratcher here.
I thought how can I make a state that would deal percentage of the damage dealt back at the attacker, but all other threads refer to the Skills, and I need a State.
Similarly, this State should also harm the healer if they cast a healing spell by the percentage of the amount they heal to the target.
I'm a complete zero at JavaScript, but I do have YanFly plugins, so any help would be appreciated
If you have the Yanfly suite (still wondering where people are getting that capital F in Yanfly from), then you can use the Thornmail tip and trick.
If you have the Yanfly suite (still wondering where people are getting that capital F in Yanfly from), then you can use the Thornmail tip and trick.
You have a point about the capital F, lol
But I keep tripping on the Thornmail tip and trick. Thornmail State makes you deal damage back at the enemy, but I wanna make it so that the actor, basically, punches themselves back.
And, if you heal, you damage yourself by the amount you healed.
I tried swapping user and target in the Thornmail State, didn't work
I tried swapping user and target in the Thornmail State, didn't work
it wouldnt. react effects trigger then the battler with the state is on the receiving end of an action. swapping the user and the target wouldnt change that. replace the react effect with a confirm effect so that it activates when the battler with the states make their action instead of then they get hit.

how can I make a state that would deal percentage of the damage dealt back at the attacker... this State should also harm the healer if they cast a healing spell by the percentage of the amount they heal to the target.
Code:
<custom confirm effect>
var rate = .5;
if (this.isDamage() && value > 0)
    user.gainHp(-Math.ceil(rate*value));
else if (this.isRecover() && value < 0)
    user.gainHp(Math.ceil(rate*value));
if (user.hp === 0)
    user.performCollapse();
</custom confirm effect>
that should make it so that the user takes damage equal to 50% of the damage or healing they dealt. adjust the first line as needed to change the rate at which the affected battler takes damage.
it wouldnt. react effects trigger then the battler with the state is on the receiving end of an action. swapping the user and the target wouldnt change that. replace the react effect with a confirm effect so that it activates when the battler with the states make their action instead of then they get hit.


Code:
<custom confirm effect>
var rate = .5;
if (this.isDamage() && value > 0)
    user.gainHp(-Math.ceil(rate*value));
else if (this.isRecover() && value < 0)
    user.gainHp(Math.ceil(rate*value));
if (user.hp === 0)
    user.performCollapse();
</custom confirm effect>
that should make it so that the user takes damage equal to 50% of the damage or healing they dealt. adjust the first line as needed to change the rate at which the affected battler takes damage.
Yup, it works!
Thank you so much!

Original thread: https://forums.rpgmakerweb.com/threads/recoil-damage-state.173293/