#============================================================================ # # ■追加地形タイル □Ver1.00 □製作者:月紳士 # ・RPGツクールVX用 RGSS2スクリプト # # ●…書き換えメソッド(競合注意) ◎…メソッドのエイリアス ○…新規メソッド # # ※二次配布禁止!配布元には利用規約があります。必ずそちらを見てください。 #============================================================================ =begin  このスクリプトは  高山、沼といった新たな地形タイルを追加する為のスクリプトです。  地形タイルは、オートタイルとして表示されます。  Ex_Field_Tile.png  という画像タイルが必須になります。  規格は TileA2.png と同様のサイズ・配置です。  (最大32種類の追加が可能です)  Ex_Field_Tile.png ファイルは、あらかじめ  Graphic/System フォルダへのインポートが必要です。  地形タイルの配置には、カスタマイズ項目で指定した  タイルB〜Eのタイルを使用します。  このタイルをエディタで配置すると、  ゲーム上では対応する地形オートタイルに変更される仕組みです。 ※置き換えるタイルの通行判定が、配置されるオートタイルに反映されます。  追加する地形タイルの通行を不可にしたい場合は  置き換えに使うタイルの通行判定を×に、  通行可能にしたいなら○にしてください。  ☆にすると、追加される地形タイルは茂み表現になります。   =end #============================================================================== # □ カスタマイズ項目 #============================================================================== module Ex_Field_Tile ID = [772, 773, 774, 775] # ここで地形タイルに置き換えるタイルIDを指定します。 # Bタイル(ID 0〜255)、Cタイル(ID 256〜511)、 # Dタイル(ID 512〜767)、Eタイル(ID 768〜1023)の内から指定できます。 # ここでIDを挙げた順番に、 # Ex_Field_Tile.png ファイルの左上から右へと # オートタイルが対応します。 end #============================================================================== # ■ Game_Map #------------------------------------------------------------------------------ #  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。 # このクラスのインスタンスは $game_map で参照されます。 #============================================================================== class Game_Map #-------------------------------------------------------------------------- # ○ 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :eft_ex_data #-------------------------------------------------------------------------- # ◎ セットアップ # map_id : マップ ID #-------------------------------------------------------------------------- alias tig_eft_setup setup def setup(map_id) tig_eft_setup(map_id) @eft_ex_data = Table.new(width, height, 3) setup_eft_tiles end #-------------------------------------------------------------------------- # ○ 追加地形タイルのセットアップ #-------------------------------------------------------------------------- def setup_eft_tiles for i in Ex_Field_Tile::ID if @passages[i] & 0x10 == 0x10 @passages[i] = 0x40 end end for x in 0...width for y in 0...height next unless Ex_Field_Tile::ID.include?(@map.data[x, y, 2]) index = Ex_Field_Tile::ID.index(@map.data[x, y, 2]) next if index > 31 auto_tile_id = 0 if round_y(y - 1) >= 0 and @map.data[x, round_y(y-1), 2] != Ex_Field_Tile::ID[index] auto_tile_id = 20 end if round_x(x - 1) >= 0 and @map.data[round_x(x-1), y, 2] != Ex_Field_Tile::ID[index] case auto_tile_id when 0 ; auto_tile_id = 16 when 20 ; auto_tile_id = 34 end end if round_x(x + 1) < width and @map.data[round_x(x+1), y, 2] != Ex_Field_Tile::ID[index] case auto_tile_id when 0 ; auto_tile_id = 24 when 16 ; auto_tile_id = 32 when 20 ; auto_tile_id = 36 when 34 ; auto_tile_id = 42 end end if round_x(y + 1) < height and @map.data[x, round_y(y+1), 2] != Ex_Field_Tile::ID[index] case auto_tile_id when 0 ; auto_tile_id = 28 when 16 ; auto_tile_id = 40 when 20 ; auto_tile_id = 33 when 24 ; auto_tile_id = 38 when 32 ; auto_tile_id = 44 when 34 ; auto_tile_id = 43 when 36 ; auto_tile_id = 45 when 42 ; auto_tile_id = 46 end end if round_x(x - 1) >= 0 and round_y(y - 1) >= 0 and @map.data[round_x(x-1), round_y(y-1), 2] != Ex_Field_Tile::ID[index] case auto_tile_id when 0 ; auto_tile_id = 1 when 24 ; auto_tile_id = 26 when 28 ; auto_tile_id = 29 when 38 ; auto_tile_id = 39 end end if round_x(x + 1) < width and round_y(y - 1) >= 0 and @map.data[round_x(x+1), round_y(y-1), 2] != Ex_Field_Tile::ID[index] case auto_tile_id when 0 ; auto_tile_id = 2 when 1 ; auto_tile_id = 3 when 16 ; auto_tile_id = 17 when 28 ; auto_tile_id = 30 when 29 ; auto_tile_id = 31 when 40 ; auto_tile_id = 41 end end if round_x(x - 1) >= 0 and round_x(y + 1) < height and @map.data[round_x(x-1), round_y(y+1), 2] != Ex_Field_Tile::ID[index] case auto_tile_id when 0 ; auto_tile_id = 8 when 1 ; auto_tile_id = 9 when 2 ; auto_tile_id = 10 when 3 ; auto_tile_id = 11 when 20 ; auto_tile_id = 22 when 24 ; auto_tile_id = 25 when 26 ; auto_tile_id = 27 when 36 ; auto_tile_id = 37 end end if round_x(x + 1) < width and round_x(y + 1) < height and @map.data[round_x(x+1), round_y(y+1), 2] != Ex_Field_Tile::ID[index] case auto_tile_id when 0 ; auto_tile_id = 4 when 1 ; auto_tile_id = 5 when 2 ; auto_tile_id = 6 when 3 ; auto_tile_id = 7 when 8 ; auto_tile_id = 12 when 9 ; auto_tile_id = 13 when 10 ; auto_tile_id = 14 when 11 ; auto_tile_id = 15 when 16 ; auto_tile_id = 18 when 17 ; auto_tile_id = 19 when 20 ; auto_tile_id = 21 when 22 ; auto_tile_id = 23 when 34 ; auto_tile_id = 35 end end @eft_ex_data[x, y, 1] = index * 48 + 2816 + auto_tile_id end end for x in 0...width for y in 0...height next unless Ex_Field_Tile::ID.include?(@map.data[x, y, 2]) @map.data[x, y, 1] = @map.data[x, y, 2] @map.data[x, y, 2] = @map.data[x, y, 0] end end end #-------------------------------------------------------------------------- # ● 通行可能判定 # x : X 座標 # y : Y 座標 # flag : 調べる通行禁止ビット (通常 0x01、乗り物の場合のみ変更) #-------------------------------------------------------------------------- def passable?(x, y, flag = 0x01) for event in events_xy(x, y) # 座標が一致するイベントを調べる next if event.tile_id == 0 # グラフィックがタイルではない next if event.priority_type > 0 # [通常キャラの下] ではない next if event.through # すり抜け状態 pass = @passages[event.tile_id] # 通行属性を取得 next if pass & 0x10 == 0x10 # [☆] : 通行に影響しない return true if pass & flag == 0x00 # [○] : 通行可 return false if pass & flag == flag # [×] : 通行不可 end for i in [2, 1, 0] # レイヤーの上から順に調べる tile_id = @map.data[x, y, i] # タイル ID を取得 next if i == 2 and tile_id > 1023 ##### 追加部分 (この行) ##### return false if tile_id == nil # タイル ID 取得失敗 : 通行不可 pass = @passages[tile_id] # 通行属性を取得 next if pass & 0x10 == 0x10 # [☆] : 通行に影響しない return true if pass & flag == 0x00 # [○] : 通行可 return false if pass & flag == flag # [×] : 通行不可 end return false # 通行不可 end end #============================================================================== # ■ Spriteset_Map #------------------------------------------------------------------------------ #  マップ画面のスプライトやタイルマップなどをまとめたクラスです。このクラスは # Scene_Map クラスの内部で使用されます。 #============================================================================== class Spriteset_Map #-------------------------------------------------------------------------- # ◎ ビューポートの作成 #-------------------------------------------------------------------------- alias tig_eft_create_viewports create_viewports def create_viewports @viewport0 = Viewport.new(0, 0, 544, 416) # 追加レイヤー用ビューポート tig_eft_create_viewports @viewport6 = Viewport.new(0, 0, 544, 416) # 色調変更用ビューポート @viewport6.z = 25 end #-------------------------------------------------------------------------- # ◎ タイルマップの作成 #-------------------------------------------------------------------------- alias tig_eft_create_tilemap create_tilemap def create_tilemap tig_eft_create_tilemap @eft_ex_tilemap = Tilemap.new(@viewport1) @eft_ex_tilemap.bitmaps[0] = Cache.system("TileA1") @eft_ex_tilemap.bitmaps[1] = Cache.system("Ex_Field_Tile") @eft_ex_tilemap.bitmaps[2] = Cache.system("TileA3") @eft_ex_tilemap.bitmaps[3] = Cache.system("TileA4") @eft_ex_tilemap.bitmaps[4] = Cache.system("TileA5") @eft_ex_tilemap.bitmaps[5] = Cache.system("TileB") @eft_ex_tilemap.bitmaps[6] = Cache.system("TileC") @eft_ex_tilemap.bitmaps[7] = Cache.system("TileD") @eft_ex_tilemap.bitmaps[8] = Cache.system("TileE") @eft_ex_tilemap.map_data = $game_map.eft_ex_data @eft_ex_tilemap.passages = $game_map.passages end #-------------------------------------------------------------------------- # ◎ タイルマップの解放 #-------------------------------------------------------------------------- alias tig_eft_dispose_tilemap dispose_tilemap def dispose_tilemap tig_eft_dispose_tilemap @eft_ex_tilemap.dispose end #-------------------------------------------------------------------------- # ◎ ビューポートの解放 #-------------------------------------------------------------------------- alias tig_eft_dispose_viewports dispose_viewports def dispose_viewports tig_eft_dispose_viewports @viewport0.dispose @viewport6.dispose end #-------------------------------------------------------------------------- # ◎ タイルマップの更新 #-------------------------------------------------------------------------- alias tig_eft_update_tilemap update_tilemap def update_tilemap tig_eft_update_tilemap @eft_ex_tilemap.ox = $game_map.display_x / 8 @eft_ex_tilemap.oy = $game_map.display_y / 8 @eft_ex_tilemap.update end #-------------------------------------------------------------------------- # ◎ フレーム更新 #-------------------------------------------------------------------------- alias tig_eft_update update def update tig_eft_update update_eft_ex_viewports end #-------------------------------------------------------------------------- # ● ビューポートの更新 #-------------------------------------------------------------------------- def update_viewports @viewport6.tone = $game_map.screen.tone ##### 修正部分 (この行) ##### @viewport1.ox = $game_map.screen.shake @viewport2.color = $game_map.screen.flash_color @viewport3.color.set(0, 0, 0, 255 - $game_map.screen.brightness) @viewport1.update @viewport2.update @viewport3.update @viewport6.update ##### 追加部分 (この行) ##### end #-------------------------------------------------------------------------- # ○ 拡張ビューポートの更新 #-------------------------------------------------------------------------- def update_eft_ex_viewports @viewport0.ox = $game_map.screen.shake @viewport0.update end end