Applying a status on a party member when their MP reaches 0

Hey there, Im having trouble finding a way to give a character a status effect if there HP or MP falls beyond a certain point or reaches 0. I know that the "death" status effect does this when HP reaeches zero but I dont know how it does it. It just says "State #1 will be automatically added when HP reaches 0."

Thanks.
Please don't make your text look like that. If you want help, make your post as easy to read as possible. That is not easy to read.


State 1 is death.


State 2 is guard.


You can't mess around with them.


I've moved this thread to RGSS3 Script Requests. Please be sure to post your threads in the correct forum next time. Thank you.
In the script Game_BattlerBase , around line 500 

#-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh state_resist_set.each {|state_id| erase_state(state_id) } @hp = [[@hp, mhp].min, 0].max @mp = [[@mp, mmp].min, 0].max @hp == 0 ? add_state(death_state_id) : remove_state(death_state_id) @mp == 0 ? add_state(id) : remove_state(id) #Add this line to the script endadd @mp == 0 ? add_state(id) : remove_state(id) , and write instead of id the index of the state you want to apply.
In the script Game_BattlerBase , around line 500 

#-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh state_resist_set.each {|state_id| erase_state(state_id) } @hp = [[@hp, mhp].min, 0].max @mp = [[@mp, mmp].min, 0].max @hp == 0 ? add_state(death_state_id) : remove_state(death_state_id) @mp == 0 ? add_state(id) : remove_state(id) #Add this line to the script endadd @mp == 0 ? add_state(id) : remove_state(id) , and write instead of id the index of the state you want to apply.

Thanks! This is actually the first thing I tried but I used the name of the status instead of its index number.

Also, is there a way to do this with enemy's aswell? So that whenever any enemy has zero mp they also have a status applied to them?
I'm pretty sure this does automatically work with enemies too, though I can't check at the moment.
Enemies are based on Game_BattlerBase so anything you put in that method will apply to actors and enemies.


Never use names. Just use ids (without leading zeros).

Original thread: https://forums.rpgmakerweb.com/threads/applying-a-status-on-a-party-member-when-their-mp-reaches-0.37969/