Remove State by Damage Amount

I'm using Yanflys BuffsStatesCore and want to make a State be removed by a specific amount of damage.
So if my actor takes 500 points of damage than state drops off.
This is what I was trying out in the state note box with no luck:
Code:
<Custom Respond Effect>
user.hp - 500;
</Custom Respond Effect>

<Custom Establish Effect>
user.removeState(69);
</Custom Establish Effect>

Could someone please help me with the proper syntax.

Thanks.
Do you want the 500 damage to occur all at once or can it be between multiple hits?

For one hit:
<Custom Respond Effect>
if (value >= 500) {
target.removeState(69);
}
</Custom Respond Effect>

Over the course of multiple hits is a little tougher, but it should look something like this:
<Custom Apply Effect>
user._stateDamage = user._stateDamage || 0;
</Custom Apply Effect>

<Custom Respond Effect>
target._stateDamage = target._stateDamage || 0;
target._stateDamage += value;
if (target._stateDamage >= 500) {
target.removeState(69);
}
</Custom Respond Effect>

<Custom Remove Effect>
user._stateDamage = undefined;
</Custom Remove Effect>

This is a rough idea of how it should look. You can change the bold variables and numbers to fit your needs.
That worked perfectly.

Thanks a lot!

Original thread: https://forums.rpgmakerweb.com/threads/remove-state-by-damage-amount.76108/