A simple script that Aliases the make_action_result method of the Scene_Battle so that when you defend a certain percentage of HP and SP will be recovered. Made for a request
Screenshots:
Look at the script, you have yourself a screenshot with extra flavored text.
The Script
Place Above Main.
CODE
#============================================================================
# Regenerate when Defend
#----------------------------------------------------------------------------
# Written by Synthesize
# Version 2.00
# August 11, 2007
#============================================================================
#----------------------------------------------------------------------------
# Being Customization Area
#----------------------------------------------------------------------------
# Order = {Actor_id, Percentage}
HP_regen = {1 => 5, 2 => 7}
HP_regen.default = 5
SP_regen = {1 => 10, 2 => 7}
SP_regen.default = 5
#----------------------------------------------------------------------------
# End Customization Area
#----------------------------------------------------------------------------
class Scene_Battle
alias syn_regen_on_defend make_basic_action_result
def make_basic_action_result
syn_regen_on_defend
hp_restore = ((@active_battler.maxhp * HP_regen[@active_battler.id]) / 100)
sp_restore = ((@active_battler.maxsp * SP_regen[@active_battler.id]) / 100)
@temp_value_hp = (@active_battler.maxhp - @active_battler.hp)
@temp_value_sp = (@active_battler.maxsp - @active_battler.sp)
if @active_battler.current_action.basic == 1
if @active_battler.hp != @active_battler.maxhp and @active_battler.sp != @active_battler.maxsp
syn_restore(hp_restore, 1)
syn_restore(sp_restore, 0)
if @temp_value_hp >> hp_restore and @temp_value_sp >> sp_restore
@help_window.set_text("#{@active_battler.name} #{$data_system.words.hp} increased by #{@temp_value_hp} and #{@active_battler.name} #{$data_system.words.sp} increased by #{@temp_value_sp}", 1)
end
elsif @active_battler.hp != @active_battler.maxhp and @active_battler.sp == @active_battler.maxsp
syn_restore(hp_restore,1)
if @temp_value_hp >> hp_restore
@help_window.set_text("#{@active_battler.name} #{$data_system.words.hp} increased by #{@temp_value_hp}", 1)
else
@help_window.set_text("#{@active_battler.name} #{$data_system.words.hp} increased by #{hp_restore}", 1)
end
elsif @active_battler.hp == @active_battler.maxhp and @active_battler.sp != @active_battler.maxsp
syn_restore(sp_restore,0)
if @temp_value_sp >> sp_restore
@help_window.set_text("#{@active_battler.name} #{$data_system.words.sp} increased by #{@temp_value_sp}", 1)
else
@help_window.set_text("@{active_battler.name} #{$data_system.words.sp} increased by #{sp_restore}", 1)
end
else
@help_window.set_text("#{@active_battler.name} is defending", 1)
end
end
end
def syn_restore(amount,stat)
if stat == 1
@active_battler.hp += amount
else
@active_battler.sp += amount
end
end
end
# Regenerate when Defend
#----------------------------------------------------------------------------
# Written by Synthesize
# Version 2.00
# August 11, 2007
#============================================================================
#----------------------------------------------------------------------------
# Being Customization Area
#----------------------------------------------------------------------------
# Order = {Actor_id, Percentage}
HP_regen = {1 => 5, 2 => 7}
HP_regen.default = 5
SP_regen = {1 => 10, 2 => 7}
SP_regen.default = 5
#----------------------------------------------------------------------------
# End Customization Area
#----------------------------------------------------------------------------
class Scene_Battle
alias syn_regen_on_defend make_basic_action_result
def make_basic_action_result
syn_regen_on_defend
hp_restore = ((@active_battler.maxhp * HP_regen[@active_battler.id]) / 100)
sp_restore = ((@active_battler.maxsp * SP_regen[@active_battler.id]) / 100)
@temp_value_hp = (@active_battler.maxhp - @active_battler.hp)
@temp_value_sp = (@active_battler.maxsp - @active_battler.sp)
if @active_battler.current_action.basic == 1
if @active_battler.hp != @active_battler.maxhp and @active_battler.sp != @active_battler.maxsp
syn_restore(hp_restore, 1)
syn_restore(sp_restore, 0)
if @temp_value_hp >> hp_restore and @temp_value_sp >> sp_restore
@help_window.set_text("#{@active_battler.name} #{$data_system.words.hp} increased by #{@temp_value_hp} and #{@active_battler.name} #{$data_system.words.sp} increased by #{@temp_value_sp}", 1)
end
elsif @active_battler.hp != @active_battler.maxhp and @active_battler.sp == @active_battler.maxsp
syn_restore(hp_restore,1)
if @temp_value_hp >> hp_restore
@help_window.set_text("#{@active_battler.name} #{$data_system.words.hp} increased by #{@temp_value_hp}", 1)
else
@help_window.set_text("#{@active_battler.name} #{$data_system.words.hp} increased by #{hp_restore}", 1)
end
elsif @active_battler.hp == @active_battler.maxhp and @active_battler.sp != @active_battler.maxsp
syn_restore(sp_restore,0)
if @temp_value_sp >> sp_restore
@help_window.set_text("#{@active_battler.name} #{$data_system.words.sp} increased by #{@temp_value_sp}", 1)
else
@help_window.set_text("@{active_battler.name} #{$data_system.words.sp} increased by #{sp_restore}", 1)
end
else
@help_window.set_text("#{@active_battler.name} is defending", 1)
end
end
end
def syn_restore(amount,stat)
if stat == 1
@active_battler.hp += amount
else
@active_battler.sp += amount
end
end
end
F.A.Q.
Q. How do I call the script?
A. You don't simply install it and let it do it's job.
Q. How do I make it so Current HP is calculated instead of Max HP?
A. If you want the percent of HP/SP to recover to be based on current HP/SP simply change all occurences of .maxhp and .maxsp to only .hp and .sp.