#===============================================================================
# ** States : Max HP/SP Refill
#===============================================================================
Â
#-------------------------------------------------------------------------------
# * SDK Log
#-------------------------------------------------------------------------------
if Object.const_defined?(:SDK)
 SDK.log('States.MaxHP/SPRefill', 'Kain Nobel ©', 3.0, '04.01.2009')
end
Â
#===============================================================================
# * RPG::State::FillRate
#===============================================================================
Â
module RPG::State::FillRate
 #-----------------------------------------------------------------------------
 # * For states that'll reduce HP when inflicted, can HP be 0?
 #-----------------------------------------------------------------------------
 HP0_CanKill = {}
 #-----------------------------------------------------------------------------
 # * The Direct HP filled when this state is inflicted.
 #-----------------------------------------------------------------------------
 HP_Direct  = {}
 #-----------------------------------------------------------------------------
 # * The Percent HP filled when this state is inflicted.
 #-----------------------------------------------------------------------------
 HP_Percent  = {}
 #-----------------------------------------------------------------------------
 # * The random Variance of HP filled when this state is inflicted.
 #-----------------------------------------------------------------------------
 HP_Variance = {}
 #-----------------------------------------------------------------------------
 # * The Direct SP filled when this state is inflicted.
 #-----------------------------------------------------------------------------
 SP_Direct  = {}
 #-----------------------------------------------------------------------------
 # * The Percent SP filled when this state is inflicted.
 #-----------------------------------------------------------------------------
 SP_Percent  = {}
 #-----------------------------------------------------------------------------
 # * The random Variance of HP filled when this state is inflicted.
 #-----------------------------------------------------------------------------
 SP_Variance = {}
 #-----------------------------------------------------------------------------
 # * Default Settings (DON'T TOUCH : Will affect all states not defined.)
 #-----------------------------------------------------------------------------
 HP0_CanKill.default = true
 HP_Direct.default  = 0
 HP_Percent.default  = 0
 HP_Variance.default = 0
 SP_Direct.default  = 0
 SP_Percent.default  = 0
 SP_Variance.default = 0
end
Â
#===============================================================================
# ** RPG::State
#===============================================================================
Â
class RPG::State
 #-----------------------------------------------------------------------------
 # * HP Fill Rate
 #-----------------------------------------------------------------------------
 def hp_fill_rate(old, new)
  new -= old
  new *= FillRate::HP_Percent[@id] / 100.0
  new += FillRate::HP_Direct[@id]
  var = rand(FillRate::HP_Variance[@id] + 1)
  new += rand(2) > 0 ? var : -var
  return Integer(new)
 end
 #-----------------------------------------------------------------------------
 # * SP Fill Rate
 #-----------------------------------------------------------------------------
 def sp_fill_rate(old, new)
  new -= old
  new *= FillRate::SP_Percent[@id] / 100.0
  new += FillRate::SP_Direct[@id]
  var = rand(FillRate::HP_Variance[@id] + 1)
  new += rand(2) > 0 ? var : -var
  return Integer(new)
 end
end
Â
#===============================================================================
# ** Game_Battler
#===============================================================================
Â
class Game_Battler
 #-----------------------------------------------------------------------------
 # * Alias Listings
 #-----------------------------------------------------------------------------
 alias_method :statesmaxhpsprefill_gmbtlr_addstate, :add_state
 #-----------------------------------------------------------------------------
 # * Add State
 #-----------------------------------------------------------------------------
 def add_state(id)
  if self.states.include?(id)
   statesmaxhpsprefill_gmbtlr_addstate(id)
   return
  end
  old_maxhp, old_maxsp = self.maxhp, self.maxsp
  statesmaxhpsprefill_gmbtlr_addstate(id)
  new_maxhp, new_maxsp = self.maxhp, self.maxsp
  fill_hp = self.hp + $data_states[id].hp_fill_rate(old_maxhp, new_maxhp)
  fill_sp = self.sp + $data_states[id].sp_fill_rate(old_maxsp, new_maxsp)
  unless self.hp.zero?
   self.hp = [fill_hp, 1].max
  end
  self.sp = fill_sp
 end
end