#============================================================================== # ■ VXAce-RGSS3-23 リッチアクターコマンド [Ver.1.0.0] by Claimh #------------------------------------------------------------------------------ #・戦闘時のコマンド表示方法を変更します。 #・戦闘コマンドごとにアイコン表示がつきます # - 攻撃 :装備武器のアイコン + 設定にある攻撃アイコン を描画する # - スキル・防御・アイテム :設定にあるアイコンのみ描画する #・アクター個別のコマンド名を使うことができます #============================================================================== module RICH_ACTCMD # アクターポジションに合わせる # true : Game_Actor#screen_x, screen_yに合わせる ACTPOS = true # 固定ポジション(ACTPOS=false用) FIXPOS = [0, 0] # [x, y] #-------------------------------------------------------------------------- # ● ファイル定義 #-------------------------------------------------------------------------- # IconIndex(Graphics/System/IconSet.png) HAND = 116 # 武器なし(素手)のアイコンIndex GUARD = 161 # 防御のアイコンIndex ITEM = 260 # アイテムのアイコンIndex # TEXT背景色 BACK = Color.new(0,0,0,128) # 表示最大数 CMD_MAX = 4 # 「攻撃」の表示形式 # 0: システム用語(Vocab.attack) # 1: 武器名 # 2: 武器のメモ欄から取得 … @cmd[コマンド名] W_NAME = 1 #-------------------------------------------------------------------------- # ● スキルタイプコマンド設定 #-------------------------------------------------------------------------- # スキルタイプのアイコンIndex SKILL = [] # SKILL[スキルタイプID] = アイコンIndex SKILL[1] = 115 SKILL[2] = 119 #-------------------------------------------------------------------------- # ● 個別コマンド設定 #-------------------------------------------------------------------------- # アクター別のコマンド名 ACT_CMD_T = [] # ここは変更禁止 # ACT_CMD_T[アクターID] = [攻撃, 防御, アイテム] # ※nilを入れるとW_NAMEの設定になります ACT_CMD_T[1] = ["斬撃", nil, nil] ACT_CMD_T[2] = ["突撃", nil, nil] ACT_CMD_T[3] = [ nil, nil, nil] ACT_CMD_T[4] = [ nil, nil, nil] # アクター別のコマンド用アイコンIndex ACT_CMD_I = [] # ここは変更禁止 # ACT_CMD_I[アクターID] = [攻撃, 防御, アイテム] # ※nilを入れるとファイル定義の設定と同じファイルになります ACT_CMD_I[1] = [nil, nil, nil] ACT_CMD_I[2] = [nil, nil, nil] ACT_CMD_I[3] = [nil, nil, nil] ACT_CMD_I[4] = [nil, nil, nil] #-------------------------------------------------------------------------- # ● その他 #-------------------------------------------------------------------------- # 基準Y座標 Y = 220 # TEXT背景の描画幅W、高さH W = 120 H = 28 # 横幅のモーション速さ [ 高速移動時、低速移動時 ] W_F = [40, 10] # 縦移動のモーション速さ[ 高速移動時、低速移動時 ] M_F = [40, 10] # 選択外コマンドの不透明度 OP = 100 =begin 「高速移動」と「低速移動」はコマンド切替時の動作のことです。 - 高速移動 : 次に選択する項目のモーション - 低速移動 : 前回選択した項目のモーション =end end #============================================================================== # ■ RPG::Weapon #============================================================================== class RPG::Weapon < RPG::EquipItem #-------------------------------------------------------------------------- # ● コマンド名 #-------------------------------------------------------------------------- def cmd_name cmd = @note.scan(/@cmd\[(.+)\]/)[0] return (cmd.nil? ? Vocab.attack : cmd[0]) # 設定なければVocabから取得 end end #============================================================================== # ■ WindowBattleActorCmd #------------------------------------------------------------------------------ # バトル画面で、アクターのコマンド一覧を表示するウィンドウ?です。 #============================================================================== class WindowBattleActorCmd < Window_Command include RICH_ACTCMD #-------------------------------------------------------------------------- # ● define #-------------------------------------------------------------------------- M_WAIT = 0 # 停止 M_CUR_UP = 1 # ↑移動 M_CUR_DW = 2 # ↓移動 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize @cmd_sprite = [] super(0, Y) @base_y = Y hide.deactivate self.opacity = 0 self.openness = 0 end #-------------------------------------------------------------------------- # ● 偽装 #-------------------------------------------------------------------------- def open?; true; end def open; show; end def close; hide; end #-------------------------------------------------------------------------- # ● コマンドリスト初期化 #-------------------------------------------------------------------------- def clear_command_list super dispose_sprites end #-------------------------------------------------------------------------- # ● コマンドリスト生成 #-------------------------------------------------------------------------- def make_command_list return unless @actor add_attack_command add_skill_commands add_guard_command add_item_command create_sprites end #-------------------------------------------------------------------------- # ● コマンドスプライト生成 #-------------------------------------------------------------------------- def create_sprites item_max.times {|i| @cmd_sprite.push(SpriteCmdIcon.new) } end #-------------------------------------------------------------------------- # ● コマンドスプライト生成 #-------------------------------------------------------------------------- def dispose_sprites @cmd_sprite.each {|s| s.dispose} @cmd_sprite.clear end #-------------------------------------------------------------------------- # ● コマンドの追加 #-------------------------------------------------------------------------- def add_command(name, symbol, enabled = true, icon=0, ext = nil) @list.push({:name=>name, :symbol=>symbol, :enabled=>enabled, :icon=>icon, :ext=>ext}) end #-------------------------------------------------------------------------- # ● アイコンテキスト取得 #-------------------------------------------------------------------------- def vocab_text(cmd_i) case cmd_i when 0; return attack_text when 1; return Vocab::guard when 2; return Vocab::item end end def vocab_icon(cmd_i) case cmd_i when 0; return attack_icon when 1; return GUARD when 2; return ITEM end end def attack_text w = @actor.weapons unless w.empty? case W_NAME when 1; return w[0].name when 2; return w[0].cmd_name end end return Vocab::attack end def attack_icon w = @actor.weapons return HAND if w.empty? return w[0].icon_index end def set_i(set, cmd_i, vocab) (set[@actor.id].nil? or set[@actor.id][cmd_i].nil?) ? vocab : set[@actor.id][cmd_i] end def icon_text(cmd_i) [set_i(ACT_CMD_T, cmd_i, vocab_text(cmd_i)), set_i(ACT_CMD_I, cmd_i, vocab_icon(cmd_i))] end #-------------------------------------------------------------------------- # ● 攻撃コマンドをリストに追加 #-------------------------------------------------------------------------- def add_attack_command it = icon_text(0) add_command(it[0], :attack, @actor.attack_usable?, it[1]) end #-------------------------------------------------------------------------- # ● スキルコマンドをリストに追加 #-------------------------------------------------------------------------- def add_skill_commands @actor.added_skill_types.sort.each do |stype_id| name = $data_system.skill_types[stype_id] icon = SKILL[stype_id] add_command(name, :skill, true, icon, stype_id) end end #-------------------------------------------------------------------------- # ● 防御コマンドをリストに追加 #-------------------------------------------------------------------------- def add_guard_command it = icon_text(1) add_command(it[0], :guard, @actor.guard_usable?, it[1]) end #-------------------------------------------------------------------------- # ● アイテムコマンドをリストに追加 #-------------------------------------------------------------------------- def add_item_command it = icon_text(2) add_command(it[0], :item, true, it[1]) end #-------------------------------------------------------------------------- # ● オブジェクト開放 #-------------------------------------------------------------------------- def dispose dispose_sprites super end #-------------------------------------------------------------------------- # ● 表示/非表示 切り替え #-------------------------------------------------------------------------- def visible=(flag) @cmd_sprite.each_index {|i| @cmd_sprite[i].visible = flag & (real_i(i) < CMD_MAX)} end #-------------------------------------------------------------------------- # ● X座標変更 #-------------------------------------------------------------------------- def x=(x) @cmd_sprite.each {|s| s.set_x(x+8)} end #-------------------------------------------------------------------------- # ● Y座標変更 #-------------------------------------------------------------------------- def y=(y) @base_y = y @cmd_sprite.each_index {|i| @cmd_sprite[i].set_y(y + real_i(i) * H)} end #-------------------------------------------------------------------------- # ● Index変更 #-------------------------------------------------------------------------- def index=(i) return if item_max == 0 @index = (i + 1) % item_max move(M_CUR_UP) reset end #-------------------------------------------------------------------------- # ● RealIndex #-------------------------------------------------------------------------- def real_i(i) ((i - @index + item_max + 1) % item_max) end #-------------------------------------------------------------------------- # ● セットアップ #-------------------------------------------------------------------------- def setup(actor) @actor = actor clear_command_list make_command_list refresh self.index = 0 if ACTPOS self.x = actor.screen_x - 70 self.y = actor.screen_y - 210 else self.x = FIXPOS[0] self.y = FIXPOS[1] end activate.show end #-------------------------------------------------------------------------- # ● 決定ハンドラの呼び出し #-------------------------------------------------------------------------- def call_ok_handler hide super end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) @cmd_sprite[index].refresh(@list[index][:icon], command_name(index), command_enabled?(index)) end #-------------------------------------------------------------------------- # ● カーソルを下に移動 #-------------------------------------------------------------------------- def cursor_down(wrap = false) move(M_CUR_DW) end #-------------------------------------------------------------------------- # ● カーソルを上に移動 #-------------------------------------------------------------------------- def cursor_up(wrap = false) move(M_CUR_UP) end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super update_motion end #-------------------------------------------------------------------------- # ● モーション設定 #-------------------------------------------------------------------------- def move(mode) case mode when M_CUR_UP @index = (@index - 1 + item_max) % item_max fast_index = (@index - 1 + item_max) % item_max when M_CUR_DW fast_index = (@index - 1 + item_max) % item_max @index = (@index + 1) % item_max else; return end @mode = mode @cmd_sprite.each_index do |i| @cmd_sprite[i].target(@base_y + real_i(i) * H, i == @index, i == fast_index) @cmd_sprite[i].visible = (real_i(i) < CMD_MAX) end end #-------------------------------------------------------------------------- # ● モーション動作 #-------------------------------------------------------------------------- def update_motion return if @mode == M_WAIT moving = false @cmd_sprite.each {|s| moving |= s.update } @mode = M_WAIT unless moving end #-------------------------------------------------------------------------- # ● モーションリセット #-------------------------------------------------------------------------- def reset @cmd_sprite.each { |s| s.reset} @mode = M_WAIT end end class SpriteCmdIcon < Sprite OPLUS = 25 include RICH_ACTCMD #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(nil) self.bitmap = Bitmap.new(28, H) @view = Viewport.new(20, Y, W, H) @view.z = 1000 @t_sprite = Sprite.new(@view) @t_sprite.bitmap = Bitmap.new(W, H) self.z = 1001 end #-------------------------------------------------------------------------- # ● オブジェクト開放 #-------------------------------------------------------------------------- def dispose self.bitmap.dispose super @t_sprite.bitmap.dispose @t_sprite.dispose @view.dispose end #-------------------------------------------------------------------------- # ● アイコン描画 #-------------------------------------------------------------------------- def refresh(icon, text, enabled=true) bitmap.clear draw_icon(icon, enabled) draw_text(text, enabled) end #-------------------------------------------------------------------------- # ● アイコン描画 #-------------------------------------------------------------------------- def draw_icon(icon_index, enabled=true) return if icon_index == nil bit = Cache.system("Iconset") rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24) bitmap.blt(2, (H-24)/2, bit, rect, enabled ? 255 : 128) end #-------------------------------------------------------------------------- # ● テキスト描画 #-------------------------------------------------------------------------- def draw_text(text, enabled=true) @t_sprite.bitmap.clear @t_sprite.bitmap.font.color = text_color(0) @t_sprite.bitmap.font.color.alpha = enabled ? 255 : 128 @t_sprite.bitmap.fill_rect(0,0,W,H, RICH_ACTCMD::BACK) @t_sprite.bitmap.draw_text(H+4, 0, W-22, H, text) end #-------------------------------------------------------------------------- # ● 文字色取得 # n : 文字色番号(0..31) #-------------------------------------------------------------------------- def text_color(n) Cache.system("Window").get_pixel(64 + (n % 8) * 8, 96 + (n / 8) * 8) end #-------------------------------------------------------------------------- # ● X座標変更 #-------------------------------------------------------------------------- def set_x(x) self.x = x r = @t_sprite.viewport.rect @t_sprite.viewport.rect.set(x, r.y, r.width, r.height) end #-------------------------------------------------------------------------- # ● Y座標変更 #-------------------------------------------------------------------------- def set_y(y) self.y = y r = @t_sprite.viewport.rect @t_sprite.viewport.rect.set(r.x, y, r.width, r.height) end #-------------------------------------------------------------------------- # ● Y座標、幅変更 #-------------------------------------------------------------------------- def change(y, w) self.y = y r = @t_sprite.viewport.rect @t_sprite.viewport.rect.set(r.x, y, w, r.height) end #-------------------------------------------------------------------------- # ● 不透明度変更 #-------------------------------------------------------------------------- def opacity=(o) super(o) @t_sprite.opacity = o end #-------------------------------------------------------------------------- # ● 可視状態変更 #-------------------------------------------------------------------------- def visible=(flag) super(flag) @t_sprite.visible = flag end #-------------------------------------------------------------------------- # ● 座標目標設定 #-------------------------------------------------------------------------- def target(y, enable=true, fast=false) @target_y = y @target_opacity = enable ? 255 : OP @target_w = enable ? W : 28 @m_f = fast ? M_F[0] : M_F[1] @w_f = enable ? W_F[0] : W_F[1] end #-------------------------------------------------------------------------- # ● 座標確定 #-------------------------------------------------------------------------- def reset change(@target_y, @target_w) self.opacity = @target_opacity end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update moving = false if self.y != @target_y or @t_sprite.viewport.rect.width != @target_w y = calc_diff(self.y, @target_y, @m_f) w = calc_diff(@t_sprite.viewport.rect.width, @target_w, @w_f) change(y, w) moving = true end if self.opacity != @target_opacity self.opacity = calc_diff(self.opacity, @target_opacity, OPLUS) moving = true end return moving end #-------------------------------------------------------------------------- # ● 目標との差を計算 #-------------------------------------------------------------------------- def calc_diff(org, target, step) plus = org < target ? step : -step return ( (org - target).abs > step ? (org + plus) : target ) end end