This is LockeZ's "HP Sacrifice" script. It allows the creation of skill that consume HP instead of SP.
#==============================================================================
# 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
# The "Darkness" spell (spell #28) now costs 250 HP to cast. It won't
# reduce the caster below 1 HP.
HP_Sacrifice_Action['Skill'][86] = [100, 'percent', 5, nil, false, false]
# The "Mass Darkness" spell (spell #30) now costs 500 HP to cast. It can
# kill the caster.
HP_Sacrifice_Action['Skill'][86] = [100, 'percent', 5, nil, false, false]
HP_Sacrifice_Action['Skill'][90] = [100, 'percent', 10, nil, false, false]
HP_Sacrifice_Action['Skill'][91] = [100, 'percent', 12, nil, false, false]
HP_Sacrifice_Action['Skill'][93] = [100, 'percent', 5, nil, false, false]
HP_Sacrifice_Action['Skill'][94] = [100, 'percent', 7, nil, false, false]
HP_Sacrifice_Action['Skill'][100] = [100, 'percent', 5, nil, false, false]
HP_Sacrifice_Action['Skill'][99] = [100, 'percent', 5, nil, false, false]
HP_Sacrifice_Action['Skill'][101] = [100, 'percent', 10, nil, false, false]
HP_Sacrifice_Action['Skill'][103] = [100, 'percent', 7, nil, false, false]
HP_Sacrifice_Action['Skill'][114] = [100, 'percent', 7, nil, false, false]
HP_Sacrifice_Action['Skill'][115] = [100, 'percent', 12, nil, false, false]
HP_Sacrifice_Action['Skill'][116] = [100, 'percent', 15, nil, false, false]
HP_Sacrifice_Action['Skill'][125] = [100, 'percent', 15, nil, false, false]
HP_Sacrifice_Action['Skill'][200] = [100, 'percent', 18, nil, false, false]
HP_Sacrifice_Action['Skill'][130] = [100, 'percent', 7, nil, false, false]
HP_Sacrifice_Action['Skill'][131] = [100, 'percent', 10, nil, false, false]
HP_Sacrifice_Action['Skill'][126] = [100, 'percent', 15, nil, false, false]
HP_Sacrifice_Action['Skill'][88] = [100, 'percent', 5, nil, false, false]
HP_Sacrifice_Action['Skill'][401] = [100, 'percent', 1, nil, false, false]
HP_Sacrifice_Action['Skill'][117] = [100, 'percent', 10, nil, false, false]
HP_Sacrifice_Action['Skill'][404] = [100, 'integer', 500, nil, true, false]
HP_Sacrifice_Action['Skill'][407] = [100, 'percent', 75, nil, false, false]
HP_Sacrifice_Action['Skill'][104] = [100, 'percent', 10, nil, false, false]
HP_Sacrifice_Action['Skill'][408] = [100, 'percent', 100, 111, true, true]
HP_Sacrifice_Action['Skill'][409] = [100, 'percent', 100, 111, true, true]
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
The problem I detected is that you can cast the skills regardless of the HP you currently have. For example, the very first skill in the script consume 5% of the character's current HP and yet it can still be used if the character only have 1 HP, as long as you haven't configured the skill to kill the caster if it eats more HP than they have. This also happens if you've set up an ability that uses a flat number.