Help with Counterattack skill that deals more damage based on damage taken in that specific turn or how low is user's hp to hit harder.

i saw a great guide on formulas and skills in this site (not formula 101 but equally great) but i can´t find it again, so now i´m again trying to figure out a counter attack skill that deal more damage based on damage taken in that specific turn or how low is user's hp. either is fine, i already set a counter state in database, but i don´t know how to modify that counter damage
damage based on damage taken in that specific turn
you didnt mention plugins, but i dont think that one is easily doable without plugins. Easiest way i can see it needs yanfly's buffs & states

or how low is user's hp.
that one is easy enough, but you didnt really mention how much it should scale by. you can use a.hpRate() in the formula to reference the attacker's hp% and do something along the lines of multiplying the formula by (1-a.hpRate())

Original thread: https://forums.rpgmakerweb.com/threads/help-with-counterattack-skill-that-deals-more-damage-based-on-damage-taken-in-that-specific-turn-or-how-low-is-users-hp-to-hit-harder.169109/