Help applying custom triggers/effects for states (Yanfly Buffs&States Core)

Hey.

Of course, I am a complete stranger to javascript but when it comes to game design, I tend to have a lot of ambitious ideas brewing
so you could say I bite off more than I can chew.

Anyway, I'm working on some states in my game which are "Wound states" that occur as actors lose HP - inspired from the Long War mod for XCOM: Enemy Unknown (or Enemy Within, take your pick).

Here's how it goes.
Actors would gradually lose their stats (ATK, DEF, AGI, etc.) as he/she loses HP.
Rather than apply a different state for each increment of HP an actor loses, I'd like the state penalty to be applies dynamically
according to the current HP level - do you see where I'm getting at?

In addition to this kind of state, I'm also working on more permanent states that decrease an actors Max HP according to how much damage he/she takes. For example, take damage that amount to around 25% of an actors Max HP, he/she suffers a light wound state that reduces that stat to 75%. Finally, if an actor suffers damage that is at least 75% of his/her Max HP, he/she gets a wound state that reduces it to 25%.

So I'm wondering if anyone knows how to write these triggers in javascript.
Thanks.
Sorry if this is inappropriate but I am still eager to know a solution to my query.
I have those plugins isntalled,

1. for this to work states need to update, but states are a dataObject. they have no methods(functions). Yanfly has special notetags that let you add an effect at certain points. unfortunately taking damage is not one of them. the closest is "Respond". but that won't take into account when the character takes multiple dmamages. (unless you calculate it from the last turn, kinda hacky). makign a plugin would solve the headaches of some of it.

It can be done using Yanfly's Lunatic Mode , Debuffs and modifying the debuff formula.

Spoiler: Yanflys Buff Events
Code:
Quick Reference:

Action Starts
- Attacker: Initiate
- Defender: Select
Action Connects as a Success Hit, skip if Missed or Evaded
- Attacker: Confirm
- Defender: React
Damage is Applied to the Defender
- Defender: Respond //we want this
- Attacker: Establish
These occur regardless if the action is successfully hit.
- Defender: Deselect
- Attacker: Conclude

also there are some important variables: "value" is damage, "target" is who gets hit, "user" is who made the action.
with these its possible to create what you want.

This creates the second part of your request. this requires the state to be already present. you can use passive States for this.
there holes in it for example anything else that uses buff will cuase descrepencies and glitches.
Code:
if(target.hp / target.mhp < 0.75) {
target.addDebuff(1,99) //Reduces atk when at 75% hp
}
else if(target._buffs[1] < 0){
target._buffs[1] = 0; //strength returns at 75%
}
target.refresh()

the second part is bascially the same.

Original thread: https://forums.rpgmakerweb.com/threads/help-applying-custom-triggers-effects-for-states-yanfly-buffs-states-core.82520/