=begin ▼ 移動ルートの条件分岐 ver. 1.0 RPGツクールVXAce用スクリプト 制作 : 木星ペンギン URL : http://woodpenguin.blog.fc2.com/ ------------------------------------------------------------------------------ 概要 □ 移動ルートの設定で条件分岐が使用できるようになります。 ------------------------------------------------------------------------------ 使い方 ・ 移動ルート設定のスクリプトで、以下の文字列を入力すると条件分岐を行えます。 if 条件 => 条件が真の場合の処理 else => 上記での条件に当てはまらない場合の処理 end => 条件分岐の終了 ・ unless や elsif のような機能はありません。 ・ 基本的にRubyの条件分岐と同じです。 ・ 条件分岐中に別の条件分岐を入れることは可能です。 ・ 条件では s でスイッチ、v で変数を参照できます。 ・ セルフ変数も使用できます。 併用する場合はこちらのスクリプトを下にしてください。 =end module WdTk module RouteBranch #////////////////////////////////////////////////////////////////////////////// # # 設定項目 # #////////////////////////////////////////////////////////////////////////////// #-------------------------------------------------------------------------- # ● 移動ルートの処理改善 # 1 フレームに一行しか処理されない移動ルートの処理を # 1 フレーム内に可能な限り処理を行うように変更します。 #-------------------------------------------------------------------------- RouteEX = true #////////////////////////////////////////////////////////////////////////////// # # 以降、変更する必要なし # #////////////////////////////////////////////////////////////////////////////// end @material ||= [] @material << :RouteBranch def self.include?(sym) @material.include?(sym) end end #============================================================================== # ■ Game_Character #============================================================================== class Game_Character if WdTk::RouteBranch::RouteEX #-------------------------------------------------------------------------- # ◯ ルートに沿った移動の更新 #-------------------------------------------------------------------------- alias _wooden_ex_update_routine_move update_routine_move def update_routine_move if @wait_count > 0 @wait_count -= 1 else _wooden_ex_update_routine_move if @move_route_forcing && @move_succeed && stopping? && @wait_count == 0 && @move_route_index >= 0 update_routine_move end end end end # if WdTk::RouteBranch::RouteEX #-------------------------------------------------------------------------- # ◯ 移動コマンドの処理 #-------------------------------------------------------------------------- alias _wdtk_routeb_process_move_command process_move_command def process_move_command(command) if command.code == ROUTE_SCRIPT case command.parameters[0] when /if\s+(.+)/ command_skip(/else|end/) unless route_eval($1) return when "else" command_skip("end") return when "end" return end end _wdtk_routeb_process_move_command(command) end #-------------------------------------------------------------------------- # ● 移動ルート用 #-------------------------------------------------------------------------- def route_eval(formula) s, v = $game_switches, $game_variables begin eval(formula) rescue msgbox "以下の条件判定でエラーが出ました。\n\n", formula true end end #-------------------------------------------------------------------------- # ● コマンドスキップ #-------------------------------------------------------------------------- def command_skip(text) @move_route_index += 1 loop do command = @move_route.list[@move_route_index] case command.code when ROUTE_END @move_route_index -= 1 return when ROUTE_SCRIPT case command.parameters[0] when /^if\s/ command_skip("end") when text return end end @move_route_index += 1 end end end #============================================================================== # ■ Game_Event #============================================================================== if WdTk.include?(:SelfVar) class Game_Event #-------------------------------------------------------------------------- # ● ルートに沿った移動の更新 #-------------------------------------------------------------------------- def update_routine_move $game_variables.set_key(@map_id, @id) super $game_map.interpreter.initiative_selfvar end end end # if WdTk.include?(:SelfVar)