Main Menu
  • Welcome to The RPG Maker Resource Kit.

[REQUEST]World Map-Change Enemy Encounters Script

Started by pyrodudexiii, August 14, 2010, 07:35:25 PM

0 Members and 1 Guest are viewing this topic.

pyrodudexiii

Summary
A script for World Maps that will enable you to change which enemy troops you encounter depending on which region you are currently in. Ex.While on the snowy part of the world map, you would encounter Arctic Wolves and Polar Bears but when you are in the grassland area you would encounter Goblins and Trolls.

Features Desired
The ability to switch between at least 20 different Troop Variations.

Games its been in

•It's in alot of RPGs with World Maps.
I wish I had a good signature...

pyrodudexiii

I wish I had a good signature...

IAMFORTE

I think there is a tutorial / event system for this, look for RMXP  enemy encounters based on level or RMXP enemy encounters based on location

pyrodudexiii

I wish I had a good signature...

Tenraah

You can change each tile's terrain tag in the tileset section in the database.  This allows you to have about 7 different mob lists based on the tile you're standing on with another script.  I'm not sure if there is a way to go above the 7 maximum for terrain tag number.

Insert the following script into your game.  It's not mine, don't credit me for it.
#===============================================================================
# ** Map : Change Encounters
#===============================================================================
#    * $game_map.encounter_list = [...] will change encounter list on current map
#    * $game_map.encounter_step = number will change encounter steps on current map
#    * $game_map.encounter_list = nil will reset encounter list to default
#    * $game_map.encounter_step = nil will reset encounter step to default
#    * $game_map.encounters[map_id].list = [...] will change encounter list on specified map
#    * $game_map.encounters[map_id].step = number will change encounter steps on specified map
#    * $game_map.encounters[map_id].list = nil will reset specified map's encounter list to default
#    * $game_map.encounters[map_id].step = nil will reset specified map's encounter step to default
#-------------------------------------------------------------------------------
# * SDK Log
#-------------------------------------------------------------------------------
if Object.const_defined?(:SDK)
  SDK.log('Map.ChangeEncounters', 'Kain Nobel ©', 3.5, '2009.06.17')
end

#===============================================================================
# ** Game_Map::Encounter_List
#===============================================================================

class Game_Map::Encounters
  #-----------------------------------------------------------------------------
  # * Public Instance Variables
  #-----------------------------------------------------------------------------
  attr_accessor :list
  attr_accessor :step
  #-----------------------------------------------------------------------------
  # * Object Initialization
  #-----------------------------------------------------------------------------
  def initialize
    @list = nil
    @step = nil
  end
end

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

class Game_Map
  #-----------------------------------------------------------------------------
  # * Public Instance Variables
  #-----------------------------------------------------------------------------
  attr_reader :encounters
  #-----------------------------------------------------------------------------
  # * Alias Listings
  #-----------------------------------------------------------------------------
  alias_method :chgencounters_gmmap_setup,          :setup
  alias_method :chgencounters_gmmap_encounterlist,  :encounter_list
  alias_method :chgencounters_gmmap_encounterstep,  :encounter_step
  #-----------------------------------------------------------------------------
  # * Setup
  #-----------------------------------------------------------------------------
  def setup(map_id)
    @encounters ||= Hash.new
    chgencounters_gmmap_setup(map_id)
    @encounters[map_id] ||= Game_Map::Encounters.new
  end
  #-----------------------------------------------------------------------------
  # * Reset Encounters
  #-----------------------------------------------------------------------------
  def reset_encounters
    encounter_list = @map.encounter_list
    encounter_step = @map.encounter_step
  end
  #-----------------------------------------------------------------------------
  # * Encounter List
  #-----------------------------------------------------------------------------
  def encounter_list
    unless @encounters[map_id].list.is_a?(Array)
      old_list = chgencounters_gmmap_encounterlist
      @encounters[map_id].list = old_list
    end
    @encounters[map_id].list
  end
  #-----------------------------------------------------------------------------
  # * Encounter Step
  #-----------------------------------------------------------------------------
  def encounter_step
    unless @encounters[map_id].step.is_a?(Numeric)
      old_step = chgencounters_gmmap_encounterstep
      @encounters[map_id].step = old_step
      $game_player.make_encounter_count
    end
    @encounters[map_id].step
  end
  #-----------------------------------------------------------------------------
  # * Encounter List = (list)
  #-----------------------------------------------------------------------------
  def encounter_list=(list)
    unless list.is_a?(Array) || list.is_a?(NilClass)
      err  = "Wrong argument for changing $game_map.encounter_list\n\nThe argum"
      err += "ent must be an :Array: (or :NilClass: object to reset), not a "
      err += ":#{list.class}:"
      raise ArgumentError.new(err)
    end
    @encounters[map_id].list = list
  end
  #-----------------------------------------------------------------------------
  # * Encounter Step = (step)
  #-----------------------------------------------------------------------------
  def encounter_step=(step)
    unless step.is_a?(Numeric) || step.is_a?(NilClass)
      err  = "Wrong argument for changing $game_map.encounter_step\n\nThe argum"
      err += "ent must be a :Numeric: (or :NilClass: object to reset), not a "
      err += ":#{step.class}:"
      raise ArgumentError.new(err)
    end
    @encounters[map_id].step = step
    $game_player.make_encounter_count
  end
end


Next, go to your world map tileset in the database and set each ground tile type's terrain tag to a different number depending on the environment it represents.  Make sure that tiles that aren't on the ground have a terrain tag of 0.

Now, make a common event, parallel trigger
The first command should set a variable to the character's terrain tag.
Now, make a conditional branch for each terrain tag.  Put this script into the conditional branch matching the correct terrain tag #
$game_map.encounter_list = [...]
Change the "..." to all of the troop ID's that you want to attack the player on that tile.  Separate them with a comma and space like this: [1, 2, 3, 4]

Now you should encounter different monsters depending on what type of tile you are standing on.
"...because, you know, whatever."

pyrodudexiii

I wish I had a good signature...