State applied when MP reaches zero?

Howdy!
I'm 99% sure that someone has asked the same question, but I couldn't seem to find anything.
Anyhoo, I was wondering if there was a way to add a state when an actor's MP reaches zero. That's about it.
If ya have any questions, just let me know.
Thanks!
Does the state get removed when mp is not 0?
Ruby:
# ╔═══════════════════════════════════════════════╦════════════════════╗
# ║ Title: Apply Zero MP State                    ║  Version: 1.01     ║
# ║ Author: Roninator2                            ║                    ║
# ╠═══════════════════════════════════════════════╬════════════════════╣
# ║ Function:                                     ║   Date Created     ║
# ║                                               ╠════════════════════╣
# ║   Inflict state                               ║    14 Aug 2023     ║
# ╚═══════════════════════════════════════════════╩════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Requires: nil                                                      ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Brief Description:                                                 ║
# ║       Inflict actor with state when MP is zero                     ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Instructions:                                                      ║
# ║   Specify the state to apply when MP reaches zero                  ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Updates:                                                           ║
# ║ 1.00 - 14 Aug 2023 - Script finished                               ║
# ║ 1.01 - 27 Mar 2024 - Included remove state option                  ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Credits and Thanks:                                                ║
# ║   Roninator2                                                       ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Terms of use:                                                      ║
# ║  Follow the original Authors terms of use where applicable         ║
# ║    - When not made by me (Roninator2)                              ║
# ║  Free for all uses in RPG Maker except nudity                      ║
# ║  Anyone using this script in their project before these terms      ║
# ║  were changed are allowed to use this script even if it conflicts  ║
# ║  with these new terms. New terms effective 03 Apr 2024             ║
# ║  No part of this code can be used with AI programs or tools        ║
# ║  Credit must be given                                              ║
# ╚════════════════════════════════════════════════════════════════════╝

module R2_Zero_MP_State
  State = 25 # state id to inflict
  Remove_State = false # state to be removed when mp is no longer zero
end

# ╔════════════════════════════════════════════════════════════════════╗
# ║                      End of editable region                        ║
# ╚════════════════════════════════════════════════════════════════════╝

#==============================================================================
# ** Game_BattlerBase
#==============================================================================

class Game_BattlerBase
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  alias r2_set_zero_mp_refresh      refresh
  def refresh
    r2_set_zero_mp_refresh
    if self.is_a?(Game_Actor)
     add_state(R2_Zero_MP_State::State) if @mp == 0
     remove_state(R2_Zero_MP_State::State) if @mp != 0 && R2_Zero_MP_State::Remove_State &&
     self.state?(R2_Zero_MP_State::State)
    end
  end
end
Nope!
edited
Thanks! Looks like it works!
Does the state get removed when mp is not 0?
Ruby:
module R2_Zero_MP_State
  State = 25
end

#==============================================================================
# ** Game_BattlerBase
#==============================================================================

class Game_BattlerBase
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  alias r2_set_zero_mp_refresh      refresh
  def refresh
    r2_set_zero_mp_refresh
    if self.is_a?(Game_Actor)
     add_state(R2_Zero_MP_State::State) if @mp == 0
    end
  end
end
how do you use this?
how do you use this?
Not gonna work in MV. Sorry.
Not gonna work in MV. Sorry.
;o- np

Original thread: https://forums.rpgmakerweb.com/threads/state-applied-when-mp-reaches-zero.160303/