Help - Search - Members - Calendar
Full Version: World map encounters
RPG RPG Revolution Forums > Game Engines > RPG Maker XP Discussion
Exuriel
Hello, i need help in the matter of having different enemies put out over the world map in my game.
As it would seem it does'nt have the Create area thing that RPG VX have. (Sadly started with VX before Xp).
So is there any other way around to place different mobs on different isles and such in the game? Because it'd not work
out very well having the let's say "last isle" encounters on the very first isle.

So my question is, what is the best way on RPGXP to place out different enemies on a world map?

Ps. I'm well aware i posted this in the RGSS Script Support unfortunately so i apologize for that (In case anyone came across this topic in that section.)
Thanks in advance!


//Exuriel
amerk
XP doesn't include areas by default. Perhaps a script does this, but I'm not sure what's available. You could check in script request to see.

Other options could be to event your encounters on the world map and you can also make them invisible so players won't see them. Although this task would create the illusion of random encounters, an intelligent player would soon know what enemies hover around which areas the most and could use that to there advantage. Not to mention this task can be very tedious, and could create a lot of potential lag.

You might also be able to set something up based on variables, switches, and common events, but that task could get very complicated.
Exuriel
Hmm yes that's why i find this rather crucial. As it happens a player will know where-at these specific enemies are placed out (Makes me think of FF1 in a cave where a specific corner wouldn't allow you to take 2-3 steps to there or from there without encountering the one and the very same enemy over and over.)

I don't fear the matter of how tedious it may be come, one ought to have patience. However it is true it would cause a somewhat lag to use huge amount of events which is what i'm trying to avoid by finding more simplified solutions.

Anyhow i believe i'll go and take a look inside the Script submission sections and see if i find any leads towards that which i am troubled with. While doing so i'll hope there'll be more replies eventually from here and there that may help as well happy.gif. Thank you the reply amerk!
Jens of Zanicuud
Ok, I actually had a rather simple idea to deal with your request.

I think you can bound enemy encounters to the terrain tags.

e.g.
terrain 1: woods enemies;
terrain 2: cave enemies;
...
terrain 7: demons

I have actually made a script which can extend terrain numbers up to the actual tile number of a tileset, you can find it here:

Extended Terrain Tags

(this means: more variety in enemy groups)

If you need a script to do this, I could make it in no time...
Just ask and you'll be given that smile.gif

Hope this can help.

Jens

EDIT:

Here's the script...

Tell me if it works properly.

CODE
#------------------------------------------------------------------------------
# ** Jens of Zanicuud's world map encounters script
# Credit needed, customize it as you like.
#------------------------------------------------------------------------------

WORLD_MAPS_ID = [10,20]   #Id of the world maps
TROOP_LIST = {            
1 => [1,2,3],             #terrain 1 => associated troops id
2 => [3,7,12],            #terrain 2 => associated troops id
}

class Game_Map
def encounter_list
   #check map id
   if !WORLD_MAPS_ID.include?(@map_id)
     return @map.encounter_list
   else
     #check player terrain
     terrain = $game_player.terrain_tag
     #if player terrain is in the hash, then load the correct list
     if TROOP_LIST.include?(terrain)
       return TROOP_LIST[terrain]
     else
     #else, return an empty vector
       return []
     end
   end
end

end


Now, a little explaination.

1. WORLD_MAPS_ID is the array which contains the id of any of your world maps.
2. TROOP_LIST is the hash which do what you need. It must be filled like this:

TROOP_LIST = {
terrain_tag 1 => [troop id 1, troop id 2, troop id 3...],
terrain_tag 2 => [troop id 1, troop id 2, troop id 3...],

}

e.g.

TROOP_LIST = {
5 => [1,5,8],
2 => [2,10],
}

means that on terrain 5 you can find only troops number 1, 5 and 8, while in terrain 2 you can find troops number 2 and 10.
Number 0 is reserved to non_encounter tiles...

Ask for troubleshooting anytime.

Jens
Donny
Sorry Jens, I don't mean to tread on your toes here. There's a script I've used before which is pretty good and as far as I can see does what you need:

Encounter Control by SephirothSpawn
CODE
#==============================================================================
# ** Encounter Control
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 1.01
# 2006-10-23
#------------------------------------------------------------------------------
# * Version History :
#
#   Version 1 ---------------------------------------------------- (2006-08-12)
#    Version 1.01 ------------------------------------------------ (2006-10-23)
#     - Bug Fix : Fixed Erase Event
#------------------------------------------------------------------------------
# * Requirements :
#
#   Near Fantastica's View Range Module
#------------------------------------------------------------------------------
# * Description :
#
#   This script was designed to give you more control of Random Encounters
#   Encounter Control allows you give terrain tags, circular regions and
#   rectangular regions groups of enemies, instead of just map encounters.
#   Additionally, it allows you to view in the debugger the regions on the map
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place The Script Below the SDK and Above Main.
#
#   Setting Up Terrain Groups (Game_Map::Terrain_Tag_Groups)
#   TTG = { map_id => { terrain_tag => [troop_id, ...], ... }, ... }
#   (Use 0 for map_id as a default for all maps, unless specified)
#
#   Setting Up Encounter Regions
#   Adds a Comment Line with this format:
#   Comment : Enc Ctrl <type>(<params>)[group_id, ...]
#
#   <type> = Circ (Circluar Region) or Rect (Rectangular Region)
#   Circular <params> = center_x, center_y, radius
#   Rectangular <params> = upper_left_x, upper_left_y, rect_width, rect_height
#------------------------------------------------------------------------------
# * Credits :
#
#   Thanks to Near Fantastica For His View Range Module
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Encounter Control', 'SephirothSpawn', 1.01, '2006-10-23')

#------------------------------------------------------------------------------
# * View Range Test
#------------------------------------------------------------------------------
unless SDK.state('View Range')
  # Print Error
  p 'View Range Module Not Found. Encounter Control Disabled.'
  # Disable Encounter Control
  SDK.disable('Encounter Control')
end

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('Encounter Control')

#==============================================================================
# ** View Range Module Extension
#==============================================================================

module VR
  #--------------------------------------------------------------------------
  # * In Rect Range?
  #--------------------------------------------------------------------------
  def self.in_rect_range?(rect, object)
    return object.x.between?(rect.x, rect.x + rect.width) &&
       object.y.between?(rect.y, rect.y + rect.height)
  end
end

#==============================================================================
# ** Circle
#==============================================================================

class Circle
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :x
  attr_accessor :y
  attr_accessor :radius
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y, r)
    @x, @y, @radius = x, y, r
  end
end

#==============================================================================
# ** Color
#==============================================================================

class Color
  #--------------------------------------------------------------------------
  # * To Hexidecimal
  #--------------------------------------------------------------------------
  def to_hex
    n = (self.red.to_i * 100) + (self.green.to_i * 10) + self.blue.to_i
    return eval "0x#{n.to_s(16)}"
  end
end

#==============================================================================
# ** Game_Event
#==============================================================================

class Game_Event < Game_Character
  #--------------------------------------------------------------------------
  # * Circle Encounter Areas
  #--------------------------------------------------------------------------
  def seph_circle_enconter_areas
    # Starts Enc Areas
    enc_areas = {}
    # Return Enc Areas If No List
    return enc_areas if @list.nil? || @erased
    # Checks All Event Commands
    for i in 0...@list.size
      # Checks For Comment Line
      if @list[i].code == 108
        # If Parameters Include 'Enc Ctrl'
        if @list[i].parameters[0].upcase.include?('ENC CTRL')
          # Collect Encounter List For Area
          @list[i].parameters[0].dup.gsub(/\[(.+?)\]/, '')
          list = $1.split.collect! {|x| x.to_i}
          # Test For Circular Range
          if @list[i].parameters[0].upcase.include?('CIRC')
            @list[i].parameters[0].dup.gsub(/\((.+?)\)/, '')
            unless $1.nil?
              circ = eval "Circle.new(#{$1})"
              # Stores Enc List
              enc_areas[circ] = list
            end
          end
        end
      end
    end
    # Return Encounter List
    return enc_areas
  end
  #--------------------------------------------------------------------------
  # * Rect Encounter Areas
  #--------------------------------------------------------------------------
  def seph_rect_encounter_areas
    # Starts Enc Areas
    enc_areas = {}
    # Return Enc Areas If No List
    return enc_areas if @list.nil?
    # Checks All Event Commands
    for i in 0...@list.size
      # Checks For Comment Line
      if @list[i].code == 108
        # If Parameters Include 'Enc Ctrl'
        if @list[i].parameters[0].upcase.include?('ENC CTRL')
          # Collect Encounter List For Area
          @list[i].parameters[0].dup.gsub(/\[(.+?)\]/, '')
          list = $1.split.collect! {|x| x.to_i}
          # Test For Rect Boundaries
          if @list[i].parameters[0].upcase.include?('RECT')
            @list[i].parameters[0].dup.gsub(/\((.+?)\)/, '')
            unless $1.nil?
              rect = eval "Rect.new(#{$1})"
              # Stores Enc List
              enc_areas[rect] = list
            end
          end
        end
      end
    end
    # Return Encounter List
    return enc_areas
  end
end


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

class Game_Map
  #--------------------------------------------------------------------------
  # * Terrain Tags
  #   ~ map_id = > {terrain_tag => [troop_id, ...] }
  # * Use 0 For Default For All Maps
  # * To Overwrite Default, Include Map ID And Define or Leave Blank Terrain
  #--------------------------------------------------------------------------
  Terrain_Tag_Groups = {
    0 => {
    }
  }
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias seph_enccntrl_gmmap_el encounter_list  
  #--------------------------------------------------------------------------
  # * Get Encounter List
  #--------------------------------------------------------------------------
  def encounter_list
    # Checks Terrain Tag Groups
    if Terrain_Tag_Groups.has_key?(@map_id)
      # Test For Player Terrain Tag
      if Terrain_Tag_Groups[@map_id].has_key?($game_player.terrain_tag)
        # Return List
        return Terrain_Tag_Groups[@map_id][$game_player.terrain_tag]
      end
    # Checks For Default
    elsif Terrain_Tag_Groups[0].has_key?($game_player.terrain_tag)
      # Return List
      return Terrain_Tag_Groups[0][$game_player.terrain_tag]
    end
    # Checks All Events
    for event in $game_map.events.values
      # Checks Circular Ranges Of Event
      circ_ranges = event.seph_circle_enconter_areas
      circ_ranges.each do |circle, list|
        # If Player In Range of Circle
        if VR.in_range?(circle, $game_player, circle.radius)
          # Return List
          return list
        end
      end
      # Checks Rect Ranges
      rect_ranges = event.seph_rect_encounter_areas
      rect_ranges.each do |rect, list|
        # If Player In Range of Rect
        if VR.in_rect_range?(rect, $game_player)
          # Return List
          return list
        end
      end
    end
    # Return Original Encounter List
    return seph_enccntrl_gmmap_el
  end
end

#==============================================================================
# ** Spriteset_Map
#==============================================================================

class Spriteset_Map
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias seph_encctrl_gmmap_init initialize
  alias seph_encctrl_gmmap_update update
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Original Initialization
    seph_encctrl_gmmap_init
    # Creates Flash Data Table & Flash Tile Flag
    @tilemap.flash_data = Table.new($game_map.width, $game_map.height)
    @seph_encctrl_tilesflashing = false
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Original Update
    seph_encctrl_gmmap_update
    # If Debugging
    if $DEBUG
      # If A Button Is Pressed
      if Input.trigger?(Input::A)
        # If Tiles Flashing
        if @seph_encctrl_tilesflashing
          # Unflashes All Map Tiles
          for x in 0...$game_map.width
            for y in 0...$game_map.height
              @tilemap.flash_data[x, y] = 0
            end
          end
          # Turns Flashing Flag Off
          @seph_encctrl_tilesflashing = false
        # If Tiles Not Flashing
        else
          # Sets Up Colors Array (To Prevent Matching Colors
          @flashtile_colors = []
          # Checks All Events
          for event in $game_map.events.values
            # Flashes All Circular Ranges
            event.seph_circle_enconter_areas.keys.each do |circle|
              seph_flash_circular_range(circle, circle.radius)
            end
            # Flashes All Rect Ranges
            event.seph_rect_encounter_areas.keys.each do |rect|
              seph_flash_rect_range(rect)
            end
            # Turns Flashing Flag On
            @seph_encctrl_tilesflashing = true
          end
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Flash Circular Range
  #--------------------------------------------------------------------------
  def seph_flash_circular_range(object, range)
    # Gets Flash Color
    color = get_random_color while color.nil? ||
            @flashtile_colors.include?(color)
    # Flashes Tiles Within Range
    x = object.x
    for i in (x - range)..(x + range)
      sa = (x - i).abs
      x_ = i < x ? x - sa : i == x ? x : x + sa
      y_ = Integer((range ** 2 - sa ** 2) ** 0.5)
      for j in (object.y - y_)..(object.y + y_)
        @tilemap.flash_data[i, j] = color.to_hex
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Flash Rect Range
  #--------------------------------------------------------------------------
  def seph_flash_rect_range(rect)
    color = get_random_color while color.nil? ||
            @flashtile_colors.include?(color)
    for x in 0...rect.width
      for y in 0...rect.height
        @tilemap.flash_data[rect.x + x, rect.y + y] = color.to_hex
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Get Random Color
  #--------------------------------------------------------------------------
  def get_random_color
    return Color.new(rand(18) * 15, rand(18) * 15, rand(18) * 15)
  end
end

#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end


This script does require that you have the SDK script and Near Fantastica's View Range Module (see below) as well though.

Near Fantastica's View Range Module
CODE
#==============================================================================
# ** View Range Module
#==============================================================================
# Near Fantastica
# Version 4
# 29.11.05
#==============================================================================

#--------------------------------------------------------------------------
# * SDK Log Script
#--------------------------------------------------------------------------
SDK.log("View Range", "Near Fantastica", 4, "29.11.05")

#--------------------------------------------------------------------------
# * Begin SDK Enable Test
#--------------------------------------------------------------------------
if SDK.state("View Range") == true
  module VR
    #----------------------------------------------------------------------------
    def VR.in_range?(element, object, range)
      x = (element.x - object.x) * (element.x - object.x)
      y = (element.y - object.y) * (element.y - object.y)
      r = x + y
      if r <= (range * range)
        return true
      else
        return false
      end
    end
    #----------------------------------------------------------------------------
    def VR.range(element, object)
      x = (element.x - object.x) * (element.x - object.x)
      y = (element.y - object.y) * (element.y - object.y)
      r = x + y
      r = Math.sqrt(r)
      return r.to_i
    end
  end
  
  #==========================================================================
====
  class Interpreter
    #----------------------------------------------------------------------------
    def event
      return $game_map.events[@event_id]
    end
  end
  
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.