#============================================================================== # ■ VXAce-RGSS3-46-menu スタイルチェンジ画面(Menu) [Ver.1.0.0] by Claimh #------------------------------------------------------------------------------ # メニューに戦闘スタイルチェンジ画面を追加します。 #============================================================================== module BtlStyle # スタイルの説明文 STYLE_TXT = { # 職業ID => 説明文, 1 => "近接攻撃に特化した戦闘スタイル。\n"+ "強力な攻撃力と強固な防御力を持つ。魔法には弱い。", 3 => "防御に特化した戦闘スタイル。\n"+ "パーティー全体の盾となる。魔法も使用可能。", 4 => "武器に魔力をまとわせて戦う戦闘スタイル。\n"+ "魔法に対する耐性も高い。", } end module BtlStyle def self.style_text(actor_id, class_id) return STYLE_TXT[class_id] end end #============================================================================== # ■ Window_BtlStyleCmd #============================================================================== class Window_BtlStyleCmd < Window_HorzCommand TXT = [ "戦闘スタイルを変更します。", "戦闘武器を変更します。"] #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(y) super(0, y) end #-------------------------------------------------------------------------- # ● ウィンドウ幅の取得 #-------------------------------------------------------------------------- def window_width Graphics.width end #-------------------------------------------------------------------------- # ● 桁数の取得 #-------------------------------------------------------------------------- def col_max item_max end #-------------------------------------------------------------------------- # ● コマンドリストの作成 #-------------------------------------------------------------------------- def make_command_list add_command("戦闘スタイルの変更", :change) add_command("戦闘武器変更", :equip) end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help return if @index < 0 @help_window.set_text(TXT[@index]) if @help_window call_handler(:update) end end #============================================================================== # ■ Window_BtlStyleList #============================================================================== class Window_BtlStyleList < Window_Command #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :mode # 動作モード(0:change, 1:equip) attr_reader :st_windows # ステータスウィンドウ #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y) @mode = 0 super(x, y) end #-------------------------------------------------------------------------- # ● ウィンドウ幅の取得 #-------------------------------------------------------------------------- def window_width return 160 end #-------------------------------------------------------------------------- # ● アクターの設定 #-------------------------------------------------------------------------- def actor=(actor) return if @actor == actor @actor = actor refresh unselect end #-------------------------------------------------------------------------- # ● ステータスウィンドウの設定 #-------------------------------------------------------------------------- def st_windows=(st_windows) @st_windows = st_windows call_update_help end #-------------------------------------------------------------------------- # ● 表示行数の取得 #-------------------------------------------------------------------------- def visible_line_number return 4 end #-------------------------------------------------------------------------- # ● コマンドリストの作成 #-------------------------------------------------------------------------- def make_command_list return unless @actor @actor.btl_style.classes_obj.each {|c| add_command(c.name, :ok, true, c.id)} end #-------------------------------------------------------------------------- # ● 前回の選択位置を復帰 #-------------------------------------------------------------------------- def select_last select(@actor.btl_style.classes_obj.index(@actor.class) || 0) end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help text = @actor ? BtlStyle.style_text(@actor.id, current_ext) : nil @help_window.set_text(text || "") update_status end #-------------------------------------------------------------------------- # ● ステータス更新 #-------------------------------------------------------------------------- def update_status if @actor && @st_windows && @index >= 0 @st_windows[@mode].each {|w| w.class_id = current_ext} temp_actor = Marshal.load(Marshal.dump(@actor)) temp_actor.force_change_class(current_ext) if @mode == 0 @st_windows[@mode].each {|w| w.set_temp_actor(temp_actor)} else @st_windows[@mode].each {|w| w.actor = temp_actor} end end end #-------------------------------------------------------------------------- # ● 職業変更 #-------------------------------------------------------------------------- def change @actor.change_class(current_ext) refresh update_status end end #============================================================================== # ■ Window_BtlStyleStatus #============================================================================== class Window_BtlStyleStatus < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y) super(x, y, window_width, fitting_height(4)) @actor = nil end #-------------------------------------------------------------------------- # ● ウィンドウ幅の取得 #-------------------------------------------------------------------------- def window_width Graphics.width - 160 end #-------------------------------------------------------------------------- # ● アクターの設定 #-------------------------------------------------------------------------- def actor=(actor) return if @actor == actor @actor = actor refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear return unless @actor draw_actor_face(@actor, 0, 0) draw_actor_simple_status(@actor, 108, line_height / 2) end end #============================================================================== # ■ Window_BtlSytleChangeStatus #============================================================================== class Window_BtlSytleChangeStatus < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(y) super(0, y, Graphics.width, Graphics.height - y) @actor = nil @temp_actor = nil @class_id = nil end #-------------------------------------------------------------------------- # ● アクターの設定 #-------------------------------------------------------------------------- def actor=(actor) return if @actor == actor @actor = actor @class_id = actor.class_id refresh end #-------------------------------------------------------------------------- # ● 戦闘スタイルの設定 #-------------------------------------------------------------------------- def class_id=(class_id) return if @class_id == class_id @class_id = class_id refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear 6.times {|i| draw_item(0, line_height * i, 2 + i) } draw_skill_list(220) end #-------------------------------------------------------------------------- # ● 装備変更後の一時アクター設定 #-------------------------------------------------------------------------- def set_temp_actor(temp_actor) return if @temp_actor == temp_actor @temp_actor = temp_actor refresh end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(x, y, param_id) draw_param_name(x + 4, y, param_id) draw_current_param(x + 94, y, param_id) if @actor draw_right_arrow(x + 126, y) if @temp_actor draw_new_param(x + 150, y, param_id) if @temp_actor end #-------------------------------------------------------------------------- # ● 能力値の名前を描画 #-------------------------------------------------------------------------- def draw_param_name(x, y, param_id) change_color(system_color) draw_text(x, y, 80, line_height, Vocab::param(param_id)) end #-------------------------------------------------------------------------- # ● 現在の能力値を描画 #-------------------------------------------------------------------------- def draw_current_param(x, y, param_id) change_color(normal_color) draw_text(x, y, 32, line_height, @actor.param(param_id), 2) end #-------------------------------------------------------------------------- # ● 右向き矢印を描画 #-------------------------------------------------------------------------- def draw_right_arrow(x, y) change_color(system_color) draw_text(x, y, 22, line_height, "→", 1) end #-------------------------------------------------------------------------- # ● 装備変更後の能力値を描画 #-------------------------------------------------------------------------- def draw_new_param(x, y, param_id) new_value = @temp_actor.param(param_id) change_color(param_change_color(new_value - @actor.param(param_id))) draw_text(x, y, 32, line_height, new_value, 2) end #-------------------------------------------------------------------------- # ● 桁数の取得 #-------------------------------------------------------------------------- def col_max return 2 end #-------------------------------------------------------------------------- # ● スキルリスト表示 #-------------------------------------------------------------------------- def draw_skill_list(x) item_width = (contents_width - x) / col_max @actor.btl_style[@class_id].skills.sort.each_with_index do |id, i| xx = i % col_max * item_width yy = i / col_max * line_height draw_item_name($data_skills[id], x+xx, yy) end end end #============================================================================== # ■ Window_BtlSytleEquipStatus #============================================================================== class Window_BtlSytleEquipStatus < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(y) super(0, y, 220, Graphics.height - y) @actor = nil @temp_actor = nil end #-------------------------------------------------------------------------- # ● アクターの設定 #-------------------------------------------------------------------------- def actor=(actor) return if @actor == actor @actor = actor @class_id = actor.class_id refresh end #-------------------------------------------------------------------------- # ● 戦闘スタイルの設定 #-------------------------------------------------------------------------- def class_id=(class_id) return if @class_id == class_id @class_id = class_id refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear 6.times {|i| draw_item(0, line_height * i, 2 + i) } end #-------------------------------------------------------------------------- # ● 装備変更後の一時アクター設定 #-------------------------------------------------------------------------- def set_temp_actor(temp_actor) return if @temp_actor == temp_actor @temp_actor = temp_actor refresh end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(x, y, param_id) draw_param_name(x + 4, y, param_id) draw_current_param(x + 94, y, param_id) if @actor draw_right_arrow(x + 126, y) if @temp_actor draw_new_param(x + 150, y, param_id) if @temp_actor end #-------------------------------------------------------------------------- # ● 能力値の名前を描画 #-------------------------------------------------------------------------- def draw_param_name(x, y, param_id) change_color(system_color) draw_text(x, y, 80, line_height, Vocab::param(param_id)) end #-------------------------------------------------------------------------- # ● 現在の能力値を描画 #-------------------------------------------------------------------------- def draw_current_param(x, y, param_id) change_color(normal_color) draw_text(x, y, 32, line_height, @actor.param(param_id), 2) end #-------------------------------------------------------------------------- # ● 右向き矢印を描画 #-------------------------------------------------------------------------- def draw_right_arrow(x, y) change_color(system_color) draw_text(x, y, 22, line_height, "→", 1) end #-------------------------------------------------------------------------- # ● 装備変更後の能力値を描画 #-------------------------------------------------------------------------- def draw_new_param(x, y, param_id) new_value = @temp_actor.param(param_id) change_color(param_change_color(new_value - @actor.param(param_id))) draw_text(x, y, 32, line_height, new_value, 2) end end #============================================================================== # ■ Window_BtlSytleEquip #============================================================================== class Window_BtlSytleEquip < Window_Selectable #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :status_window # ステータスウィンドウ attr_reader :item_window # アイテムウィンドウ #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y) super(x, y, Graphics.width - x, window_height) @actor = nil @class_id = nil end #-------------------------------------------------------------------------- # ● ウィンドウ高さの取得 #-------------------------------------------------------------------------- def window_height fitting_height(visible_line_number) end #-------------------------------------------------------------------------- # ● 表示行数の取得 #-------------------------------------------------------------------------- def visible_line_number item_max end #-------------------------------------------------------------------------- # ● アクターの設定 #-------------------------------------------------------------------------- def actor=(actor) return if @actor == actor @actor = actor @class_id = actor.class_id refresh end #-------------------------------------------------------------------------- # ● 戦闘スタイルの設定 #-------------------------------------------------------------------------- def class_id=(class_id) return if @class_id == class_id @class_id = class_id refresh end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super @item_window.slot_id = index if @item_window end #-------------------------------------------------------------------------- # ● 項目数の取得 #-------------------------------------------------------------------------- def item_max BtlStyle::USE_DUAL_WIELD ? 2 : 1 end #-------------------------------------------------------------------------- # ● アイテムの取得 #-------------------------------------------------------------------------- def item @actor && @class_id ? @actor.btl_style[@class_id].equips_obj[index] : nil end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) return unless @actor or @class_id rect = item_rect_for_text(index) change_color(system_color, enable?(index)) draw_text(rect.x, rect.y, 92, line_height, slot_name(index)) draw_item_name(@actor.btl_style[@class_id].equips_obj[index], rect.x + 92, rect.y, enable?(index)) end #-------------------------------------------------------------------------- # ● 装備スロットの名前を取得 #-------------------------------------------------------------------------- def slot_name(index) @actor && @class_id ? Vocab::etype(@actor.btl_style[@class_id].equip_slots[index]) : "" end #-------------------------------------------------------------------------- # ● 装備スロットを許可状態で表示するかどうか #-------------------------------------------------------------------------- def enable?(index) @actor && @class_id ? @actor.btl_style[@class_id].equip_change_ok?(index) : false end #-------------------------------------------------------------------------- # ● 選択項目の有効状態を取得 #-------------------------------------------------------------------------- def current_item_enabled? enable?(index) end #-------------------------------------------------------------------------- # ● ステータスウィンドウの設定 #-------------------------------------------------------------------------- def status_window=(status_window) @status_window = status_window call_update_help end #-------------------------------------------------------------------------- # ● アイテムウィンドウの設定 #-------------------------------------------------------------------------- def item_window=(item_window) @item_window = item_window update end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help super @help_window.set_item(item) if @help_window @status_window.set_temp_actor(nil) if @status_window end end #============================================================================== # ■ Window_BtlSytleEquipItem #============================================================================== class Window_BtlSytleEquipItem < Window_ItemList #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :status_window # ステータスウィンドウ #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y) super(x, y, Graphics.width-x, Graphics.height-y) @actor = nil @class_id = nil @slot_id = 0 end #-------------------------------------------------------------------------- # ● 桁数の取得 #-------------------------------------------------------------------------- def col_max return 1 end #-------------------------------------------------------------------------- # ● アクターの設定 #-------------------------------------------------------------------------- def actor=(actor) return if @actor == actor @actor = actor @class_id = actor.class_id refresh self.oy = 0 end #-------------------------------------------------------------------------- # ● 戦闘スタイルの設定 #-------------------------------------------------------------------------- def class_id=(class_id) return if @class_id == class_id @class_id = class_id refresh end #-------------------------------------------------------------------------- # ● 装備スロット ID の設定 #-------------------------------------------------------------------------- def slot_id=(slot_id) return if !BtlStyle::USE_DUAL_WIELD and slot_id < 0 return if @slot_id == slot_id @slot_id = slot_id refresh self.oy = 0 end #-------------------------------------------------------------------------- # ● アイテムをリストに含めるかどうか #-------------------------------------------------------------------------- def include?(item) return true if item == nil return false unless item.is_a?(RPG::EquipItem) return false if @slot_id < 0 return false if item.etype_id != @actor.btl_style[@class_id].equip_slots[@slot_id] return @actor.equippable?(item) end #-------------------------------------------------------------------------- # ● アイテムを許可状態で表示するかどうか #-------------------------------------------------------------------------- def enable?(item) return true end #-------------------------------------------------------------------------- # ● 前回の選択位置を復帰 #-------------------------------------------------------------------------- def select_last end #-------------------------------------------------------------------------- # ● ステータスウィンドウの設定 #-------------------------------------------------------------------------- def status_window=(status_window) @status_window = status_window call_update_help end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help super if @actor && @status_window temp_actor = Marshal.load(Marshal.dump(@actor)) temp_actor.force_change_equip(@slot_id, item) @status_window.set_temp_actor(temp_actor) end end end #============================================================================== # ■ Scene_BattleStyle #============================================================================== class Scene_BattleStyle < Scene_MenuBase #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start super create_help_window @y = @help_window.height create_cmd_window @y += @cmd_window.height create_actor_window create_style_window @y += @style_window.height create_change_status_window create_equip_status_window create_equip_window @y += @equip_window.height create_equip_item_window @st_windows = [[@change_status_window],[@equip_window, @item_window, @equip_status_window]] @style_window.st_windows = @st_windows @cmd_window.set_handler(:update, method(:change_window)) @cmd_window.help_window = @help_window on_actor_change end #-------------------------------------------------------------------------- # ● 選択ウィンドウ生成 #-------------------------------------------------------------------------- def create_cmd_window @cmd_window = Window_BtlStyleCmd.new(@y) @cmd_window.set_handler(:ok, method(:cmd_ok)) @cmd_window.set_handler(:cancel, method(:return_scene)) @cmd_window.set_handler(:pagedown, method(:next_actor)) @cmd_window.set_handler(:pageup, method(:prev_actor)) end #-------------------------------------------------------------------------- # ● 選択ウィンドウ : OK #-------------------------------------------------------------------------- def cmd_ok @style_window.activate @style_window.select_last if @style_window.index < 0 if @cmd_window.index == 0 @style_window.set_handler(:ok, method(:style_change_ok)) else @style_window.set_handler(:ok, method(:style_equip_ok)) end @style_window.call_update_help end #-------------------------------------------------------------------------- # ● アクターの切り替え #-------------------------------------------------------------------------- def on_actor_change @cmd_window.activate @style_window.deactivate.actor = @actor @actor_window.deactivate.actor = @actor @equip_window.deactivate.actor = @actor @item_window.deactivate.actor = @actor @change_status_window.actor = @actor @equip_status_window.actor = @actor end #-------------------------------------------------------------------------- # ● 表示Windowの切り替え #-------------------------------------------------------------------------- def change_window @style_window.mode = @cmd_window.index @style_window.update_status @st_windows[@cmd_window.index].each {|w| w.show} @st_windows[(@cmd_window.index + 1) % 2].each {|w| w.hide} end #-------------------------------------------------------------------------- # ● アクターウィンドウ生成 #-------------------------------------------------------------------------- def create_actor_window @actor_window = Window_BtlStyleStatus.new(0, @y) end #-------------------------------------------------------------------------- # ● 戦闘スタイルウィンドウ生成 #-------------------------------------------------------------------------- def create_style_window @style_window = Window_BtlStyleList.new(@actor_window.width, @y) @style_window.set_handler(:cancel, method(:style_cancel)) @style_window.help_window = @help_window end #-------------------------------------------------------------------------- # ● 戦闘スタイル : OK(change) #-------------------------------------------------------------------------- def style_change_ok @style_window.activate.change @actor_window.refresh $game_player.refresh end #-------------------------------------------------------------------------- # ● 戦闘スタイル : OK(equip) #-------------------------------------------------------------------------- def style_equip_ok if BtlStyle::USE_DUAL_WIELD @equip_window.activate @equip_window.select(0) if @equip_window.index < 0 @equip_window.call_update_help else @item_window.slot_id = 0 @item_window.activate.select(0) end end #-------------------------------------------------------------------------- # ● 戦闘スタイル : CANCEL #-------------------------------------------------------------------------- def style_cancel @cmd_window.activate #@style_window.unselect @cmd_window.call_update_help end #-------------------------------------------------------------------------- # ● 戦闘スタイル変更ステータスウィンドウ生成 #-------------------------------------------------------------------------- def create_change_status_window @change_status_window = Window_BtlSytleChangeStatus.new(@y) end #-------------------------------------------------------------------------- # ● 戦闘武器変更ステータスウィンドウ生成 #-------------------------------------------------------------------------- def create_equip_status_window @equip_status_window = Window_BtlSytleEquipStatus.new(@y) end #-------------------------------------------------------------------------- # ● 戦闘武器ウィンドウ生成 #-------------------------------------------------------------------------- def create_equip_window @equip_window = Window_BtlSytleEquip.new(@equip_status_window.width, @y) @equip_window.set_handler(:ok, method(:equip_ok)) @equip_window.set_handler(:cancel, method(:equip_cancel)) @equip_window.help_window = @help_window @equip_window.status_window = @equip_status_window end #-------------------------------------------------------------------------- # ● 戦闘武器ウィンドウ : OK #-------------------------------------------------------------------------- def equip_ok @item_window.activate.select(0) end #-------------------------------------------------------------------------- # ● 戦闘武器ウィンドウ : CANCEL #-------------------------------------------------------------------------- def equip_cancel @equip_window.deactivate.unselect @style_window.activate.call_update_help end #-------------------------------------------------------------------------- # ● 戦闘武器アイテムウィンドウ生成 #-------------------------------------------------------------------------- def create_equip_item_window @item_window = Window_BtlSytleEquipItem.new(@equip_status_window.width, @y) @item_window.set_handler(:ok, method(:item_ok)) @item_window.set_handler(:cancel, method(:item_cancel)) @item_window.help_window = @help_window @item_window.status_window = @equip_status_window @equip_window.item_window = @item_window end #-------------------------------------------------------------------------- # ● 戦闘武器アイテムウィンドウ : OK #-------------------------------------------------------------------------- def item_ok Sound.play_equip class_id = @style_window.current_ext index = BtlStyle::USE_DUAL_WIELD ? @equip_window.index : 0 if @actor.class_id == class_id @actor.change_equip(index, @item_window.item) else @actor.btl_style[class_id].change_equip(index, @item_window.item) end temp_actor = Marshal.load(Marshal.dump(@actor)) temp_actor.force_change_class(@style_window.current_ext) @equip_window.actor = temp_actor @item_window.actor = temp_actor @equip_status_window.actor = temp_actor @actor_window.refresh if BtlStyle::USE_DUAL_WIELD @equip_window.activate.call_update_help else @style_window.activate.call_update_help end @item_window.deactivate.unselect end #-------------------------------------------------------------------------- # ● 戦闘武器アイテムウィンドウ : CANCEL #-------------------------------------------------------------------------- def item_cancel @item_window.deactivate.unselect if BtlStyle::USE_DUAL_WIELD @equip_window.activate.call_update_help else @style_window.activate.call_update_help @equip_status_window.set_temp_actor(nil) end end end #============================================================================== # ■ Window_MenuCommand #============================================================================== class Window_MenuCommand < Window_Command #-------------------------------------------------------------------------- # ● 独自コマンドの追加用 #-------------------------------------------------------------------------- alias add_original_commands_style add_original_commands def add_original_commands add_original_commands_style add_command("戦闘スタイル", :style) end end #============================================================================== # ■ Scene_Menu #============================================================================== class Scene_Menu < Scene_MenuBase #-------------------------------------------------------------------------- # ● コマンドウィンドウの作成 #-------------------------------------------------------------------------- alias create_command_window_style create_command_window def create_command_window create_command_window_style @command_window.set_handler(:style, method(:command_personal)) end #-------------------------------------------------------------------------- # ● 個人コマンド[決定] #-------------------------------------------------------------------------- alias on_personal_ok_style on_personal_ok def on_personal_ok on_personal_ok_style if @command_window.current_symbol == :style SceneManager.call(Scene_BattleStyle) end end end