| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 3 |
| 经验 | |
| 最后登录 | 2026-7-19 |
| 在线时间 | 61 小时 |
- 梦石
- 0
- 星屑
- 292
- 在线时间
- 61 小时
- 注册时间
- 2014-2-9
- 回帖
- 7
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
我使用了Custom Menu Base脚本#******************************************************************************
#
# * Custom Menu Base
#
# --------------------------------------------------------------------------
# バージョン : 1.1.4
# 対 応 : RPGツクールVX Ace : RGSS3
# 制 作 者 : CACAO
# 配 布 元 : http://cacaosoft.webcrow.jp/
# --------------------------------------------------------------------------
# == 概 要 ==
#
# : カスタムメニューのベーススクリプトです。
#
# --------------------------------------------------------------------------
# == 注意事項 ==
#
# ※ このスクリプトは、なるべく下のほうのに導入してください。
# ※ カスタムメニュー関連のスクリプトより上に導入してください。
#
#
#******************************************************************************
#==============================================================================
# ◆ ユーザー設定
#==============================================================================
module CAO
module CM
#--------------------------------------------------------------------------
# ◇ メニュー項目の設定
#--------------------------------------------------------------------------
COMMAND_ITEMS = {}
COMMAND_ITEMS[:item] = {
:name => "アイテム",
:command => Scene_Item,
:help => 'アイテムを使用します。'
}
COMMAND_ITEMS[:skill] = {
:name => "スキル",
:personal => Scene_Skill,
:help => 'スキルを使用します。'
}
COMMAND_ITEMS[:equip] = {
:name => "装備",
:personal => Scene_Equip,
:help => '装備を変更します。'
}
COMMAND_ITEMS[:status] = {
:name => "ステータス",
:personal => Scene_Status,
:help => 'ステータスを確認します。'
}
COMMAND_ITEMS[:formation] = {
:name => "並び替え",
:command => :command_formation,
:enable => :formation_enabled,
:help => 'パーティを入れ替えます。'
}
COMMAND_ITEMS[:save] = {
:name => "セーブ",
:command => Scene_Save,
:hide => "$game_system.save_disabled",
:help => 'ゲームをセーブします。'
}
COMMAND_ITEMS[:game_end] = {
:name => "ゲーム終了",
:command => Scene_End,
:help => 'ゲームを終了します。'
}
COMMAND_ITEMS[:load] = {
:name => "ロード",
:command => Scene_Load,
:enable => "DataManager.save_file_exists?",
:help => 'ゲームをロードします。'
}
COMMAND_ITEMS[:script] = {
:name => "スクリプト",
:command => "msgbox 'メッセージの表示'",
:help => "メッセージボックスを表示します。"
}
COMMAND_ITEMS[:common] = {
:name => "コモンイベント",
:command => 'start_common_event(1)',
:refresh => [:command, :text]
}
COMMAND_ITEMS[:common2] = {
:name => "レベルアップ!",
:personal => 'start_common_event(3)',
:refresh => [:status]
}
COMMAND_ITEMS[:common3] = {
:name => "予約コモン",
:command => '$game_temp.reserve_common_event(2)',
}
COMMAND_ITEMS[:sw] = {
:name => [17, "スイッチ ON", "スイッチ OFF"],
:command => "$game_switches[17] ^= true",
:refresh => [:command]
}
COMMAND_ITEMS[:sub] = {
:name => "サブコマンド",
:sub => :sub,
:help => "サブコマンドのテストを行います。"
}
COMMAND_ITEMS[:file] = {
:name => "ファイル",
:sub => :file,
:help => "ゲームのセーブ・ロードを行います。"
}
#--------------------------------------------------------------------------
# ◇ 表示項目の設定
#--------------------------------------------------------------------------
COMMANDS = {} # <= 消さない!
# メインコマンド 必須
COMMANDS[:main] =
[:item, :skill, :equip, :status, :formation, :save, :game_end]
# サブコマンド
COMMANDS[:file] =
[:save, :load]
COMMANDS[:sub] =
[:item, :status, :sw, :script, :common, :common2, :common3]
#--------------------------------------------------------------------------
# ◇ コマンドウィンドウの文字サイズ
#--------------------------------------------------------------------------
COMMAND_SIZE = 24
#--------------------------------------------------------------------------
# ◇ コマンドウィンドウの一行の縦幅
#--------------------------------------------------------------------------
# 0 で文字サイズを基準に自動調整
#--------------------------------------------------------------------------
COMMAND_HEIGHT = 0
#--------------------------------------------------------------------------
# ◇ 残りHPで顔グラを変化させる
#--------------------------------------------------------------------------
EXPRESSIVE_RATE = []
#--------------------------------------------------------------------------
# ◇ 顔グラをまとめる
#--------------------------------------------------------------------------
COLLECT_FACE = false
#--------------------------------------------------------------------------
# ◇ 立ち絵のファイル名
#--------------------------------------------------------------------------
PORTRAIT_NAME = "MActor%d"
#--------------------------------------------------------------------------
# ◇ コモンイベントの自動実行
#--------------------------------------------------------------------------
START_COMMON_ID = 0 # 開始前処理
TERMINATE_COMMON_ID = 0 # 終了前処理
#--------------------------------------------------------------------------
# ◇ 背景画像
#--------------------------------------------------------------------------
# 前景画像(最前面に表示されます。)
FILE_FOREGROUND = nil
# 背景画像(デフォルトのマップ画像と入れ替えます。)
FILE_BACKGROUND = nil
# アニメ画像 ["ファイル名", vx, vy, 最背面?]
BACKIMAGE = nil
#--------------------------------------------------------------------------
# ◇ システム文字の有無
#--------------------------------------------------------------------------
VISIBLE_SYSTEM = true
#--------------------------------------------------------------------------
# ◇ 用語設定
#--------------------------------------------------------------------------
VOCABS = {}
VOCABS[:gold] = "所持金"
VOCABS[:exp] = "経験値"
VOCABS[:exp_a] = "LvUP"
end # module CM
end # module CAO
#/////////////////////////////////////////////////////////////////////////////#
# #
# 下記のスクリプトを変更する必要はありません。 #
# #
#/////////////////////////////////////////////////////////////////////////////#
class CustomizeError < Exception; end
class Game_MenuItem
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
attr_reader :symbol #
attr_reader :sub #
attr_reader :enable #
attr_reader :refresh_items #
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def initialize(symbol, params = {})
@symbol = symbol # 項目の識別子
@name = params[:name] || "" # 項目名
@help = params[:help] || "" # ヘルプ
@icon = params[:icon] # アイコン番号
@enable = params[:enable] || true # 選択の可否
@Hide = params[:hide] || false # 非表示の有無
@Scene = params[:scene] # 項目処理 シーン遷移
@command = params[:command] # 項目処理 コマンド実行
@Personal = params[:personal] # 項目処理 アクター選択
@sub = params[:sub] # 項目処理 サブコマンド
case [@scene, @command, @personal, @sub].count {|o| o }
when 0; raise CustomizeError, "項目処理が設定されていません。"
when 1 # Do Nothing
else; raise CustomizeError, "複数の項目処理が設定されています。"
end
@refresh_items = params[:refresh] || [] # 項目処理後に再描画
@auto_close = params[:auto_close] || false # アクター選択時コマンドを閉じる
@continue = params[:continue] || false # アクター選択継続
@sw_sub = params[:sw_sub] || false # サブ表示時にメインを非表示
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def _convert_value(obj)
if obj.is_a?(Array)
case obj[0]
when String
result = eval(obj[0], ::TOPLEVEL_BINDING)
return result if obj.size == 1
return obj[result ? 1 : 2] if result == !!result
return obj[result + 1]
when Integer
if obj.size == 3
return obj[$game_switches[obj[0]] ? 1 : 2]
else
return obj[$game_variables[obj[0]]]
end
else
raise "must not happen"
end
else
return obj
end
end
private :_convert_value
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def name
return _convert_value(@name)
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def help
return _convert_value(@help)
end
alias description help
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def icon_index
return _convert_value(@icon)
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def handler
return :command_ok if @scene
return @command if @command && @command.is_a?(Symbol)
return :command_ok if @command
return @personal if @personal && @personal.is_a?(Symbol)
return :command_personal if @personal
return :command_sub if @sub
raise "must not happen"
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def exec
#
# ここでエラーが発生した場合、項目の設定が間違っている可能性があります。
# 項目処理の設定を確認してください。
#
# エラーメッセージを確認の上、設定を修正してください。
# つづり間違いや文法が間違っている可能性があります。
#
if @scene
case @scene
when Class
return SceneManager.call(@scene.untaint)
when Symbol
return SceneManager.call(Kernel.const_get(@scene).untaint)
when String
return SceneManager.call(eval(@scene, ::TOPLEVEL_BINDING).untaint)
end
else
command = @command || @personal
case command
when Class
return SceneManager.call(command.untaint)
when String
return SceneManager.scene.instance_eval(command)
end
end
raise "must not happen"
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def hide?
#
# ここでエラーが発生した場合、項目の設定が間違っている可能性があります。
# オプションの :hide の設定を確認してください。
#
case @hide
when true, false
return @hide
when String
return eval(@hide, ::TOPLEVEL_BINDING)
else
raise "must not happen"
end
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def personal?
return !@personal.nil?
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def refresh?
return !@refresh_items.empty?
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def switch?
return @sw_sub
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def auto_close?
return @auto_close
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def continue?
return @continue
end
end
class Scene_Menu::Game_Interpreter < Game_Interpreter
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
undef command_101 # 文章の表示
undef command_102 # 選択肢の表示
undef command_103 # 数値入力の処理
undef command_104 # アイテム選択の処理
undef command_105 # スクロール文章の表示
undef command_201 # 場所移動
undef command_204 # マップのスクロール
undef command_205 # 移動ルートの設定
undef command_217 # 隊列メンバーの集合
undef command_261 # ムービーの再生
undef command_301 # バトルの処理
undef command_351 # メニュー画面を開く
end
class Scene_Menu
#--------------------------------------------------------------------------
# ○ 開始処理
#--------------------------------------------------------------------------
def start
super
if CAO::CM::START_COMMON_ID > 0
start_common_event(CAO::CM::START_COMMON_ID)
end
@caller = []
create_command_window
create_status_window
create_option_window
end
#--------------------------------------------------------------------------
# ○ フレーム更新
#--------------------------------------------------------------------------
def update
super
update_backimage
update_command_window
update_status_window
update_option_window
end
#--------------------------------------------------------------------------
# ○ 終了前処理
#--------------------------------------------------------------------------
def pre_terminate
super
if CAO::CM::TERMINATE_COMMON_ID > 0
start_common_event(CAO::CM::TERMINATE_COMMON_ID)
end
end
#--------------------------------------------------------------------------
# ○ 終了処理
#--------------------------------------------------------------------------
def terminate
super
dispose_command_window
dispose_status_window
dispose_option_window
end
#--------------------------------------------------------------------------
# ○ 背景の作成
#--------------------------------------------------------------------------
def create_background
if CAO::CM::FILE_BACKGROUND
@background_sprite = Sprite.new
@background_sprite.bitmap = Cache.system(CAO::CM::FILE_BACKGROUND)
else
super
end
if CAO::CM::BACKIMAGE
@backimage_sprite = Plane.new
@backimage_sprite.bitmap = Cache.system(CAO::CM::BACKIMAGE[0])
@backimage_sprite.z = -1 if CAO::CM::BACKIMAGE[3]
end
if CAO::CM::FILE_FOREGROUND
@foreground_sprite = Sprite.new
@foreground_sprite.z = 1000
@foreground_sprite.bitmap = Cache.system(CAO::CM::FILE_FOREGROUND)
end
end
#--------------------------------------------------------------------------
# ○ 背景の解放
#--------------------------------------------------------------------------
def dispose_background
super
@backimage_sprite.dispose if @backimage_sprite
@foreground_sprite.dispose if @foreground_sprite
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def update_backimage
return unless @backimage_sprite
return unless CAO::CM::BACKIMAGE[1] && CAO::CM::BACKIMAGE[2]
@backimage_sprite.ox = (@backimage_sprite.ox - CAO::CM::BACKIMAGE[1]) % 999
@backimage_sprite.oy = (@backimage_sprite.oy - CAO::CM::BACKIMAGE[2]) % 999
end
#--------------------------------------------------------------------------
# ● コマンドウィンドウの作成
#--------------------------------------------------------------------------
def create_command_window
# Do Nothing
end
#--------------------------------------------------------------------------
# ● ステータスウィンドウの作成
#--------------------------------------------------------------------------
def create_status_window
# Do Nothing
end
#--------------------------------------------------------------------------
# ● オプションウィンドウの作成
#--------------------------------------------------------------------------
def create_option_window
# Do Nothing
end
#--------------------------------------------------------------------------
# ● コマンドウィンドウの更新
#--------------------------------------------------------------------------
def update_command_window
# Do Nothing
end
#--------------------------------------------------------------------------
# ● ステータスウィンドウの更新
#--------------------------------------------------------------------------
def update_status_window
# Do Nothing
end
#--------------------------------------------------------------------------
# ● オプションウィンドウの更新
#--------------------------------------------------------------------------
def update_option_window
# Do Nothing
end
#--------------------------------------------------------------------------
# ● コマンドウィンドウの解放
#--------------------------------------------------------------------------
def dispose_command_window
# Do Nothing
end
#--------------------------------------------------------------------------
# ● ステータスウィンドウの解放
#--------------------------------------------------------------------------
def dispose_status_window
# Do Nothing
end
#--------------------------------------------------------------------------
# ● オプションウィンドウの解放
#--------------------------------------------------------------------------
def dispose_option_window
# Do Nothing
end
#--------------------------------------------------------------------------
# ● コモンイベント予約判定
# イベントの呼び出しが予約されているならマップ画面へ遷移する。
#--------------------------------------------------------------------------
def check_common_event
SceneManager.goto(Scene_Map) if $game_temp.common_event_reserved?
end
#--------------------------------------------------------------------------
# ● コモンベントの実行
#--------------------------------------------------------------------------
def start_common_event(common_event_id)
if @status_window && @status_window.index >= 0
$game_party.menu_actor = $game_party.members[@status_window.index]
end
interpreter = Scene_Menu::Game_Interpreter.new
interpreter.setup($data_common_events[common_event_id].list)
interpreter.update while interpreter.running?
end
#--------------------------------------------------------------------------
# ● 現在アクティブなコマンドウィンドウ
#--------------------------------------------------------------------------
def current_console
@caller.last || @command_window
end
#--------------------------------------------------------------------------
# ● 以前操作していたコマンドウィンドウ
#--------------------------------------------------------------------------
def previous_console
@caller[-2] || @command_window
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def change_console(console)
@caller << console
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def return_console
current_console.deactivate.close
previous_console.activate.open
@caller.pop
end
#--------------------------------------------------------------------------
# ● コマンド実行後の処理
#--------------------------------------------------------------------------
def post_terminate
item = current_console.current_data
current_console.activate if !current_console.locked?
end
#--------------------------------------------------------------------------
# ● コマンド [決定]
#--------------------------------------------------------------------------
def command_ok
current_console.current_exec
post_terminate
check_common_event
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def command_sub
if current_console == @subcommand_window
raise CustomizeError, "サブコマンドからは呼び出せません。"
end
@command_window.close if @command_window.current_data.switch?
symbol = @command_window.current_data.sub
@subcommand_window.init_command(symbol)
@subcommand_window.clear_handler
@subcommand_window.set_handler(:cancel, method(:return_console))
@subcommand_window.set_handlers(self)
change_console(@subcommand_window)
open_sub_command
end
#--------------------------------------------------------------------------
# ○ コマンド[スキル][装備][ステータス]
#--------------------------------------------------------------------------
def command_personal
@status_window.select_last
@status_window.activate
@status_window.set_handler(:ok, method(:on_personal_ok))
@status_window.set_handler(:cancel, method(:on_personal_cancel))
current_console.close if current_console.current_data.auto_close?
end
#--------------------------------------------------------------------------
# ○ 個人コマンド [決定]
#--------------------------------------------------------------------------
def on_personal_ok
command_ok
if current_console.current_data.continue?
current_console.deactivate
@status_window.activate
end
end
#--------------------------------------------------------------------------
# ○ 個人コマンド[終了]
#--------------------------------------------------------------------------
def on_personal_cancel
@status_window.unselect
current_console.activate.open
end
#--------------------------------------------------------------------------
# ○ 並び替え[キャンセル]
#--------------------------------------------------------------------------
def on_formation_cancel
if @status_window.pending_index >= 0
@status_window.pending_index = -1
@status_window.activate
else
@status_window.unselect
current_console.activate.open
end
end
#--------------------------------------------------------------------------
# ● サブコマンドウィンドウを開く
#--------------------------------------------------------------------------
def open_sub_command
return if scene_changing?
@subcommand_window.activate.open
end
#--------------------------------------------------------------------------
# ● サブコマンドウィンドウを閉じる
#--------------------------------------------------------------------------
def close_sub_command
@subcommand_window.deactivate.close
end
end
module CustomMenuCommand
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(ident)
@ident = ident
super()
unlock
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def init_command(ident)
@ident = ident
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def current_commands
CAO::CM::COMMANDS[@ident]
end
#--------------------------------------------------------------------------
# ● 項目数の取得
#--------------------------------------------------------------------------
def item_max
@list.size
end
#--------------------------------------------------------------------------
# ● コマンドリストのクリア
#--------------------------------------------------------------------------
def clear_command_list
@list = []
end
#--------------------------------------------------------------------------
# ● コマンドリストの作成
#--------------------------------------------------------------------------
def make_command_list
return unless @ident
unless current_commands
raise CustomizeError,
"識別子 :#{@ident} のメニューコマンドの設定がありません。(COMMANDS)"
end
current_commands.each do |symbol|
unless CAO::CM::COMMAND_ITEMS[symbol]
puts "識別子 :#{symbol} の項目の設定がありません。(COMMAND_ITEMS)"
next
end
item = Game_MenuItem.new(symbol, CAO::CM::COMMAND_ITEMS[symbol])
@list << item unless item.hide?
end
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def lock
@locked = true
self
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def unlock
@locked = false
self
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def locked?
@locked
end
#--------------------------------------------------------------------------
# ● コマンドの有効状態を取得
#--------------------------------------------------------------------------
def command_enabled?(index)
param = @list[index].enable
return false if @list[index].personal? && !$game_party.exists
return true if param == true
return false if param == false
return eval(param.to_s) if param.is_a?(Symbol) || param.is_a?(String)
raise "must not happen"
end
#--------------------------------------------------------------------------
# ● コマンド名の取得
#--------------------------------------------------------------------------
def command_name(index)
@list[index].name
end
#--------------------------------------------------------------------------
# ● コマンドアイコン番号の取得
#--------------------------------------------------------------------------
def command_icon_index(index)
return @list[index].icon_index
end
#--------------------------------------------------------------------------
# ● 選択項目のコマンドデータを取得
#--------------------------------------------------------------------------
def current_data
index >= 0 ? @list[index] : nil
end
#--------------------------------------------------------------------------
# ● 選択項目の有効状態を取得
#--------------------------------------------------------------------------
def current_item_enabled?
index >= 0 ? command_enabled?(index) : false
end
#--------------------------------------------------------------------------
# ● 選択項目のシンボルを取得
#--------------------------------------------------------------------------
def current_symbol
current_data ? current_data.symbol : nil
end
#--------------------------------------------------------------------------
# ● 選択項目のインデックスを取得
#--------------------------------------------------------------------------
def current_index
@list.index {|item| item.symbol == current_symbol }
end
#--------------------------------------------------------------------------
# ● 選択項目の実行
#--------------------------------------------------------------------------
def current_exec
current_data.exec
end
#--------------------------------------------------------------------------
# ● 指定されたシンボルを持つコマンドにカーソルを移動
#--------------------------------------------------------------------------
def select_symbol(symbol)
@list.each_index {|i| select(i) if @list.symbol == symbol }
end
#--------------------------------------------------------------------------
# ● ハンドラのクリア
#--------------------------------------------------------------------------
def clear_handler
@handler = {}
end
#--------------------------------------------------------------------------
# ● 動作に対応するハンドラの設定
#--------------------------------------------------------------------------
def set_handlers(obj)
#
# ここでエラーが発生した場合、項目の設定が間違っている可能性があります。
# 項目処理の設定を確認してください。
#
# NameError : undefined method `○○' for class `Scene_Menu'
# つづりが間違っていないか確認してください。
#
# NameError : undefined method `command_sub' for class `Scene_Menu'
# 『サブコマンド』スクリプトが未導入の可能性があります。
#
@list.each {|cmd| @handler[cmd.symbol] = obj.method(cmd.handler) }
end
end
class Window_CustomMenuCommand < Window_MenuCommand
include CustomMenuCommand
#--------------------------------------------------------------------------
# ● ウィンドウ内容の幅を計算
#--------------------------------------------------------------------------
def contents_width
(item_width + spacing) * col_max - spacing
end
#--------------------------------------------------------------------------
# ● 行の高さを取得
#--------------------------------------------------------------------------
def line_height
if CAO::CM::COMMAND_HEIGHT == 0
return default_font_size
else
return CAO::CM::COMMAND_HEIGHT
end
end
#--------------------------------------------------------------------------
# ● 横に項目が並ぶときの空白の幅を取得
#--------------------------------------------------------------------------
def spacing
return 8
end
#--------------------------------------------------------------------------
# ● 初期フォントサイズ
#--------------------------------------------------------------------------
def default_font_size
return Font.default_size if CAO::CM::COMMAND_SIZE == 0
return CAO::CM::COMMAND_SIZE
end
#--------------------------------------------------------------------------
# ● フォントサイズのリセット
#--------------------------------------------------------------------------
def reset_font_size
contents.font.size = default_font_size
end
#--------------------------------------------------------------------------
# ● カーソルを下に移動
#--------------------------------------------------------------------------
def cursor_down(wrap = false)
if index < item_max - col_max || (wrap && col_max == 1)
select((index + col_max) % item_max)
elsif col_max != 1 && index < (item_max.to_f/col_max).ceil*col_max-col_max
select(item_max - 1)
end
end
#--------------------------------------------------------------------------
# ● 項目の描画
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
enabled = command_enabled?(index)
if command_icon_index(index)
draw_icon(command_icon_index(index), rect.x, rect.y, enabled)
rect.x += 26
rect.width -= 28
else
rect.x += 4
rect.width -= 8
end
change_color(normal_color, enabled)
draw_text(rect, command_name(index), alignment)
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
self.contents.clear
reset_font_size
draw_all_items
end
end
class Sprite_CustomMenuCursor < Sprite
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def initialize(data, viewport = nil)
super(viewport)
@filename = data[0]
@distance_x = data[1] || 1
@distance_y = data[2] || 1
@view_behind = data[3] || data[3] == nil
@flash_amount = data[4] || 0
self.bitmap = Cache.system(@filename)
self.z = @view_behind ? -1 : 1
self.ox = self.bitmap.width / 2
self.oy = self.bitmap.height / 2
self.opacity = 0
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def update
super
update_flash
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def update_flash
return if @flash_amount == 0
last_opacity = self.opacity
self.opacity += @flash_amount
@flash_amount *= -1 if self.opacity == last_opacity
end
end
class Spriteset_CustomMenuCommand
#--------------------------------------------------------------------------
# ● 定数
#--------------------------------------------------------------------------
OPEN_SPEED = 16
#--------------------------------------------------------------------------
# ● クラスインスタンス変数
#--------------------------------------------------------------------------
class << self
attr_accessor :last_command_symbol # カーソル位置 保存用
end
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :index
attr_reader :openness
attr_reader :help_window # ヘルプウィンドウ
attr_accessor :x
attr_accessor :y
attr_accessor :viewport
attr_accessor :visible
attr_accessor :active
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
@handler = {}
@index = -1
@x = 0
@y = 0
@visible = true
@active = false
@openness = 255 # 変更は self.openness で行なう
@opening = false
@closing = false
end
#--------------------------------------------------------------------------
# ● 項目数の取得 (要再定義)
#--------------------------------------------------------------------------
def item_max
return 0
end
#--------------------------------------------------------------------------
# ● コマンド名の取得 (要再定義)
#--------------------------------------------------------------------------
def command_name(index)
return ""
end
#--------------------------------------------------------------------------
# ● コマンドファイル名 (要再定義)
#--------------------------------------------------------------------------
def command_filename
return ""
end
#--------------------------------------------------------------------------
# ● コマンド総数の取得 (要再定義)
#--------------------------------------------------------------------------
def command_max
return 0
end
#--------------------------------------------------------------------------
# ● カーソルデータの取得
#--------------------------------------------------------------------------
def cursor_data
return nil
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def dispose
dispose_command_sprites
dispose_cursor_sprite
end
#--------------------------------------------------------------------------
# ● スプライトの表示
#--------------------------------------------------------------------------
def show
self.visible = true
self
end
#--------------------------------------------------------------------------
# ● スプライトの非表示
#--------------------------------------------------------------------------
def hide
self.visible = false
self
end
#--------------------------------------------------------------------------
# ● スプライトのアクティブ化
#--------------------------------------------------------------------------
def activate
self.active = true
self
end
#--------------------------------------------------------------------------
# ● スプライトの非アクティブ化
#--------------------------------------------------------------------------
def deactivate
self.active = false
self
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def openness=(value)
@openness = value
update_openness
end
#--------------------------------------------------------------------------
# ● ウィンドウを開く
#--------------------------------------------------------------------------
def open
@opening = true unless open?
@closing = false
self
end
#--------------------------------------------------------------------------
# ● ウィンドウを閉じる
#--------------------------------------------------------------------------
def close
@closing = true unless close?
@opening = false
self
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def open?
@openness = 255 if @openness > 255
return @openness == 255
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def close?
@openness = 0 if @openness < 0
return @openness == 0
end
#--------------------------------------------------------------------------
# ● 開く処理の更新
#--------------------------------------------------------------------------
def update_open
@openness += OPEN_SPEED
@opening = false if open?
end
#--------------------------------------------------------------------------
# ● 閉じる処理の更新
#--------------------------------------------------------------------------
def update_close
@openness -= OPEN_SPEED
@closing = false if close?
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def visible=(value)
@visible = value
@cursor_sprite.visible = value if @cursor_sprite
end
#--------------------------------------------------------------------------
# ● カーソル位置の設定
#--------------------------------------------------------------------------
def index=(index)
@index = index
refresh
call_update_help
end
#--------------------------------------------------------------------------
# ● 項目の選択
#--------------------------------------------------------------------------
def select(index)
self.index = index if index && @index != index
end
#--------------------------------------------------------------------------
# ● 項目の選択解除
#--------------------------------------------------------------------------
def unselect
self.index = -1
end
#--------------------------------------------------------------------------
# ● 前回の選択位置を復帰
#--------------------------------------------------------------------------
def select_last
select_symbol(self.class.last_command_symbol)
end
#--------------------------------------------------------------------------
# ● 項目の選択位置を記憶
#--------------------------------------------------------------------------
def save_command_position
self.class.last_command_symbol = current_symbol
end
#--------------------------------------------------------------------------
# ● 前回の選択位置を削除
#--------------------------------------------------------------------------
def init_command_position
self.class.last_command_symbol = nil
end
#--------------------------------------------------------------------------
# ● 動作に対応するハンドラの設定
# method : ハンドラとして設定するメソッド (Method オブジェクト)
#--------------------------------------------------------------------------
def set_handler(symbol, method)
@handler[symbol] = method
end
#--------------------------------------------------------------------------
# ● ハンドラの存在確認
#--------------------------------------------------------------------------
def handle?(symbol)
@handler.include?(symbol)
end
#--------------------------------------------------------------------------
# ● ハンドラの呼び出し
#--------------------------------------------------------------------------
def call_handler(symbol)
@handler[symbol].call if handle?(symbol)
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
update_cursor_sprite
update_command_sprites
update_openness
process_cursor_move
process_handling
end
#--------------------------------------------------------------------------
# ● 開閉更新
#--------------------------------------------------------------------------
def update_openness
return unless @command_sprites
update_open if @opening
update_close if @closing
@command_sprites.each {|sp| sp.opacity = @openness }
end
#--------------------------------------------------------------------------
# ● カーソルの移動処理
#--------------------------------------------------------------------------
def process_cursor_move
return unless cursor_movable?
last_index = @index
cursor_down (Input.trigger?(:DOWN)) if Input.repeat?(:DOWN)
cursor_up (Input.trigger?(:UP)) if Input.repeat?(:UP)
cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
cursor_left (Input.trigger?(:LEFT)) if Input.repeat?(:LEFT)
cursor_pagedown if !handle?(:pagedown) && Input.trigger?(:R)
cursor_pageup if !handle?(:pageup) && Input.trigger?(:L)
Sound.play_cursor if @index != last_index
end
#--------------------------------------------------------------------------
# ● 決定やキャンセルなどのハンドリング処理
#--------------------------------------------------------------------------
def process_handling
return unless active
return process_ok if Input.trigger?(:C)
return process_cancel if Input.trigger?(:B)
end
#--------------------------------------------------------------------------
# ● カーソルの移動可能判定
#--------------------------------------------------------------------------
def cursor_movable?
active && item_max > 0
end
#--------------------------------------------------------------------------
# ● カーソルを下に移動
#--------------------------------------------------------------------------
def cursor_down(wrap = false)
if @index + cursor_dy >= 0 && @index + cursor_dy < item_max || wrap
select((@index + cursor_dy) % item_max)
end
end
#--------------------------------------------------------------------------
# ● カーソルを上に移動
#--------------------------------------------------------------------------
def cursor_up(wrap = false)
if @index - cursor_dy >= 0 && @index - cursor_dy < item_max || wrap
select((@index - cursor_dy) % item_max)
end
end
#--------------------------------------------------------------------------
# ● カーソルを右に移動
#--------------------------------------------------------------------------
def cursor_right(wrap = false)
if @index + cursor_dx >= 0 && @index + cursor_dx < item_max || wrap
select((@index + cursor_dx) % item_max)
end
end
#--------------------------------------------------------------------------
# ● カーソルを左に移動
#--------------------------------------------------------------------------
def cursor_left(wrap = false)
if @index - cursor_dx >= 0 && @index - cursor_dx < item_max || wrap
select((@index - cursor_dx) % item_max)
end
end
#--------------------------------------------------------------------------
# ● カーソルを 1 ページ後ろに移動
#--------------------------------------------------------------------------
def cursor_pagedown
# Do Nothing
end
#--------------------------------------------------------------------------
# ● カーソルを 1 ページ前に移動
#--------------------------------------------------------------------------
def cursor_pageup
# Do Nothing
end
#--------------------------------------------------------------------------
# ● 決定ボタンが押されたときの処理
#--------------------------------------------------------------------------
def process_ok
save_command_position
if current_item_enabled?
Sound.play_ok
Input.update
deactivate
if handle?(current_symbol)
call_handler(current_symbol)
elsif handle?(:ok)
call_handler(:ok)
else
activate
end
else
Sound.play_buzzer
end
end
#--------------------------------------------------------------------------
# ● キャンセルボタンが押されたときの処理
#--------------------------------------------------------------------------
def process_cancel
Sound.play_cancel
Input.update
deactivate
call_handler(:cancel)
end
#--------------------------------------------------------------------------
# ● ヘルプウィンドウの設定
#--------------------------------------------------------------------------
def help_window=(help_window)
@help_window = help_window
call_update_help
end
#--------------------------------------------------------------------------
# ● ヘルプウィンドウ更新メソッドの呼び出し
#--------------------------------------------------------------------------
def call_update_help
update_help if active && @help_window
end
#--------------------------------------------------------------------------
# ● ヘルプウィンドウの更新
#--------------------------------------------------------------------------
def update_help
@help_window.clear
end
#--------------------------------------------------------------------------
# ● 主要コマンドの有効状態を取得
#--------------------------------------------------------------------------
def main_commands_enabled
$game_party.exists
end
#--------------------------------------------------------------------------
# ● 並び替えの有効状態を取得
#--------------------------------------------------------------------------
def formation_enabled
$game_party.members.size >= 2 && !$game_system.formation_disabled
end
#--------------------------------------------------------------------------
# ● セーブの有効状態を取得
#--------------------------------------------------------------------------
def save_enabled
!$game_system.save_disabled
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def create_cursor_sprite
unless cursor_data
raise CustomizeError, "カーソルの情報が設定されていません。"
end
return unless cursor_data[0]
return if cursor_data[0].empty?
@cursor_sprite = Sprite_CustomMenuCursor.new(cursor_data, viewport)
update_cursor_sprite
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def update_cursor_sprite
return unless @cursor_sprite
if !open? || !@visible
@cursor_sprite.visible = false
end
if @active
if @index < 0
@cursor_sprite.visible = false
else
@cursor_sprite.visible = true
@cursor_sprite.x = @command_sprites[@index].x
@cursor_sprite.y = @command_sprites[@index].y
@cursor_sprite.update
end
end
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def dispose_cursor_sprite
return unless @cursor_sprite
@cursor_sprite.dispose
end
#--------------------------------------------------------------------------
# ● カーソル画像の取得
#--------------------------------------------------------------------------
def cursor_bitmap
return nil unless cursor_data
return nil if cursor_data[0].empty?
return Cache.system(cursor_data[0])
end
#--------------------------------------------------------------------------
# ● カーソルの移動量
#--------------------------------------------------------------------------
def cursor_dx
return cursor_data[1]
end
#--------------------------------------------------------------------------
# ● カーソルの移動量
#--------------------------------------------------------------------------
def cursor_dy
return cursor_data[2]
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new(0, 0, 0, 0)
rect.x = @command_sprites[index].x
rect.y = @command_sprites[index].y
rect.width = @command_sprites[index].bitmap.width
rect.height = @command_sprites[index].bitmap.height
return rect
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def create_command_sprites
@command_sprites = Array.new(item_max) do |i|
sp = Sprite.new(viewport)
sp.bitmap = Bitmap.new(image_width(i), image_height(i))
sp.ox = sp.bitmap.width / 2
sp.oy = sp.bitmap.height / 2
yield(sp, i) if defined? yield
sp
end
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update_command_sprites
return unless @command_sprites
@command_sprites.each {|sp| sp.update }
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def dispose_command_sprites
return unless @command_sprites
@command_sprites.each do |sp|
sp.bitmap.dispose
sp.dispose
end
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def image_index(index)
result = 0
result += 1 if @index == index
result += 2 unless command_enabled?(index)
return result
end
#--------------------------------------------------------------------------
# ● src_rect
#--------------------------------------------------------------------------
def image_rect(index)
rect = @command_sprites[index].bitmap.rect
if multi_image?
cmd_index = current_commands.index(@list[index].symbol)
rect.x = @command_sprites[index].bitmap.width * image_index(index)
rect.y = @command_sprites[index].bitmap.height * cmd_index
else
rect.x = 0
rect.y = @command_sprites[index].bitmap.height * image_index(index)
end
return rect
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def refresh_command(index)
bitmap = @command_sprites[index].bitmap
bitmap.clear
bitmap.blt(0, 0, command_image(index), image_rect(index))
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def refresh_commands
@command_sprites.each_with_index do |sp, i|
refresh_command(i)
yield(sp, i) if defined? yield
end
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def command_image(index)
if multi_image?
Cache.system(command_filename)
else
Cache.system(command_name(index))
end
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def multi_image?
return !command_filename.empty?
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def image_width(index)
return command_image(index).width / 4 if multi_image?
return command_image(index).width
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def image_height(index)
return command_image(index).height / command_max if multi_image?
return command_image(index).height / 4
end
end
class Game_Actor
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :portrait_name # 立ち絵 ファイル名
#--------------------------------------------------------------------------
# ● 立ち絵のファイル名を取得
#--------------------------------------------------------------------------
def portrait_name
filename = @portrait_name ? @portrait_name : CAO::CM::PORTRAIT_NAME
return sprintf(filename, self.id, self.expression_index)
end
#--------------------------------------------------------------------------
# ● 顔グラ(表情)のインデックスを取得
#--------------------------------------------------------------------------
def face_expression_index
index = CAO::CM::COLLECT_FACE ? @face_index - (@face_index % 4) : 0
return index + self.expression_index
end
#--------------------------------------------------------------------------
# ● 表情のインデックスを取得
#--------------------------------------------------------------------------
def expression_index
rate = (self.hp_rate * 100).ceil
index = CAO::CM::EXPRESSIVE_RATE.index {|r| r < rate }
return index || CAO::CM::EXPRESSIVE_RATE.size
end
#--------------------------------------------------------------------------
# ● 経験値の割合を取得
#--------------------------------------------------------------------------
def cm_exp_rate
return 1.0 if max_level?
return self.cm_accumulated_exp / self.cm_requisite_exp.to_f
end
#--------------------------------------------------------------------------
# ● レベルアップに必要な経験値を取得
#--------------------------------------------------------------------------
def cm_requisite_exp
return 0 if max_level?
return self.next_level_exp - self.current_level_exp
end
#--------------------------------------------------------------------------
# ● 獲得した経験値を取得 (現レベル)
#--------------------------------------------------------------------------
def cm_accumulated_exp
return self.exp - self.current_level_exp
end
#--------------------------------------------------------------------------
# ● レベルアップに必要な残りの経験値を取得
#--------------------------------------------------------------------------
def cm_remaining_exp
return 0 if max_level?
return self.next_level_exp - self.exp
end
end
class CAO::CM::Canvas
include CAO::CM
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :window
attr_reader :bitmap
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(obj)
case obj
when Window
@window = obj
@bitmap = obj.contents
when Bitmap
@window = nil
@bitmap = obj
else
raise TypeError,
"wrong argument type #{obj.class} (expected Bitmap or Window)"
end
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def contents
return @window ? @window.contents : @bitmap
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def draw_actor_items(actor, x, y, list)
#
# メニューステータスの設定が間違っている可能性があります。
# 表示項目の設定を確認してください。
#
# TypeError
# 引数の型(数値や文字列など)が間違っています。
# 設定がずれているかもしれません。
# 設定は必ず [シンボル, 数値, 数値, ... ] の形で始まります。
# 識別子とx座標とy座標の設定は省略できません。
#
# ArgumentError : wrong number of arguments
# 引数の数が間違っています。
# オプション部分の設定に間違いがないか確認してください。
#
list.each do |params|
symbol = params[0]
argv = params[1, params.size]
xx, yy = argv[0], argv[1]
unless METHODS_NAME[symbol]
puts "識別子 :#{symbol} の処理は定義されていません。"
next
end
unless xx && yy
raise CustomizeError, "描画する座標が設定されていません。"
end
begin
opt = (argv.size <= 2) ? [] : argv[2, argv.size - 2]
eval("#{METHODS_NAME[symbol]}(actor, x + xx, y + yy, *opt)")
rescue
msg = "{ Actor(#{actor.respond_to?(:id)&&actor.id}) "
msg << "Symbol(:#{symbol}) Method(#{METHODS_NAME[symbol]}) }\n"
msg << $!.message
raise $!, msg, $!.backtrace
end
end
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
METHODS_NAME = {}
METHODS_NAME[:w_chara] = '@window.draw_actor_graphics'
METHODS_NAME[:w_face] = '@window.draw_actor_face'
METHODS_NAME[:w_name] = '@window.draw_actor_name'
METHODS_NAME[:w_class] = '@window.draw_actor_class'
METHODS_NAME[:w_nick] = '@window.draw_actor_nickname'
METHODS_NAME[:w_level] = '@window.draw_actor_level'
METHODS_NAME[:w_state] = '@window.draw_actor_icons'
METHODS_NAME[:w_hp] = '@window.draw_actor_hp'
METHODS_NAME[:w_mp] = '@window.draw_actor_mp'
METHODS_NAME[:w_tp] = '@window.draw_actor_tp'
if CAO::CM::EXPRESSIVE_RATE.empty?
METHODS_NAME[:face] = :draw_actor_face
else
METHODS_NAME[:face] = :draw_actor_expression
end
METHODS_NAME[:chara] = :draw_actor_graphic
METHODS_NAME[:name] = :draw_actor_name
METHODS_NAME[:class] = :draw_actor_class
METHODS_NAME[:nick] = :draw_actor_nickname
METHODS_NAME[:level] = :draw_actor_level
METHODS_NAME[:lv_g] = :draw_actor_level_g
METHODS_NAME[:state] = :draw_actor_icons
METHODS_NAME[:hp] = :draw_actor_hp
METHODS_NAME[:mp] = :draw_actor_mp
METHODS_NAME[:tp] = :draw_actor_tp
METHODS_NAME[:exp] = :draw_actor_exp
METHODS_NAME[:param] = :draw_actor_param
METHODS_NAME[:icon] = :draw_actor_icon
METHODS_NAME[:bust] = :draw_actor_portrait
METHODS_NAME[:fill] = :draw_actor_rect
METHODS_NAME[:pict] = :draw_actor_picture
METHODS_NAME[:text] = :draw_actor_text
METHODS_NAME[:num] = :draw_actor_number
#--------------------------------------------------------------------------
# ● 定数
#--------------------------------------------------------------------------
COLOR_AIB_1 = Color.new(0, 0, 0) # アクターアイコンの縁の色
COLOR_AIB_2 = Color.new(255, 255, 255) # アクターアイコンの背景色
#--------------------------------------------------------------------------
# ● 行の高さを取得
#--------------------------------------------------------------------------
def line_height
return 24
end
#--------------------------------------------------------------------------
# ● 半透明描画用のアルファ値を取得
#--------------------------------------------------------------------------
def translucent_alpha
return 160
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def str2color(value)
case value
when Color
return value
when Array
return Color.new(*value)
when Integer
num = value
when Symbol, String
text = value.to_s.sub(/^(0x|x)/, "")
case text.size
when 1; text = text * 6 << 'FF'
when 2; text = text[0] * 6 << text[1] * 2
when 3; text = text[0] * 2 << text[1] * 2 << text[2] * 2 << 'FF'
when 4; text = text[0] * 2 << text[1] * 2 << text[2] * 2 << text[3] * 2
when 6; text = text[0, 6] << 'FF'
end
num = eval("0x#{text}")
end
return Color.new(num >> 24, num >> 16 & 255, num >> 8 & 255, num & 255)
end
#--------------------------------------------------------------------------
# ● 文字色取得
# n : 文字色番号(0..31)
#--------------------------------------------------------------------------
def text_color(n, enabled = true)
color = Cache.system("Window").get_pixel(64+(n%8)*8, 96+(n/8)*8)
color.alpha = translucent_alpha unless enabled
return color
end
#--------------------------------------------------------------------------
# ● 各種文字色の取得
#--------------------------------------------------------------------------
def normal_color; text_color(0); end; # 通常
def system_color; text_color(16); end; # システム
def crisis_color; text_color(17); end; # ピンチ
def knockout_color; text_color(18); end; # 戦闘不能
def gauge_back_color; text_color(19); end; # ゲージ背景
def hp_gauge_color1; text_color(20); end; # HP ゲージ 1
def hp_gauge_color2; text_color(21); end; # HP ゲージ 2
def mp_gauge_color1; text_color(22); end; # MP ゲージ 1
def mp_gauge_color2; text_color(23); end; # MP ゲージ 2
def mp_cost_color; text_color(23); end; # 消費 MP
def power_up_color; text_color(24); end; # 装備 パワーアップ
def power_down_color; text_color(25); end; # 装備 パワーダウン
def tp_gauge_color1; text_color(28); end; # TP ゲージ 1
def tp_gauge_color2; text_color(29); end; # TP ゲージ 2
def tp_cost_color; text_color(29); end; # 消費 TP
def exp_gauge_color1; text_color(30); end; # EXP ゲージ 1
def exp_gauge_color2; text_color(31); end; # EXP ゲージ 2
#--------------------------------------------------------------------------
# ● 保留項目の背景色を取得
#--------------------------------------------------------------------------
def pending_color
Cache.system("Window").get_pixel(80, 80)
end
#--------------------------------------------------------------------------
# ● テキスト描画色の変更
#--------------------------------------------------------------------------
def change_color(color, enabled = true)
if block_given?
last_color = self.contents.font.color.dup
change_color(color, enabled)
yield
self.contents.font.color = last_color
else
self.contents.font.color.set(color)
self.contents.font.color.alpha = translucent_alpha unless enabled
end
end
#--------------------------------------------------------------------------
# ● テキストサイズの変更
#--------------------------------------------------------------------------
def change_size(size)
if block_given?
last_size = self.contents.font.size
change_size(size)
yield
self.contents.font.size = last_size
else
self.contents.font.size = size
end
end
#--------------------------------------------------------------------------
# ● テキストの描画
#--------------------------------------------------------------------------
def draw_text(*args)
contents.draw_text(*args)
end
#--------------------------------------------------------------------------
# ● テキストサイズの取得
#--------------------------------------------------------------------------
def text_size(str)
contents.text_size(str)
end
#--------------------------------------------------------------------------
# ● 制御文字つきテキストの描画
#--------------------------------------------------------------------------
def draw_text_ex(x, y, text)
reset_font_settings
text = convert_escape_characters(text)
pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
process_character(text.slice!(0, 1), text, pos) until text.empty?
end
#--------------------------------------------------------------------------
# ● フォント設定のリセット
#--------------------------------------------------------------------------
def reset_font_settings
change_color(normal_color)
contents.font.size = Font.default_size
contents.font.bold = Font.default_bold
contents.font.italic = Font.default_italic
end
#--------------------------------------------------------------------------
# ● 制御文字の事前変換
# 実際の描画を始める前に、原則として文字列に変わるものだけを置き換える。
# 文字「\」はエスケープ文字(\e)に変換。
#--------------------------------------------------------------------------
def convert_escape_characters(text)
result = text.to_s.clone
result.gsub!(/\r\n/) { "\n" }
result.gsub!(/\\/) { "\e" }
result.gsub!(/\e\e/) { "\\" }
result.gsub!(/\e({+)/i) { "\e{" * $1.count("{") }
result.gsub!(/\e(}+)/i) { "\e}" * $1.count("}") }
result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }
result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }
result.gsub!(/\eS\[(\d+),(.*?),(.*?)\]/i) { $game_switches[$1.to_i]?$2:$3 }
result.gsub!(/\eN\[(\d+)\]/i) { actor_name($1.to_i) }
result.gsub!(/\eP\[(\d+)\]/i) { party_member_name($1.to_i) }
result.gsub!(/\eG/i) { Vocab::currency_unit }
result.gsub!(/\e\$/) { $game_party.gold }
result.gsub!(/\eW/) { $game_party.steps }
result.gsub!(/\eT\[(.+?)\]/i) { play_time($1) }
result.gsub!(/\eT/i) { play_time }
result.gsub!(/\en/) { "\n" }
result.gsub!(/<%(.*?)%>/) { eval($1) }
result
end
#--------------------------------------------------------------------------
# ● アクター n 番の名前を取得
#--------------------------------------------------------------------------
def actor_name(n)
actor = n >= 1 ? $game_actors[n] : nil
actor ? actor.name : ""
end
#--------------------------------------------------------------------------
# ● パーティメンバー n 番の名前を取得
#--------------------------------------------------------------------------
def party_member_name(n)
actor = n >= 1 ? $game_party.members[n - 1] : nil
actor ? actor.name : ""
end
#--------------------------------------------------------------------------
# ● プレイ時間を取得
#--------------------------------------------------------------------------
def play_time(format = '%3d:%02d:%02d')
total = Graphics.frame_count / Graphics.frame_rate
return sprintf(format,
(total / 3600), (total / 60 % 60), (total % 60), (total / 60), total)
end
#--------------------------------------------------------------------------
# ● 文字の処理
# c : 文字
# text : 描画処理中の文字列バッファ(必要なら破壊的に変更)
# pos : 描画位置 {:x, :y, :new_x, :height}
#--------------------------------------------------------------------------
def process_character(c, text, pos)
case c
when "\n" # 改行
process_new_line(text, pos)
when "\e" # 制御文字
process_escape_character(obtain_escape_code(text), text, pos)
else # 普通の文字
process_normal_character(c, pos)
end
end
#--------------------------------------------------------------------------
# ● 通常文字の処理
#--------------------------------------------------------------------------
def process_normal_character(c, pos)
text_width = text_size(c).width
draw_text(pos[:x], pos[:y], text_width * 2, pos[:height], c)
pos[:x] += text_width
end
#--------------------------------------------------------------------------
# ● 改行文字の処理
#--------------------------------------------------------------------------
def process_new_line(text, pos)
pos[:x] = pos[:new_x]
pos[:y] += pos[:height]
pos[:height] = calc_line_height(text)
end
#--------------------------------------------------------------------------
# ● 制御文字の本体を破壊的に取得
#--------------------------------------------------------------------------
def obtain_escape_code(text)
text.slice!(/^[\$\.\|\^!><\{\}\\]|^[A-Z]+/i)
end
#--------------------------------------------------------------------------
# ● 制御文字の引数を破壊的に取得
#--------------------------------------------------------------------------
def obtain_escape_param(text)
text.slice!(/^\[-?\d+\]/)[/-?\d+/].to_i rescue 0
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def obtain_escape_value(text, value)
text.slice!(/^\[([+-]?)(\d+)\]/i)
return value + $2.to_i if $1 == '+'
return value - $2.to_i if $1 == '-'
return $2.to_i
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def obtain_escape_picparam(text)
return [] unless text.slice!(/^\[(.+?)\]/)
params = $1.split(',')
params.each {|s| s.strip! }
return params
end
#--------------------------------------------------------------------------
# ● 制御文字の処理
# code : 制御文字の本体部分(「\C[1]」なら「C」)
#--------------------------------------------------------------------------
def process_escape_character(code, text, pos)
case code.upcase
when 'C'
change_color(text_color(obtain_escape_param(text)))
when 'I'
if text[/^\[\d+\]/]
process_draw_icon(obtain_escape_param(text), pos)
else
process_draw_picture(obtain_escape_picparam(text))
end
when 'P'
process_draw_picture(obtain_escape_picparam(text))
when 'F'
process_draw_face(obtain_escape_picparam(text))
when '{'
make_font_bigger
when '}'
make_font_smaller
when 'X'
pos[:x] = obtain_escape_value(text, pos[:x])
when 'Y'
pos[:y] = obtain_escape_value(text, pos[:y])
when 'L'
process_draw_line(text, pos)
end
end
#--------------------------------------------------------------------------
# ● 制御文字によるライン描画の処理
#--------------------------------------------------------------------------
def process_draw_line(text, pos)
if text.slice!(/^\[(\d+)\s*,\s*(\d+)(?:\s*,\s*([AFHTMBXS]+))?\]/i)
x, y, w, h, params = pos[:x], pos[:y], $1.to_i, $2.to_i, ($3 || "")
# 描画幅を文字サイズから (A:自動,F:全角,H:半角)
case params
when /A/i; w = text_size(text[0, w]).width
when /F/i; w = text_size(" " * w).width
when /H/i; w = text_size(" " * w).width
end
# 線の描画位置 (t:上,m:中,b:下, デフォルトは下)
unless params[/T/i]
if params[/M/i]
y += (pos[:height] + h) / 2
else
y += pos[:height] - h
end
end
# 影の描画
if params[/S/i]
w -= 1
color = gauge_back_color
color.alpha = translucent_alpha
self.contents.fill_rect(x + 1, y + 1, w, h, color)
end
# 線の描画
self.contents.fill_rect(x, y, w, h, self.contents.font.color)
# x座標を進める
x += w if params[/X/i]
elsif text.slice!(/^\[([0-9, ]+?)(0x[0-9A-F]+)?\]/i)
color = $2
param = $1.sub(/, *$/, '').split(',').map {|s| s.to_i }
if param.is_a?(Array) && param.size == 4
if color
draw_fill_rect(*param, str2color(color))
else
self.contents.fill_rect(*param, self.contents.font.color)
end
end
end
end
#--------------------------------------------------------------------------
# ● 制御文字によるアイコン描画の処理
#--------------------------------------------------------------------------
def process_draw_icon(icon_index, pos)
draw_icon(icon_index, pos[:x], pos[:y] + (pos[:height] - 24) / 2)
pos[:x] += 24
end
#--------------------------------------------------------------------------
# ● 制御文字によるピクチャ描画の処理
#--------------------------------------------------------------------------
def process_draw_picture(params)
return if params.empty?
bitmap = Cache.picture(params[0] || "")
x = (params[1] || 0).to_i
y = (params[2] || 0).to_i
opacity = (params[3] || 255).to_i
hue = (params[4] || 0).to_i
if hue != 0
bitmap = bitmap.dup
bitmap.hue_change(hue)
end
contents.blt(x, y, bitmap, bitmap.rect, opacity)
end
#--------------------------------------------------------------------------
# ● 制御文字による顔グラ描画の処理
#--------------------------------------------------------------------------
def process_draw_face(params)
return if params.empty?
if params.size == 3
actor = $game_actors[params[0].to_i]
bitmap = Cache.face(actor.face_name)
index = actor.face_index
x = (params[1] || 0).to_i
y = (params[2] || 0).to_i
else
bitmap = Cache.face(params[0] || "")
index = (params[1] || 0).to_i
x = (params[2] || 0).to_i
y = (params[3] || 0).to_i
end
contents.blt(x, y, bitmap, Rect.new(index % 4 * 96, index / 4 * 96, 96, 96))
end
#--------------------------------------------------------------------------
# ● フォントを大きくする
#--------------------------------------------------------------------------
def make_font_bigger
contents.font.size += 4 if contents.font.size <= 92
end
#--------------------------------------------------------------------------
# ● フォントを小さくする
#--------------------------------------------------------------------------
def make_font_smaller
contents.font.size -= 4 if contents.font.size >= 10
end
#--------------------------------------------------------------------------
# ● 行の高さを計算
# restore_font_size : 計算後にフォントサイズを元に戻す
#--------------------------------------------------------------------------
def calc_line_height(text, restore_font_size = true)
result = [line_height, contents.font.size].max
last_font_size = contents.font.size
text.slice(/^.*$/).scan(/\e[\{\}]/).each do |esc|
make_font_bigger if esc == "\e{"
make_font_smaller if esc == "\e}"
result = [result, contents.font.size].max
end
contents.font.size = last_font_size if restore_font_size
result
end
#--------------------------------------------------------------------------
# ● 矩形の描画
#--------------------------------------------------------------------------
def draw_fill_rect(x, y, width, height, color)
bitmap = Bitmap.new(width, height)
bitmap.fill_rect(bitmap.rect, color)
self.contents.blt(x, y, bitmap, bitmap.rect)
bitmap.dispose
end
#--------------------------------------------------------------------------
# ● ゲージの描画
# rate : 割合(1.0 で満タン)
# color1 : グラデーション 左端
# color2 : グラデーション 右端
#--------------------------------------------------------------------------
def draw_gauge(x, y, width, rate, color1, color2)
fill_w = (width * rate).to_i
gauge_y = y + line_height - 8
contents.fill_rect(x, gauge_y, width, 6, gauge_back_color)
contents.gradient_fill_rect(x, gauge_y, fill_w, 6, color1, color2)
end
#--------------------------------------------------------------------------
# ● アイコンの描画
#--------------------------------------------------------------------------
def draw_icon(icon_index, x, y, enabled = true)
bitmap = Cache.system("Iconset")
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
end
#--------------------------------------------------------------------------
# ● 顔グラフィックの描画
#--------------------------------------------------------------------------
def draw_face(face_name, face_index, x, y, size = 96, enabled = true)
bitmap = Cache.face(face_name)
dest_rect = Rect.new(x, y, 96, 96)
src_rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
opacity = enabled ? 255 : translucent_alpha
case size
when Integer
src_rect.x += (96 - size) / 2
src_rect.y += (96 - size) / 2
src_rect.width = size
src_rect.height = size
contents.blt(x, y, bitmap, src_rect, opacity)
when Array
case size.size
when 1
dest_rect.width, dest_rect.height = size[0], size[0]
when 2
dest_rect.width, dest_rect.height = size[0], size[1]
when 4
dest_rect.width, dest_rect.height = size[2], size[3]
src_rect.width, src_rect.height = size[2], size[3]
src_rect.x, src_rect.y = src_rect.x + size[0], src_rect.y + size[1]
else
raise "wrong number of elements (#{size.size} of 2)"
end
contents.stretch_blt(dest_rect, bitmap, src_rect, opacity)
else
raise TypeError,
"wrong argument type #{size.class} (expected Integer or Array)"
end
end
#--------------------------------------------------------------------------
# ● 歩行グラフィックの描画
#--------------------------------------------------------------------------
def draw_character(character_name, character_index, x, y)
return unless character_name
bitmap = Cache.character(character_name)
sign = character_name[/^[\!\$]./]
if sign && sign.include?('$')
cw = bitmap.width / 3
ch = bitmap.height / 4
else
cw = bitmap.width / 12
ch = bitmap.height / 8
end
n = character_index
src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
#--------------------------------------------------------------------------
# ● HP の文字色を取得
#--------------------------------------------------------------------------
def hp_color(actor)
return knockout_color if actor.hp == 0
return crisis_color if actor.hp < actor.mhp / 4
return normal_color
end
#--------------------------------------------------------------------------
# ● MP の文字色を取得
#--------------------------------------------------------------------------
def mp_color(actor)
return crisis_color if actor.mp < actor.mmp / 4
return normal_color
end
#--------------------------------------------------------------------------
# ● TP の文字色を取得
#--------------------------------------------------------------------------
def tp_color(actor)
return normal_color
end
#--------------------------------------------------------------------------
# ● アクターの歩行グラフィック描画
#--------------------------------------------------------------------------
def draw_actor_graphic(actor, x, y)
draw_character(actor.character_name, actor.character_index, x, y)
end
#--------------------------------------------------------------------------
# ● アクターの顔グラフィック描画
#--------------------------------------------------------------------------
def draw_actor_face(actor, x, y, size = 96)
draw_face(actor.face_name, actor.face_index, x, y, size)
end
#--------------------------------------------------------------------------
# ● アクターの表情グラフィック描画
#--------------------------------------------------------------------------
def draw_actor_expression(actor, x, y, size = 96)
draw_face(actor.face_name, actor.face_expression_index, x, y, size)
end
#--------------------------------------------------------------------------
# ● 歩行アイコンの描画
# enabled : 有効フラグ。false のとき半透明で描画
#--------------------------------------------------------------------------
def draw_actor_icon(actor, x, y, enabled = true)
return unless actor
self.contents.fill_rect(x, y, 24, 24, COLOR_AIB_1)
self.contents.fill_rect(x + 1, y + 1, 22, 22, COLOR_AIB_2)
return unless actor.character_name
return if actor.character_name.empty?
bitmap = Cache.character(actor.character_name)
sign = actor.character_name[/^[\!\$]./]
if sign != nil and sign.include?('$')
cw = bitmap.width / 3
ch = bitmap.height / 4
else
cw = bitmap.width / 12
ch = bitmap.height / 8
end
n = actor.character_index
src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, 20, 20)
src_rect.x += (cw - src_rect.width) / 2
src_rect.y += (ch - src_rect.height) / 4
opacity = (enabled ? 255 : translucent_alpha)
self.contents.blt(x + 2, y + 2, bitmap, src_rect, opacity)
end
#--------------------------------------------------------------------------
# ● 立ち絵の描画
#--------------------------------------------------------------------------
def draw_actor_portrait(actor, x, y, enabled = true)
return unless actor
bitmap = Cache.picture(actor.portrait_name)
opacity = (enabled ? 255 : translucent_alpha)
self.contents.blt(x, y, bitmap, bitmap.rect, opacity)
end
#--------------------------------------------------------------------------
# ● ピクチャの描画
# [:pict, x, y, "file", "script"]
# [:pict, x, y, nil, "script"]
# [:pict, x, y, ["file","file"], "script(bool)"]
# [:pict, x, y, ["file","file"], "script(number)"]
# [:pict, x, y, "pattern", "script"]
#--------------------------------------------------------------------------
def draw_actor_picture(actor, x, y, file, script = nil)
return unless actor
r, f1, f2 = script && eval(script), *file
case r
when nil
filename = (actor.battle_member? ? f1 : f2) || f1
when true, false
filename = r ? f1 : f2
else
filename = file.nil? ? r
: file.kind_of?(String) ? sprintf(file, *r)
: file[r]
end
if filename && filename != ""
bitmap = Cache.picture(filename % actor.id)
self.contents.blt(x, y, bitmap, bitmap.rect)
end
end
#--------------------------------------------------------------------------
# ● テキストの描画
#--------------------------------------------------------------------------
def draw_actor_text(actor, x, y, text, script = nil)
return if script && !eval(script)
draw_text_ex(x, y, text.gsub(/\\{(\w+?)}/) { actor.__send__($1) })
end
#--------------------------------------------------------------------------
# ● 数字画像の描画
#--------------------------------------------------------------------------
def draw_actor_number(actor, x, y, num, file)
bitmap = Cache.picture(file)
r_num = Rect.new(0, 0, bitmap.width / 13, bitmap.height)
param = String(num.is_a?(String) ? eval(num) : num)
param.split(//).each_with_index do |c,i|
case c
when ' '; next
when '+'; index = 10
when '-'; index = 11
when /\d/; index = Integer(c)
else; index = 12
end
r_num.x = r_num.width * index
self.contents.blt(x + r_num.width * i, y, bitmap, r_num)
end
end
#--------------------------------------------------------------------------
# ● 名前の描画
#--------------------------------------------------------------------------
def draw_actor_name(actor, x, y, width = 124)
change_color(hp_color(actor))
draw_text(x, y, width, line_height, actor.name)
end
#--------------------------------------------------------------------------
# ● 職業の描画
#--------------------------------------------------------------------------
def draw_actor_class(actor, x, y, width = 124)
change_color(normal_color)
draw_text(x, y, width, line_height, actor.class.name)
end
#--------------------------------------------------------------------------
# ● 二つ名の描画
#--------------------------------------------------------------------------
def draw_actor_nickname(actor, x, y, width = 124)
change_color(normal_color)
draw_text(x, y, width, line_height, actor.nickname)
end
#--------------------------------------------------------------------------
# ● レベルの描画
#--------------------------------------------------------------------------
def draw_actor_level(actor, x, y, width = 64)
if VISIBLE_SYSTEM
change_color(system_color)
draw_text(x, y, 32, line_height, Vocab::level_a)
end
change_color(normal_color)
draw_text(x + width - 32, y, 32, line_height, actor.level, 2)
end
#--------------------------------------------------------------------------
# ● レベルの描画 (経験値ゲージ付)
#--------------------------------------------------------------------------
def draw_actor_level_g(actor, x, y, width = 64)
draw_gauge(x,y,width,actor.cm_exp_rate,exp_gauge_color1,exp_gauge_color2)
if VISIBLE_SYSTEM
change_color(system_color)
draw_text(x, y, 32, line_height, Vocab::level_a)
end
change_color(tp_color(actor))
draw_text(x + width - 32, y, 32, line_height, actor.level, 2)
end
#--------------------------------------------------------------------------
# ● ステートおよび強化/弱体のアイコンを描画
#--------------------------------------------------------------------------
def draw_actor_icons(actor, x, y, width = 96, align = 0)
icons = (actor.state_icons + actor.buff_icons)[0, width / 24]
case align
when 0; left = 0
when 1; left = (width - icons.size * 24) / 2
when 2; left = (width - icons.size * 24)
end
icons.each_with_index {|n, i| draw_icon(n, x + left + 24 * i, y) }
end
#--------------------------------------------------------------------------
# ● 現在値/最大値を分数形式で描画
#--------------------------------------------------------------------------
def draw_current_and_max_values(x, y, width, current, max, color1, color2)
change_color(color1)
xr = x + width
if width < 96
draw_text(xr - 40, y, 42, line_height, current, 2)
else
draw_text(xr - 92, y, 42, line_height, current, 2)
change_color(color2)
draw_text(xr - 52, y, 12, line_height, "/", 2)
draw_text(xr - 42, y, 42, line_height, max, 2)
end
end
#--------------------------------------------------------------------------
# ● HP の描画
#--------------------------------------------------------------------------
def draw_actor_hp(actor, x, y, width = 124)
draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
if VISIBLE_SYSTEM
change_color(system_color)
draw_text(x, y, 30, line_height, Vocab::hp_a)
end
draw_current_and_max_values(x, y, width, actor.hp, actor.mhp,
hp_color(actor), normal_color)
end
#--------------------------------------------------------------------------
# ● MP の描画
#--------------------------------------------------------------------------
def draw_actor_mp(actor, x, y, width = 124)
draw_gauge(x, y, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2)
if VISIBLE_SYSTEM
change_color(system_color)
draw_text(x, y, 30, line_height, Vocab::mp_a)
end
draw_current_and_max_values(x, y, width, actor.mp, actor.mmp,
mp_color(actor), normal_color)
end
#--------------------------------------------------------------------------
# ● TP の描画
#--------------------------------------------------------------------------
def draw_actor_tp(actor, x, y, width = 124)
draw_gauge(x, y, width, actor.tp_rate, tp_gauge_color1, tp_gauge_color2)
if VISIBLE_SYSTEM
change_color(system_color)
draw_text(x, y, 30, line_height, Vocab::tp_a)
end
change_color(tp_color(actor))
draw_text(x + width - 42, y, 42, line_height, actor.tp.to_i, 2)
end
#--------------------------------------------------------------------------
# ● 経験値の描画
#--------------------------------------------------------------------------
def draw_actor_exp(actor, x, y, width = 124)
draw_gauge(x, y, width, actor.cm_exp_rate,
exp_gauge_color1, exp_gauge_color2)
if VISIBLE_SYSTEM
change_color(system_color)
draw_text(x, y, width, line_height, VOCABS[:exp_a])
end
change_color(normal_color)
draw_text(x, y, width, line_height, actor.cm_remaining_exp, 2)
end
#--------------------------------------------------------------------------
# ● 経験値情報の描画
#--------------------------------------------------------------------------
def draw_actor_exp_info(actor, x, y, width = 124)
s1 = actor.max_level? ? "-------" : actor.exp
s2 = actor.max_level? ? "-------" : actor.cm_remaining_exp
s_next = sprintf(Vocab::ExpNext, Vocab::level)
change_color(system_color)
draw_text(x, y + line_height * 0, 180, line_height, Vocab::ExpTotal)
draw_text(x, y + line_height * 2, 180, line_height, s_next)
change_color(normal_color)
draw_text(x, y + line_height * 1, 180, line_height, s1, 2)
draw_text(x, y + line_height * 3, 180, line_height, s2, 2)
end
#--------------------------------------------------------------------------
# ● 能力値の描画
#--------------------------------------------------------------------------
def draw_actor_param(actor, x, y, param_id, width = 124)
if param_id < 0 || param_id > 7
raise ArgumentError, "能力値の ID は 0 から 7 までの数値です。"
end
if VISIBLE_SYSTEM
change_color(system_color)
draw_text(x, y, width, line_height, Vocab::param(param_id))
end
change_color(normal_color)
draw_text(x, y, width, line_height, actor.param(param_id), 2)
end
#--------------------------------------------------------------------------
# ● 矩形の描画
#--------------------------------------------------------------------------
def draw_actor_rect(actor, x, y, w, h, color, script = nil)
return if script && !eval(script)
draw_fill_rect(x, y, w, h, str2color(color))
end
#--------------------------------------------------------------------------
# ● アイテム名の描画
#--------------------------------------------------------------------------
def draw_item_name(item, x, y, width = 172, enabled = true)
return unless item
draw_icon(item.icon_index, x, y, enabled)
change_color(normal_color, enabled)
draw_text(x + 24, y, width, line_height, item.name)
end
#--------------------------------------------------------------------------
# ● 通貨単位つき数値(所持金など)の描画
#--------------------------------------------------------------------------
def draw_currency_value(value, name, unit, x, y, width)
cx = text_size(unit).width
change_color(normal_color)
draw_text(x, y, width - cx - 2, line_height, value, 2)
if VISIBLE_SYSTEM
change_color(system_color)
draw_text(x, y, width, line_height, name)
draw_text(x, y, width, line_height, unit, 2)
end
end
#--------------------------------------------------------------------------
# ● 通貨単位つき数値(所持金など)の描画
#--------------------------------------------------------------------------
def draw_gold(x, y, width)
draw_currency_value(
$game_party.gold, VOCABS[:gold], Vocab::currency_unit, x, y, width)
end
end
的菜单美化角本,我想要在里面增加分配点数的功能。
分配点数的脚本为パラメータ振り分け。
パラメータ振り分け#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/ ◆ パラメータ振り分け - KMS_DistributeParameter ◆ VXAce ◆
#_/ ◇ Last update : 2012/08/05 (TOMY@Kamesoft) ◇
#_/----------------------------------------------------------------------------
#_/ パラメータ振り分け機能を作成します。
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#==============================================================================
# ★ 設定項目 - BEGIN Setting ★
#==============================================================================
module KMS_DistributeParameter
# ◆ パラメータ振り分け箇所
# 振り分け箇所および増加量を
# {
# :key => キー,
# :name => "名称",
# :limit => 回数上限,
# :cost => [消費 RP, 消費 RP 補正],
# :パラメータ => [上昇量, 上昇量補正],
# # 以降、パラメータを必要なだけ記述
# },
# という書式で追加。
# 振り分け画面では、追加した順に表示。
# 「キー」には、他の箇所と被らない名称を指定。
# (内部で振り分け箇所を特定するために使用。数値、文字列など何でもOK)
# 「回数上限」以外は小数でもOK。
# 「回数上限」を 0 にすると回数無制限。
# 「消費 RP 補正」と「上昇量補正」は省略可。省略時は 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 => :luk,
:name => "運",
:limit => 20,
:cost => [1, 0.5],
:luk => [1]
},
{
:key => :hit,
:name => "命中率",
:limit => 20,
:cost => [1, 0.5],
:hit => [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 に上書き。
# 指定しなかったパラメータ/アクターは 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] = [ 振り分け箇所 ]
# という書式で指定。
# その他はアクター固有の設定と同様。
# (優先度は 職業 > アクター > デフォルト)
# ◆ RP (振り分け用ポイント) の名称
VOCAB_RP = "RP"
# ◆ RP の名称 (略)
VOCAB_RP_A = "R"
# ◆ MaxRP 計算式
# 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
# ◆ メニュー画面に「パラメータ振り分け」コマンドを追加する
# 追加する場所は、メニューコマンドの最下部です。
# 他の部分に追加したい場合は、≪カスタムメニューコマンド≫ をご利用ください。
USE_MENU_DISTRIBUTE_PARAMETER_COMMAND = true
# ◆ メニュー画面の「パラメータ振り分け」コマンドの名称
VOCAB_MENU_DISTRIBUTE_PARAMETER = "パラメータ振分"
# ◆ 振り分け解除を許可
# true : 振り分け確定後もパラメータを下げ、RP を取り戻せる。
# 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
但是不管怎么调整一直出错。
|
|