#=========================================================================== # ◆ A1 Scripts ◆ # ミリ秒ウェイト・ミリ秒エフェクト(RGSS3) # # バージョン : 1.10 (2012/01/02) # 作者 : A1 # URL     : http://a1tktk.web.fc2.com/ #--------------------------------------------------------------------------- # 機能: # ・ウェイトや画面効果、ピクチャ関連に関する時間をミリ秒で行います #--------------------------------------------------------------------------- # 更新履歴   :2011/12/15 Ver1.00 リリース #    :2012/01/02 Ver1.10 A1共通スクリプトVer3.30対応 #--------------------------------------------------------------------------- # 設置場所 #  A1共通スクリプトより下 # # 必要スクリプト # A1共通スクリプトVer3.30以上 #--------------------------------------------------------------------------- # 使い方 # イベントコマンド「注釈」に記述 # # ウェイト d : d ミリ秒の間ウェイトします # エフェクトウェイト d : 次に実行するエフェクト時間を d ミリ秒にします # 「フェードイン」「フェードアウト」「画面の色調変更」 # 「ピクチャの移動」「ピクチャの色調変更」で有効 # # イベントコマンド「移動ルートの設定」「スクリプト」に記述 # # wait(d) : d ミリ秒の間ウェイトします # # 文章に入力 # # \UW[d] : d ミリ秒の間ウェイトします #============================================================================== $imported ||= {} $imported["A1_Use_Usec"] = true if $imported["A1_Common_Script"] old_common_script("ミリ秒ウェイト", "3.30") if common_version < 3.30 #============================================================================== # ■ Game_Picture #------------------------------------------------------------------------------ #  ピクチャを扱うクラスです。このクラスは Game_Screen クラスの内部で使用され # ます。マップ画面のピクチャとバトル画面のピクチャは別々に扱われます。 #============================================================================== class Game_Picture #-------------------------------------------------------------------------- # ☆ オブジェクト初期化 #-------------------------------------------------------------------------- alias a1_usec_wait_gp_initialize initialize def initialize(number) a1_usec_wait_gp_initialize(number) @usec_duration = 0 @tone_usec_duration = 0 end #-------------------------------------------------------------------------- # ☆ ピクチャの移動 #-------------------------------------------------------------------------- alias a1_usec_wait_gp_move move def move(origin, x, y, zoom_x, zoom_y, opacity, blend_type, duration) a1_usec_wait_gp_move(origin, x, y, zoom_x, zoom_y, opacity, blend_type, duration.abs) return unless duration < 0 @usec_duration = duration.abs.to_f @org_x = @x @org_y = @y @org_zoom_x = @zoom_x @org_zoom_y = @zoom_y @org_opacity = @opacity @plus_x = (@target_x - @x) / @usec_duration @plus_y = (@target_y - @y) / @usec_duration @plus_zoom_x = (@target_zoom_x - @zoom_x) / @usec_duration @plus_zoom_y = (@target_zoom_y - @zoom_y) / @usec_duration @plus_opacity = (@target_opacity - @opacity) / @usec_duration @start_time = $a1_common.now_usec end #-------------------------------------------------------------------------- # ☆ 色調変更の開始 #-------------------------------------------------------------------------- alias a1_usec_wait_gp_start_tone_change start_tone_change def start_tone_change(tone, duration) a1_usec_wait_gp_start_tone_change(tone, duration.abs) return unless duration < 0 @tone_usec_duration = duration.abs.to_f @org_tone = @tone.clone @plus_red = (@org_tone.red - tone.red) / @tone_usec_duration @plus_green = (@org_tone.green - tone.green) / @tone_usec_duration @plus_blue = (@org_tone.blue - tone.blue) / @tone_usec_duration @plus_gray = (@org_tone.gray - tone.gray) / @tone_usec_duration @tone_start_time = $a1_common.now_usec end #-------------------------------------------------------------------------- # ☆ 移動の更新 #-------------------------------------------------------------------------- alias a1_usec_wait_gp_update_move update_move def update_move return a1_usec_wait_gp_update_move if @usec_duration == 0 d = $a1_common.now_usec - @start_time @x = @org_x + @plus_x * d @y = @org_y + @plus_y * d @zoom_x = @org_zoom_x + @plus_zoom_x * d @zoom_y = @org_zoom_y + @plus_zoom_y * d @opacity = @org_opacity + @plus_opacity * d @usec_duration = 0 if d >= @usec_duration end #-------------------------------------------------------------------------- # ○ 色調の更新 #-------------------------------------------------------------------------- alias a1_usec_wait_gp_update_tone_change update_tone_change def update_tone_change return a1_usec_wait_gp_update_tone_change if @tone_usec_duration == 0 d = $a1_common.now_usec - @tone_start_time @tone.red = Integer(@org_tone.red - @plus_red * d) @tone.green = Integer(@org_tone.green - @plus_green * d) @tone.blue = Integer(@org_tone.blue - @plus_blue * d) @tone.gray = Integer(@org_tone.gray - @plus_gray * d) @tone_usec_duration = 0 if d >= @tone_usec_duration end end #============================================================================== # ■ Game_Screen #------------------------------------------------------------------------------ #  色調変更やフラッシュなど、画面全体に関係する処理のデータを保持するクラスで # す。このクラスは Game_Map クラス、Game_Troop クラスの内部で使用されます。 #============================================================================== class Game_Screen #-------------------------------------------------------------------------- # ☆ クリア #-------------------------------------------------------------------------- alias a1_usec_wait_gs_clear clear def clear a1_usec_wait_gs_clear @fadeout_usec_duration = 0 @fadein_usec_duration = 0 @tone_usec_duration = 0 end #-------------------------------------------------------------------------- # ☆ フェードアウトの開始 #-------------------------------------------------------------------------- alias a1_usec_wait_gs_start_fadeout start_fadeout def start_fadeout(duration) return a1_usec_wait_gs_start_fadeout(duration) unless duration < 0 @fadeout_usec_duration = duration.abs.to_f @org_brightness = @brightness @plus_brightness = @brightness / @fadeout_usec_duration @fadeout_start_time = $a1_common.now_usec end #-------------------------------------------------------------------------- # ☆ フェードインの開始 #-------------------------------------------------------------------------- alias a1_usec_wait_gs_start_fadein start_fadein def start_fadein(duration) return a1_usec_wait_gs_start_fadein(duration) unless duration < 0 @fadein_usec_duration = duration.abs.to_f @org_brightness = @brightness @plus_brightness = 255 / @fadein_usec_duration @fadein_start_time = $a1_common.now_usec end #-------------------------------------------------------------------------- # ☆ 色調変更の開始 #-------------------------------------------------------------------------- alias a1_usec_wait_gs_start_tone_change start_tone_change def start_tone_change(tone, duration) return a1_usec_wait_gs_start_tone_change(tone, duration) unless duration < 0 @tone_usec_duration = duration.abs.to_f @org_tone = @tone.clone @plus_red = (@org_tone.red - tone.red) / @tone_usec_duration @plus_green = (@org_tone.green - tone.green) / @tone_usec_duration @plus_blue = (@org_tone.blue - tone.blue) / @tone_usec_duration @plus_gray = (@org_tone.gray - tone.gray) / @tone_usec_duration @tone_start_time = $a1_common.now_usec end #-------------------------------------------------------------------------- # ☆ フェードアウトの更新 #-------------------------------------------------------------------------- alias a1_usec_wait_gs_update_fadeout update_fadeout def update_fadeout return a1_usec_wait_gs_update_fadeout if @fadeout_usec_duration == 0 d = $a1_common.now_usec - @fadeout_start_time @brightness = Integer(@org_brightness - @plus_brightness * d) @fadeout_usec_duration = 0 if d >= @fadeout_usec_duration end #-------------------------------------------------------------------------- # ☆ フェードインの更新 #-------------------------------------------------------------------------- alias a1_usec_wait_gs_update_fadein update_fadein def update_fadein return a1_usec_wait_gs_update_fadein if @fadein_usec_duration == 0 d = $a1_common.now_usec - @fadein_start_time @brightness = Integer(@org_brightness + @plus_brightness * d) @fadein_usec_duration = 0 if d >= @fadein_usec_duration end #-------------------------------------------------------------------------- # ☆ 色調の更新 #-------------------------------------------------------------------------- alias a1_usec_wait_gs_update_tone update_tone def update_tone return a1_usec_wait_gs_update_tone if @tone_usec_duration == 0 d = $a1_common.now_usec - @tone_start_time @tone.red = Integer(@org_tone.red - @plus_red * d) @tone.green = Integer(@org_tone.green - @plus_green * d) @tone.blue = Integer(@org_tone.blue - @plus_blue * d) @tone.gray = Integer(@org_tone.gray - @plus_gray * d) @tone_usec_duration = 0 if d >= @tone_usec_duration end end #============================================================================== # ■ Game_Character #------------------------------------------------------------------------------ #  主に移動ルートなどの処理を追加したキャラクターのクラスです。Game_Player、 # Game_Follower、GameVehicle、Game_Event のスーパークラスとして使用されます。 #============================================================================== class Game_Character < Game_CharacterBase #-------------------------------------------------------------------------- # ☆ 非公開メンバ変数の初期化 #-------------------------------------------------------------------------- alias a1_usec_wait_init_gc_init_private_members init_private_members def init_private_members a1_usec_wait_init_gc_init_private_members @wait_start = 0 end #-------------------------------------------------------------------------- # ○ ウェイト #-------------------------------------------------------------------------- def wait(count) @wait_start = $a1_common.now_usec @wait_count = count end #-------------------------------------------------------------------------- # ☆ ルートに沿った移動の更新 #-------------------------------------------------------------------------- alias a1_usec_wait_init_gc_update_routine_move update_routine_move def update_routine_move return a1_usec_wait_init_gc_update_routine_move if @wait_start == 0 return if @wait_start + @wait_count > $a1_common.now_usec @wait_count = 0 @wait_start = 0 end end #============================================================================== # ■ Window_Message #------------------------------------------------------------------------------ #  文章表示に使うメッセージウィンドウです。 #============================================================================== class Window_Message < Window_Base #-------------------------------------------------------------------------- # ☆ 制御文字の処理 #-------------------------------------------------------------------------- alias a1_usec_wait_wm_process_escape_character process_escape_character def process_escape_character(code, text, pos) case code.upcase when 'UW' text.slice!(/\[([0-9]+)\]/) rescue 0 break_time = $a1_common.now_usec + $1.to_i Fiber.yield while break_time > $a1_common.now_usec else a1_usec_wait_wm_process_escape_character(code, text, pos) end end end #============================================================================== # ■ A1_System::CommonModule #============================================================================== class A1_System::CommonModule #-------------------------------------------------------------------------- # ☆ 注釈コマンド定義 #-------------------------------------------------------------------------- alias a1_usec_wait_define_command define_command def define_command a1_usec_wait_define_command @cmd_108["ウェイト"] = :a1_usec_wait @cmd_108["エフェクトウェイト"] = :effect_usec_wait end end #============================================================================== # ■ Game_Interpreter #------------------------------------------------------------------------------ #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、 # Game_Troop クラス、Game_Event クラスの内部で使用されます。 #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ☆ ウェイト #-------------------------------------------------------------------------- alias a1_usec_wait_gi_wait wait def wait(duration) return a1_usec_wait_gi_wait(duration) unless duration < 0 usec_wait(duration.abs) end #-------------------------------------------------------------------------- # ☆ 画面のフェードアウト #-------------------------------------------------------------------------- alias a1_usec_wait_gi_command_221 command_221 def command_221 return a1_usec_wait_gi_command_221 if @params[0] == nil or @params[0].empty? Fiber.yield while $game_message.visible screen.start_fadeout(@params[0]) wait(@params[0]) end #-------------------------------------------------------------------------- # ☆ 画面のフェードイン #-------------------------------------------------------------------------- alias a1_usec_wait_gi_command_222 command_222 def command_222 return a1_usec_wait_gi_command_222 if @params[0] == nil or @params[0].empty? Fiber.yield while $game_message.visible screen.start_fadein(@params[0]) wait(@params[0]) end #-------------------------------------------------------------------------- # ○ ミリ秒ウェイト #-------------------------------------------------------------------------- def usec_wait(duration) break_time = $a1_common.now_usec + duration Fiber.yield while break_time > $a1_common.now_usec end #-------------------------------------------------------------------------- # ○ ウェイト #-------------------------------------------------------------------------- def a1_usec_wait(params) usec_wait(params[0].to_i) end #-------------------------------------------------------------------------- # ○ エフェクトウェイト #-------------------------------------------------------------------------- def effect_usec_wait(params) case next_event_code when 221,222; @list[@index + 1].parameters[0] = params[0].to_i * -1 when 223; @list[@index + 1].parameters[1] = params[0].to_i * -1 when 232; @list[@index + 1].parameters[10] = params[0].to_i * -1 when 234; @list[@index + 1].parameters[2] = params[0].to_i * -1 end end end end