=begin ▼ セルフ変数の追加 ver. 1.5 RPGツクールVXAce用スクリプト 制作 : 木星ペンギン URL : http://woodpenguin.blog.fc2.com/ ------------------------------------------------------------------------------ 概要 □ 各イベントにセルフ変数を実装します ------------------------------------------------------------------------------ 使い方 ・設定項目にて、セルフ変数の操作・参照に使う変数番号の設定してください。 ・その変数を操作すると、実行中のイベントのセルフ変数が操作されます。 ・その変数を参照すると、実行中のイベントのセルフ変数が参照されます。 ・コモンイベントで操作・参照を行った場合、呼び出しているイベントの  セルフ変数が操作・参照されます。 ・自動実行や並列処理のコモンイベント、トループのバトルイベントで  操作・参照した場合、何も起こりません。 ・通常のイベントでも、並列処理では以下のイベントコマンドは使用出来ません。  (並列処理以外であれば使用出来ます) ------------------------------------------------------------------------------ 並列処理で使用できないイベントコマンド一覧 ・文章の表示(制御文字) ・選択肢の表示(制御文字) ・数値入力の処理 ・アイテム選択の処理 ・文章のスクロール表示(制御文字) =end module WdTk module SelfVar #////////////////////////////////////////////////////////////////////////////// # # 設定項目 # #////////////////////////////////////////////////////////////////////////////// #-------------------------------------------------------------------------- # ● セルフ変数の操作に使う変数番号の配列 #-------------------------------------------------------------------------- SELF_VARIABLE = [] #////////////////////////////////////////////////////////////////////////////// # # 以降、変更する必要なし # #////////////////////////////////////////////////////////////////////////////// end @material ||= [] @material << :SelfVar def self.include?(sym) @material.include?(sym) end end #============================================================================== # ■ Game_Variables #============================================================================== class Game_Variables #-------------------------------------------------------------------------- # ● モジュール #-------------------------------------------------------------------------- include WdTk::SelfVar #-------------------------------------------------------------------------- # ◯ オブジェクト初期化 #-------------------------------------------------------------------------- alias _wooden_selfvar_initialize initialize def initialize _wooden_selfvar_initialize @self_variables = {} @map_id = @event_id = 0 end #-------------------------------------------------------------------------- # ☆ 変数の取得 #-------------------------------------------------------------------------- def [](variable_id) if SELF_VARIABLE.include?(variable_id) key = [@map_id, @event_id, variable_id] @self_variables[key] || 0 else @data[variable_id] || 0 end end #-------------------------------------------------------------------------- # ☆ 変数の設定 #-------------------------------------------------------------------------- def []=(variable_id, value) if SELF_VARIABLE.include?(variable_id) return if @event_id == 0 key = [@map_id, @event_id, variable_id] @self_variables[key] = value else @data[variable_id] = value end unless WdTk.include?(:EvEX) && WdTk::EvEX::Static_Variables.include?(variable_id) on_change end end #-------------------------------------------------------------------------- # ● マップ ID とイベント ID の設定と取得 #-------------------------------------------------------------------------- def set_key(map_id, event_id) @map_id, @event_id = map_id, event_id end end #============================================================================== # ■ Game_Event #============================================================================== class Game_Event #-------------------------------------------------------------------------- # ◯ リフレッシュ #-------------------------------------------------------------------------- alias _wooden_selfvar_refresh refresh def refresh $game_variables.set_key(@map_id, @id) _wooden_selfvar_refresh end end #============================================================================== # ■ Game_Interpreter #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ◯ フレーム更新 #-------------------------------------------------------------------------- alias _wooden_selfvar_update update def update initiative_selfvar @fiber.resume if @fiber $game_map.interpreter.initiative_selfvar end #-------------------------------------------------------------------------- # ● セルフ変数の使用権を得る #-------------------------------------------------------------------------- def initiative_selfvar $game_variables.set_key(@map_id, @event_id) end end