脚本(By: Hime)
=begin
#===============================================================================
Title: Equip Param Formulas
Author: Hime
Date: Mar 15, 2014
URL: http://www.himeworks.com/2014/03/15/equip-param-formulas/
--------------------------------------------------------------------------------
** Change log
Mar 15, 2014
- Initial release
--------------------------------------------------------------------------------
** Terms of Use
* Free to use in non-commercial projects
* Contact me for commercial use
* No real support. The script is provided as-is
* Will do bug fixes, but no compatibility patches
* Features may be requested but no guarantees, especially if it is non-trivial
* Credits to Hime Works in your project
* Preserve this header
--------------------------------------------------------------------------------
** Description
This script allows you to use formulas to define parameters for weapons and
armors.
For example, if you were using a script that provided equip levels, you can
define a formula that uses the level to determine the weapon's parameters.
All attributes that the equip holds can be referenced.
Formula variables are also available to use.
#---------------------------------------------------------------------------
# Not the most efficient way to do it but it preserves the interface
#---------------------------------------------------------------------------
def params
load_notetag_param_formulas unless @param_formulas_checked
return @param_formulas.collect {|f| eval_param_formula(f)}
end
def eval_param_formula(formula, p=$game_party, s=$game_switches, t=$game_troop, v=$game_variables)
eval(formula)
end
def load_notetag_param_formulas
@param_formulas_checked = true
@param_formulas = @params.map {|val| val.to_s }
results = self.note.scan(TH::Equip_Param_Formulas::Ext_Regex)
results.each do |res|
type = res[0].strip.downcase.to_sym
id = TH::Equip_Param_Formulas::Param_Table[type]
formula = res[1]
@param_formulas[id] = formula
end
end
end
end