#===============================================================================
# ** Configuration
#===============================================================================
module TH
module Param_Tables
# Where to store parameter tables
Param_Directory = "Data/Params"
# Prefixes for your filenames. For example,
Actor_Prefix = "params_actor"
Class_Prefix = "params_class"
Enemy_Prefix = "params_enemy"
def has_param_table?
!self.param_table.nil?
end
def param_table
load_param_table unless @param_table_checked
return @param_table
end
def load_param_table
@param_table_checked = true
dir = TH::Param_Tables::Param_Directory
filename = sprintf("%s%d.csv", param_file_prefix, @id)
path = File.join(dir, filename)
begin
data = load_data(path)
rescue
p 'no table found for %s' %path
return
end
data = data.split($INPUT_RECORD_SEPARATOR)
# Don't use tables, since they only signed 2-byte integers.
# For a range (-32677, 32678)
@param_table = Data_ParamTable.new
@xstatmod = Data_ParamTable.new
data[1..-1].each do |line|
line = line.split(",")
level = line[0].to_i
for i in 0..7
@param_table[i, level] = line[i+1].to_i
end
for i in 8..8
@xstatmod[i, level] = line[i+1].to_i
end
end
end
end
end
module RPG
class Actor < BaseItem
include TH::Param_Tables
def param_file_prefix
TH::Param_Tables::Actor_Prefix
end
def params
return @param_table if self.param_table
end
def xstatmod
return @xstatmod
end
end
end
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias r2_actor_init_xstat_param_table initialize
def initialize(actor_id)
r2_actor_init_xstat_param_table(actor_id)
i = 1
CRYSTAL::XSTAT::STATS.each do |stat|
act = $data_actors[actor_id]
@xstat_plus[stat] = act.xstatmod[i+7,@level]
i += 1
end
end
#--------------------------------------------------------------------------
# * Level Up
#--------------------------------------------------------------------------
alias r2_level_up_xstat_param_table level_up
def level_up
r2_level_up_xstat_param_table
prelvl = @level - 1
i = 1
CRYSTAL::XSTAT::STATS.each do |stat|
act = $data_actors[self.id]
stpr = act.xstatmod[i+7,prelvl]
stcl = act.xstatmod[i+7,@level]
diflv = stcl - stpr
@xstat_plus[stat] += diflv
i += 1
end
end
end
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
# This is a super class of all windows within the game.
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# * Draw Parameters
#--------------------------------------------------------------------------
def draw_actor_xstat(actor, x, y, stat)
change_color(system_color)
draw_text(x, y, 120, line_height, CRYSTAL::XSTAT::TERMS[stat])
change_color(normal_color)
p(stat)
p(actor.xstat_plus)
value = actor.xstat_plus[stat.to_sym]
p(value)
draw_text(x + 120, y, 36, line_height, value, 2)
end
end