If you use Atoa's custom battle system, use this version:

#==============================================================================
# HP Sacrifice
# By LockeZ
#==============================================================================
# This script allows you to create skills and items that cost HP when used.
#
# Compatible with Atoa's Custom Battle System.
#
# Contact me at ff3lockez@yahoo.com with questions.
#==============================================================================

module LockeZ
  # Do not remove this line
  HP_Sacrifice_Action = {'Skill' => {}, 'Item' => {}}
  # Do not remove this line
  
  # Below here are the lines you can change to control which actions
  #   cost HP, and how much.
  
  # Format for each line:
  # ---------------------
  # HP_Sacrifice_Action[action_type][id] = [chance, formula, amount, anim_id, pop, can_kill]
  
  
  # And here is what each of those things means:
  
  # action_type = Should be set to 'Skill' or 'Item'
  # id          = ID number of the skill/item that costs HP
  #
  # chance  = chance of damaging self
  # formula = How the amount lost is calculated.  Must be 'integer' or 'percent'.
  # amount  = Amount of HP lost, based on formula.  If formula is set to
  #           integer, this is the actual amount lost.  If it's set to percent,
  #           this is the percent lost.
  # anim_id = ID of the animation shown over the user; leave nil or 0 for
  #           no animation
  # pop     = true or false, whether the sacrificed amount pops up visually
  #           over the user's head like damage.
  # can_kill = true or false.  If false the skill will not reduce the user below
  #            1 HP.  If true it can kill the user.
  
  
  # Example Skills
  HP_Sacrifice_Action['Skill'][28] = [100, 'integer', 250, nil, true, false]
  # The "Darkness" spell (spell #28) now costs 250 HP to cast.  It won't
  #   reduce the caster below 1 HP.
  
  HP_Sacrifice_Action['Skill'][30] = [100, 'integer', 500, nil, true, false]
  # The "Mass Darkness" spell (spell #30) now costs 500 HP to cast.  It can
  #   kill the caster.
  
  HP_Sacrifice_Action['Item'][10] = [100, 'percent', 100, 51, false, true]
  # The "Full Tonic" item (item #10) now costs 100% of the user's max HP.
  #   In other words, it always kills the user.  Animation 51 is shown.
  #   The amount of damage isn't shown.
  
  
end

#==============================================================================
# ** Don't modify anything below this point.
#==============================================================================


#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
  include LockeZ
  
  #--------------------------------------------------------------------------
  # This method makes the script compatible with Atoa's Custom Battle System.
  #--------------------------------------------------------------------------
  alias step4_part3_hp_sacrifice step4_part3
  def step4_part3(battler)
    step4_part3_hp_sacrifice(battler)
    action = battler.now_action
    if action != nil and HP_Sacrifice_Action[action.type_name] != nil and
       HP_Sacrifice_Action[action.type_name].include?(action_id(action))
      sacrifice_hp(battler, HP_Sacrifice_Action[action.type_name][action_id(action)].dup)
    end
  end
  
  #--------------------------------------------------------------------------
  # Sacrifice HP
  #     battler : active battler
  #     action  : action
  #--------------------------------------------------------------------------
  def sacrifice_hp(battler, action)
    if action[0] >= rand(100)
      if action[1] == 'integer'
        hp_sacrificed = action[2].to_i
      elsif action[1] == 'percent'
        hp_sacrificed = (battler.maxhp * action[2] / 100).to_i
      end
      if action[5] == false
        hp_sacrificed = [battler.hp - 1, hp_sacrificed].min
      end
      if hp_sacrificed != 0
        battler.damage = hp_sacrificed
        battler.animation_id = action[3].nil? ? 0 : action[3]
        battler.damage_pop = action[4]
        @status_window.refresh
      end
    end
  end
end




And if you use the default battle system or Tankentai, use the one below:

#==============================================================================
# HP Sacrifice
# By LockeZ
#==============================================================================
# This script allows you to create skills and items that cost HP when used.
#
# Compatible with the default battle system.
# Compatible with Tankentai.
#
# Contact me at ff3lockez@yahoo.com with questions.
#==============================================================================

module LockeZ
  # Do not remove this line
  HP_Sacrifice_Action = {'Skill' => {}, 'Item' => {}}
  # Do not remove this line
  
  # Below here are the lines you can change to control which actions
  #   cost HP, and how much.
  
  # Format for each line:
  # ---------------------
  # HP_Sacrifice_Action[action_type][id] = [chance, formula, amount, anim_id, pop, can_kill]
  
  
  # And here is what each of those things means:
  
  # action_type = Should be set to 'Skill' or 'Item'
  # id          = ID number of the skill/item that costs HP
  #
  # chance  = chance of damaging self
  # formula = How the amount lost is calculated.  Must be 'integer' or 'percent'.
  # amount  = Amount of HP lost, based on formula.  If formula is set to
  #           integer, this is the actual amount lost.  If it's set to percent,
  #           this is the percent lost.
  # anim_id = ID of the animation shown over the user; leave nil or 0 for
  #           no animation
  # pop     = true or false, whether the sacrificed amount pops up visually
  #           over the user's head like damage.
  # can_kill = true or false.  If false the skill will not reduce the user below
  #            1 HP.  If true it can kill the user.
  
  
  # Example Skills
  HP_Sacrifice_Action['Skill'][28] = [100, 'integer', 250, nil, true, false]
  # The "Darkness" spell (spell #28) now costs 250 HP to cast.  It won't
  #   reduce the caster below 1 HP.
  
  HP_Sacrifice_Action['Skill'][30] = [100, 'integer', 500, nil, true, false]
  # The "Mass Darkness" spell (spell #30) now costs 500 HP to cast.  It can
  #   kill the caster.
  
  HP_Sacrifice_Action['Item'][10] = [100, 'percent', 100, 51, false, true]
  # The "Full Tonic" item (item #10) now costs 100% of the user's max HP.
  #   In other words, it always kills the user.  Animation 51 is shown.
  #   The amount of damage isn't shown.
  
  
end

#==============================================================================
# ** Don't modify anything below this point.
#==============================================================================


#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
  include LockeZ
  
  #--------------------------------------------------------------------------
  # These 2 methods makes the script compatible with the default battle system.
  #--------------------------------------------------------------------------
  unless respond_to?('step4_part3')
    alias make_skill_action_result_hp_sacrifice make_skill_action_result
    def make_skill_action_result
      make_skill_action_result_hp_sacrifice
      action = @active_battler.current_action
      if action != nil and HP_Sacrifice_Action['Skill'].include?(action.skill_id)
        sacrifice_hp(@active_battler, HP_Sacrifice_Action['Skill'][action.skill_id].dup)
      end
    end
  
    alias make_item_action_result_hp_sacrifice make_item_action_result
    def make_item_action_result
      make_item_action_result_hp_sacrifice
      action = @active_battler.current_action
      if action != nil and HP_Sacrifice_Action['Item'].include?(action.item_id)
        sacrifice_hp(@active_battler, HP_Sacrifice_Action['Item'][action.item_id].dup)
      end
    end
  end
  
  #--------------------------------------------------------------------------
  # Sacrifice HP
  #     battler : active battler
  #     action  : action
  #--------------------------------------------------------------------------
  def sacrifice_hp(battler, action)
    if action[0] >= rand(100)
      if action[1] == 'integer'
        hp_sacrificed = action[2].to_i
      elsif action[1] == 'percent'
        hp_sacrificed = (battler.maxhp * action[2] / 100).to_i
      end
      if action[5] == false
        hp_sacrificed = [battler.hp - 1, hp_sacrificed].min
      end
      if hp_sacrificed != 0
        # This line happens only in the DBS
        # Atoa's CBS does this automatically for all damage
        battler.hp -= hp_sacrificed

        battler.damage = hp_sacrificed
        battler.animation_id = action[3].nil? ? 0 : action[3]
        battler.damage_pop = action[4]
        @status_window.refresh
      end
    end
  end
end