#==============================================================================
# Action Point System v1.0 (16/02/2013)
#==============================================================================
# AUTHOR:
# esrann (sakari.rannikko@gmail.com)
#
# Feel free to adapt to your own needs. Give credit if you want.
#--------------------------------------------------------------------------
# DESCRIPTION:
# This snippet allows you to set up a formula for calculating actor's 
# maximum TP (default formula: Actor TP = Actor AGI divided by 2).
# Also the TP is set to 100% at battle start (unless Preserve TP is enabled).
#--------------------------------------------------------------------------
# USAGE:
# Can be used to create for example an Action Point System:
# - Set battle commands to reduce TP
# - When out of TP in battle, use item/skill to restore points.
#   (for example, set 'Wait' skill to restore TP)
#--------------------------------------------------------------------------
# INSTALLATION:
# Install this script in the Materials section in your project's
# script editor.
#==============================================================================


#==============================================================================
# ++ Game_BattlerBase
#==============================================================================
class Game_BattlerBase
  #--------------------------------------------------------------------------
  # alias : max_tp | Calculate maximum TP using a formula
  #--------------------------------------------------------------------------
  alias esrann_max_tp max_tp
  def max_tp
    esrann_max_tp # alias

    self.agi / 2 # edit this formula
  end
  #--------------------------------------------------------------------------
  # alias: tp_rate | Calculate TP percentage correctly
  #--------------------------------------------------------------------------
  alias esrann_tp_rate tp_rate
  def tp_rate
    esrann_tp_rate # alias
    
    @tp.to_f / max_tp
  end

end # class Game_BattlerBase

#==============================================================================
# ++ Game_Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # alias : init_tp | Set initial TP to maximum
  #--------------------------------------------------------------------------
  alias esrann_init_tp init_tp
  def init_tp
    esrann_init_tp # alias
    
    self.tp = max_tp
  end  
end # class Game_Battler