make certain states disappear whenever mp reaches 0

   Don't usually like making requests, makes me feel a bit like a beggar... usually I'd try to find a way to event it if a script doesn't exist, and while I could do that here there are a few problems with it.

   Basically why I need this is because in the game I'm working on magic exists but it's actually as rare as it usually is in fantasy settings (only 2 playable characters are actually 'really' magical). However, everyone is capable of drawing on at least a little bit of magical energies even if they don't have the talent to become an actual magic user. So a lot of characters have 'enhancer abilities' which basically use the little magical power that they possess to increase various physical traits. I need these abilities to go away once the characters mp is drained completely though.

   It's doable with events I know but setting up parallel events to check for every character and each ability they might be under the effects of can really fill up my troops event menu so if anyone feels like helping me out or knows of a script that already exists that does this (though I searched extensively for it already) I would greatly appreciate it.
Would you like this to be both in the middle of battle, and on the map screen?
If you're comfortable with scripting, you could look at the Game_BattlerBase class for the method mp= (or one of its subclasses, if the method isn't there).


Then just add a conditional branch saying if mp == 0, loop through an array of the states you want to remove, and do a remove_state(id) for that state for each one.


Or do you want it a bit more fancy than that, where you can put something in the notes of the state saying to remove it when mp = 0?
@ Venima: Only in battle, All the states go away at the end of battle anyway as state increases don't help much overworld.

@Shaz: I'm not that comfortable with it but I understand the basics of it. I'll start up a test project and see if I can get that to work. Thanks for pointing me towards the right place.

Edit: Ok, I think I've gotten it to work. I'm just worried I might run into problems with the way I've set it up. I'm not sure about the loops and arrays, basically all I need to do is get any active states that are the ones I'm needing gone to go away after the mp hits zero. So this is what I've changed the mp= method to

Old:

  def mp=(mp)
    @mp = mp
    refresh
  end

New:

  def mp=(mp)
    @mp = mp
    if mp == 0
      self.remove_state(3)
      self.remove_state(4)

      self.remove_state(5)
    end
    refresh
  end

As far as I can tell it doesn't cause any problems, just not really experienced enough to know whether or not I might run into problems with it in the future. Hopefully it works even though I know it's simple and sloppy.
Yeah, that's about it. If you have more states, you can do something like this to make it a bit shorter:

Code:
 def mp=(mp)    @mp = mp    if mp == 0      [3, 4, 5, 18, 20, 21, 23].each do |state|        self.remove_state(state)      end    end    refresh  end
Awesome, I've already tested it in every scenario I could think of where it might do something strange and it all works perfectly. Thanks Shaz, I guess this one 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/make-certain-states-disappear-whenever-mp-reaches-0.18994/