Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

BDR Height v1.1

BDR Height Version: 1.1 for RMVX
By: Fustel

Introduction
Ever wanted to make simple bridges and 3D mazes ??
With this new BDR script, it is now up to you. All you have to do is define tiles height, decoration size, and put simple bridge events.
And you have the choice of the method to map your heights: directily on your map, or via a height map linked to your real map.

Features
  • Define the maximum height the Hero can cross from one tile to another.
  • Define base ground tiles height by
    • assigning it to ground tile and puting them on the real map
      OR
    • assigning it to decorative tile and puting them on a height map linked to the real map
  • Define decorative tiles size, which is added to the base height
  • Define the height of an event. The final height of a tile is the higher of its own (plus any decorative) and that of any event plaved on it.
  • Tiles that are too high/low for one another are mutually impassable.
  • Define the game variable containing the Hero height and decide if an event is drawn ABOVE or BELOW the Hero depending on the value of this variable. Thus easyly making bridges.
  • The Hero cannot interact whith event on tiles he cannot reach.
  • If a height map is defined, it is used instead of the 'direct mapping' method.

Screenshots
The purpose of this script is about moving. No static image could be of any help

Demo
http://www.mediafire.com/file/nnz34gmngtm/BDR Height - v1.1.zip

Try and speak to the old man, taking note of where you can (and can't move), and of what is under your feets or over your head.
The 2 map are basically the same except:
  • The first uses the 'direct mapping' method
  • The second uses non-mapped tiles, but is linked to its 'height map'

Script
[rgss]#==============================================================================
# ** BDR Height
#------------------------------------------------------------------------------
#  © Fustel, 2010
#  13/04/10
#  Version 1.1
#------------------------------------------------------------------------------
#  VERSION HISTORY:
#   - 1.0 (13/04/10), Initial release
#   - 1.1 (19/04/10), dual height mapping ('direct' or 'height map')
#-------------------------------------------------------------------------------
#  INSTRUCTIONS:
#   - Install the 'BDR Tile v1.2' script
#   - Place this script in the 'Materials' section
#   - Set the following constants:
#     - BDR::Height::VAR (ID of variable to store player height)
#     - BDR::Height::NO_WALK (height difference with is impassable)
#     - for mapping on real map
#       - BDR::Height::Real_Height (Base height for ground tiles on real map)
#     - for mapping on height map
#       - BDR::Height::Map_Height (Base height for deco tiles on height map)
#       - BDR::Height::Map (linking real map and height map)
#     - BDR::Height::Deco_Size (added height added for deco on real map)
#---------------------------------------------------------------------------
# NOTES
#   You cannot interact with event on a tile too high/low (events_xy returns [])
#   To make a bridge/ladder, create an event with 2 pages:
#     - one is the defaut and drawn ABOVE the hero
#     - the other is drawn BELOW the hero, but is set when the vriable identified
#         by BDR::Height::VAR is at bridge height. Also, thit page MUST have a
#         comment with containining the line:
#           BDR_HEIGHT=<h>
#         where h is the desired height for the bridge.
#     - remeber to put the bridge within height reach of its extremities
#     - also remember to put the bridge high enough so the hero could not
#         reach it from below.
#==============================================================================
 
module BDR
  module Height
 
    # both systems
    #=============
    # variable ID to store the player tile height
    #--------------------------------------------
    VAR = 1
 
    # both systems
    #=============
    # Max height difference tha is passable while walking
    #----------------------------------------------------
    NO_WALK = 2
 
    # HEIGHT MAP
    #===========
    # Links between height map and real map
    # key  = real map ID
    # data = height map ID
    #----------------------------------
    Map = {}
    Map[2] = 3
 
    # HEIGHT MAP
    #===========
    # Base height from decorative tile put in height map
    # key  = [ column in panel,
    #          row in panel,
    #          panel ("B" to "E")
    #        ]
    # data = height
    #------------------------------------
    Map_Height = {}
    Map_Height[ [ 0, 0, "E"]] = -2
    Map_Height[ [ 1, 0, "E"]] = -1
    Map_Height[ [ 3, 0, "E"]] =  1
    Map_Height[ [ 4, 0, "E"]] =  2
    Map_Height[ [ 5, 0, "E"]] =  3
    Map_Height[ [ 6, 0, "E"]] =  4
 
    # DIRECT MAPPING
    #===============
    # Base height from ground tiles in real map (panel A)
    # key  = [ column in panel A,
    #          row in panel A
    #        ]
    # data = height
    #------------------------------------
    Real_Height = {}
    Real_Height[ [ 0,  1]] = -2  # water pool
    Real_Height[ [ 4, 10]] =  4  # roof
 
    # both systems
    #=============
    # Additional height from decorative in real map (panel B to E)
    # key  = [ column in panel,
    #          row in panel,
    #          pane ("A" to "E")
    #        ]
    # data = height adjustment
    #---------------------------------
    Deco_Size = {}        # height adjustment for items (tiles B to E)
    Deco_Size[ [ 4,  0, "C"]] = 3 # ladder: top
    Deco_Size[ [ 4,  1, "C"]] = 2 # ladder: middle
    Deco_Size[ [ 4,  2, "C"]] = 1 # ladder: bottom
    Deco_Size[ [ 0,  0, "C"]] = 1 # stairs
    Deco_Size[ [ 1,  2, "B"]] = 1 # wooden stairs
    Deco_Size[ [ 5, 14, "B"]] = 2 # bushes
  end
end
 
 
 
class Game_Map
  attr_reader :bdr_height_map
 
  alias bdr_height_initialize initialize
  def initialize
    @bdr_height_map = nil
    bdr_height_initialize
  end
 
  alias bdr_height_setup setup
  def setup( map_id)
    bdr_height_setup( map_id)
 
    m = BDR::Height::Map[ map_id]
    @bdr_height_map = m != nil ? load_data( sprintf( "Data/Map%03d.rvdata", m)) : nil
  end
end
 
class Game_Event < Game_Character
  BDR_HEIGHT_HEIGHT = "BDR_HEIGHT_HEIGHT"
  BDR_HEIGHT_SIZE   = "BDR_HEIGHT_SIZE"
 
  attr_reader :bdr_height_height
  attr_reader :bdr_height_size
 
  alias bdr_height_initialize initialize
  def initialize(map_id, event)
    @bdr_height_height = nil
    @bdr_height_size   = 0
    bdr_height_initialize(map_id, event)
  end
 
  alias bdr_height_setup setup
  def setup(new_page)
    bdr_height_setup( new_page)
    @bdr_height_height = nil
    @bdr_height_size = 0
    if @page != nil
      for command in @page.list
        next unless [ 108, 408].include?( command.code)
        s = command.parameters[ 0].upcase.delete " "
 
        k = BDR_HEIGHT_HEIGHT.upcase + "="
        begin
          @bdr_height_height = s.sub( k){|v| ""}.to_i if s.index( k) == 0
        rescue
        end
 
        k = BDR_HEIGHT_SIZE.upcase + "="
        begin
          @bdr_height_size = s.sub( k){|v| ""}.to_i if s.index( k) == 0
        rescue
        end
      end
    end
  end
end
 
class Game_Map
  def tile_height( x, y)
    return 0 if x == nil or y == nil
 
    if $game_map.bdr_height_map == nil
      tile_grnd = $game_map.tile_id( x, y)
      height = BDR::Height::Real_Height[ tile_grnd]
    else
      tile_grnd = $game_map.bdr_height_map.tile_id( x, y, 2).with_panel
      height = BDR::Height::Map_Height[ tile_grnd]
    end
    height = 0 if height == nil
 
    tile_deco = $game_map.tile_id( x, y, 2).with_panel
    plus = BDR::Height::Deco_Size[ tile_deco]
    height += plus if plus != nil
 
    for ev in events.values
      height = [ ev.bdr_height_height+ev.bdr_height_size, height].max if ev.bdr_height_height != nil and ev.pos?(x, y)
    end
 
    return height
  end
 
  # no event at ( x, y) if too high/low from player
  #------------------------------------------------
  alias bdr_height_events_xy events_xy
  def events_xy(x, y)
    return ( ( tile_height( x, y) - $game_player.height).abs < BDR::Height::NO_WALK ? bdr_height_events_xy( x, y) : [])
  end
end
 
# Event management
#-----------------
class Game_Character
  alias bdr_height_map_passable? map_passable?
  def map_passable?( x, y)
    return false unless bdr_height_map_passable?( x, y)
    return false if ( $game_map.tile_height( @x, @y) - $game_map.tile_height( x, y)).abs >= BDR::Height::NO_WALK
    return true
  end
end
 
class Game_Player < Game_Character
  attr_reader :height
 
  alias bdr_height_initialize initialize
  def initialize
    bdr_height_initialize
    @height = nil
  end
 
  def bdr_height_update
    h = $game_map.tile_height( @x, @y)
    return if h == @height
    @height = h
    return if BDR::Height::VAR == nil
    $game_variables[ BDR::Height::VAR] = @height
    $game_map.need_refresh = true
  end
 
  alias bdr_height_moveto moveto
  def moveto(x, y)
    bdr_height_moveto(x, y)
    bdr_height_update
  end
 
  alias bdr_height_increase_steps increase_steps
  def increase_steps
    bdr_height_increase_steps
    bdr_height_update
  end
 
  alias bdr_height_map_passable? map_passable?
  def map_passable?( x, y)
    return false unless bdr_height_map_passable?( x, y)
    return false if ( $game_map.tile_height( @x, @y) - $game_map.tile_height( x, y)).abs >= BDR::Height::NO_WALK
    return true
  end
end
 
[/rgss]

InstructionsInsZ
Installation

Configuration
  • Set parameters in the BDR::Height module in the script
    • the 'VAR' constant identies the Game_Variables that will contain the Hero height.
    • the 'NO_WALK' constant containd the height difference the hero cannot cross
    • for the 'direct mapping' method
      • the 'Real_Height' hash contains the ground tiles (panel A) base height. The default height of a tile is 0. Only tiles that have a different height need to be placed in this hash.
        • the key is an array containing [ tile column in the A panle, tile row in the A panel]
        • the data is the tile height
    • for the 'height map' method
      • the 'Map_Height' hash contains the base height assigned to decorative tiles (panle B-E) thet will be put in the height map. If no deco is put on a tile in the height map, its height will be 0.
        • the key is an array containing [ tile column in the A panle, tile row in the A panel, panel ID ("B" to "E")]
        • the data is the tile height
      • the 'Map' hash contains the links between 'real maps' and 'height maps'
        • the key is the ID of the real map
        • the data is the ID of the height map
    • the 'Deco_Size' hash contains the decoratinve tiles (panel B-E) size which is added, if set, to the ground tile base height.
      • the key is an array containing [ tile column in the panle, tile row in the panel, tile pabel ID ("B" to "E")]
      • the data is the tile size

Usage
  • for 'direct mapping'
    • assign base height to ground tiles (Real_Height)
    • draw the real map with ground tiles
  • for 'height map'
    • assign base height to decorative tiles (Map_Height) (also, see E panel in demo)
    • copy the real map into a height map
    • put the 'height-defined-deco' tiles on the height map
    • link the height map to the real map (Map)
  • for both
    • define size for decoratives (Deco_Size)
    • put them on the real map

To make a bridge
  • Create an event with 2 page, each with the same graphic (if necessary)
    • the first (the Hero is blew the bridge) is drawn ABOVE the hero.
    • the second (the Hero is at bridge level or above)
      • is drawn BELOW the hero
      • has is height set by adding the following line in a comment: 'BDR_HEIGHT=<h>' where <h> is the bridge desired height
      • is conditioned by the value of the Game_Variables identified by BDR::Height::VAR, which must be equal or lower than the bridge, but within reach
  • Remember to set the bridge height close enought to that of its extemity tiles so the Hero can access it.
  • Remember to set the bridge height far enough from the bottom so that the Hero cannot access it from ther.

FAQ

Compatibility
No issue known, although the Game_Map.events_xy returns an empty array when the tile is too high/low from the Hero

Credits and Thanks
All done by myself

Author's Notes
If you have any trouble setting your hieghts, look thoroughly at the demo, and do not hesitate to ask the silly question.
Also, note that I considered giving size to events (thus definig a base height and a top height). Remember when the Hero push a pillar into a gap from below, climbs a stair and cross the gap ON TOP of the pillar ? But this brings up the matter of BIG events (more than 32*32 pixels), their full size mapping (not every 32*32 square should have the same 'size') and the time consuming process to compute a tile height considering any far event that may overlap the tile from afar. But the discussion is still open on the subject. I am expecting your opinion on this.

v1.0 to v1.1
  • Dual height mapping: on real map, of via a linked height map
  • Requires 'BDR Tile' v1.2 or higher
  • Keus for tile IDs in hash are now [ column, row, panel]
  • Configuration constants renamed

Terms and Conditions
You may not use this in a commercial game without my explicit permission.
You may not post this script anywhere without my explict permission.
You must give me credit.
 
Interestingly, this is exactly what I talked about with Zeriab yesterday ^^ Well, not your script, but a version I made back in my RMXP days that was quite unuseable because I used terrain tags to define heights. Your version isn't all that different to be honest, as to have multiple height grass tiles, you need it multiple times on your tile sheet, right? (at least as far as I understand it... even if I'm wrong, what I'm about to tell you is a better solution ^^)
Because I was thinking about it yesterday, I can already supply you with a way I think would make this a lot easier and less cluttered to use: Instead of script definitions of tile heights, use a complete tile panel for height assignment. Similar to my Tile Overlay script, it'd contain tiles labelled "G", "1", "2", "-1", and so forth... you'd need to set these to 25% opaque or something, and actually write that text on them. If you don't have the necessary programs, give me a call and I'll do that (as it's not really any effort ^^)
Now, actually placing those tiles on your map will define the height level - areas with the tile labelled "G" on them will be your ground level, tiles with "1" will be 1 higher up. That was, you spare the user from ANY setup aside from putting in a custom tileset and sparing a tile panel, which - considering RMVX has about 50 of them - shouldn't really matter. This way, however, you can get it to work within a minute with any sized tileset you can think of.

Other than that, it's a nice idea obviously (as it was mine as well XD ). You already know about my view of using one-time-used constants or blurry method or class names, so I guess you like to fight the power ;)
As far as your mentioned compatibility note goes, you might think about fixing that though, unless it's intentional...

Keep up the good work!
 
Sorry... I didn't know you already did something about height. Just tell me what you DIDN'T make a script about... :thumb:
There are many XP features missing in VX, as there are may VX features missing in XP. Terrain Tags was a great one, although I VX was out before I scripted XP :cry:
I considered a couple solutions before choosing this one. It has its limits, but also some litlle advantages. But perhaps the one I just used for the famous soon-to-come 'BDR Sweep' is better... Time will say.
See ya at 'BDR Sweep'.... unless you already wrote it :tongue:
 
Lol... well, there'd be no way to know about this, as I scrapped it (I found the terrain method way too insufficient, so yeah... back then, I didn't think about what I told you earlier ^^" ). If you say you started scripting when VX was out already, I guess I have a bit more experience than you, which exlains why I made some more scripts than you XD However, I'm kind wonder where you got your ideas, now that you mention it... :huh:

Anyway, I never made anything sweepy, so I think you're good there XD
 
v1.1 released
  • 2 methods are now available to map the heights:
    • direct mapping as in v1.0
    • use of a heght map
  • now requires 'BDR Tile' v1.2 or higher (see main post for link)
  • some configuration constants renamed
  • some hash keys for configuration constants have changed.

Enjoy
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top