#============================================================================== # ■ RGSS3 パーティメンバー選択肢 Ver1.01 by 星潟 #------------------------------------------------------------------------------ # パーティメンバーの名前で簡単に選択肢を作る事が出来ます。 #============================================================================== # イベントコマンドの選択肢を使用します。 #============================================================================== # 選択肢1つ目の内容としてパーティコマンドと記述します。(必須) # 分岐の中身は自由ですが、特に何も必要ありません。 # # 選択肢2つ目の内容としてどのアクターIDのキャラを選択したかを # 保存する為の変数IDを記述します。 # 省略した場合、デフォルト設定の変数に格納されます。 # # 選択肢3つ目の内容として選択肢の表示限界数を指定します。 # パーティメンバーが大量にいるような状態では # 選択肢が画面上方に突き抜けてしまう為、その対策です。 # 限界数を超えるメンバーはスクロールにて表示します。 # 省略した場合、デフォルトとなります。 # # 選択肢4つ目の内容として表示に特定のアクターのみにする場合に # そのアクターIDを指定します。 # # 例.アクターID2、3、4だけを対象とする場合 # # 2,3,4 # # イベントを実行すると、現在のパーティメンバー名で選択肢が表示されます。 # 選択によって指定変数にアクターIDが格納されるので # 条件分岐のイベントコマンドで選択結果を用いた分岐が行えます。 # この選択肢の本来の分岐の中身は自由ですが特に何も必要はなく # 実際の分岐は上記の通り、条件分岐のイベントコマンドで行います。 # # なお、選択肢に何れのアクターも表示出来ない場合は-1、 # キャンセルが有効な場合にキャンセルした場合は0が変数に格納されます。 #============================================================================== # イベントコマンドのスクリプトを使用します。 #============================================================================== # menu_actor_set(1) # # メニューアクターとしてアクターID1を設定します。 # このコマンドはマップ上から直接スキル画面や # ステータス画面を呼び出す際に使用するのを想定した物です。 #------------------------------------------------------------------------------ # menu_actor_set($game_variables[1]) # # メニューアクターとして変数ID1番の値のアクターIDのアクターを設定します。 #============================================================================== module PartyMemberCommand Word = "パーティコマンド" DVID = 1 end class Game_Message attr_accessor :ptm_choice attr_accessor :ptm_array attr_accessor :ptm_line_n end class Game_Interpreter #-------------------------------------------------------------------------- # 選択肢のセットアップ #-------------------------------------------------------------------------- alias setup_choices_ptm_choice setup_choices def setup_choices(params) v = nil if params[0][0] == PartyMemberCommand::Word v = PartyMemberCommand::DVID l = nil i = nil if params[0][1] && !params[0][1].empty? d = eval(params[0][1]) v = d if d.is_a?(Numeric) end if params[0][2] && !params[0][2].empty? d = eval(params[0][2]) l = d if d.is_a?(Numeric) end if params[0][3] && !params[0][3].empty? d = params[0][3].split(/\s*,\s*/).inject([]) {|r,n| r += [n.to_i]} i = d.select {|n| n.is_a?(Numeric) && $game_actors[n]} end $game_message.ptm_choice = v $game_message.ptm_line_n = l m = i ? $game_party.members.select {|a| i.include?(a.id)} : $game_party.members $game_message.ptm_array = m.collect {|a| a.id} true_params = [m.collect {|a| a.name},params[1]] else true_params = params end $game_variables[v] = -1 if true_params[0].empty? && v setup_choices_ptm_choice(true_params) Fiber.yield while $game_message.choice? $game_message.ptm_array = nil $game_message.ptm_choice = nil $game_message.ptm_line_n = nil end #-------------------------------------------------------------------------- # メニューアクターの指定 #-------------------------------------------------------------------------- def menu_actor_set(actor_id) a = $game_actors[actor_id] $game_party.menu_actor = a if a end end class Window_ChoiceList < Window_Command #-------------------------------------------------------------------------- # 決定ハンドラの呼び出し #-------------------------------------------------------------------------- alias call_ok_handler_ptm_choice call_ok_handler def call_ok_handler v = $game_message.ptm_choice $game_variables[v] = $game_message.ptm_array[index] if v call_ok_handler_ptm_choice end #-------------------------------------------------------------------------- # キャンセルハンドラの呼び出し #-------------------------------------------------------------------------- alias call_cancel_handler_ptm_choice call_cancel_handler def call_cancel_handler v = $game_message.ptm_choice $game_variables[v] = 0 if v call_cancel_handler_ptm_choice end #-------------------------------------------------------------------------- # 項目最大数 #-------------------------------------------------------------------------- alias fitting_height_ptm_choice fitting_height unless $! def fitting_height(line_number) l = $game_message.ptm_line_n fitting_height_ptm_choice(l ? [l,line_number].min : line_number) end end