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.

I require an encounter area script that uses terrain tags.

I require an encounter area script that uses terrain tags as well as setting areas, i have an old one now, but it does not have options for terrain tags.

Right now i have a script that allows me to make encounter areas, i can set up squared areas in which to encounter sertin(not sure how sertin is spelled, sorry) groups of monsters, but there are no options in the script to set up terrains so that you only run into some of those monster groups on sertin terrain tags compared to other tags.

So like, say i wanna run into elves in the forest but not on grass within a square, there is no way to set that up.
I require a script that lets me set up a square and also let's me dictate what monsters in that square space i will run into on a terrain tag and not on other terrain tags.

I realize sepherothspawn made script just like this already, i have searched, but it requires SDK, and i can't get SDK to work with a lot of the scripts i have.
 
It has two versions. One for XP and one for VX.

As the instructions, I apologize for not have them in English. I'll leave them here on the topic in your language.


> Just above the main paste and follow the instructions below:

Maker = Cross_Battletag (XP) or VX_Battle_Terrain(VX)

Maker  
 
 
I'm trying to translate it myself now.
Google translate is such a pain in the ass...

So this script allows for not only setting up battle zones, but also to set up terrains for some of those monsters?

Currently i am using this script, which lets me set up a square space for monster groups, but does not allow for terrains.
Code:
#==============================================================================

# Encounter Area Restriction

# Version: 1.1 

# Author: Modern Algebra  (rmrk.net)

# Date: February 5, 2008

#------------------------------------------------------------------------------

#  Instructions:

#    See inside the editable region at line 48 for instructions on setting up 

#    the database.

#    You can also add a new region at any time in the game by using this code

#    in a call script:

#

#     $game_system.set_area(x, y, width, height, monster troop array, map_id, name)

#

#    In order to make it fit, it may be easier to first assign each value to a 

#    variable, like so:

#

#      x = starting x coordinate for area

#      y = starting y coordinate for area

#      w = width of area

#      h = height of area

#      t = [1st troop ID, 2nd Troop ID, ...] for all troops in the area

#      m = map id to set the new area in

#      n = 'name' of area

#      $game_system.set_area (x,y,w,h,t,m,n)

#

#    If you ever want to disable or enable an area (for instance, if the player

#    comes back to the map after a major event and you no longer want him to 

#    fight the troops held in an old array), then you can use these codes:

#   

#    $game_system.area(name, map ID).active = true

#    $game_system.area(name, map ID).active = true

#

#     If you do not specify map ID, then it will be assumed to be the map you

#     are currently located on.

#==============================================================================

# *** Encounter_Regions

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#  Stores all pertinent data regarding encounters

#==============================================================================

 

module Encounter_Regions

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  # * Regions

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  def self.areas

    @areas = []

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    # * Editable Region

    #----------------------------------------------------------------------

    # Set initial areas here. Set them up like this:

    #

    #    self.set_area (x, y, width, height, monster troop array, map_id, name)

    #

    # In the 1st example area below, we have defined an area at x = 10, y = 6, 

    # width = 4, height = 5, in the 1st map with monsters 2, 3, and 8 appearing

    # in the area. Essentially, this means that on the first map, you can 

    # encounter monster troops 2, 3 and 8 if the player coordinates are within

    # (10-13, 6-10). The name is 'Lies'. If you do not want to give the area

    # a name, then merely type in nil.

    #

    # You can set as many areas as you like for as many maps as you like.

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    self.set_area (2, 1, 26, 13, [2,3,4,5,6,7], 2, 'First Area')

    self.set_area (1, 15, 33, 20,[2,3,4], 2, 'Second Area')

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    # * End Editable Region                                                                                    

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    return @areas

  end

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  # * Set Area

  #     Adds an Encounter_Area object to the areas array.

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  def self.set_area (x, y, width, height, array, map_id, name = '')

    # Initialize array if this is the first map for which there is an area

    @areas[map_id] = [] if @areas[map_id].nil?

    id = @areas[map_id].size

    area = Encounter_Area.new (x, y, width, height, array, map_id, name)

    @areas[map_id].push (area)

  end

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  # ** Encounter Area  

  #--------------------------------------------------------------------------

  #  The object which represents an area

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  class Encounter_Area

    #----------------------------------------------------------------------

    # * Public Instance Variables                                                              

    #----------------------------------------------------------------------

    attr_reader   :map_id

    attr_reader   :rect

    attr_reader   :monster_troops # The monsters within the troop

    attr_reader   :name

    attr_accessor :active

    #----------------------------------------------------------------------

    # * Initialize                                          

    #     Adds a Game_Area object to the array.       

    #----------------------------------------------------------------------

    def initialize (x, y, width, height, array, map_id, name)

      @rect = Rect.new (x, y, width, height)

      @monster_troops = array

      @name = name

      @map_id = map_id

      @active = true

    end

    #----------------------------------------------------------------------

    # * Within?                                                       

    #     Checks if the position specified is within the area                 

    #----------------------------------------------------------------------

    def within? (x, y)

      return x.between? (@rect.x, @rect.x + @rect.width - 1) &&

                y.between? (@rect.y, @rect.y + @rect.height - 1)

    end

    #----------------------------------------------------------------------

    # * Equals?                                           

    #     Determine if two Encounter_Area objects are equal     

    #----------------------------------------------------------------------

    def == (other)

      return other.map_id == @map_id && other.rect == @rect

    end

  end

end

 

#==============================================================================

# ** Game_System

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#  Summary of Changes:

#       aliased methods - initialize

#       new methods - set_area, update_regions

#       new instance variables - regions

#==============================================================================

 

class Game_System

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   

  # * Public Instance Variables

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  attr_reader :regions              # Contains area data

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  # * Object Initialization

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  alias ma_encounter_areas_init initialize

  def initialize

    ma_encounter_areas_init

    @regions = []

  end

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   

  # * Set Area

  #     Adds an Encounter_Area object to the areas array.

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  def set_area (x, y, width, height, array, name = '', map_id = $game_map.map_id)

    area = Encounter_Regions::Encounter_Area.new  (x, y, width, height, array, map_id, name)

    # If first area in the map, initialize array

    @regions[map_id] = [] if @regions[map_id].nil?

    @regions[map_id].push (area) unless @regions[map_id].include? (area)

  end

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   

  # * Update Areas

  #     Adds an Encounter_Area object to the areas array.

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  def update_regions 

    # For all areas in the database

    Encounter_Regions.areas.each {|regions|

      next if regions.nil?

      regions.each {|area|

        # Initialize the array if this is the first area to be set to that map

        @regions[area.map_id] = [] if @regions[area.map_id].nil?

        # Add the area to the regions if it does not already exist

        @regions[area.map_id].push (area) unless @regions.include? (area)

      }

    }

  end

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  # * Retrieve Area by name and map_id

  #       map_id : the ID of the map

  #       name    : the name of the area you want

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  def area (name = '', map_id = $game_map.map_id)

    @regions[map_id].each {|i| return i if i.name == name}

    return false

  end

end

 

#==============================================================================

# ** Game_Map

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#  Summary of Changes:

#      aliased methods - encounter_list

#==============================================================================

 

class Game_Map

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  # * Encounter List

  #       Returns the encounter list, with modifications based on level

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  alias ma_encounter_areas_encounter_list encounter_list

  def encounter_list

    # Run original method

    encounters = ma_encounter_areas_encounter_list

    return encounters if $game_system.regions[@map_id].nil?

    # Add monsters from each area the player is within

    $game_system.regions[@map_id].each { |area|

      next unless area.active

      # Add all unique elements from the area to the encounter_list 

      encounters |= area.monster_troops if area.within? ($game_player.x, $game_player.y)

    }

    return encounters

  end

end

 

#======================================================================

# ** Scene_Title

#------------------------------------------------------------------------------

#  Summary of Changes:

#       aliased method - main

#======================================================================

 

class Scene_Title

  alias ma_encounter_regions_main_update main

  def main

    # Run original method

    ma_encounter_regions_main_update

    # Merge new database entries with the game areas

    $game_system.update_regions

  end

end

Your script only seems to rely on terrains and not defined square areas.
Also, your script seems to rely on this other script for terrains, i don't need more terrains, the ones they already allow for are enough, not to mention i can use events to set up battle backgrounds using the built in terrain tags already there, i only need 7.

I need a script that allows for both the built in terrain tags, as well as defined areas like in the script i pasted...
I appreciate you're trying to help, but your system is not what i'm looking for.
 

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