class Game_Action
#--------------------------------------------------------------------------
# ● 行動速度の計算
#--------------------------------------------------------------------------
alias speed_KMS_DistributeParameter speed
def speed
speed = speed_KMS_DistributeParameter
return speed if attack?
if item.is_a?(RPG::Skill) && item.speed < 0
n = [subject.distributed_param(:skill_speed), item.speed.abs].min
speed += n
elsif item.is_a?(RPG::Item) && item.speed < 0
n = [subject.distributed_param(:item_speed), item.speed.abs].min
speed += n
end
gain_parameter_list.each { |gain|
next if gain == nil
cost = 0
distributed_count(gain.key).times { |i|
cost += Integer(gain.cost + gain.cost_rev * i)
gain.params.each { |param, v|
@distributed_param[param] += v.value + v.value_rev * i
}
}
@rp_cost += [cost, 0].max
}
KMS_DistributeParameter::PARAMS.each { |param|
@distributed_param[param] = @distributed_param[param]
}
end
#--------------------------------------------------------------------------
# ○ 各種修正値を修復
#--------------------------------------------------------------------------
def restore_distribution_values
calc_distribution_values
self.hp = self.hp
self.mp = self.mp
end
#--------------------------------------------------------------------------
# ○ 振り分けによる上昇値を取得
# param : パラメータの Symbol
#--------------------------------------------------------------------------
def distributed_param(param)
return 0 if @distributed_param == nil
return 0 if @distributed_param[param] == nil
return @distributed_param[param]
end
PARAM_SYMBOL = [:mhp, :mmp, :atk, :def, :mat, :mdf, :agi, :luk]
XPARAM_SYMBOL = [:hit, :eva, :cri, :cev, :mev, :mrf, :cnt, :hrg, :mrg, :trg]
SPARAM_SYMBOL = [:tgr, :grd, :rec, :pha, :mcr, :tcr, :pdr, :mdr, :fdr, :exr]
#--------------------------------------------------------------------------
# ● 通常能力値の基本値取得
#--------------------------------------------------------------------------
alias param_base_KMS_DistributeParameter param_base
def param_base(param_id)
n = param_base_KMS_DistributeParameter(param_id)
if PARAM_SYMBOL[param_id] != nil
n += distributed_param(PARAM_SYMBOL[param_id])
end
return Integer(n)
end
#--------------------------------------------------------------------------
# ● 命中率の取得
#--------------------------------------------------------------------------
alias hit_KMS_DistributeParameter hit
def hit
n = hit_KMS_DistributeParameter + distributed_param(:hit)
return n
end
#--------------------------------------------------------------------------
# ● 回避率の取得
#--------------------------------------------------------------------------
alias eva_KMS_DistributeParameter eva
def eva
n = eva_KMS_DistributeParameter + distributed_param(:eva)
return n
end
#--------------------------------------------------------------------------
# ● クリティカル率の取得
#--------------------------------------------------------------------------
alias cri_KMS_DistributeParameter cri
def cri
n = cri_KMS_DistributeParameter + distributed_param(:cri)
return n
end
#--------------------------------------------------------------------------
# ● 狙われ率の取得
#--------------------------------------------------------------------------
alias tgr_KMS_DistributeParameter tgr
def tgr
n = tgr_KMS_DistributeParameter + distributed_param(:tgr)
return n
end
#--------------------------------------------------------------------------
# ○ MaxRP の取得
#--------------------------------------------------------------------------
def mrp
n = Integer(eval(KMS_DistributeParameter::MAXRP_EXP))
return [n + mrp_plus, 0].max
end
#--------------------------------------------------------------------------
# ○ MaxRP 補正値の取得
#--------------------------------------------------------------------------
def mrp_plus
@mrp_plus = 0 if @mrp_plus == nil
return @mrp_plus
end
#--------------------------------------------------------------------------
# ○ RP の取得
#--------------------------------------------------------------------------
def rp
return [mrp - @rp_cost, 0].max
end
#--------------------------------------------------------------------------
# ○ 振り分け回数の取得
# param : 振り分け先パラメータ (キー)
#--------------------------------------------------------------------------
def distributed_count(param)
clear_distribution_values if @distributed_count == nil
@distributed_count[param] = 0 if @distributed_count[param] == nil
return @distributed_count[param]
end
#--------------------------------------------------------------------------
# ○ RP の増減
# value : 増減量
#--------------------------------------------------------------------------
def gain_rp(value)
@mrp_plus = mrp_plus + value
end
#--------------------------------------------------------------------------
# ○ 振り分け回数の増減
# param : 振り分け先パラメータ (キー)
# value : 増減量
#--------------------------------------------------------------------------
def gain_distributed_count(param, value = 1)
n = distributed_count(param)
@distributed_count[param] += value if n.is_a?(Integer)
end
#--------------------------------------------------------------------------
# ○ RP 振り分けによる成長効果適用
# param : 振り分け先パラメータ (キー)
# reverse : 逆加算のときは true
#--------------------------------------------------------------------------
def rp_growth_effect(param, reverse = false)
gain = gain_parameter(param)
return if gain == nil # 無効なパラメータ
if reverse
return if distributed_count(param) == 0 # 逆加算不可
else
return unless can_distribute?(param)
end
gain_distributed_count(param, reverse ? -1 : 1)
restore_distribution_values
end
#--------------------------------------------------------------------------
# ○ パラメータ振り分け可否判定
# param : 振り分け先パラメータ (キー)
#--------------------------------------------------------------------------
def can_distribute?(param)
gain = gain_parameter(param)
return false if gain == nil # 無効なパラメータ
return false if self.rp < distribute_cost(param) # RP 不足
if gain.limit > 0
return false if gain.limit <= distributed_count(param) # 回数上限
end
return true
end
#--------------------------------------------------------------------------
# ○ パラメータ振り分けコスト計算
# param : 振り分け先パラメータ (キー)
#--------------------------------------------------------------------------
def distribute_cost(param)
gain = gain_parameter(param)
return 0 if gain == nil # 無効なパラメータ
n = gain.cost
count = distributed_count(param)
count = [count, gain.limit - 1].min if gain.limit > 0
n += gain.cost_rev * count
return [Integer(n), 0].max
end
#--------------------------------------------------------------------------
# ○ パラメータ振り分け後の増加量計算
# param : 振り分け先パラメータ (キー)
# amt : 振り分け数
#--------------------------------------------------------------------------
def distribute_gain(param, amt = 1)
gain = gain_parameter(param)
# 無効なパラメータ
return 0 if gain == nil
result = {}
KMS_DistributeParameter::PARAMS.each { |par|
result[par] = distributed_param(par)
}
# 振り分け不可
if amt > 0
return result if gain.limit > 0 && gain.limit == distributed_count(param)
else
return result if distributed_count(param) + amt < 0
end
class Window_MenuCommand < Window_Command
if KMS_DistributeParameter::USE_MENU_DISTRIBUTE_PARAMETER_COMMAND &&
!$kms_imported["CustomMenuCommand"]
#--------------------------------------------------------------------------
# ● コマンドリストの作成
#--------------------------------------------------------------------------
alias make_command_list_KMS_DistributeParameter make_command_list
def make_command_list
make_command_list_KMS_DistributeParameter
add_distribute_parameter_command
end
end
#--------------------------------------------------------------------------
# ○ 振り分けコマンドをリストに追加
#--------------------------------------------------------------------------
def add_distribute_parameter_command
add_command(Vocab::distribute_parameter,
:distribute_parameter,
distribute_parameter_enabled)
end
#--------------------------------------------------------------------------
# ○ パラメータ振り分けの有効状態を取得
#--------------------------------------------------------------------------
def distribute_parameter_enabled
return true
end
end
# コスト描画
value = @actor.distribute_cost(param)
draw_text(x + 120, y, 40, line_height, value, 2)
# 振り分け回数描画
if gain.limit > 0
value = sprintf("%3d/%3d", @actor.distributed_count(param), gain.limit)
else
value = sprintf("%3d%s", @actor.distributed_count(param),
KMS_DistributeParameter::HIDE_MAX_COUNT_INFINITE ? "" : "/---")
end
draw_actor_distribute_gauge(@actor, param, x + 170, y, 80)
draw_text(x + 170, y, 80, line_height, value, 2)
change_color(normal_color)
end
#--------------------------------------------------------------------------
# ● 決定やキャンセルなどのハンドリング処理
#--------------------------------------------------------------------------
def process_handling
super
call_handler(:increase) if handle?(:increase) && Input.repeat?(:RIGHT)
call_handler(:decrease) if handle?(:decrease) && Input.repeat?(:LEFT)
call_handler(:up) if handle?(:up) && Input.repeat?(:UP)
call_handler(:down) if handle?(:down) && Input.repeat?(:DOWN)
end
end
contents.clear
# change_color(system_color)
# draw_text(0, 0, width - 32, line_height, "パラメータ変化", 1)
# change_color(normal_color)
#
# dy = line_height
dy = 0
KMS_DistributeParameter::PARAMS.each { |param|
draw_parameter(0, dy, param)
dy += line_height
}
end
#--------------------------------------------------------------------------
# ○ 能力値の描画
# x : 描画先 X 座標
# y : 描画先 Y 座標
# type : 能力値の種類
#--------------------------------------------------------------------------
def draw_parameter(x, y, type)
is_float = false
case type
when :mhp
name = Vocab.hp
value = @actor.mhp
when :mmp
name = Vocab.mp
value = @actor.mmp
when :atk
name = Vocab.param(2)
value = @actor.atk
when :def
name = Vocab.param(3)
value = @actor.def
when :mat
name = Vocab.param(4)
value = @actor.mat
when :mdf
name = Vocab.param(5)
value = @actor.mdf
when :agi
name = Vocab.param(6)
value = @actor.agi
when :luk
name = Vocab.param(7)
value = @actor.luk
when :hit
name = Vocab.hit
value = @actor.hit
is_float = true
when :eva
name = Vocab.eva
value = @actor.eva
is_float = true
when :cri
name = Vocab.cri
value = @actor.cri
is_float = true
when :skill_speed
name = Vocab.skill_speed
value = @actor.distributed_param(type)
when :item_speed
name = Vocab.item_speed
value = @actor.distributed_param(type)
when :tgr
name = Vocab.tgr
value = @actor.tgr
is_float = true
else
return
end
# パラメータ名
change_color(system_color)
draw_text(x + 4, y, 96, line_height, name)
change_color(normal_color)
draw_text(x + 106, y, 48, line_height, convert_value(value, is_float), 2)
return if @distribute_gain == nil
# パラメータ変化
draw_text(x + 154, y, 16, line_height, "→", 1)
curr = @actor.distributed_param(type)
gain = @distribute_gain[type]
change_color(gain > curr ? text_color(3) : gain < curr ?
text_color(2) : normal_color)
new_value = value + (gain - curr)
draw_text(x + 174, y, 48, line_height, convert_value(new_value, is_float), 2)
change_color(normal_color)
end
def convert_value(value, is_float)
if is_float
return sprintf("%.2f", value)
else
return value.to_i.to_s
end
end
end