Remove state by a certain value (or higher) instead of %?

So, for default, VXAce (as most others RPGMAKER) has an option in states to remove them if you receive a % of damage.
I found this script that also adds the possibility to remove states by an element id.
So I was wondering if it was possible to make an add-on or a separated script that instead of a % of damage, it could be done with a certain value of damage or higher.
Let's say I want a state to be removed when I receive 500 of damage or more. So any damage of 499 or lower won't remove the state, but a damage of 500 or higher will remove it 100% all the time.

Thanks in advance!
Just to clarify, unless VX Ace specifically says something different from the other makers, that's a percent chance to remove the state when receiving any amount of damage. It's not a percentage of the battler's health or something.

I know that's not helping with your question, but I wanted to make sure you had that correct understanding 😉
So, for default, VXAce (as most others RPGMAKER) has an option in states to remove them if you receive a % of damage.
I found this script that also adds the possibility to remove states by an element id.
So I was wondering if it was possible to make an add-on or a separated script that instead of a % of damage, it could be done with a certain value of damage or higher.
Let's say I want a state to be removed when I receive 500 of damage or more. So any damage of 499 or lower won't remove the state, but a damage of 500 or higher will remove it 100% all the time.

Thanks in advance!
How would you want that to intersect in the event that you had both the setting for damage threshold and a percentage chance set in the database? Would the former completely override that?
How would you want that to intersect in the event that you had both the setting for damage threshold and a percentage chance set in the database? Would the former completely override that?

To be honest, I would never use the percentage chance in my game. My goal is to use only flat numbers to determine if the state is gonna be removed, so if the script override the percentage chance, I wouldn't complain at all.
This is my attempt and it seems to work.
Add below the original script
Spoiler: Addon
Ruby:
# State Remove by Weakness by Coelocanth
# Addon by Roninator2
#
# This script alters the "remove by damage" flag on states by giving some
# extra options about what sort of damage removes the state.
#
# Instructions
#
# Install this script in the usual way by inserting below Materials in the
# script editor.
#
# In the database, add the following note tags to states with the
# "remove by damage" flag set:
#
# <remove by element damage: amount>
# e.g. <remove by element damage: 50>
#
# Damage will only remove the state if it is higher than the value specified.

class RPG::State < RPG::BaseItem
  attr_accessor :remove_by_element_damage
  def load_notetags_ccsrw
    @remove_by_weakness = false
    @remove_by_strength = false
    @remove_by_elements = []
    @remove_by_element_damage = 0
    self.note.split(/^/).each do |line|
      case line
      when /<remove by weakness>/i
        @remove_by_weakness = true
      when /<remove by strength>/i
        @remove_by_strength = true
      when /<remove by element:(\d+)/
        @remove_by_elements.push($1.to_i)
      when /<remove by element damage:[ _-](\d+)/
        @remove_by_element_damage = ($1.to_i)
      end
    end
  end
end

class Game_Battler
  def remove_states_by_damage
    states.each do |state|
      if state.remove_by_damage && rand(100) < state.chance_by_damage
        next if state.remove_by_weakness && @result.element_rate <= 1.0
        next if state.remove_by_strength && @result.element_rate >= 1.0
        if @result.hp_damage >= state.remove_by_element_damage
          remove_state(state.id)
          next
        end
        next unless state.remove_by_elements.empty? ||
                    state.remove_by_elements.include?(@result.element_id)
        remove_state(state.id)
      end
    end
  end
end

I think the previous code doesn't allow the original options.
This should fix that. Tested to be working so far
Spoiler: addon ver2
Ruby:
# State Remove by Weakness by Coelocanth
# Addon by Roninator2
#
# This script alters the "remove by damage" flag on states by giving some
# extra options about what sort of damage removes the state.
#
# Instructions
#
# Install this script in the usual way by inserting below Materials in the
# script editor.
#
# In the database, add the following note tags to states with the
# "remove by damage" flag set:
#
# <remove by element damage: amount>
# e.g. <remove by element damage: 50>
#
# You can also add in if the element is required to remove the state
# If no element is in the attack then the state is not removed
# to be combined with remove by element id tag
#
# <remove by element required>
#
# Damage will only remove the state if it is higher than the value specified.

class RPG::State < RPG::BaseItem
  attr_accessor :remove_by_element_damage
  attr_accessor :remove_by_element_required
  def load_notetags_ccsrw
    @remove_by_weakness = false
    @remove_by_strength = false
    @remove_by_elements = []
    @remove_by_element_damage = 0
    @remove_by_element_required = false
    self.note.split(/^/).each do |line|
      case line
      when /<remove by weakness>/i
        @remove_by_weakness = true
      when /<remove by strength>/i
        @remove_by_strength = true
      when /<remove by element:(\d+)/
        @remove_by_elements.push($1.to_i)
      when /<remove by element damage:[ _-](\d+)/
        @remove_by_element_damage = ($1.to_i)
      when /<remove by element required>/i
        @remove_by_element_required = true
      end
    end
  end
end

class Game_Battler
  def remove_states_by_damage
    states.each do |state|
      if state.remove_by_damage && rand(100) < state.chance_by_damage
        next if state.remove_by_weakness && @result.element_rate <= 1.0
        next if state.remove_by_strength && @result.element_rate >= 1.0
        ele = state.remove_by_elements.empty?
        req = state.remove_by_element_required
        inc = state.remove_by_elements.include?(@result.element_id)
        base = state.remove_by_element_damage > 0
        dam = @result.hp_damage >= state.remove_by_element_damage
        rems = false
        rems = true if ((ele == true) && (base == true) && (dam == true) && (req == false))
        rems = true if ((req == true) && (inc == true) && (base == true) && (dam == true) && (ele == false))
        rems = true if ((base == true) && (dam == true) && (ele == false) && (req == false))
        rems = true if ((req == true) && (inc == true) && (ele == false) && (base == false))
        rems = true if ((inc == true) && (ele == false) && (base == false) && (req == false))
        if rems == true
          remove_state(state.id)
        end
      end
    end
  end
end
This is my attempt and it seems to work.
Add below the original script
Spoiler: Addon
Ruby:
# State Remove by Weakness by Coelocanth
# Addon by Roninator2
#
# This script alters the "remove by damage" flag on states by giving some
# extra options about what sort of damage removes the state.
#
# Instructions
#
# Install this script in the usual way by inserting below Materials in the
# script editor.
#
# In the database, add the following note tags to states with the
# "remove by damage" flag set:
#
# <remove by element damage: amount>
# e.g. <remove by element damage: 50>
#
# Damage will only remove the state if it is higher than the value specified.

class RPG::State < RPG::BaseItem
  attr_accessor :remove_by_element_damage
  def load_notetags_ccsrw
    @remove_by_weakness = false
    @remove_by_strength = false
    @remove_by_elements = []
    @remove_by_element_damage = 0
    self.note.split(/^/).each do |line|
      case line
      when /<remove by weakness>/i
        @remove_by_weakness = true
      when /<remove by strength>/i
        @remove_by_strength = true
      when /<remove by element:(\d+)/
        @remove_by_elements.push($1.to_i)
      when /<remove by element damage:[ _-](\d+)/
        @remove_by_element_damage = ($1.to_i)
      end
    end
  end
end

class Game_Battler
  def remove_states_by_damage
    states.each do |state|
      if state.remove_by_damage && rand(100) < state.chance_by_damage
        next if state.remove_by_weakness && @result.element_rate <= 1.0
        next if state.remove_by_strength && @result.element_rate >= 1.0
        if @result.hp_damage >= state.remove_by_element_damage
          remove_state(state.id)
          next
        end
        next unless state.remove_by_elements.empty? ||
                    state.remove_by_elements.include?(@result.element_id) ||
        remove_state(state.id)
      end
    end
  end
end
That's more options than I was providing in my script so I'll leave you to it. 😛
This is my attempt and it seems to work.
Add below the original script
Spoiler: Addon
Ruby:
# State Remove by Weakness by Coelocanth
# Addon by Roninator2
#
# This script alters the "remove by damage" flag on states by giving some
# extra options about what sort of damage removes the state.
#
# Instructions
#
# Install this script in the usual way by inserting below Materials in the
# script editor.
#
# In the database, add the following note tags to states with the
# "remove by damage" flag set:
#
# <remove by element damage: amount>
# e.g. <remove by element damage: 50>
#
# Damage will only remove the state if it is higher than the value specified.

class RPG::State < RPG::BaseItem
  attr_accessor :remove_by_element_damage
  def load_notetags_ccsrw
    @remove_by_weakness = false
    @remove_by_strength = false
    @remove_by_elements = []
    @remove_by_element_damage = 0
    self.note.split(/^/).each do |line|
      case line
      when /<remove by weakness>/i
        @remove_by_weakness = true
      when /<remove by strength>/i
        @remove_by_strength = true
      when /<remove by element:(\d+)/
        @remove_by_elements.push($1.to_i)
      when /<remove by element damage:[ _-](\d+)/
        @remove_by_element_damage = ($1.to_i)
      end
    end
  end
end

class Game_Battler
  def remove_states_by_damage
    states.each do |state|
      if state.remove_by_damage && rand(100) < state.chance_by_damage
        next if state.remove_by_weakness && @result.element_rate <= 1.0
        next if state.remove_by_strength && @result.element_rate >= 1.0
        if @result.hp_damage >= state.remove_by_element_damage
          remove_state(state.id)
          next
        end
        next unless state.remove_by_elements.empty? ||
                    state.remove_by_elements.include?(@result.element_id) ||
        remove_state(state.id)
      end
    end
  end
end

My hero as always <3 I missed you buddy.

Original thread: https://forums.rpgmakerweb.com/threads/remove-state-by-a-certain-value-or-higher-instead-of.154354/