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.

Sephirothspawn's Extra Terrain Script

Status
Not open for further replies.
Can anyone tell me how you customize extra terrain using this script? I am using it with the Encounter Control script, which I finally figured out (the older version, can't get new one to work). This is the part that I need an example for:

# Extra_Terrains = { tileset_name => { tile_id => n, ...}, ... }
#
# Calculating Tile ID:
#
# - x = (tile_id - 384) % 8 * 32
# - y - (tile_id - 384) / 8 * 32

What should tileset_name be? And how exactly do you get the tile_id using those two formulas? Also, will this even work with encounter control? Here is the full script:

Code:
#==============================================================================
# ** Extra Terrains
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 1.01
# 2007-01-24
# SDK : Version 2.0+, Parts I & II
#------------------------------------------------------------------------------
# * Version History :
#
#   Version 1 ---------------------------------------------------- (2006-12-14)
#    Version 1.01 ------------------------------------------------ (2007-01-24)
#     - Update : Updated to SDK 2.0
#------------------------------------------------------------------------------
# * Description :
#
#   This Script was designed to allow you to have more than the default
#   terrains. You can set the terrain for any tile.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place The Script Below the SDK and Above Main.
#   To Customize your terrains, refer to the customization instructions.
#------------------------------------------------------------------------------
# * Customization :
#
#   Extra_Terrains = { tileset_name => { tile_id => n, ...}, ... }
#
#   Calculating Tile ID: 
#
#    - x = (tile_id - 384) % 8 * 32
#    - y = (tile_id - 384) / 8 * 32
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Extra Terrains', 'SephirothSpawn', 1.01, '2007-01-24')
SDK.check_requirements(2.0, [2])

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.enabled?('Extra Terrains')

#==============================================================================
# ** Game_Map
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # * Extra Terrains
  #
  #   Extra_Terrains = { tileset_name => { tile_id => n, ...}, ... }
  #
  #   Calculating Tile ID: 
  #
  #    - x = (tile_id - 384) % 8 * 32
  #    - y - (tile_id - 384) / 8 * 32
  #--------------------------------------------------------------------------
  Extra_Terrains = {}
  Extra_Terrains.default = {}
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_extraterrain_st, :setup_tileset
  #--------------------------------------------------------------------------
  # * Setup Tileset
  #--------------------------------------------------------------------------
  def setup_tileset
    # Original Setup Tilesets
    seph_extraterrain_st
    # Setup Extra Terrains
    seph_setup_extra_terrains(map_id)
  end
  #--------------------------------------------------------------------------
  # * Setup : Extra Terrains
  #--------------------------------------------------------------------------
  def seph_setup_extra_terrains(map_id)
    # Pass Through All Defined Tile_IDs
    Extra_Terrains[@tileset_name].each do |tile_id, n|
      # Overwrite Terrain Tag
      @terrain_tags[tile_id] = n
    end
  end
end

#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
 
I really should have done some better instructions on getting the tile_id.

Start with 384. The formula for tile_id is 384 + x + 8 * y.

Now on your tileset, pick a tile. Lets say for the basic 001-Grassland01 tileset, lets pick the second tree stump with the moss on it. The x tile is 4 (fifth tile from the right, we start counting with 0). The y tile is 1 (second from the top, ignoring the autotiles, we start counting with 0).

So, you tileset name is '001-Grassland01' and tile_id is 384 + 4 + 8 * 1 = 396.

So your code will be:
Code:
  Extra_Terrains = {}
  # New Code below this
  Extra_Terrains['001-Grassland01'] = {}
  Extra_Terrains['001-Grassland01'][396] = your_new_terrain_id

I will be sure to update the instructions. It should work fine with the Encounter Control system.
 
Status
Not open for further replies.

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