| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 13 |
| 经验 | |
| 最后登录 | 2026-4-22 |
| 在线时间 | 135 小时 |
- 梦石
- 0
- 星屑
- 1250
- 在线时间
- 135 小时
- 注册时间
- 2021-2-28
- 回帖
- 26
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 506785728 于 2021-9-7 18:35 编辑
能力值加点#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/ ◆ 能力值加点 - KMS_DistributeParameter ◆ VXAce ◆
#_/ ◇ Last update : 2012/08/05 (TOMY@Kamesoft) ◇
#_/----------------------------------------------------------------------------
#_/ 创建能力值加点的功能。
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#==============================================================================
# ★ 设定部分 - BEGIN Setting ★
#==============================================================================
module KMS_DistributeParameter
# ◆ 加点类型设定
# 设定加点类型,和影响能力值的大小
# {
# :key => 标志,
# :name => "名称",
# :limit => 加点数上限,
# :cost => [消耗技能点, 消耗技能点修正],
# :能力值 => [提升量, 提升量修正],
# # 能力值的设定可以是任意数量的
# },
# 在以下列表中添加加点类型。
# 再加点画面中、会按顺序显示。
# 对于「标志」、请设定一个不重复的能力值标志。
# (用语设定加点类型显示的顺序。数值或字符串都OK)
# 「加点数上限」以外的设定都可以使用小数。
# 「加点数上限」设定为 0 时则没有上限。
# 「消耗技能点修正」和「提升量修正」可以被省略。省略时视为 0。
GAIN_PARAMETER = [
{
:key => :health,
:name => "体力",
:limit => 30,
:cost => [ 1, 0.4],
:mhp => [30, 2],
:def => [ 1, 0.25],
},
{
:key => :magic,
:name => "魔力",
:limit => 30,
:cost => [1, 0.4],
:mmp => [5, 0.5],
:mat => [2, 0.5],
},
{
:key => :pow,
:name => "力量",
:limit => 30,
:cost => [1, 0.4],
:atk => [2, 0.5],
:def => [1, 0.25],
},
{
:key => :dex,
:name => "防御",
:limit => 30,
:cost => [1, 0.4],
:agi => [2, 0.5],
:hit => [0.005],
:eva => [0.005],
},
{
:key => :mat,
:name => "智力",
:limit => 30,
:cost => [1, 0.4],
:mat => [2, 0.5],
},
{
:key => :mdf,
:name => "信仰",
:limit => 30,
:cost => [1, 0.4],
:mdf => [2, 0.5],
:mmp => [1, 0.5],
},
{
:key => :agi,
:name => "敏捷",
:limit => 20,
:cost => [1, 0.5],
:agi => [1]
},
{
:key => :luk,
:name => "幸运",
:limit => 20,
:cost => [1, 0.5],
:luk => [1]
},
{
:key => :hit,
:name => "机警",
:limit => 20,
:cost => [1, 0.5],
:hit => [0.01],
:eva => [0.01],
},
#~ {
#~ :key => :eva,
#~ :name => "闪避率",
#~ :limit => 20,
#~ :cost => [1, 0.5],
#~ :eva => [0.01],
#~ },
{
:key => :crt,
:name => "爆发",
:limit => 20,
:cost => [1, 0.7],
:cri => [0.01],
},
{
:key => :chant,
:name => "咏唱速度",
:limit => 0,
:cost => [1, 0.5],
:skill_speed => [1],
},
{
:key => :item,
:name => "物品速度",
:limit => 0,
:cost => [1, 0.5],
:item_speed => [1],
},
{
:key => :tgr,
:name => "针对率", #受到攻击几率
:limit => 5,
:cost => [1],
:tgr => [0.2],
}
] # ← 这个 ] 别删掉了!
# ◆ 指定角色的加点变化
PERSONAL_GAIN_PARAMETER = []
# 以下、设定某角色的加点能力值变化,格式:
# PERSONAL_GAIN_PARAMETER[角色ID] = [ 加点类型列表 ]
#
# 「加点类型列表」和 GAIN_PARAMETER 的设定格式相同。
# 如果某标志的设定与 GAIN_PARAMETER 的相同,则会覆盖 GAIN_PARAMETER 中的设定。
#
# <例> 单独设定1号角色的"体力"加点效果。
PERSONAL_GAIN_PARAMETER[1] = [
{
:key => :health,
:name => "体力",
:limit => 30,
:cost => [ 1, 0.4],
:mhp => [50, 3],
:def => [ 1, 0.3],
},
]
# ◆ 指定职业的加点变化
CLASS_GAIN_PARAMETER = []
# 以下、设定某职业的加点能力值变化,格式:
# CLASS_GAIN_PARAMETER[职业ID] = [ 加点类型列表 ]
#
# 职业设定会覆盖以上两种设定。
# (优先级 职业 > 角色 > 默认)
CLASS_GAIN_PARAMETER[1] = [
{
:key => :item,
:name => "物品速度",
:limit => 0,
:cost => [1, 0.5],
:item_speed => [2],
},
]
# ◆ 消耗点数的名称
VOCAB_RP = "消耗"
# ◆ 属性点的缩写
VOCAB_RP_A = "属性点"
# ◆ 最大属性点的计算式
# level .. 等级
# 计算结果是小数也OK(会自动替换成整数)。
MAXRP_EXP = "(level ** 0.25 + 2.0) * level"
# ◆ 能力值名
# 如果同时使用脚本 ?拡張装備画面? 、则优先使用下面的设定。
VOCAB_PARAM = {
:hit => "命中率", # 命中率
:eva => "闪避率", # 闪避率
:cri => "暴击率", # 暴击率
:skill_speed => "咏唱速度", # 技能速度修正
:item_speed => "物品速度", # 物品速度補正
:tgr => "针对率", # 受到攻击几率
} # ← 这个 } 别删了!
# ◆ 是否只显示已加点次数,而不显示加点上限
# true : 次数
# false : 次数/---
HIDE_MAX_COUNT_INFINITE = false
# ◆ 加点类型值槽的颜色
# 数值 : \C[n] 的颜色相同。
# Color : 指定颜色。 ( Color.new(255, 128, 128) 等等 )
GAUGE_START_COLOR = 28 # 开始色
GAUGE_END_COLOR = 29 # 结束色
# ◆ 是否显示"通用值槽图片效果"
# 使用脚本 ?汎用ゲージ描画? 时才有效。
ENABLE_GENERIC_GAUGE = true
# ◆ 值槽设定
# 图片放在 "Graphics/System" 里。
GAUGE_IMAGE = "GaugeDist" # 图片文件名
GAUGE_OFFSET = [-23, -2] # 位置修正 [x, y]
GAUGE_LENGTH = -4 # 长度修正
GAUGE_SLOPE = 30 # 倾角 (-89 ~ 89)
# ◆ 加点结束确认
CONFIRM_COMMANDS = [
" 确定", # 确认加点
" 退出", # 退出加点画面
" 取消", # 取消
] # ← 这个 } 别删了!
# ◆ 确认指令帮助文本
CONFIRM_COMMAND_HELP = [
"应用加点。", # 确认加点
"撤回之前的加点并退出。", # 退出加点画面
"返回加点画面。", # 取消
] # ← 这个 } 别删了!
# ◆ 确认窗口的宽度
CONFIRM_WIDTH = 112
# ◆ 是否在菜单中添加"加点"的指令
# true时,加点出现在菜单指令的最下方。
# 如果要改变位置、请使用脚本?カスタムメニューコマンド? 。
USE_MENU_DISTRIBUTE_PARAMETER_COMMAND = true
# ◆ 指令名称
VOCAB_MENU_DISTRIBUTE_PARAMETER = "加点"
# ◆ 是否允许修改加点分配
# true : 就算确认加点后、也可以撤回加点并重新分配加点。
# false : 一旦确认则不可修改。
ENABLE_REVERSE_DISTRIBUTE = true
end
#==============================================================================
# ☆ 设定结束 - END Setting ☆
#==============================================================================
$kms_imported = {} if $kms_imported == nil
$kms_imported["DistributeParameter"] = true
module KMS_DistributeParameter
# 振り分け対象パラメータ
PARAMS = [:mhp, :mmp, :atk, :def, :mat, :mdf, :agi, :luk,
:hit, :eva, :cri, :skill_speed, :item_speed, :tgr]
PARAMS |= [:hit, :eva, :cri, :cev, :mev, :mrf, :cnt, :hrg, :mrg, :trg]
PARAMS |= [:tgr, :grd, :rec, :pha, :mcr, :tcr, :pdr, :mdr, :fdr, :exr]
# パラメータ増加量構造体
GainInfo = Struct.new(:key, :name, :limit, :cost, :cost_rev, :params)
ParamInfo = Struct.new(:value, :value_rev)
# 振り分け情報構造体
DistInfo = Struct.new(:count, :hp, :mp)
#--------------------------------------------------------------------------
# ○ パラメータ増加量を構造体化
#--------------------------------------------------------------------------
def self.create_gain_param_structs(target)
result = []
target.each { |v|
info = GainInfo.new
info.key = v[:key]
info.name = v[:name]
info.limit = v[:limit]
info.cost = v[:cost][0]
info.cost_rev = (v[:cost][1] == nil ? 0 : v[:cost][1])
info.params = {}
PARAMS.each { |param|
next unless v.has_key?(param)
pinfo = ParamInfo.new
pinfo.value = v[param][0]
pinfo.value_rev = (v[param][1] == nil ? 0 : v[param][1])
info.params[param] = pinfo
}
result << info
}
return result
end
#--------------------------------------------------------------------------
# ○ パラメータ増加量を構造体化 (固有増加量用)
#--------------------------------------------------------------------------
def self.create_gain_param_structs_for_personal(target)
result = []
target.each { |list|
next if list == nil
result << create_gain_param_structs(list)
}
return result
end
#--------------------------------------------------------------------------
# ○ パラメータ増加量を併合
#--------------------------------------------------------------------------
def self.merge(list1, list2)
result = list1.clone
list2.each { |info2|
overwrite = false
list1.each_with_index { |info1, i|
if info1.key == info2.key
result = info2
overwrite = true
break
end
}
result << info2 unless overwrite
}
return result
end
# パラメータ増加量を構造体化
GAIN_PARAMS = create_gain_param_structs(GAIN_PARAMETER)
PERSONAL_GAIN_PARAMS =
create_gain_param_structs_for_personal(PERSONAL_GAIN_PARAMETER)
CLASS_GAIN_PARAMS =
create_gain_param_structs_for_personal(CLASS_GAIN_PARAMETER)
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Vocab
#==============================================================================
module Vocab
# 命中率
def self.hit
return KMS_DistributeParameter::VOCAB_PARAM[:hit]
end
# 回避率
def self.eva
return KMS_DistributeParameter::VOCAB_PARAM[:eva]
end
# クリティカル率
def self.cri
return KMS_DistributeParameter::VOCAB_PARAM[:cri]
end
# スキル速度補正
def self.skill_speed
return KMS_DistributeParameter::VOCAB_PARAM[:skill_speed]
end
# アイテム速度補正
def self.item_speed
return KMS_DistributeParameter::VOCAB_PARAM[:item_speed]
end
# 狙われやすさ
def self.tgr
return KMS_DistributeParameter::VOCAB_PARAM[:tgr]
end
# RP
def self.rp
return KMS_DistributeParameter::VOCAB_RP
end
# RP (略)
def self.rp_a
return KMS_DistributeParameter::VOCAB_RP_A
end
# パラメータ振り分け
def self.distribute_parameter
return KMS_DistributeParameter::VOCAB_MENU_DISTRIBUTE_PARAMETER
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ DataManager
#==============================================================================
module DataManager
module_function
#--------------------------------------------------------------------------
# ● セーブ内容の展開
#--------------------------------------------------------------------------
class << DataManager
unless method_defined?(:extract_save_contents_KMS_DistributeParameter)
alias extract_save_contents_KMS_DistributeParameter extract_save_contents
end
end
def extract_save_contents(contents)
extract_save_contents_KMS_DistributeParameter(contents)
KMS_Commands.check_distribution_values
Graphics.frame_reset
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# □ KMS_Commands
#==============================================================================
module KMS_Commands
module_function
#--------------------------------------------------------------------------
# ○ パラメータ振り分けに関する値をチェック
#--------------------------------------------------------------------------
def check_distribution_values
(1...$data_actors.size).each { |i|
actor = $game_actors
actor.check_distribution_values
actor.restore_distribution_values
}
end
#--------------------------------------------------------------------------
# ○ RP の増減
# actor_id : アクター ID
# value : 増減量
#--------------------------------------------------------------------------
def gain_rp(actor_id, value)
actor = $game_actors[actor_id]
return if actor == nil
actor.gain_rp(value)
end
#--------------------------------------------------------------------------
# ○ 振り分けの実行
# actor_id : アクター ID
# key : 対象パラメータのキー
# num : 振り分け次数
#--------------------------------------------------------------------------
def distribute_param_actor(actor_id, key, num = 1)
actor = $game_actors[actor_id]
return if actor == nil
# 逆加算判定
reverse = false
if num < 0
reverse = true
num = num.abs
end
# 適用
num.times { |i| actor.rp_growth_effect(key, reverse) }
end
#--------------------------------------------------------------------------
# ○ 振り分け次数をリセット
# actor_id : アクター ID
#--------------------------------------------------------------------------
def reset_distributed_count(actor_id)
actor = $game_actors[actor_id]
return if actor == nil
actor.clear_distribution_values
actor.restore_distribution_values
end
#--------------------------------------------------------------------------
# ○ パラメータ振り分け画面の呼び出し
# actor_index : アクターインデックス
#--------------------------------------------------------------------------
def call_distribute_parameter(actor_index = 0)
return if $game_party.in_battle
$game_temp.call_distribute_parameter = true
$game_party.menu_actor = $game_party.members[actor_index]
end
end
class Game_Interpreter
include KMS_Commands
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_Temp
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :call_distribute_parameter # 振り分け画面呼び出しフラグ
attr_accessor :menu_actor_index # 各種メニュー画面用のアクター index
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias initialize_KMS_DistributeParameter initialize
def initialize
initialize_KMS_DistributeParameter
@call_distribute_parameter = false
@menu_actor_index = 0
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_BattlerBase
#==============================================================================
class Game_BattlerBase
#--------------------------------------------------------------------------
# ● 能力値に加算する値をクリア
#--------------------------------------------------------------------------
alias clear_param_plus_KMS_DistributeParameter clear_param_plus
def clear_param_plus
clear_param_plus_KMS_DistributeParameter
clear_distribution_values
calc_distribution_values
end
#--------------------------------------------------------------------------
# ○ パラメータ振り分けに関する値をクリア
#--------------------------------------------------------------------------
def clear_distribution_values
@distributed_count = {}
KMS_DistributeParameter::PARAMS.each { |param|
@distributed_count[param] = 0
}
end
#--------------------------------------------------------------------------
# ○ パラメータ振り分けに関する値をチェック
#--------------------------------------------------------------------------
def check_distribution_values
last_distributed_count = @distributed_count
clear_distribution_values
@distributed_count = last_distributed_count if last_distributed_count != nil
end
#--------------------------------------------------------------------------
# ○ 各種修正値を計算
#--------------------------------------------------------------------------
def calc_distribution_values
# 継承先で定義
end
#--------------------------------------------------------------------------
# ○ 振り分けによる上昇値を取得
# param : パラメータの Symbol
#--------------------------------------------------------------------------
def distributed_param(param)
return 0
end
#--------------------------------------------------------------------------
# ○ 振り分けに関する情報を取得
#--------------------------------------------------------------------------
def distribution_info
info = KMS_DistributeParameter::DistInfo.new
info.count = @distributed_count.clone
info.hp = self.hp
info.mp = self.mp
return info
end
#--------------------------------------------------------------------------
# ○ 振り分けに関する情報を設定
#--------------------------------------------------------------------------
def set_distribution_info(info)
return unless info.is_a?(KMS_DistributeParameter::DistInfo)
@distributed_count = info.count
calc_distribution_values
self.hp = info.hp
self.mp = info.mp
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_Action
#==============================================================================
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
return speed
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ○ クラス変数
#--------------------------------------------------------------------------
@@__distribute_gain_params = {}
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# actor_id : アクター ID
#--------------------------------------------------------------------------
alias initialize_KMS_DistributeParameter initialize
def initialize(actor_id)
@actor_id = actor_id
@class_id = actor.class_id
initialize_KMS_DistributeParameter(actor_id)
end
#--------------------------------------------------------------------------
# ○ パラメータ増加量一覧を取得
#--------------------------------------------------------------------------
def gain_parameter_list
key = "#{@actor_id}_#{@class_id}"
unless @@__distribute_gain_params.has_key?(key)
result = KMS_DistributeParameter::GAIN_PARAMS
# アクター固有
list = KMS_DistributeParameter::PERSONAL_GAIN_PARAMS[@actor_id]
result = KMS_DistributeParameter.merge(result, list) if list != nil
# 職業固有
list = KMS_DistributeParameter::CLASS_GAIN_PARAMS[@class_id]
result = KMS_DistributeParameter.merge(result, list) if list != nil
@@__distribute_gain_params[key] = result
end
return @@__distribute_gain_params[key]
end
#--------------------------------------------------------------------------
# ○ パラメータ増加量を取得
# key : 振り分けキー
#--------------------------------------------------------------------------
def gain_parameter(key)
return gain_parameter_list.find { |v| v.key == key }
end
#--------------------------------------------------------------------------
# ○ 各種修正値を計算
#--------------------------------------------------------------------------
def calc_distribution_values
@rp_cost = 0
@distributed_param = {}
KMS_DistributeParameter::PARAMS.each { |param|
@distributed_param[param] = 0
}
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
last_hp = self.hp
last_mp = self.mp
last_count = distributed_count(param)
rp_growth_effect(param)
KMS_DistributeParameter::PARAMS.each { |par|
result[par] = distributed_param(par) if gain.params.include?(par)
}
rp_growth_effect(param, true) if last_count < distributed_count(param)
self.hp = last_hp
self.mp = last_mp
return result
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ○ RP の文字色を取得
# actor : アクター
#--------------------------------------------------------------------------
def rp_color(actor)
return (actor.rp == 0 ? knockout_color : normal_color)
end
#--------------------------------------------------------------------------
# ○ 振り分けゲージの色 1 の取得
#--------------------------------------------------------------------------
def distribute_gauge_color1
color = KMS_DistributeParameter::GAUGE_START_COLOR
return (color.is_a?(Integer) ? text_color(color) : color)
end
#--------------------------------------------------------------------------
# ○ 振り分けゲージの色 2 の取得
#--------------------------------------------------------------------------
def distribute_gauge_color2
color = KMS_DistributeParameter::GAUGE_END_COLOR
return (color.is_a?(Integer) ? text_color(color) : color)
end
#--------------------------------------------------------------------------
# ○ RP の描画
# actor : アクター
# x : 描画先 X 座標
# y : 描画先 Y 座標
# width : 幅
#--------------------------------------------------------------------------
def draw_actor_rp(actor, x, y, width = 124)
change_color(system_color)
draw_text(x, y, 30, line_height, Vocab::rp_a)
draw_current_and_max_values(x, y, width, actor.rp, actor.mrp,
rp_color(actor), normal_color)
change_color(normal_color)
end
#--------------------------------------------------------------------------
# ○ 振り分けゲージの描画
# actor : アクター
# param : パラメータ
# x : 描画先 X 座標
# y : 描画先 Y 座標
# width : 幅
#--------------------------------------------------------------------------
def draw_actor_distribute_gauge(actor, param, x, y, width = 124)
gain = actor.gain_parameter(param)
return if gain == nil || gain.limit <= 0
rate = actor.distributed_count(param) * 1.0 / gain.limit
if $kms_imported["GenericGauge"] &&
KMS_DistributeParameter::ENABLE_GENERIC_GAUGE
# 汎用ゲージ
draw_generic_gauge(KMS_DistributeParameter::GAUGE_IMAGE,
x, y, width, rate,
KMS_DistributeParameter::GAUGE_OFFSET,
KMS_DistributeParameter::GAUGE_LENGTH,
KMS_DistributeParameter::GAUGE_SLOPE)
else
# デフォルトゲージ
gc1 = distribute_gauge_color1
gc2 = distribute_gauge_color2
draw_gauge(x, y, width, rate, gc1, gc2)
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Window_MenuCommand
#==============================================================================
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
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# □ Window_DistributeParameterActor
#------------------------------------------------------------------------------
# 振り分け画面で、アクターの情報を表示するウィンドウです。
#==============================================================================
class Window_DistributeParameterActor < Window_Base
#--------------------------------------------------------------------------
# ○ 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :actor
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# x : ウィンドウの X 座標
# y : ウィンドウの Y 座標
# actor : アクター
#--------------------------------------------------------------------------
def initialize(x, y, actor)
super(x, y, Graphics.width, line_height + 32)
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_actor_name(@actor, 4, 0)
draw_actor_level(@actor, 140, 0)
draw_actor_rp(@actor, 240, 0)
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# □ Window_DistributeParameterList
#------------------------------------------------------------------------------
# 振り分け画面で、成長させるパラメータを選択するウィンドウです。
#==============================================================================
class Window_DistributeParameterList < Window_Selectable
#--------------------------------------------------------------------------
# ○ 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :actor
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# actor : アクター
#--------------------------------------------------------------------------
def initialize(actor)
off_h = line_height + 32
super(0, off_h, 286, Graphics.height - off_h)
@actor = actor
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ○ 選択中のパラメータの Symbol を取得
#--------------------------------------------------------------------------
def parameter_key
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 項目数の取得
#--------------------------------------------------------------------------
def item_max
return @data == nil ? 0 : @data.size
end
#--------------------------------------------------------------------------
# ● 1 ページに表示できる行数の取得
#--------------------------------------------------------------------------
def page_row_max
return super - 1
end
#--------------------------------------------------------------------------
# ● 項目を描画する矩形の取得
# index : 項目番号
#--------------------------------------------------------------------------
def item_rect(index)
rect = super(index)
rect.y += line_height
return rect
end
#--------------------------------------------------------------------------
# ● カーソルを 1 ページ後ろに移動
#--------------------------------------------------------------------------
def cursor_pagedown
return if Input.repeat?(Input::R)
super
end
#--------------------------------------------------------------------------
# ● カーソルを 1 ページ前に移動
#--------------------------------------------------------------------------
def cursor_pageup
return if Input.repeat?(Input::L)
super
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
@gain_list = @actor.gain_parameter_list
@data = []
@gain_list.each { |gain| @data << gain.key }
@item_max = @data.size + 1
create_contents
@item_max -= 1
draw_caption
@item_max.times { |i| draw_item(i, @actor.can_distribute?(@data)) }
end
#--------------------------------------------------------------------------
# ○ 見出しの描画
#--------------------------------------------------------------------------
def draw_caption
change_color(system_color)
draw_text( 4, 0, 96, line_height, "加点类型")
draw_text(120, 0, 40, line_height, Vocab.rp, 2)
draw_text(170, 0, 80, line_height, "次数", 2)
change_color(normal_color)
end
#--------------------------------------------------------------------------
# ○ 項目の描画
# index : 項目番号
# enabled : 有効フラグ
#--------------------------------------------------------------------------
def draw_item(index, enabled = true)
rect = item_rect(index)
contents.clear_rect(rect)
item = @data[index]
if item != nil
draw_parameter(rect.x, rect.y, @data[index], enabled)
end
end
#--------------------------------------------------------------------------
# ○ 能力値の描画
# x : 描画先 X 座標
# y : 描画先 Y 座標
# param : 振り分け先
# enabled : 有効フラグ
#--------------------------------------------------------------------------
def draw_parameter(x, y, param, enabled)
gain = @gain_list.find { |v| v.key == param }
return if gain == nil
change_color(normal_color)
contents.font.color.alpha = enabled ? 255 : 128
draw_text(x + 4, y, 96, line_height, gain.name)
# コスト描画
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
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# □ Window_DistributeParameterStatus
#------------------------------------------------------------------------------
# 振り分け画面で、アクターのステータスを表示するウィンドウです。
#==============================================================================
class Window_DistributeParameterStatus < Window_Base
#--------------------------------------------------------------------------
# ○ 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :actor
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# actor : アクター
#--------------------------------------------------------------------------
def initialize(actor)
dx = 286
off_h = line_height + 32
super(dx, off_h, Graphics.width - dx, Graphics.height - off_h)
@actor = actor
refresh(actor.gain_parameter_list[0].key)
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh(param = nil)
@distribute_gain = nil
if param != nil
@distribute_gain = @actor.distribute_gain(param)
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
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# □ Window_DistributeParameterConfirm
#------------------------------------------------------------------------------
# 振り分け画面で、振り分けの確定/中止を選択するウィンドウです。
#==============================================================================
class Window_DistributeParameterConfirm < Window_Command
#--------------------------------------------------------------------------
# ● ウィンドウ幅の取得
#--------------------------------------------------------------------------
def window_width
return KMS_DistributeParameter::CONFIRM_WIDTH
end
#--------------------------------------------------------------------------
# ● コマンドリストの作成
#--------------------------------------------------------------------------
def make_command_list
super
add_command(KMS_DistributeParameter::CONFIRM_COMMANDS[0], :decide)
add_command(KMS_DistributeParameter::CONFIRM_COMMANDS[1], :stop)
add_command(KMS_DistributeParameter::CONFIRM_COMMANDS[2], :cancel)
end
#--------------------------------------------------------------------------
# ● ヘルプテキスト更新
#--------------------------------------------------------------------------
def update_help
text = index >= 0 ? KMS_DistributeParameter::CONFIRM_COMMAND_HELP[index] : nil
@help_window.set_text(text)
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# ● シーン遷移に関連する更新
#--------------------------------------------------------------------------
alias update_scene_KMS_DistributeParameter update_scene
def update_scene
update_scene_KMS_DistributeParameter
update_call_distribute_parameter unless scene_changing?
end
#--------------------------------------------------------------------------
# ○ パラメータ振り分け画面呼び出し判定
#--------------------------------------------------------------------------
def update_call_distribute_parameter
if $game_temp.call_distribute_parameter && !$game_player.moving?
$game_temp.call_distribute_parameter = false
call_distribute_parameter
end
end
#--------------------------------------------------------------------------
# ○ パラメータ振り分け画面への切り替え
#--------------------------------------------------------------------------
def call_distribute_parameter
SceneManager.call(Scene_DistributeParameter)
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_Menu
#==============================================================================
class Scene_Menu < Scene_MenuBase
#--------------------------------------------------------------------------
# ● コマンドウィンドウの作成
#--------------------------------------------------------------------------
alias create_command_window_KMS_DistributeParameter create_command_window
def create_command_window
create_command_window_KMS_DistributeParameter
@command_window.set_handler(:distribute_parameter, method(:command_personal))
end
#--------------------------------------------------------------------------
# ○ コマンド [パラメータ振り分け]
#--------------------------------------------------------------------------
def command_distribute_parameter
SceneManager.call(Scene_DistributeParameter)
end
#--------------------------------------------------------------------------
# ● 個人コマンド[決定]
#--------------------------------------------------------------------------
alias on_personal_ok_KMS_DistributeParameter on_personal_ok
def on_personal_ok
on_personal_ok_KMS_DistributeParameter
if @command_window.current_symbol == :distribute_parameter
command_distribute_parameter
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# □ Scene_DistributeParameter
#------------------------------------------------------------------------------
# パラメータ振り分け画面の処理を行うクラスです。
#==============================================================================
class Scene_DistributeParameter < Scene_MenuBase
#--------------------------------------------------------------------------
# ● 開始処理
#--------------------------------------------------------------------------
def start
super
@prev_actor = @actor
@prev_info = @actor.distribution_info
create_help_window
create_actor_window
create_parameter_window
create_status_window
create_confirm_window
end
#--------------------------------------------------------------------------
# ○ アクターウィンドウ作成
#--------------------------------------------------------------------------
def create_actor_window
@actor_window = Window_DistributeParameterActor.new(0, 0, @actor)
@actor_window.viewport = @viewport
end
#--------------------------------------------------------------------------
# ○ パラメータリストウィンドウ作成
#--------------------------------------------------------------------------
def create_parameter_window
@parameter_window = Window_DistributeParameterList.new(@actor)
@parameter_window.viewport = @viewport
@parameter_window.activate
@parameter_window.set_handler(:ok, method(:on_parameter_ok))
@parameter_window.set_handler(:cancel, method(:on_parameter_cancel))
@parameter_window.set_handler(:increase, method(:on_parameter_increase))
@parameter_window.set_handler(:decrease, method(:on_parameter_decrease))
@parameter_window.set_handler(:down, method(:update_status))
@parameter_window.set_handler(:up, method(:update_status))
@parameter_window.set_handler(:pagedown, method(:next_actor))
@parameter_window.set_handler(:pageup, method(:prev_actor))
end
#--------------------------------------------------------------------------
# ○ 振り分けステータスウィンドウ作成
#--------------------------------------------------------------------------
def create_status_window
@status_window = Window_DistributeParameterStatus.new(@actor)
@status_window.viewport = @viewport
@help_window.z = @status_window.z + 100
@help_window.openness = 0
end
#--------------------------------------------------------------------------
# ○ 確認ウィンドウ作成
#--------------------------------------------------------------------------
def create_confirm_window
@confirm_window = Window_DistributeParameterConfirm.new(0, 0)
@confirm_window.x = (Graphics.width - @confirm_window.width) / 2
@confirm_window.y = (Graphics.height - @confirm_window.height) / 2
@confirm_window.z = @help_window.z
@confirm_window.viewport = @viewport
@confirm_window.help_window = @help_window
@confirm_window.openness = 0
@confirm_window.deactivate
@confirm_window.set_handler(:decide, method(:on_confirm_decide))
@confirm_window.set_handler(:stop, method(:on_confirm_stop))
@confirm_window.set_handler(:cancel, method(:on_confirm_cancel))
end
#--------------------------------------------------------------------------
# ○ ウィンドウ再描画
#--------------------------------------------------------------------------
def refresh_window
@actor_window.refresh
@parameter_window.refresh
@status_window.refresh(@parameter_window.parameter_key)
Graphics.frame_reset
end
#--------------------------------------------------------------------------
# ○ パラメータ選択 [決定]
#--------------------------------------------------------------------------
def on_parameter_ok
command_confirm
end
#--------------------------------------------------------------------------
# ○ パラメータ選択 [キャンセル]
#--------------------------------------------------------------------------
def on_parameter_cancel
command_confirm
end
#--------------------------------------------------------------------------
# ○ パラメータ選択 [加算]
#--------------------------------------------------------------------------
def on_parameter_increase
param = @parameter_window.parameter_key
unless @actor.can_distribute?(param)
Sound.play_buzzer
return
end
Sound.play_cursor
@actor.rp_growth_effect(param)
refresh_window
end
#--------------------------------------------------------------------------
# ○ パラメータ選択 [減算]
#--------------------------------------------------------------------------
def on_parameter_decrease
param = @parameter_window.parameter_key
unless reversible?(param)
Sound.play_buzzer
return
end
Sound.play_cursor
@actor.rp_growth_effect(param, true)
refresh_window
end
#--------------------------------------------------------------------------
# ○ ステータス更新
#--------------------------------------------------------------------------
def update_status
@status_window.refresh(@parameter_window.parameter_key)
end
#--------------------------------------------------------------------------
# ○ 減算可否判定
# param : 対象パラメータ
#--------------------------------------------------------------------------
def reversible?(param)
return false if @actor.distributed_count(param) == 0
return true if KMS_DistributeParameter::ENABLE_REVERSE_DISTRIBUTE
# 前回より減らなければ OK
base = @prev_info.count[param]
return ( base < @actor.distributed_count(param) )
end
#--------------------------------------------------------------------------
# ○ パラメータウィンドウに切り替え
#--------------------------------------------------------------------------
def command_parameter
@confirm_window.deactivate
@confirm_window.close
@help_window.close
@parameter_window.activate
end
#--------------------------------------------------------------------------
# ○ 確認ウィンドウに切り替え
#--------------------------------------------------------------------------
def command_confirm
@status_window.refresh
@confirm_window.index = 0
@confirm_window.activate
@confirm_window.open
@help_window.open
@parameter_window.deactivate
end
#--------------------------------------------------------------------------
# ○ 確認 [確定]
#--------------------------------------------------------------------------
def on_confirm_decide
return_scene
end
#--------------------------------------------------------------------------
# ○ 確認 [中止]
#--------------------------------------------------------------------------
def on_confirm_stop
@actor.set_distribution_info(@prev_info)
return_scene
end
#--------------------------------------------------------------------------
# ○ 確認 [キャンセル]
#--------------------------------------------------------------------------
def on_confirm_cancel
command_parameter
end
#--------------------------------------------------------------------------
# ● アクターの切り替え
#--------------------------------------------------------------------------
def on_actor_change
@prev_actor.set_distribution_info(@prev_info)
@prev_info = @actor.distribution_info
@prev_actor = @actor
@actor_window.actor = @actor
@parameter_window.actor = @actor
@status_window.actor = @actor
@parameter_window.activate
refresh_window
end
end
新增能力值#==============================================================================
# 新規パラメータ追加 ver1.21
#------------------------------------------------------------------------------
#[特徴]
# 新たにパラメータを追加します。
#
#[設定方法]
# 下記の設定項目を参照してください。
#
#[本スクリプトは]
# Kamesoft様の『パラメータ振り分け』を参考にしています。
# URL :http://ytomy.sakura.ne.jp/
# 著作者:TOMY様
#
# 作成:ぶちょー
# URL :http://nyannyannyan.bake-neko.net/
# 著作:リードミーとかに私の名前の載せたりするのは任意で。
#==============================================================================
#==============================================================================
# バージョンアップ情報
# ver1.21 アクター・職業のメモ欄の記述にも対応するように
# ver1.20 パッシブスキルの効果を追加
# スキルのメモ欄に記述することで、習得している間は能力値が上昇します
# 転職時、パラメータの増加量が初期化されていたのを修正
# %増加の設定が正しく反映されていなかったのを修正
# %増加を加算か乗算か選択できるように
# ver1.13 職業ごとにも初期値と成長値を設定できるように
# ver1.12 能力上昇効果のアイテムが使用できなかったのを修正
# ver1.11 特殊能力値の計算を一部修正
# ver1.10 新規パラメータが能力値に反映されていなかったのを修正
# 反映される能力値を追加
# ver1.01 能力値の描画に誤りがあったのを修正
# ver1.00 公開
#==============================================================================
#==============================================================================
# 設定項目
#==============================================================================
module Kazari
module AddNewParameter
# 新規パラメータの設定
# { :key => :key_name,
# :name => "パラメータ名",
# :limit => [1, 99], # [下限, 上限]
# :mhp => 1, # 1 当たりの最大HP増加量
# :mmp => 1, # 最大MP
# :atk => 1, # 攻撃力
# :def => 1, # 防御力
# :mat => 1, # 魔法力
# :mdf => 1, # 魔法防御
# :agi => 1, # 敏捷性
# :luk => 1, # 運
# :hit => 0.01, # 命中率
# :eva => 0.01, # 回避率
# :cri => 0.01, # 会心率
# :cev => 0.01, # 会心回避率
# :mev => 0.01, # 魔法回避率
# :mrf => 0.01, # 魔法反射率
# :cnt => 0.01, # 反撃率
# :hrg => 0.01, # HP再生率
# :mrg => 0.01, # MP再生率
# :trg => 0.01, # TP再生率
# :tgr => 0.01, # 狙われ率
# :grd => 0.01, # 防御効果率
# :rec => 0.01, # 回復効果率
# :pha => 0.01, # 薬の知識
# :mcr => -0.01, # MP消費率( - で軽減)
# :tcr => 0.01, # TPチャージ率
# :pdr => -0.01, # 物理ダメージ率
# :mdr => -0.01, # 魔法ダメージ率
# :fdr => -0.01, # 床ダメージ率
# :exr => 0.01, # 経験獲得率
# },
# :key は他と被らないように設定してください。
# NG: :atk, :def, :hit 等
APARAMS = [
{ :key => :str,
:name => "筋力",
:limit => [0, 99],
:mhp => 10,
:atk => 10,
},
{ :key => :vit,
:name => "体力",
:limit => [0, 99],
:mhp => 50,
:def => 10,
},
{ :key => :int,
:name => "知力",
:limit => [0, 99],
:mmp => 10,
:mat => 10,
},
{ :key => :mnd,
:name => "精神",
:limit => [0, 99],
:mmp => 50,
:mdf => 10,
:mcr => -0.01,
},
{ :key => :dex,
:name => "器用",
:limit => [0, 99],
:atk => 1,
:mat => 1,
:agi => 10,
:hit => 0.01,
},
]
# アクター毎の初期値・成長値の設定
# パラメータは 【初期値 + 成長値 × レベル】 となります。
ACTOR_PARAMETER = [
{ :id => 1, # アクターID:1
:str => [10, 0.0], # [初期値, 成長値]
:vit => [10, 0.0],
:int => [10, 0.0],
:mnd => [10, 0.0],
:dex => [10, 0.0],
},
{ :id => 2,
:str => [ 8, 0.0],
:vit => [10, 0.0],
# 設定しなかった INT は、下限値の 1 から成長しない。
:mnd => [ 3, 0.0],
:dex => [ 5, 0.0],
},
{ :id => 3,
:str => [ 5, 0.0],
:vit => [10, 0.0],
:int => [ 5, 0.0],
:mnd => [10, 0.0],
:dex => [ 5, 0.0],
},
]
# 職業毎の初期値・成長値の設定
CLASS_PARAMETER = [
{ :id => 1, # 職業ID:1
:str => [0, 0.1], # [初期値, 成長値]
:vit => [0, 0.1],
:int => [0, 0.0], # レベルアップで成長しない。
:mnd => [0, 0.1],
:dex => [0, 0.1],
},
{ :id => 2,
:str => [0, 0.1],
:vit => [0, 0.1],
# 設定しなかった INT は、下限値から成長しない。
:mnd => [0, 0.05],
:dex => [0, 0.08],
},
{ :id => 3,
:str => [0, 0.08],
:vit => [0, 0.1],
:int => [0, 0.08],
:mnd => [0, 0.1],
:dex => [0, 0.08],
},
]
# %増加の計算方法
# 0 : 加算 (例) 20%増加 + 20%増加 = 40%増加
# 120% + 120% = 140%
# 1 : 乗算 (例) 20%増加 x 20%増加 = 44%増加
# 120% x 120% = 144%
CALC_RATE = 0
#
# 《アクター/職業/武器/防具/スキル/ステートの設定方法》
# メモ欄に <パラメータ名増加:数値>
# 例)<筋力増加:10> ; 10増加
# <体力増加:10%> ; 10%増加
#
# 《アクター/職業に関して》
# この2つは、上記で設定したパラメータとメモ欄に記述したパラメータの
# 両方が反映されます。
#
# 《アイテム》
# メモ欄に <パラメータ名増加:数値> で、使用することで基礎値が永久増加。
# 例)<知力増加:1>
#
# 《エネミーの設定》
# メモ欄に <パラメータ名:数値> で、設定。設定しなかったパラメータは下限値。
# 例)<筋力:30> <器用:10>
#
end
end
#
# 《パラメータの使い方》
# スキルのダメージ計算式で使用するには以下で設定する必要があります。
# 設定すると a.key で参照可能。
# 例)a.str b.vit a.int b.mnd a.dex
#
class Game_BattlerBase
def str ; aparam(:str) ; end
def vit ; aparam(:vit) ; end
def int ; aparam(:int) ; end
def mnd ; aparam(:mnd) ; end
def dex ; aparam(:dex) ; end
end
#
# 《ステータス画面などでの描画方法》
# draw_new_parameters(actor, x, y) と書くことで追加したパラメータを描画できます。
#
#==============================================================================
# ここまで
#==============================================================================
$kzr_imported = {} if $kzr_imported == nil
$kzr_imported["AddNewParameter"] = true
#==============================================================================
# ■ Kazari::AddNewParameter
#==============================================================================
module Kazari::AddNewParameter
PARAMS = [:mhp, :mmp, :atk, :def, :mat, :mdf, :agi, :luk,
:hit, :eva, :cri, :cev, :mev, :mrf, :cnt, :hrg, :mrg, :trg,
:tgr, :grd, :rec, :pha, :mcr, :tcr, :pdr, :mdr, :fdr, :exr]
GainInfo = Struct.new(:key, :name, :limit, :params)
ParamInfo = Struct.new(:value)
ActorInfo = Struct.new(:actor_id, :params)
ClassInfo = Struct.new(:class_id, :params)
GrowInfo = Struct.new(:init, :grow)
ANAMES = {}
ALIMITS = {}
#--------------------------------------------------------------------------
# ● パラメータ増加量を構造体化
#--------------------------------------------------------------------------
def self.create_gain_param_structs(target)
result = []
target.each {|v|
ANAMES[v[:key]] = v[:name]
ALIMITS[v[:key]] = v[:limit]
info = GainInfo.new
info.key = v[:key]
info.name = v[:name]
info.limit = v[:limit]
info.params = {}
PARAMS.each {|param|
next unless v.has_key?(param)
pinfo = ParamInfo.new
pinfo.value = v[param]
info.params[param] = pinfo
}
result << info
}
return result
end
GAIN_PARAMS = create_gain_param_structs(APARAMS)
#--------------------------------------------------------------------------
# ● アクターのパラメータ成長値を構造体化
#--------------------------------------------------------------------------
def self.create_actor_param_structs(target)
result = []
load_data("Data/Actors.rvdata2").size.times do |i|
info = ActorInfo.new
info.actor_id = i
info.params = {}
GAIN_PARAMS.each {|param|
ginfo = GrowInfo.new
ginfo.init = param[:limit][0]
ginfo.grow = 0
info.params[param[:key]] = ginfo
}
result << info
end
target.each {|v|
info = ActorInfo.new
info.actor_id = v[:id]
info.params = {}
GAIN_PARAMS.each {|param|
ginfo = GrowInfo.new
if v.has_key?(param[:key])
ginfo.init = v[param[:key]][0]
ginfo.grow = v[param[:key]][1]
else
ginfo.init = param[:limit][0]
ginfo.grow = 0
end
info.params[param[:key]] = ginfo
}
result[v[:id]] = info
}
return result
end
ACTOR_PARAMS = create_actor_param_structs(ACTOR_PARAMETER)
#--------------------------------------------------------------------------
# ● 職業のパラメータ成長値を構造体化
#--------------------------------------------------------------------------
def self.create_class_param_structs(target)
result = []
load_data("Data/Classes.rvdata2").size.times do |i|
info = ClassInfo.new
info.class_id = i
info.params = {}
GAIN_PARAMS.each {|param|
ginfo = GrowInfo.new
ginfo.init = param[:limit][0]
ginfo.grow = 0
info.params[param[:key]] = ginfo
}
result << info
end
target.each {|v|
info = ClassInfo.new
info.class_id = v[:id]
info.params = {}
GAIN_PARAMS.each {|param|
ginfo = GrowInfo.new
if v.has_key?(param[:key])
ginfo.init = v[param[:key]][0]
ginfo.grow = v[param[:key]][1]
else
ginfo.init = param[:limit][0]
ginfo.grow = 0
end
info.params[param[:key]] = ginfo
}
result[v[:id]] = info
}
return result
end
CLASS_PARAMS = create_actor_param_structs(CLASS_PARAMETER)
end
#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base < Window
include Kazari::AddNewParameter
#--------------------------------------------------------------------------
# ● 新規能力値の描画
#--------------------------------------------------------------------------
def draw_new_parameters(actor, x, y)
GAIN_PARAMS.each_with_index {|param, i|
draw_actor_aparam(actor, x, y + line_height * i, param[:key])
}
end
#--------------------------------------------------------------------------
# ● 新規能力値の描画
#--------------------------------------------------------------------------
def draw_actor_aparam(actor, x, y, key)
change_color(system_color)
draw_text(x, y, 120, line_height, ANAMES[key])
change_color(normal_color)
draw_text(x + 120, y, 36, line_height, actor.aparam(key), 2)
end
end
#==============================================================================
# ■ Game_BattlerBase
#==============================================================================
class Game_BattlerBase
include Kazari::AddNewParameter
#--------------------------------------------------------------------------
# ● 能力値に加算する値をクリア
#--------------------------------------------------------------------------
alias kzr_add_new_param_clear_param_plus clear_param_plus
def clear_param_plus
kzr_add_new_param_clear_param_plus
@aparam_plus ||= {}
@ps_aparam_plus ||= {}
@ps_aparam_rate ||= {}
GAIN_PARAMS.each {|param|
@aparam_plus[param[:key]] ||= 0
@ps_aparam_plus[param[:key]] ||= 0
@ps_aparam_rate[param[:key]] ||= 1.0
}
end
#--------------------------------------------------------------------------
# ● 特徴を保持する全オブジェクトの配列取得
#--------------------------------------------------------------------------
def add_new_param_feature_objects
states
end
#--------------------------------------------------------------------------
# ● 通常能力値の加算値取得
#--------------------------------------------------------------------------
alias kzr_add_new_param_param_plus param_plus
def param_plus(param_id)
value = kzr_add_new_param_param_plus(param_id)
key = [:mhp, :mmp, :atk, :def, :mat, :mdf, :agi, :luk][param_id]
value + APARAMS.inject(0) {|r, a| r += a[key] ? a[key] * aparam(a[:key]) : 0 }
end
#--------------------------------------------------------------------------
# ● 追加能力値の取得
#--------------------------------------------------------------------------
alias kzr_add_new_param_xparam xparam
def xparam(xparam_id)
value = kzr_add_new_param_xparam(xparam_id)
key = [:hit, :eva, :cri, :cev, :mev, :mrf, :cnt, :hrg, :mrg, :trg][xparam_id]
APARAMS.inject(value) {|r, a| r += a[key] ? a[key] * aparam(a[:key]) : 0.0 }
end
#--------------------------------------------------------------------------
# ● 特殊能力値の取得
#--------------------------------------------------------------------------
alias kzr_add_new_param_sparam sparam
def sparam(sparam_id)
value = kzr_add_new_param_sparam(sparam_id)
key = [:tgr, :grd, :rec, :pha, :mcr, :tcr, :pdr, :mdr, :fdr, :exr][sparam_id]
[APARAMS.inject(value) {|r, a| r += a[key] ? a[key] * aparam(a[:key]) : 0.0 }, 0.0].max
end
#--------------------------------------------------------------------------
# ● 新規能力値の取得
#--------------------------------------------------------------------------
def aparam(key)
value = (aparam_base(key) + aparam_plus(key)) * aparam_rate(key)
[[value, ALIMITS[key][1]].min, ALIMITS[key][0]].max.to_i
end
#--------------------------------------------------------------------------
# ● 新規能力値の基礎値
#--------------------------------------------------------------------------
def aparam_base(key)
return 0
end
#--------------------------------------------------------------------------
# ● 新規能力値の加算値取得
#--------------------------------------------------------------------------
def aparam_plus(key)
@aparam_plus[key] + @ps_aparam_plus[key] + states.inject(0) {|r, obj| r += obj.aparam_plus[key] }
end
#--------------------------------------------------------------------------
# ● 新規能力値の変化率取得
#--------------------------------------------------------------------------
def aparam_rate(key)
if CALC_RATE == 0
add_new_param_feature_objects.inject(@ps_aparam_rate[key]) {|r, obj| r += obj.aparam_rate[key] - 1.0 }
else
add_new_param_feature_objects.inject(@ps_aparam_rate[key]) {|r, obj| r *= obj.aparam_rate[key] }
end
end
end
#==============================================================================
# ■ Game_Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# ● スキル/アイテムに有効な使用効果が一つでもあるかを判定
#--------------------------------------------------------------------------
alias kzr_add_new_param_item_has_any_valid_effects? item_has_any_valid_effects?
def item_has_any_valid_effects?(user, item)
return true if kzr_add_new_param_item_has_any_valid_effects?(user, item)
return item.aparam_plus.any? {|w| w[1] != 0 && !self.aparam_max?(w[0]) }
end
#--------------------------------------------------------------------------
# ● スキル/アイテムの使用者側への効果
#--------------------------------------------------------------------------
alias kzr_add_new_param_item_user_effect item_user_effect
def item_user_effect(user, item)
kzr_add_new_param_item_user_effect(user, item)
if item.aparam_plus.any? {|w| w[1] != 0 }
item.aparam_plus.each {|param|
@aparam_plus[param[0]] += param[1] }
@result.success = true
end
end
end
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
include Kazari::AddNewParameter
#--------------------------------------------------------------------------
# ● 特徴を保持する全オブジェクトの配列取得
#--------------------------------------------------------------------------
def add_new_param_feature_objects
super + [actor] + [self.class] + equips.compact
end
#--------------------------------------------------------------------------
# ● 新規能力値の基礎値
#--------------------------------------------------------------------------
def aparam_base(key)
param = ACTOR_PARAMS[@actor_id][:params][key][0]
param += ACTOR_PARAMS[@actor_id][:params][key][1] * @level
param += CLASS_PARAMS[@class_id][:params][key][0]
param += CLASS_PARAMS[@class_id][:params][key][1] * @level
param.to_i
end
#--------------------------------------------------------------------------
# ● 新規能力値の加算値取得
#--------------------------------------------------------------------------
def aparam_plus(key)
objects = [actor] + [self.class] + equips.compact
objects.inject(super) {|r, item| r += item.aparam_plus[key] }
end
#--------------------------------------------------------------------------
# ● スキルを覚える
#--------------------------------------------------------------------------
alias kzr_add_new_param_learn_skill learn_skill
def learn_skill(skill_id)
skill = $data_skills[skill_id]
unless skill_learn?(skill)
GAIN_PARAMS.each {|param|
@ps_aparam_plus[param[:key]] += skill.aparam_plus[param[:key]]
if CALC_RATE == 0
@ps_aparam_rate[param[:key]] += skill.aparam_rate[param[:key]] - 1.0
else
@ps_aparam_rate[param[:key]] *= skill.aparam_rate[param[:key]]
end
}
end
kzr_add_new_param_learn_skill(skill_id)
end
#--------------------------------------------------------------------------
# ● スキルを忘れる
#--------------------------------------------------------------------------
alias kzr_add_new_param_forget_skill forget_skill
def forget_skill(skill_id)
skill = $data_skills[skill_id]
if skill_learn?(skill)
GAIN_PARAMS.each {|param|
@ps_aparam_plus[param[:key]] -= skill.aparam_plus[param[:key]]
if CALC_RATE == 0
@ps_aparam_rate[param[:key]] -= skill.aparam_rate[param[:key]] - 1.0
else
@ps_aparam_rate[param[:key]] /= skill.aparam_rate[param[:key]]
end
}
end
kzr_add_new_param_forget_skill(skill_id)
end
#--------------------------------------------------------------------------
# ● 新規能力値が最大か判定
#--------------------------------------------------------------------------
def aparam_max?(key)
param = aparam_base(key) + @aparam_plus[key] + @ps_aparam_plus[key]
param *= @ps_aparam_rate[key]
return param > ALIMITS[key][1]
end
end
#==============================================================================
# ■ Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# ● 新規能力値の基礎値
#--------------------------------------------------------------------------
def aparam_base(key)
enemy.aparam_base[key]
end
end
#==============================================================================
# ■ RPG
#==============================================================================
module RPG
class BaseItem
def aparam_plus
return @aparam_plus if @aparam_plus != nil
@aparam_plus = {}
Kazari::AddNewParameter::GAIN_PARAMS.each {|param|
key = param[:key]
@aparam_plus[key] = get_param_plus(Kazari::AddNewParameter::ANAMES[key])
}
return @aparam_plus
end
def aparam_rate
return @aparam_rate if @aparam_rate != nil
@aparam_rate = {}
Kazari::AddNewParameter::GAIN_PARAMS.each {|param|
key = param[:key]
@aparam_rate[key] = get_param_rate(Kazari::AddNewParameter::ANAMES[key])
}
return @aparam_rate
end
def get_param_plus(name)
note.each_line {|line|
case line
when /<#{name}増加:([-])?(\d+)([%])?>/i
return $2.to_i * ($1 ? -1 : 1) unless $3
end
}
return 0
end
def get_param_rate(name)
note.each_line {|line|
case line
when /<#{name}増加:([-])?(\d+)([%])?>/i
return (100 + ($2.to_i * ($1 ? -1 : 1))) / 100.0 if $3
end
}
return 1.0
end
end
class Enemy
def aparam_base
return @aparam_base if @aparam_base != nil
@aparam_base = {}
Kazari::AddNewParameter::GAIN_PARAMS.each {|param|
key = param[:key]
@aparam_base[key] = get_param_base(key, Kazari::AddNewParameter::ANAMES[key])
}
return @aparam_base
end
def get_param_base(key, name)
note.each_line {|line|
case line
when /<#{name}:((\d+))/i ; return $1.to_i
end
}
return Kazari::AddNewParameter::ALIMITS[key][0]
end
end
end
目前在用2个脚本,一个是新增能力值脚本,可以新定义一些新的能力值并且在人物的状态画面上显示,例如力量、体质等;另一个是能力值加点脚本,可以进行能力值的加点。有没有办法让这个能力加点的脚本可以对新能力值进行加点?我搞了很久都失败了,即使在加点页面能读取新能力值数据,加的点也是无效的。 |
|