#=================================================
#  Random Basic Battle Modifications v1.0
#     by Karin's Soulkeeper, Jan 17 2015
#
#  This is simply a compilation of some basic
#  functions of ACE's battle engine, allowing
#  for some quick, minor modifications.
#
#  Ins: Just insert under 'Materials', above main
#  Customize as seen fit.
#
#  Credit: If you feel like it, why not?
#=================================================

#=================================================
#  Stuff to customize
#=================================================

$hasMin = false  #Enable/Disable minimum damage
$minVal = 1      #Set minimum damage (invalid if $hasMin = false)

$criMul = 3      #Set critical Multiplier

$useLuk = true   #Enable/Disable Luck

$randTP = true   #Enable/Disable TP randomization pre-battle
$tpStVl = 0      #Set TP initial value (invalid if $randTP = false)

$bufRat = 0.25   #Set the param buff/debuff rate (used by add buff/debuff feature)

#-------------------------------------------------------------------------------
#  Default Values: false, 1, 3, true, true, 0, 0.25
#-------------------------------------------------------------------------------

#=================================================
#  End of Customization
#    Modify at your own risk.
#=================================================

class Game_Battler < Game_BattlerBase
  
  def make_damage_value(user, item)
    value = item.damage.eval(user, self, $game_variables)
    value *= item_element_rate(user, item)
    value *= pdr if item.physical?
    value *= mdr if item.magical?
    value *= rec if item.damage.recover?
    value = apply_critical(value) if @result.critical
    value = apply_variance(value, item.damage.variance)
    value = apply_guard(value)
    if value <= 0 and $hasMin
      value = $minVal
    end
    @result.make_damage(value.to_i, item)
  end
  def apply_critical(damage)
    damage * $criMul
  end
  def luk_effect_rate(user)
    if $useLuk
      [1.0 + (user.luk - luk) * 0.001, 0.0].max
    else
      return 1
    end
  end
  def init_tp
    if $randTP
      self.tp = rand * 25
    else
      return $tpStVl
    end
  end
end
class Game_BattlerBase
  def param_buff_rate(param_id)
    @buffs[param_id] * $bufRat + 1.0
  end
end