Star Ocean Style MP death script

Right, my project mostly revolves around Magic and it is like their spiritual life source so I am looking for a script that works similar to Star Ocean's MP system, when their MP hits 0 they die.

if there is already a script made can you please point that out to me, thanks!
My first script(snippet) request fulfilled (seems to work ok for me thusfar, but yeah, am a novice scripter at best.)

class Game_BattlerBase  alias mpdeath refresh    def mp=(mp)    @mp = mp                                                    if mp == 0                                                    self.add_state(death_state_id)    end    refresh  endendJust insert below main, like all other scripts.
uhm, why did you even aliased refresh and not even used the alias???

that method is basically same as this one:

Code:
class Game_BattlerBase  def mp=(mp)    @mp = mp                                                    if mp == 0                                                    self.add_state(death_state_id)    end    refresh  endend
Also scripts are added ABOVE Main, but below Materials
uhm, why did you even aliased refresh and not even used the alias???
Most likely he was being cautious about the refresh method, and forgot to clear up unused stuff after checking that his code works fine.
I will test this out.

One more question, is there a way to let one character be immune to this 0 MP death script because her character like plays an important role of not having MP, sorry for making this a little bit more complicated.
class Game_Actor def mp=(mp) @mp = mp if mp == 0 and not actor_id == whatever_actor_id_of_the_one_who_should_be_immune self.add_state(death_state_id) end refresh endendthe 0 mp will only affect actors btw, the old one affects actors and enemies...

though you can use them both if you want it to still affect enemies while having the

immunity of some actor
I had this one before with Kread. It might have bugs, haven't tested it in-depth 😮

Code:
class Game_BattlerBase  #--------------------------------------------------------------------------  # ● 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    @mp == 0 ? add_state(death_state_id) :    remove_state(death_state_id)  endend class Game_Battler < Game_BattlerBase  #--------------------------------------------------------------------------  # ● Revive  #--------------------------------------------------------------------------  def revive    @mp = 1 if @mp == 0  end  #--------------------------------------------------------------------------  # ● Die  #--------------------------------------------------------------------------  def die    @mp = 0    clear_states    clear_buffs  endend
The immunity isn't working, actually it isn't killing anyone when their MP is 0 I added actor 2 on the "whatever_actor_id_of_the_one_who_should_be_immune " but not sure if I am doing it right

Error.png

This is the error I get when my character with the no MP starts her turn. I get a similar error like this when a character with MP dies from having 0 MP also
Standard did you try in an empty project? I was testing it a while ago and it seemed to be fine?
Then the other scripts seem to be rejecting it, dammit Q^Q

Although it makes no sense, the very first script given doesn't make errors and works perfect but the script that you can make a character immune to the MP death crashes when a character dies from 0 MP death.
Your missing the @ symbol for the actor_id.

Methinks, it should be

@actor_idInstead of

actor_idWell, that's what I deduct from the console.

The code could look like this (I'll use existing code block) :

Code:
class Game_Actor  def mp=(mp)    @mp = mp                                             unless @actor_id == put_actor_id_here ||           @actor_id == put_another_actor_id_here_or_remove_this_line ||           @actor_id == put_another_actor_id_here_or_remove_this_line ||           @actor_id == put_another_actor_id_here_or_remove_this_line      self.add_state(death_state_id) if mp == 0    end    refresh  endend
yes... it should be @actor_id or if it doesn't work, try self.id
ALRIGHT! Managed to get it to work, thanks so much everyone you are the best! This can be closed now.
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/star-ocean-style-mp-death-script.22444/