*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.