MV Recreating Latent Power from Monster Hunter: World

I am trying to recreate the Skill: Latent Power from Monster Hunter: World & Iceborne as 2 states in RMMV using Yanfly's Buffs and States Core and Auto Passive States.
Spoiler: Latent Power
Temporarily increases affinity and reduces stamina depletion when certain conditions are met.
(Triggers after taking 180 damage or 300 seconds. Reduced to 130 damage with Latent Power Secret. Lasts 120 seconds.)

The 1st state is the stat buffs, the 2nd would act as the conditional cooldown/damage build up.
Currently, I am trying to get the 2nd state to apply the 1st state after either taking a set amount of damage (or % of MHP) or after the 2nd state has expired.

I can get the 1st state to be applied after the 2nd expires, but I am unsure how to get it to apply through damage received.

Alternatively/additionally, if it can be condensed down to just one state, that would help as well.
I am trying to recreate the Skill: Latent Power from Monster Hunter: World & Iceborne as 2 states in RMMV using Yanfly's Buffs and States Core and Auto Passive States.
Welcome! You should realize that most people in a given place won't have played the video games you've played, so referencing skills by name doesn't mean anything to us 😉

You do provide a description for Latent Power, but it's not super helpful because it uses terminology from Monster Hunter that doesn't mean anything in RPG Maker. We need to know what you want it to do.

I can get the 1st state to be applied after the 2nd expires, but I am unsure how to get it to apply through damage received.
There's probably a Yanfly Tip & Trick that demonstrates this, but it's easier to just type it out than it is to look for it.

In your second state you'd put...well, I'm not positive - you reference both a set amount of damage and a % of health, so, again, I don't know what you want the skill to do. I'll make it trigger when you've taken 100 damage.

Code:
<Custom Respond Effect>
user.damReceived=user.damReceived || 0;
if (value>0)
{
    user.damReceived+=value;
    if (user.damReceived>=100)
    {
        user.addState(first_id);
        delete user.damReceived;
    }
}
</Custom Respond Effect>
where first_id is the ID of your first state that you want to add.

If this isn't exactly what you want, we can get it set up if you provide more accurate details.

Alternatively/additionally, if it can be condensed down to just one state, that would help as well.
Again, it depends on what the states do. If their functionality is entirely in notetags, you can probably finagle the code to do what you want in one state. But if you're using anything in the database settings, it should be two separate.
To help clarify, the maximum health in Monster Hunter: World is 200, so taking 180 damage would be 90% of your max health, which is what I was aiming for.

The code works, I just had to swap out "user" with "target" since I didn't want the enemy battlers to get the state when damaging allied battlers.

The only remaining thing I would like is to get it to trigger when the user takes 90% of their max HP, if possible.
The only remaining thing I would like is to get it to trigger when the user takes 90% of their max HP, if possible.
So you'll just change the line I indicated. Instead of the number 100 make it 90% of the max HP: target.mhp*.9
Thank you! Everything is working as intended now.

Original thread: https://forums.rpgmakerweb.com/threads/recreating-latent-power-from-monster-hunter-world.152099/