#============================================================================== # ★ ExMap_AutoPlane for RGSS3 Ver1.03 #------------------------------------------------------------------------------ #  霧や雲など、特定のマップ画面で自動的に表示されるプレーン (フォグ) を設定 # できるようにするスクリプト素材です。 # # 本素材はRPGツクールVX サンプルゲームである # 『レクト―ルと黒獅子の紋章』おまけスクリプトを改変した物である為 # RPGツクールVX Aceだけでなく、RPGツクールVXの正規ユーザーである事が求められます。 #------------------------------------------------------------------------------ # Ver1.01 透過度設定の不具合を解消。 # Ver1.02 XP環境で落ちる恐れがある箇所を修正。 # Ver1.03 イベントコマンドのスクリプトでフォグ変更が可能になりました。 # # 以下の物を、イベントコマンドのスクリプトで実行して下さい。 # # fog = [0]#配列作成 # fog[1] = "fog" #ファイル名設定 # fog[2] = 1 #スクロール(x) # fog[3] = 1 #スクロール(y) # fog[4] = 50 #Z座標 # fog[5] = 200 #透明度設定 # fog[6] = 0 #合成方法 # $game_map.re_setup_fog(fog) # #============================================================================== # マップ設定。 # マップ ID、グラフィック名、横スクロール、縦スクロール、Z 座標、 # 不透明度(0 〜 255)、合成方法 (0:通常 1:加算 2:減算)の順に # 格納した配列を必要なだけ並べます。 # 例) マップ 5 で、グラフィック「fog.png」を、半透明でピクチャの下に通常表示。 #   左に 5 下に 2 ずつスクロール => [5, "fog", 5, -2, 50, 128, 0] EXMAP_ATPLN_MAPS = [ [0, "", 0, 0, 50, 0, 0], [0, "", 0, 0, 50, 0, 0], ] # グラフィックフォルダ。 # フォグプレーン用の画像ファイルがあるフォルダ (Graphic/xxx/) を指定します。 # 0:System 1:Parallaxes 2:Pictures 3:Animations EXMAP_ATPLN_FOLDER = 1 #------------------------------------------------------------------------------ class Game_Map alias _exmapln_setup setup alias _exmapln_update update alias _exmapln_set_display_pos set_display_pos alias _exmapln_scroll_down scroll_down alias _exmapln_scroll_left scroll_left alias _exmapln_scroll_right scroll_right alias _exmapln_scroll_up scroll_up #-------------------------------------------------------------------------- # ○ 公開インスタンス変数 (追加定義) #-------------------------------------------------------------------------- attr_reader :fog # フォグデータ #-------------------------------------------------------------------------- # ○ セットアップ (追加定義) # map_id : マップ ID #-------------------------------------------------------------------------- def setup(map_id) _exmapln_setup(map_id) setup_fog end #-------------------------------------------------------------------------- # ☆ フォグのセットアップ #-------------------------------------------------------------------------- def setup_fog @fog = [0, "", 0, 0, 50, 0, 0] @fog_sx = 0 @fog_sy = 0 @fog_x = 0 @fog_y = 0 for data in EXMAP_ATPLN_MAPS if @map_id == data[0] @fog = data @fog_sx = data[2] @fog_sy = data[3] break end end end #-------------------------------------------------------------------------- # ☆ フォグのセットアップ #-------------------------------------------------------------------------- def re_setup_fog(fog_data) @fog = fog_data @fog_sx = fog_data[2] @fog_sy = fog_data[3] end #-------------------------------------------------------------------------- # ○ フレーム更新 (追加定義) #-------------------------------------------------------------------------- def update(main = false) _exmapln_update(main) update_fog end #-------------------------------------------------------------------------- # ○ 表示位置の設定 (追加定義) # x : 新しい表示 X 座標 (*256) # y : 新しい表示 Y 座標 (*256) #-------------------------------------------------------------------------- def set_display_pos(x, y) _exmapln_set_display_pos(x, y) @fog_x = x @fog_y = y end #-------------------------------------------------------------------------- # ☆ フォグ表示 X 座標の計算 # bitmap : フォグビットマップ #-------------------------------------------------------------------------- def calc_fog_x(bitmap) return bitmap == nil ? 0 : @fog_x / 8 end #-------------------------------------------------------------------------- # ☆ フォグ表示 Y 座標の計算 # bitmap : フォグビットマップ #-------------------------------------------------------------------------- def calc_fog_y(bitmap) return bitmap == nil ? 0 : @fog_y / 8 end #-------------------------------------------------------------------------- # ○ 下にスクロール (追加定義) # distance : スクロールする距離 #-------------------------------------------------------------------------- def scroll_down(distance) last_y = @display_y _exmapln_scroll_down(distance) if loop_vertical? @fog_y += distance else @fog_y += @display_y - last_y end end #-------------------------------------------------------------------------- # ○ 左にスクロール (追加定義) # distance : スクロールする距離 #-------------------------------------------------------------------------- def scroll_left(distance) last_x = @display_x _exmapln_scroll_left(distance) if loop_horizontal? @fog_x -= distance else @fog_x += @display_x - last_x end end #-------------------------------------------------------------------------- # ○ 右にスクロール (追加定義) # distance : スクロールする距離 #-------------------------------------------------------------------------- def scroll_right(distance) last_x = @display_x _exmapln_scroll_right(distance) if loop_horizontal? @fog_x += distance else @fog_x += @display_x - last_x end end #-------------------------------------------------------------------------- # ○ 上にスクロール (追加定義) # distance : スクロールする距離 #-------------------------------------------------------------------------- def scroll_up(distance) last_y = @display_y _exmapln_scroll_up(distance) if @fog != nil if loop_vertical? @fog_y -= distance else @fog_y += @display_y - last_y end end end #-------------------------------------------------------------------------- # ☆ フォグの更新 #-------------------------------------------------------------------------- def update_fog @fog_x += @fog_sx * 2 @fog_y += @fog_sy * 2 end end class Spriteset_Map alias _exmapln_initialize initialize alias _exmapln_dispose dispose alias _exmapln_update update #-------------------------------------------------------------------------- # ○ オブジェクト初期化 (追加定義) #-------------------------------------------------------------------------- def initialize create_fog _exmapln_initialize end #-------------------------------------------------------------------------- # ☆ フォグの作成 #-------------------------------------------------------------------------- def create_fog @fog = Plane.new if $game_map.fog != nil @fog.z = $game_map.fog[4] @fog.opacity = $game_map.fog[5] @fog.blend_type = $game_map.fog[6] end end #-------------------------------------------------------------------------- # ○ 解放 (追加定義) #-------------------------------------------------------------------------- def dispose @fog.dispose _exmapln_dispose end #-------------------------------------------------------------------------- # ○ フレーム更新 (追加定義) #-------------------------------------------------------------------------- def update _exmapln_update update_fog end #-------------------------------------------------------------------------- # ☆ フォグの更新 #-------------------------------------------------------------------------- def update_fog if @fog_name != $game_map.fog[1] @fog_name = $game_map.fog[1] if @fog.bitmap != nil @fog.bitmap.dispose @fog.bitmap = nil end if @fog_name != "" case EXMAP_ATPLN_FOLDER when 0 @fog.bitmap = Cache.system(@fog_name) when 1 @fog.bitmap = Cache.parallax(@fog_name) when 2 @fog.bitmap = Cache.picture(@fog_name) when 3 @fog.bitmap = Cache.animation(@fog_name, 0) end end Graphics.frame_reset end @fog.ox = $game_map.calc_fog_x(@fog.bitmap) @fog.oy = $game_map.calc_fog_y(@fog.bitmap) @fog.z = $game_map.fog[4] @fog.opacity = $game_map.fog[5] @fog.blend_type = $game_map.fog[6] end end