#=========================================================================== # ◆ A1 Scripts ◆ # 拡張条件分岐(RGSS3) # # バージョン : 1.00 (2012/01/05) # 作者 : A1 # URL     : http://a1tktk.web.fc2.com/ #--------------------------------------------------------------------------- # 機能: # ・メソッド定義された条件を元に # 続く「条件分岐」の条件を拡張条件分岐のものにします #--------------------------------------------------------------------------- # 更新履歴   :2012/01/05 Ver1.00 リリース #--------------------------------------------------------------------------- # 設置場所 #  A1共通スクリプトより下 # # 必要スクリプト # A1共通スクリプトVer3.80以上 #--------------------------------------------------------------------------- # 使い方 # イベントコマンド「注釈」に記述 # # 拡張条件分岐 コマンド,条件 # 拡張条件分岐 and|or,[コマンド,条件],[コマンド,条件]・・・ # # and を指定した時は、続くコマンド全てが true の時に true を返します # or を指定した時は、続くコマンドいずれかが true の時に true を返します # # コマンドや条件の判定は別途定義する必要があります # 条件を配列にすることも可能です # 詳しくは「拡張条件分岐定義例」参照のこと #============================================================================== $imported ||= {} $imported["A1_ProcExCondition"] = true if $imported["A1_Common_Script"] old_common_script("拡張条件分岐メソッド定義", "3.80") if common_version < 3.80 #============================================================================== # ■ A1_System::CommonModule #============================================================================== class A1_System::CommonModule #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- alias a1_ex_command_111_cms_initialize initialize def initialize a1_ex_command_111_cms_initialize define_condition_method end #-------------------------------------------------------------------------- # ○ 拡張条件分岐メソッド定義 #-------------------------------------------------------------------------- def define_condition_method @cmd_111 = {} end #-------------------------------------------------------------------------- # ○ 拡張条件分岐メソッド定義取得 #-------------------------------------------------------------------------- def cmd_111 @cmd_111 end #-------------------------------------------------------------------------- # ☆ 注釈コマンド定義 #-------------------------------------------------------------------------- alias a1_ex_command_111_define_command define_command def define_command a1_ex_command_111_define_command @cmd_108["拡張条件分岐"] = :ex_condition end end #============================================================================== # ■ Game_Interpreter #------------------------------------------------------------------------------ #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、 # Game_Troop クラス、Game_Event クラスの内部で使用されます。 #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ○ 条件分岐 #-------------------------------------------------------------------------- alias a1_ex_command_111 command_111 def command_111 return a1_ex_command_111 if @params[0].is_a?(Integer) result = ex_command_111(@params) if @params[0] != "or" && @params[0] != "and" result = proc_and_condition if @params[0] == "and" result = proc_or_condition if @params[0] == "or" @branch[@indent] = result command_skip if !@branch[@indent] end #-------------------------------------------------------------------------- # ○ 拡張条件分岐の実行(AND条件) #-------------------------------------------------------------------------- def proc_and_condition @params.delete_at(0) @params.each {|params| return false unless ex_command_111(params) } return true end #-------------------------------------------------------------------------- # ○ 拡張条件分岐の実行(OR条件) #-------------------------------------------------------------------------- def proc_or_condition @params.delete_at(0) @params.each {|params| return true if ex_command_111(params) } return false end #-------------------------------------------------------------------------- # ○ 拡張条件分岐の実行 #-------------------------------------------------------------------------- def ex_command_111(params) cmd_111 = $a1_common.cmd_111[params[0]] return method(cmd_111).call(params[1]) if cmd_111 != nil end #-------------------------------------------------------------------------- # ○ 拡張条件分岐 #-------------------------------------------------------------------------- def ex_condition(params) return unless next_event_code == 111 @list[@index + 1].parameters = params end end end