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.

Monster Area System

Looking for the RM2K3 Monster Area Script for RMXP

You probably remember the days back in RM2K3 where you can have a certain monster in an area on the world map or in any other map? Well, I don't know if this was already requested, I'm looking for one for RMXP where you place monster groups in certain areas on the map. If you want an example of what I'm talking about, just say post some screenshots. Hopefully somebody has it, because I already searched.

I don't think I can do this on my one because I'm not a scripter. Any help will be appreciated. Thanks.
 
*shameless advertising*
You can try mine
[rgss] 
#===========================================================
# ** Monster Area
#-----------------------------------------------------------
# by silver wind
# V1.0
#
# This script brings back a feature from RM2K3.
# It lets you define areas on the map.
# each area has different monsters (encounter list).
#
# * Define a new area :
#   use a tile with terrain tag (other than 0)
#   and simply draw with it on the map.
#   notes:
#    - use tags 1-7. tag 0 means no encounters
#    - may not work with events with a tile graphic.
#    - you can use a white tile on layer 3,
#      so the area is invisible.
#
# * Add monsters to an area :
#   see 'configure' below.
#===========================================================
class Area
  attr_reader :id
  attr_reader :monster_list
 
  def initialize(id,list)
    @id = id
    @monster_list = list
  end
 
end
 
class Map_Area
 
  def initialize(map_id)
    @id = map_id
    @areas = {}
  end
 
  # i : area id
  def [](i)
    # return the area's monster list
    return nil if @areas.nil?
    @areas.monster_list
  end
 
  # i : area id
  def add(area)
    i = area.id
    @areas = area
  end
 
end
 
class Monster_Area
 
  def get_map
    $game_map.map_id
  end
 
  def initialize
    @areas = {}
    for i in map_list
      @areas = Map_Area.new(i)
    end
    setup
  end
 
  def [](area_id)
    # return the area's monster list
    # of the current map
    i = get_map
    j = area_id
    @areas[j]
  end
 
  def map_list
    maps = load_data('Data/MapInfos.rxdata')
    return maps.keys
  end
 
  # if you wish to know a map's id:
  def get_map_id( name )
    maps = load_data('Data/MapInfos.rxdata')
    maps.each_key {|key|
                    m = maps[key]
                    return key if m.name == name
                    }
    return nil
  end
 
  # id = the area number, which is the terain tag's number
  def new_area(map, id, monsters )
    ar = Area.new( id, monsters )
    @areas[map].add(ar)
  end
 
  def setup
    data = [ [],
#=============================================================
# Configure
#-------------------------------------------------------------
#
#  Each line defines the areas in one map.
#  genarally, use:
#  [ [area001_troops], [area002_troops] (and so on)],
# for example, the line [ [1,2], [3,4] ]
# means troops 1&2 in area 001, 3&4 in area 002.
           # map 1
           [ [2], [3,4]  ],
           # map 2
           [],
           # add more lines if you need
          ]
#=============================================================
    for i in 1...data.size
      foes = data
      for j in 0...foes.size
        foe_list = foes[j]
        # turn 0-7 to 1-8
        k = j+ 1
        new_area(i, k, foe_list)
      end
    end
   
  end
 
  def get_troop
    # get current area
    area = $game_player.terrain_tag
    return nil unless (area >= 0 and area <= 7)
    # get monster list
    list = self[area]
    n = rand(list.size)
    troop_id = list[n]
    # If troop is valid
    if $data_troops[troop_id] != nil
      return troop_id
    end
   
  end
 
end
 
 
class Scene_Title
 
  alias areas_new_game command_new_game
  def command_new_game
    $monster_area = Monster_Area.new
    areas_new_game
  end
 
 
end
 
class Scene_Map
 
  def update
    # Loop
    loop do
      # Update map, interpreter, and player order
      # (this update order is important for when conditions are fulfilled
      # to run any event, and the player isn't provided the opportunity to
      # move in an instant)
      $game_map.update
      $game_system.map_interpreter.update
      $game_player.update
      # Update system (timer), screen
      $game_system.update
      $game_screen.update
      # Abort loop if player isn't place moving
      unless $game_temp.player_transferring
        break
      end
      # Run place move
      transfer_player
      # Abort loop if transition processing
      if $game_temp.transition_processing
        break
      end
    end
    # Update sprite set
    @spriteset.update
    # Update message window
    @message_window.update
    # If game over
    if $game_temp.gameover
      # Switch to game over screen
      $scene = Scene_Gameover.new
      return
    end
    # If returning to title screen
    if $game_temp.to_title
      # Change to title screen
      $scene = Scene_Title.new
      return
    end
    # If transition processing
    if $game_temp.transition_processing
      # Clear transition processing flag
      $game_temp.transition_processing = false
      # Execute transition
      if $game_temp.transition_name == ""
        Graphics.transition(20)
      else
        Graphics.transition(40, "Graphics/Transitions/" +
          $game_temp.transition_name)
      end
    end
    # If showing message window
    if $game_temp.message_window_showing
      return
    end
   
    #=======================================================
    # my edit
    if $game_player.encounter_count == 0
      unless $game_system.map_interpreter.running? or
             $game_system.encounter_disabled
        #
        troop_id = $monster_area.get_troop
        if troop_id != nil
          # Set battle calling flag
          $game_temp.battle_calling = true
          $game_temp.battle_troop_id = troop_id
          $game_temp.battle_can_escape = true
          $game_temp.battle_can_lose = false
          $game_temp.battle_proc = nil
        end
      end
    end
   #=======================================================
    # If B button was pressed
    if Input.trigger?(Input::B)
      # If event is running, or menu is not forbidden
      unless $game_system.map_interpreter.running? or
             $game_system.menu_disabled
        # Set menu calling flag or beep flag
        $game_temp.menu_calling = true
        $game_temp.menu_beep = true
      end
    end
    # If debug mode is ON and F9 key was pressed
    if $DEBUG and Input.press?(Input::F9)
      # Set debug calling flag
      $game_temp.debug_calling = true
    end
    # If player is not moving
    unless $game_player.moving?
      # Run calling of each screen
      if $game_temp.battle_calling
        call_battle
      elsif $game_temp.shop_calling
        call_shop
      elsif $game_temp.name_calling
        call_name
      elsif $game_temp.menu_calling
        call_menu
      elsif $game_temp.save_calling
        call_save
      elsif $game_temp.debug_calling
        call_debug
      end
    end
  end
 
end
 
[/rgss]
^ it uses terrain tags, so the areas don't have to be square.
Suppose you have a sand-worm enemy, and you only want it to show on sand tiles in the beach tileset, so you set the tile's terrain tag to 1.
then add the sand-worm troop in area 1 of your beach map. if it's map 3, do it in line 3, etc.
If you don't know the id of a map, do:
p $monster_area.get_map_id( name )
-name should be in brackets, ie 'Smallvil'

I believe the other one is only for world map, so you can't define different areas for different maps.
 
I've been using the script and I keep getting this error:

Script 'Monster Areas' line 135: NoMethodError occurred.

undefined method `size' for nil:NilClass


Line 135 in the script is:
n = rand(list.size)

What am I doing wrong with it?
 
Seriously, I dislike silverwind's script, variables should be more self documenting (that means many of the comments would be useless and should be deleted afterwards). There are some variables or methods that shouldn't exist because there aren't needed at all. I hope he'll improve it, I don't think it should take him too much time to correct those things.

pyro, did you ever create any monster area? The thing is that might be one of the reasons this is happening. I'll still need to check the script a little more to confirm or deny my previous statement.

Edit / Shilzen...

OK, maybe you did configure some map areas or just use the ones that are included in the script, but silverwind forgot to modify his script in line 135...

list = self[area]

It should be...

list = self[area+1]

@silverwind: it could have been named...

list = @areas[$game_map.map_id][$game_player.terrain_tag + 1]
 
Thanks for the effort kyonides, but it's still causing the same problem. Alright, here's some additional details I probably should've added:
The error pops up whenever I'm supposed to have a random encounter,ragardless of whether or not I have set any troops to encounter. Ex.My seaside town obviously has no encounters set. The default map properties state that an encounter is going to happen in 30 steps approx. After filling said quota, the game displays that error. I'm going to post an exact copy of the script that I have. I've only tinkered with the CONFIGURE area and the area kyonides told me to change.

[pastebin]123[/pastebin]
 
Shouldn't it be better if you post a demo? I mean, maybe that could help us test it. Perhaps another script conflicts with this one... I'm just saying this just in case. Even so I'll take a look at the script, but I really thought it shouldn't fail after I implemented the bug fix because it worked on my PC...
 

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