Project1
标题:
KGC加点出错
[打印本页]
作者:
夜沫痕
时间:
2013-6-15 14:53
标题:
KGC加点出错
本帖最后由 夜沫痕 于 2013-6-15 14:55 编辑
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ 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 = KGC::DistributeParameter::GAUGE_START_COLOR
return (color.is_a?(Integer) ? text_color(color) : color)
end
#--------------------------------------------------------------------------
# ○ 振り分けゲージの色 2 の取得
#--------------------------------------------------------------------------
def distribute_gauge_color2
color = KGC::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 = 120)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 40, WLH, Vocab::rp_a)
self.contents.font.color = rp_color(actor)
xr = x + width
if width < 120
self.contents.draw_text(xr - 40, y, 40, WLH, actor.rp, 2)
else
self.contents.draw_text(xr - 90, y, 40, WLH, actor.rp, 2)
self.contents.font.color = normal_color
self.contents.draw_text(xr - 50, y, 10, WLH, "/", 2)
self.contents.draw_text(xr - 40, y, 40, WLH, actor.maxrp, 2)
end
self.contents.font.color = normal_color
end
#--------------------------------------------------------------------------
# ○ 振り分けゲージの描画
# actor : アクター
# param : パラメータ
# x : 描画先 X 座標
# y : 描画先 Y 座標
# width : 幅
#--------------------------------------------------------------------------
def draw_actor_distribute_gauge(actor, param, x, y, width = 120)
gain = actor.gain_parameter(param)
return if gain == nil || gain.limit <= 0
if KGC::DistributeParameter::ENABLE_GENERIC_GAUGE &&
$imported["GenericGauge"]
# 汎用ゲージ
draw_gauge(KGC::DistributeParameter::GAUGE_IMAGE,
x, y, width, actor.distributed_count(param), gain.limit,
KGC::DistributeParameter::GAUGE_OFFSET,
KGC::DistributeParameter::GAUGE_LENGTH,
KGC::DistributeParameter::GAUGE_SLOPE)
else
# デフォルトゲージ
gw = width * actor.distributed_count(param) / gain.limit
gc1 = distribute_gauge_color1
gc2 = distribute_gauge_color2
self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Window_Command
#==============================================================================
class Window_Command < Window_Selectable
unless method_defined?(:add_command)
#--------------------------------------------------------------------------
# ○ コマンドを追加
# 追加した位置を返す
#--------------------------------------------------------------------------
def add_command(command)
@commands << command
@item_max = @commands.size
item_index = @item_max - 1
refresh_command
draw_item(item_index)
return item_index
end
#--------------------------------------------------------------------------
# ○ コマンドをリフレッシュ
#--------------------------------------------------------------------------
def refresh_command
buf = self.contents.clone
self.height = [self.height, row_max * WLH + 32].max
create_contents
self.contents.blt(0, 0, buf, buf.rect)
buf.dispose
end
#--------------------------------------------------------------------------
# ○ コマンドを挿入
#--------------------------------------------------------------------------
def insert_command(index, command)
@commands.insert(index, command)
@item_max = @commands.size
refresh_command
refresh
end
#--------------------------------------------------------------------------
# ○ コマンドを削除
#--------------------------------------------------------------------------
def remove_command(command)
@commands.delete(command)
@item_max = @commands.size
refresh
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# □ Window_DistributeParameterActor
#------------------------------------------------------------------------------
# 振り分け画面で、アクターの情報を表示するウィンドウです。
#==============================================================================
class Window_DistributeParameterActor < Window_Base
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# x : ウィンドウの X 座標
# y : ウィンドウの Y 座標
# actor : アクター
#--------------------------------------------------------------------------
def initialize(x, y, actor)
super(x, y, Graphics.width, WLH + 32)
[url=home.php?mod=space&uid=95897]@actor[/url] = actor
refresh
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
self.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
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# actor : アクター
#--------------------------------------------------------------------------
def initialize(actor)
off_h = WLH + 32
super(0, off_h, 286, Graphics.height - off_h)
[url=home.php?mod=space&uid=95897]@actor[/url] = actor
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ○ 選択中のパラメータの Symbol を取得
#--------------------------------------------------------------------------
def parameter_key
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 1 ページに表示できる行数の取得
#--------------------------------------------------------------------------
def page_row_max
return super - 1
end
#--------------------------------------------------------------------------
# ● 項目を描画する矩形の取得
# index : 項目番号
#--------------------------------------------------------------------------
def item_rect(index)
rect = super(index)
rect.y += WLH
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[i])) }
end
#--------------------------------------------------------------------------
# ○ 見出しの描画
#--------------------------------------------------------------------------
def draw_caption
self.contents.font.color = system_color
self.contents.draw_text( 4, 0, 96, WLH, "パラメータ")
self.contents.draw_text(120, 0, 40, WLH, Vocab.rp, 2)
self.contents.draw_text(170, 0, 80, WLH, "回数", 2)
self.contents.font.color = normal_color
end
#--------------------------------------------------------------------------
# ○ 項目の描画
# index : 項目番号
# enabled : 有効フラグ
#--------------------------------------------------------------------------
def draw_item(index, enabled = true)
rect = item_rect(index)
self.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
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(x + 4, y, 96, WLH, gain.name)
value = @actor.distribute_cost(param)
self.contents.draw_text(x + 120, y, 40, WLH, 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),
KGC::DistributeParameter::HIDE_MAX_COUNT_INFINITE ? "" : "/---")
end
draw_actor_distribute_gauge(@actor, param, x + 170, y, 80)
self.contents.draw_text(x + 170, y, 80, WLH, value, 2)
self.contents.font.color = normal_color
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# □ Window_DistributeParameterStatus
#------------------------------------------------------------------------------
# 振り分け画面で、アクターのステータスを表示するウィンドウです。
#==============================================================================
class Window_DistributeParameterStatus < Window_Base
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# actor : アクター
#--------------------------------------------------------------------------
def initialize(actor)
dx = 286
off_h = WLH + 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
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, 0, width - 32, WLH, "パラメータ変化", 1)
self.contents.font.color = normal_color
dy = WLH
KGC::DistributeParameter::PARAMS.each { |param|
draw_parameter(0, dy, param)
dy += WLH
}
end
#--------------------------------------------------------------------------
# ○ 能力値の描画
# x : 描画先 X 座標
# y : 描画先 Y 座標
# type : 能力値の種類
#--------------------------------------------------------------------------
def draw_parameter(x, y, type)
case type
when :maxhp
name = Vocab.hp
value = @actor.maxhp
when :maxmp
name = Vocab.mp
value = @actor.maxmp
when :atk
name = Vocab.atk
value = @actor.atk
when :def
name = Vocab.def
value = @actor.def
when :spi
name = Vocab.spi
value = @actor.spi
when :agi
name = Vocab.agi
value = @actor.agi
when :hit
name = Vocab.hit
value = @actor.hit
when :eva
name = Vocab.eva
value = @actor.eva
when :cri
name = Vocab.cri
value = @actor.cri
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 :odds
name = Vocab.odds
value = @actor.odds
else
return
end
self.contents.font.color = system_color
self.contents.draw_text(x + 4, y, 96, WLH, name)
self.contents.font.color = normal_color
self.contents.draw_text(x + 106, y, 48, WLH, value, 2)
return if @distribute_gain == nil
self.contents.draw_text(x + 154, y, 16, WLH, "→", 1)
curr = @actor.distributed_param(type)
gain = @distribute_gain[type]
self.contents.font.color = (gain > curr ? text_color(3) :
gain < curr ? text_color(2) : normal_color)
self.contents.draw_text(x + 174, y, 48, WLH, value + (gain - curr), 2)
self.contents.font.color = normal_color
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# ● 画面切り替えの実行
#--------------------------------------------------------------------------
alias update_scene_change_KGC_DistributeParameter update_scene_change
def update_scene_change
return if $game_player.moving? # プレイヤーの移動中?
if $game_temp.next_scene == :distribute_parameter
call_distribute_parameter
return
end
update_scene_change_KGC_DistributeParameter
end
#--------------------------------------------------------------------------
# ○ パラメータ振り分け画面への切り替え
#--------------------------------------------------------------------------
def call_distribute_parameter
$game_temp.next_scene = nil
$scene = Scene_DistributeParameter.new(
$game_temp.next_scene_actor_index,
0,
Scene_DistributeParameter::HOST_MAP)
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_Menu
#==============================================================================
class Scene_Menu < Scene_Base
if KGC::DistributeParameter::USE_MENU_DISTRIBUTE_PARAMETER_COMMAND
#--------------------------------------------------------------------------
# ● コマンドウィンドウの作成
#--------------------------------------------------------------------------
alias create_command_window_KGC_DistributeParameter create_command_window
def create_command_window
create_command_window_KGC_DistributeParameter
return if $imported["CustomMenuCommand"]
@__command_distribute_parameter_index =
@command_window.add_command(Vocab.distribute_parameter)
if @command_window.oy > 0
@command_window.oy -= Window_Base::WLH
end
@command_window.index = @menu_index
end
end
#--------------------------------------------------------------------------
# ● コマンド選択の更新
#--------------------------------------------------------------------------
alias update_command_selection_KGC_DistributeParameter update_command_selection
def update_command_selection
call_distribute_parameter_flag = false
if Input.trigger?(Input::C)
case @command_window.index
when @__command_distribute_parameter_index # パラメータ振り分け
call_distribute_parameter_flag = true
end
end
# パラメータ振り分け画面に移行
if call_distribute_parameter_flag
if $game_party.members.size == 0
Sound.play_buzzer
return
end
Sound.play_decision
start_actor_selection
return
end
update_command_selection_KGC_DistributeParameter
end
#--------------------------------------------------------------------------
# ● アクター選択の更新
#--------------------------------------------------------------------------
alias update_actor_selection_KGC_DistributeParameter update_actor_selection
def update_actor_selection
if Input.trigger?(Input::C)
$game_party.last_actor_index = @status_window.index
Sound.play_decision
case @command_window.index
when @__command_distribute_parameter_index # パラメータ振り分け
$scene = Scene_DistributeParameter.new(
@status_window.index,
@__command_distribute_parameter_index,
Scene_DistributeParameter::HOST_MENU)
return
end
end
update_actor_selection_KGC_DistributeParameter
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# □ Scene_DistributeParameter
#------------------------------------------------------------------------------
# パラメータ振り分け画面の処理を行うクラスです。
#==============================================================================
class Scene_DistributeParameter < Scene_Base
#--------------------------------------------------------------------------
# ○ 定数
#--------------------------------------------------------------------------
HOST_MENU = 0 # 呼び出し元 : メニュー
HOST_MAP = 1 # 呼び出し元 : マップ
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# actor_index : アクターインデックス
# menu_index : コマンドのカーソル初期位置
# host_scene : 呼び出し元 (0..メニュー 1..マップ)
#--------------------------------------------------------------------------
def initialize(actor_index = 0, menu_index = 0, host_scene = HOST_MENU)
@actor_index = actor_index
@menu_index = menu_index
@host_scene = host_scene
end
#--------------------------------------------------------------------------
# ● 開始処理
#--------------------------------------------------------------------------
def start
super
create_menu_background
@actor = $game_party.members[@actor_index]
@prev_info = @actor.distribution_info
create_windows
end
#--------------------------------------------------------------------------
# ○ ウィンドウ作成
#--------------------------------------------------------------------------
def create_windows
@actor_window = Window_DistributeParameterActor.new(0, 0, @actor)
@parameter_window = Window_DistributeParameterList.new(@actor)
@status_window = Window_DistributeParameterStatus.new(@actor)
@confirm_help_window = Window_Help.new
@confirm_help_window.z = @status_window.z + 100
@confirm_help_window.openness = 0
@confirm_window = Window_Command.new(
KGC::DistributeParameter::CONFIRM_WIDTH,
KGC::DistributeParameter::CONFIRM_COMMANDS)
@confirm_window.x = (Graphics.width - @confirm_window.width) / 2
@confirm_window.y = (Graphics.height - @confirm_window.height) / 2
@confirm_window.z = @confirm_help_window.z
@confirm_window.active = false
@confirm_window.openness = 0
end
#--------------------------------------------------------------------------
# ● 終了処理
#--------------------------------------------------------------------------
def terminate
super
dispose_menu_background
@actor_window.dispose
@parameter_window.dispose
@status_window.dispose
@confirm_help_window.dispose
@confirm_window.dispose
end
#--------------------------------------------------------------------------
# ○ 元の画面へ戻る
#--------------------------------------------------------------------------
def return_scene
case @host_scene
when HOST_MENU
$scene = Scene_Menu.new(@menu_index)
when HOST_MAP
$scene = Scene_Map.new
end
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
super
update_menu_background
update_window
if @parameter_window.active
update_parameter_list
elsif @confirm_window.active
update_confirm_command
end
end
#--------------------------------------------------------------------------
# ○ ウィンドウ更新
#--------------------------------------------------------------------------
def update_window
@actor_window.update
@parameter_window.update
@status_window.update
@confirm_help_window.update
@confirm_window.update
end
#--------------------------------------------------------------------------
# ○ ウィンドウ再描画
#--------------------------------------------------------------------------
def refresh_window
@actor_window.refresh
@parameter_window.refresh
@status_window.refresh(@parameter_window.parameter_key)
Graphics.frame_reset
end
#--------------------------------------------------------------------------
# ○ 次のアクターの画面に切り替え
#--------------------------------------------------------------------------
def next_actor
@actor_index += 1
@actor_index %= $game_party.members.size
$scene = Scene_DistributeParameter.new(@actor_index,
@menu_index, @host_scene)
end
#--------------------------------------------------------------------------
# ○ 前のアクターの画面に切り替え
#--------------------------------------------------------------------------
def prev_actor
@actor_index += $game_party.members.size - 1
@actor_index %= $game_party.members.size
$scene = Scene_DistributeParameter.new(@actor_index,
@menu_index, @host_scene)
end
#--------------------------------------------------------------------------
# ○ フレーム更新 (パラメータウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_parameter_list
if @last_index != @parameter_window.index
@status_window.refresh(@parameter_window.parameter_key)
@last_index = @parameter_window.index
end
if Input.trigger?(Input::B)
Sound.play_cancel
activate_confirm_window
elsif Input.trigger?(Input::C)
Sound.play_decision
activate_confirm_window
elsif Input.repeat?(Input::RIGHT)
# 加算
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
elsif Input.repeat?(Input::LEFT)
# 減算
param = @parameter_window.parameter_key
unless reversible?(param)
Sound.play_buzzer
return
end
Sound.play_cursor
@actor.rp_growth_effect(param, true)
refresh_window
elsif Input.trigger?(Input::R)
Sound.play_cursor
next_actor
elsif Input.trigger?(Input::L)
Sound.play_cursor
prev_actor
end
end
#--------------------------------------------------------------------------
# ○ 減算可否判定
# param : 対象パラメータ
#--------------------------------------------------------------------------
def reversible?(param)
return false if @actor.distributed_count(param) == 0
return true if KGC::DistributeParameter::ENABLE_REVERSE_DISTRIBUTE
base = @prev_info.count[param]
return ( base < @actor.distributed_count(param) )
end
#--------------------------------------------------------------------------
# ○ 確認ウィンドウに切り替え
#--------------------------------------------------------------------------
def activate_confirm_window
@last_index = -1
@status_window.refresh
@confirm_window.index = 0
@confirm_window.active = true
@confirm_window.open
@confirm_help_window.open
@parameter_window.active = false
@last_confirm_index = -1
end
#--------------------------------------------------------------------------
# ○ フレーム更新 (確認ウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_confirm_command
if @last_confirm_index != @confirm_window.index
@confirm_help_window.set_text(
KGC::DistributeParameter::CONFIRM_COMMAND_HELP[@confirm_window.index])
@last_confirm_index = @confirm_window.index
end
if Input.trigger?(Input::B)
Sound.play_cancel
# パラメータウィンドウに切り替え
@confirm_window.active = false
@confirm_window.close
@confirm_help_window.close
@parameter_window.active = true
elsif Input.trigger?(Input::C)
Sound.play_decision
case @confirm_window.index
when 0 # 確定
return_scene
when 1 # 中止
@actor.set_distribution_info(@prev_info)
return_scene
when 2 # キャンセル
# パラメータウィンドウに切り替え
@confirm_window.active = false
@confirm_window.close
@confirm_help_window.close
@parameter_window.active = true
end
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_File
#==============================================================================
class Scene_File < Scene_Base
#--------------------------------------------------------------------------
# ● セーブデータの読み込み
# file : 読み込み用ファイルオブジェクト (オープン済み)
#--------------------------------------------------------------------------
alias read_save_data_KGC_DistributeParameter read_save_data
def read_save_data(file)
read_save_data_KGC_DistributeParameter(file)
KGC::Commands.check_distribution_values
Graphics.frame_reset
end
end
复制代码
---------------------------
此脚本 的第 428 行发生了 NameError .
uninitialized constant KGC::DistributeParameter
---------------------------
确定
---------------------------
翻译得:如果KGC::::分布参数使用菜单分配参数的命令
如何解决?
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1