How to add an incapacitated state at 50% hp?

For context, I've wanted to add a Dnd style hp system where taking enough damage kills someone outright. Originally, I wanted to have another health bar that would appear when your 1st health bar is at 0, one that would come with a lower target rate and no actions. This 2nd health bar would drain unless treated by another party member. Any damage would decrease the health and re-add the status "hemorrhaging". In the event this health bar reaches 0, the party member dies and is removed.

This is what I wrote in the scripts. It's probably garbage, I copied the formatting of the OG death state script as much as possible. I'm totally new to this, so any help at all would be greatly appreciated.

#I have no idea what I'm doing here's half dead
def half_dead_state?
state?(half_dead_id)
end

def half_dead_id
return 55
end

def half_dead_id
half_dead_id = state_id 55
end
def half_dead
@hp = 0.5 * mhp ? add_state(half_dead_id) : remove_state(half_dead_id)
end
end

I've moved this thread to Learning Ruby. Thank you.


I moved it here since you are working on the code yourself. If you'd prefer to try to find someone to do it for you, I can move it to script requests.
Moved to: Learning Ruby
I moved it here since you are working on the code yourself. If you'd prefer to try to find someone to do it for you, I can move it to script requests.
Ok, thank you
You could set variables to actors max HP before battle and divide those variables by 2.

Then, in battle events, you could set different variables to each actors current HP each turn, then use conditional branches to check if the second variable is lower than the first variable. Then apply a second state and remove the first one

Original thread: https://forums.rpgmakerweb.com/threads/how-to-add-an-incapacitated-state-at-50-hp.147053/