#=========================================================================== # ◆ A1 Scripts ◆ # 画面外自律許可(RGSS3) # # バージョン : 1.10 (2012/01/02) # 作者 : A1 # URL     : http://a1tktk.web.fc2.com/ #--------------------------------------------------------------------------- # 機能: # ・イベントの画面外自律行動を許可します #--------------------------------------------------------------------------- # 更新履歴   :2011/12/30 Ver1.00 リリース #    :2012/01/02 Ver1.10 A1共通スクリプトVer3.30対応 #--------------------------------------------------------------------------- # 設置場所 #  A1共通スクリプトより下 # # 必要スクリプト # A1共通スクリプトVer3.30以上 #--------------------------------------------------------------------------- # 使い方 # イベントコマンド「注釈」に記述 # # 画面外自律許可 EventID,on|off # 画面外自律許可 EventID-EventID,on|off # # 例: 画面外自律許可 10,on イベントID10のイベントが画面外でも自律行動を取ります # 例: 画面外自律許可 10-50,on イベントID10から50のイベントが画面外でも自律行動を取ります #--------------------------------------------------------------------------- # 注意事項 # 当機能は、画面外でもイベントに自律行動を取らせる処理なので # 全体的に処理を重くします #============================================================================== $imported ||= {} $imported["A1_NearTheScreen"] = true if $imported["A1_Common_Script"] old_common_script("画面外自律許可", "3.30") if common_version < 3.30 #============================================================================== # ■ Game_Event #------------------------------------------------------------------------------ #  イベントを扱うクラスです。条件判定によるイベントページ切り替えや、並列処理 # イベント実行などの機能を持っており、Game_Map クラスの内部で使用されます。 #============================================================================== class Game_Event < Game_Character #-------------------------------------------------------------------------- # ☆ 非公開メンバ変数の初期化 #-------------------------------------------------------------------------- alias a1_enable_near_the_screen_ge_init_private_members init_private_members def init_private_members a1_enable_near_the_screen_ge_init_private_members @enable_near_the_screen = true end #-------------------------------------------------------------------------- # ☆ 画面の可視領域付近にいるか判定 # dx : 画面中央から左右何マス以内を判定するか # dy : 画面中央から上下何マス以内を判定するか #-------------------------------------------------------------------------- alias a1_enable_near_the_screen_ge_near_the_screen? near_the_screen? def near_the_screen?(dx = 12, dy = 8) return a1_enable_near_the_screen_ge_near_the_screen?(dx, dy) if enable_near_the_screen return true end #-------------------------------------------------------------------------- # ○ 画面外自律行動許可 #-------------------------------------------------------------------------- def enable_near_the_screen=(flag) @enable_near_the_screen = flag end #-------------------------------------------------------------------------- # ○ 画面外自律行動許可 #-------------------------------------------------------------------------- def enable_near_the_screen return @enable_near_the_screen end end #============================================================================== # ■ A1_System::CommonModule #============================================================================== class A1_System::CommonModule #-------------------------------------------------------------------------- # ☆ 注釈コマンド定義 #-------------------------------------------------------------------------- alias a1_enable_near_the_screen_define_command define_command def define_command a1_enable_near_the_screen_define_command @cmd_108["画面外自律許可"] = :enable_near_the_screen end end #============================================================================== # ■ Game_Interpreter #------------------------------------------------------------------------------ #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、 # Game_Troop クラス、Game_Event クラスの内部で使用されます。 #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ○ 画面外自律行動許可 #-------------------------------------------------------------------------- def enable_near_the_screen(params) return proc_enable_near_the_screen(params[0].to_i, params) unless params[0] =~ /(\d+)-(\d+)/ ($1.to_i..$2.to_i).each {|id| proc_enable_near_the_screen(id, params) } end #-------------------------------------------------------------------------- # ○ 画面外自律行動許可の実行 #-------------------------------------------------------------------------- def proc_enable_near_the_screen(event_id, params) flag = params[1] == "on" ? false : true event = $game_map.events[event_id] event.enable_near_the_screen = flag end end end