Overhealing on battle?

Hellu, I have searched for the whole internet and haven't find anything like this for VX ACE, but I did for MV/MZ. Is there a possibility to make a script that take in count when you get overhealed?

What I want to accomplish is:
Let's say my Hero has a Max HP of 800, and its current HP is 500, and it get healed by a skill with + 500. It HP now should be 1000, but the Max HP prevents going over that amount. So, I was wondering if it was possible to make a script that take that extra value and add it to the current HP, but only during the battle. So when the battle ends, the character will have it current Max HP as default.

Maybe I don't need a script for this and this could be achieved with states and I'm missing something?
Anyways, thanks in advance to anyone interested on helping me out with this!
Spoiler: Without state
Ruby:
# ╔═══════════════════════════════════════════════╦════════════════════╗
# ║ Title: Battle Overheal - no state             ║  Version: 1.00     ║
# ║ Author: Roninator2                            ║                    ║
# ╠═══════════════════════════════════════════════╬════════════════════╣
# ║ Function:                                     ║   Date Created     ║
# ║                                               ╠════════════════════╣
# ║  HP goes above max in battle                  ║    18 Sep 2023     ║
# ╚═══════════════════════════════════════════════╩════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Requires: nil                                                      ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Brief Description:                                                 ║
# ║       Make Hp go above MHP in battle                               ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Instructions:                                                      ║
# ║                                                                    ║
# ║   Plug and play                                                    ║
# ║   Effects are temporary                                            ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Updates:                                                           ║
# ║ 1.00 - 18 Sep 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                                              ║
# ╚════════════════════════════════════════════════════════════════════╝

module BattleManager
  class << self
    alias :pro_vic :process_victory
    alias :pro_esp :process_escape
    alias :pro_abt :process_abort
  end
 
  #--------------------------------------------------------------------------
  # * Victory Processing
  #--------------------------------------------------------------------------
  def self.process_victory
    reset_hp
    pro_vic
  end
  #--------------------------------------------------------------------------
  # * Escape Processing
  #--------------------------------------------------------------------------
  def self.process_escape
    reset_hp
    pro_esp
  end
  #--------------------------------------------------------------------------
  # * Abort Processing
  #--------------------------------------------------------------------------
  def self.process_abort
    reset_hp
    pro_abt
  end
  #--------------------------------------------------------------------------
  # * Reset HP
  #--------------------------------------------------------------------------
  def self.reset_hp
    $game_party.members.each do |act|
      act.hp = act.mhp if act.hp > act.mhp
    end
  end
end

class Game_BattlerBase
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    state_resist_set.each {|state_id| erase_state(state_id) }
    if SceneManager.scene_is?(Scene_Battle)
      if self.is_a?(Game_Actor)
        if self.hp > self.mhp
          @hp = [@hp, mhp].max
        else
          @hp = [[@hp, mhp].min, 0].max
        end
      else
        @hp = [[@hp, mhp].min, 0].max
      end
    else
      @hp = [[@hp, mhp].min, 0].max
    end
    @mp = [[@mp, mmp].min, 0].max
    @hp == 0 ? add_state(death_state_id) : remove_state(death_state_id)
  end
end
Spoiler: With state
Ruby:
# ╔═══════════════════════════════════════════════╦════════════════════╗
# ║ Title: Battle Overheal                        ║  Version: 1.01     ║
# ║ Author: Roninator2                            ║                    ║
# ╠═══════════════════════════════════════════════╬════════════════════╣
# ║ Function:                                     ║   Date Created     ║
# ║                                               ╠════════════════════╣
# ║  HP goes above max in battle                  ║    18 Sep 2023     ║
# ╚═══════════════════════════════════════════════╩════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Requires: nil                                                      ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Brief Description:                                                 ║
# ║       Make Hp go above MHP in battle                               ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Instructions:                                                      ║
# ║                                                                    ║
# ║   Plug and play                                                    ║
# ║   Effects are temporary                                            ║
# ║                                                                    ║
# ║   Updated to only work with a state inflicted                      ║
# ║   Change the state id below                                        ║
# ║                                                                    ║
# ║   The state will be removed at the end of battle                   ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Updates:                                                           ║
# ║ 1.00 - 18 Sep 2023 - Script finished                               ║
# ║ 1.01 - 18 Sep 2023 - Added State needed to function                ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ 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_Overheal
  State = 26 # change this number to the state you set up
end

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

module BattleManager
  class << self
    alias :pro_vic :process_victory
    alias :pro_esp :process_escape 
    alias :pro_abt :process_abort
  end
  
  #--------------------------------------------------------------------------
  # * Victory Processing
  #--------------------------------------------------------------------------
  def self.process_victory
    reset_hp
    pro_vic
  end
  #--------------------------------------------------------------------------
  # * Escape Processing
  #--------------------------------------------------------------------------
  def self.process_escape
    reset_hp
    pro_esp
  end
  #--------------------------------------------------------------------------
  # * Abort Processing
  #--------------------------------------------------------------------------
  def self.process_abort
    reset_hp
    pro_abt
  end
  #--------------------------------------------------------------------------
  # * Reset HP
  #--------------------------------------------------------------------------
  def self.reset_hp
    $game_party.members.each do |act|
      act.remove_state(R2_Overheal::State)
      act.hp = act.mhp if act.hp > act.mhp
    end
  end
end

class Game_BattlerBase
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    state_resist_set.each {|state_id| erase_state(state_id) }
    if SceneManager.scene_is?(Scene_Battle)
      if self.is_a?(Game_Actor)
        if self.hp > self.mhp && self.state?(R2_Overheal::State)
          @hp = [@hp, mhp].max
        else
          @hp = [[@hp, mhp].min, 0].max
        end
      else
        @hp = [[@hp, mhp].min, 0].max
      end
    else
      @hp = [[@hp, mhp].min, 0].max
    end
    @mp = [[@mp, mmp].min, 0].max
    @hp == 0 ? add_state(death_state_id) : remove_state(death_state_id)
  end
end
wtf that was incredibly fast! Thank you very much Roni!
wtf that was incredibly fast! Thank you very much Roni!
Changed it to do alias for supporting other scripts

Original thread: https://forums.rpgmakerweb.com/threads/overhealing-on-battle.161277/