Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
- # In-Depth Maps v2.1
- # FenixFyreX
- # RPG Maker VxAce
- #×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
- # This script allows the player to define two regions:
- # overhead ceilings, and blocking tiles.
- # When the system finds the overhead ceilings region on top of a tile, it will
- # move that tile to the highest layer in the tilemap, and put the tile above
- # that tile (y - 1) in it's place on the 'ground', this allows the player to pass
- # underneath the tile.
- # To turn the system OFF, simply turn the switch defined below ON. To turn it
- # on, flip the switch OFF. This allows the user to traverse the 'ceilings' when
- # on top of them, but go behind them when on the ground.
- #
- #×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
- module Fyx
- module MapDepth
- # This is the switch to turn ON to turn the overhead system OFF.
- # Remember, all switches are OFF by default, so the system is ON at startup.
- Switch = 1
- # Does the script turn on the switch automatically when each map loads?
- AutoSwitch = true
- # This is the region defining tiles that need to be above the player.
- Overhead_Region = 1
- # This is the region defining tiles that need to be unpassable no matter
- # what.
- Block_Region = 2
- # This is the region to use when defining 'secret passages'. This region
- # ensures that the tiles below it are ALWAYS above and passable.
- Secret_Region = 3
- # This is the user defined fall-back for when the system can't obtain a
- # tile to place under overhead tiles.
- Default_Ground_Tile = 2816
- end
- end
- #×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
- # Don't edit below unless you know what it means.
- #×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
- class Game_Map
- Pass = { down: 0x0001, left: 0x0002, right: 0x0004, up: 0x0008,
- norm: 0x0010, ladder: 0x0020, bush: 0x0040, counter: 0x0080,
- floor: 0x0100, boat: 0x0200, ship: 0x0400, airship: 0x0800,
- terrain: 0xF000 }
- CeilPass = [:down, :left, :right, :up, :bush, :floor, :terrain]
- alias setup_no_ceilings setup
- def setup(*argv, &argb)
- setup_no_ceilings(*argv, &argb)
- setup_ceiling_data
- end
- def setup_ceiling_data
- $game_switches[ohead_switch] = false if Fyx::MapDepth::AutoSwitch
- @ohead_switch = ohead_sys_is_on?
- define_ceilings if @ohead_switch
- end
- def ohead_sys_is_on?
- return false if $game_switches[ohead_switch]
- return true
- end
- def ohead_switch
- Fyx::MapDepth::Switch
- end
- def ohead_region
- Fyx::MapDepth::Overhead_Region
- end
- def block_region
- Fyx::MapDepth::Block_Region
- end
- def secret_region
- Fyx::MapDepth::Secret_Region
- end
- def default_ground_tile
- Fyx::MapDepth::Default_Ground_Tile
- end
- def ceiling_ground_tile(x, y)
- return valid?(x, y - 1) ? @map.data[x, y - 1, 0] : default_ground_tile
- end
- alias passable_no_ceilings? passable?
- def passable?(*argv, &argb)
- return false if (ceiling_block?(*argv, &argb) && ohead_sys_is_on?)
- passable_no_ceilings?(*argv, &argb)
- end
- def ceiling?(x, y)
- region_id(x, y) == ohead_region
- end
- def secret_passage?(x, y)
- region_id(x, y) == secret_region
- end
- def ceiling_block?(*argv, &argb)
- x, y = *argv[0...2]
- region_id(x, y) == block_region
- end
- def reset_ceilings
- @ceilings, @ceiling_blocks, @pass_ceilings = [], [], []
- @map.data = load_data(sprintf("Data/Map%03d.rvdata2", @map_id)).data
- tileset.flags = load_data("Data/Tilesets.rvdata2")[@map.tileset_id].flags
- end
- def get_ceil_xys
- reset_ceilings
- height.times do |y|
- width.times do |x|
- @ceilings << [x, y] if ceiling?(x, y)
- @pass_ceilings << [x, y] if secret_passage?(x, y)
- @ceiling_blocks << [x, y] if ceiling_block?(x, y)
- end
- end
- end
- def define_ceilings
- get_ceil_xys
- $game_switches[ohead_switch] = true
- @ceilings.each do |x, y|
- tid = @map.data[x, y, 0]
- bit = 0x10
- CeilPass.each do |sym|
- bit = (bit | Pass[sym]) if tileset.flags[tid] & Pass[sym] == Pass[sym]
- end
- tileset.flags[tid] = bit
- @map.data[x, y, 2] = tid
- $game_map.data[x, y, 0] = ceiling_ground_tile(x, y)
- end
- @pass_ceilings.each do |x, y|
- tid = @map.data[x, y, 0]
- bit = 0x10
- CeilPass.each do |sym|
- bit = (bit | Pass[sym]) if tileset.flags[tid] & Pass[sym] == Pass[sym]
- end
- tileset.flags[tid] = bit
- @map.data[x, y, 2] = tid
- @map.data[x, y, 0] = default_ground_tile
- end
- $game_switches[ohead_switch] = false
- end
- alias update_no_ceilings update
- def update(*argv, &argb)
- if @ohead_switch != ohead_sys_is_on?
- @ohead_switch = ohead_sys_is_on?
- ohead_sys_is_on? ? define_ceilings : reset_ceilings
- end
- update_no_ceilings(*argv, &argb)
- end
- end
- module DataManager
- class << self
- alias reload_map_if_reset_ohead reload_map_if_updated
- def reload_map_if_updated(*argv, &argb)
- $game_map.setup_ceiling_data
- reload_map_if_reset_ohead(*argv, &argb)
- end
- end
- end
- #×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
- # ×END OF SCRIPT×
- #×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
Advertisement
Add Comment
Please, Sign In to add comment