Exclude states from the "Full Recovery" command script?

I am quite surprised that a script like this does not already exist but Google only provided irrelevant results.


I need a way to exclude certain states to be ignored when the "Full Recovery" command is initiated, like a place such as an inn or a bed.

Full Recovery removes literally everything, this includes buffs and enhancements. If I have an XP Candy buff on an actor (which increases their XP earned per battle) and I rest at an inn, it removes that XP buff state. Same for states that temporarily raise stats like HP or even encounter half/none.

There are also negative states that I do not want to be removed from Full Recovery. This includes but not limited to the "Shrunken" debuff state.

I know that I could just manually set the "Remove State" and add every state that I do want to remove at the inns and stuff, but that gets to be a pain to do when you have a lot of states and I would need to constantly update it—even if I used a common event.


Could I get someone to make a script that allows certain states to be ignored from "Full Recovery"? I would prefer to define these states by adding something to the state's note box rather than defining state IDs in the script.


Could I please get someone to make something like this for VX Ace? I would appreciate it very much. Thank You.
Ruby:
# ╔═══════════════════════════════════════════════╦════════════════════╗
# ║ Title: Retain States                          ║  Version: 1.00     ║
# ║ Author: Roninator2                            ║                    ║
# ╠═══════════════════════════════════════════════╬════════════════════╣
# ║ Function:                                     ║   Date Created     ║
# ║                                               ╠════════════════════╣
# ║ Prevent states from being removed             ║    18 Aug 2023     ║
# ╚═══════════════════════════════════════════════╩════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Requires: nil                                                      ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Brief Description:                                                 ║
# ║       Prevent death from removing all states                       ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Instructions:                                                      ║
# ║   Add <no recover> to the states you want to not be                ║
# ║   removed when the actor is recovered.                             ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Updates:                                                           ║
# ║ 1.00 - 18 Aug 2023 - Script finished                               ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ 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                                              ║
# ╚════════════════════════════════════════════════════════════════════╝

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

class Game_BattlerBase
  #--------------------------------------------------------------------------
  # * Recover All
  #--------------------------------------------------------------------------
  def recover_all
    clean_states
    @hp = mhp
    @mp = mmp
  end
  #--------------------------------------------------------------------------
  # * Clear State Information
  #--------------------------------------------------------------------------
  def clean_states
    if self.is_a?(Game_Actor) && @states != nil
      @states.each_with_index do |st, i|
        stnb = $data_states[st]
        next if stnb.note.include?("<no recover>")
        @states[i] = nil
      end
      @states.compact!
    else
      @states = []
      @state_turns = {}
      @state_steps = {}
    end
  end
end

#==============================================================================
# ** Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Setup
  #--------------------------------------------------------------------------
  alias r2_actor_setup  setup
  def setup(actor_id)
    r2_actor_setup(actor_id)
    clear_states
  end
end
Roninator2 has already posted a solution to your question, but is states being removed when your character is defeated also an issue then? Or just the recovery?
There's a problem with array methods that end with a bang! If they didn't change the contents of that array, they will return nil instead of the array itself as expected. :S
1692372281660.png
1692372302969.png
Roninator2 has already posted a solution to your question, but is states being removed when your character is defeated also an issue then? Or just the recovery?
I saw a script that addresses the issue for when an actor is defeated, but that script, you just specify in the script what states to keep after death and you cannot pick individual states. It defines a range of states. I posted in that thread asking for a alternate version where you can pick individual states but no response.
I posted in that thread asking for a alternate version where you can pick individual states but no response.
It's good to see that compact! is an exception to that rule.

Original thread: https://forums.rpgmakerweb.com/threads/exclude-states-from-the-full-recovery-command-script.160387/