#============================================================================== # ■ VX-RGSS2-27 リッチアクターコマンド [Ver.1.0.0] by Claimh #------------------------------------------------------------------------------ #・戦闘時のコマンド表示方法を変更します。 #・戦闘コマンドごとにアイコン表示がつきます # - 攻撃 :装備武器のアイコン + 設定にある攻撃アイコン を描画する # - スキル・防御・アイテム :設定にあるアイコンのみ描画する #・アクター個別のコマンド名を使うことができます #------------------------------------------------------------------------------ #【再定義】 Scene_Battle#create_info_viewport #============================================================================== module RICH_ACTCMD #-------------------------------------------------------------------------- # ● ファイル定義 #-------------------------------------------------------------------------- # IconIndex(Graphics/Icons/IconSet) # ※nilにするとアイコン無し ATTACK = 0 # 攻撃のアイコンIndex SKILL = 131 # スキルのアイコンIndex DEFFENCE = 52 # 防御のアイコンIndex ITEM = 144 # アイテムのアイコンIndex HAND = 132 # 武器なし(素手)のアイコンIndex # TEXT背景色 BACK = Color.new(0,0,0,128) #-------------------------------------------------------------------------- # ● 個別コマンド設定 #-------------------------------------------------------------------------- # 個別コマンド名を使用する USE_ACT_CMD = true # アクター別のコマンド名 ACT_CMD_T = [] # ここは変更禁止 # ACT_CMD_T[アクターID] = [攻撃, スキル, 防御, アイテム] # ※nilを入れるとシステム用語と同じ名称になります 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] # アクター別のコマンド用アイコンIndex ACT_CMD_I = [] # ここは変更禁止 # ACT_CMD_I[アクターID] = [攻撃, スキル, 防御, アイテム] # ※nilを入れるとファイル定義の設定と同じファイルになります ACT_CMD_I[1] = [nil, nil, nil, nil] ACT_CMD_I[2] = [nil, nil, nil, nil] ACT_CMD_I[3] = [nil, 128, nil, nil] ACT_CMD_I[4] = [nil, 129, 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 #============================================================================== # ■ WindowBattleActorCmd #------------------------------------------------------------------------------ # バトル画面で、アクターのコマンド一覧を表示するウィンドウ?です。 #============================================================================== class WindowBattleActorCmd include RICH_ACTCMD #-------------------------------------------------------------------------- # ● define #-------------------------------------------------------------------------- M_WAIT = 0 # 停止 M_CUR_UP = 1 # ↑移動 M_CUR_DW = 2 # ↓移動 #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :index attr_accessor :active #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize # text @text = [ Vocab::attack, Vocab::skill, Vocab::guard, Vocab::item ] @item_max = @text.size # icon @icon = [ATTACK, SKILL, DEFFENCE, ITEM] # create sprite @cmd_sprite = [] for i in 0...@item_max @cmd_sprite[i] = SpriteCmdIcon.new(@icon[i], @text[i]) end # @base_y = Y self.index = 0 @active = false self.visible = false end #-------------------------------------------------------------------------- # ● オブジェクト開放 #-------------------------------------------------------------------------- def dispose for sprite in @cmd_sprite sprite.dispose end end #-------------------------------------------------------------------------- # ● 表示/非表示 切り替え #-------------------------------------------------------------------------- def visible=(flag) for sprite in @cmd_sprite sprite.visible = flag end end #-------------------------------------------------------------------------- # ● X座標変更 #-------------------------------------------------------------------------- def x=(x) for sprite in @cmd_sprite sprite.set_x(x+8) end end #-------------------------------------------------------------------------- # ● Y座標変更 #-------------------------------------------------------------------------- def y=(y) @base_y = y for i in 0...@item_max @cmd_sprite[i].set_y(y + real_i(i) * H) end end #-------------------------------------------------------------------------- # ● Index変更 #-------------------------------------------------------------------------- def index=(i) @index = (i + 1) % @item_max move(M_CUR_UP) reset end #-------------------------------------------------------------------------- # ● RealIndex #-------------------------------------------------------------------------- def real_i(i) return ((i - @index + @item_max + 1) % @item_max) end #-------------------------------------------------------------------------- # ● アクター設定 #-------------------------------------------------------------------------- def setup(actor) attack_icon = HAND attack_icon = actor.weapons[1].icon_index if actor.weapons[1].is_a?(RPG::Weapon) attack_icon = actor.weapons[0].icon_index if actor.weapons[0].is_a?(RPG::Weapon) if actor.class.skill_name_valid # スキルのコマンド名が有効? @text[1] = actor.class.skill_name # コマンド名を置き換える else @text[1] = Vocab::skill # コマンド名を置き換える end if USE_ACT_CMD unless ACT_CMD_I[actor.id].nil? for i in 0...@item_max @cmd_sprite[i].bitmap.clear @cmd_sprite[i].draw_icon(attack_icon) if i == 0 icn = ACT_CMD_I[actor.id][i].nil? ? @icon[i] : ACT_CMD_I[actor.id][i] @cmd_sprite[i].draw_icon(icn) end else draw_attack_icon(attack_icon) end cmds = ACT_CMD_T[actor.id].nil? ? @text : ACT_CMD_T[actor.id] for i in 0...@item_max txt = cmds[i].nil? ? @text[i] : cmds[i] @cmd_sprite[i].draw_text(txt) end else draw_attack_icon(attack_icon) @cmd_sprite[1].draw_text(@text[1]) # VX仕様に基づく end end # 個別を使わなかった時用のメソッド def draw_attack_icon(attack_icon) @cmd_sprite[0].bitmap.clear @cmd_sprite[0].draw_icon(attack_icon) @cmd_sprite[0].draw_icon(ATTACK) end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update return unless @active # 方向ボタンの下が押された場合 if Input.repeat?(Input::DOWN) Sound.play_cursor move(M_CUR_DW) end # 方向ボタンの上が押された場合 if Input.repeat?(Input::UP) Sound.play_cursor move(M_CUR_UP) end 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 for i in 0...@item_max @cmd_sprite[i].target(@base_y + real_i(i) * H, i == @index, i == fast_index) end end #-------------------------------------------------------------------------- # ● モーション動作 #-------------------------------------------------------------------------- def update_motion return if @mode == M_WAIT moving = false for sprite in @cmd_sprite moving |= sprite.update end @mode = M_WAIT unless moving end #-------------------------------------------------------------------------- # ● モーションリセット #-------------------------------------------------------------------------- def reset for sprite in @cmd_sprite sprite.reset end @mode = M_WAIT end end class SpriteCmdIcon < Sprite OPLUS = 25 include RICH_ACTCMD #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(icon, text) super(nil) self.bitmap = Bitmap.new(28, H) @view = Viewport.new(20, Y, W, H) @t_sprite = Sprite.new(@view) @t_sprite.bitmap = Bitmap.new(W, H) self.z = 1001 @t_sprite.viewport.z = 1000 # draw_icon(icon) draw_text(text) end #-------------------------------------------------------------------------- # ● オブジェクト開放 #-------------------------------------------------------------------------- def dispose self.bitmap.dispose super @t_sprite.bitmap.dispose @t_sprite.dispose @view.dispose end #-------------------------------------------------------------------------- # ● アイコン描画 #-------------------------------------------------------------------------- def draw_icon(icon_index) return if icon_index == nil bit = Cache.system("Iconset") rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24) self.bitmap.blt(2, (H-24)/2, bit, rect) end #-------------------------------------------------------------------------- # ● テキスト描画 #-------------------------------------------------------------------------- def draw_text(text) @t_sprite.bitmap.clear @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 #-------------------------------------------------------------------------- # ● 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 class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● 情報表示ビューポートの作成 #-------------------------------------------------------------------------- def create_info_viewport @info_viewport = Viewport.new(0, 288, 544, 128) @info_viewport.z = 100 @status_window = Window_BattleStatus.new @party_command_window = Window_PartyCommand.new @actor_command_window = WindowBattleActorCmd.new @status_window.viewport = @info_viewport @party_command_window.viewport = @info_viewport # @actor_command_window.viewport = @info_viewport @status_window.x = 128 @actor_command_window.x = 410 @actor_command_window.y = 300 @info_viewport.visible = false @actor_command_window.visible = false end #-------------------------------------------------------------------------- # ● パーティコマンド選択の開始 #-------------------------------------------------------------------------- alias start_party_command_selection_rich start_party_command_selection def start_party_command_selection start_party_command_selection_rich @actor_command_window.visible = false end #-------------------------------------------------------------------------- # ● アクターコマンド選択の開始 #-------------------------------------------------------------------------- alias start_actor_command_selection_rich start_actor_command_selection def start_actor_command_selection start_actor_command_selection_rich @actor_command_window.visible = true end #-------------------------------------------------------------------------- # ● 戦闘処理の実行開始 #-------------------------------------------------------------------------- alias start_main_rich start_main def start_main @actor_command_window.visible = false start_main_rich end end