#----------------------------------------------------------------------
#Regions System
# By GubiD
# Created 8/23/07
#----------------------------------------------------------------------
class Game_Map
#----------------------------------------------------------------------
# This item enables and disables the system. This allows lower level maps
# to be enabled as well, if desired
#----------------------------------------------------------------------
REGIONS_ENABLED = true
#--------------------------------------------------------------------------
# Region Setup
# This simply add the new variables for regioning.
#--------------------------------------------------------------------------
alias region_setup setup
def setup(map_id)
region_setup(map_id)
@cur_reg = []
@regions = REGIONS::regions(@map_id)
end
#--------------------------------------------------------------------------
# Region Update
# This item runs Check Region, which in turn returns what region you are in
#--------------------------------------------------------------------------
alias region_update update
def update
if REGIONS_ENABLED
check_current_region
end
region_update
end
#--------------------------------------------------------------------------
# Current Region
# This checks your current region and displays it.
#--------------------------------------------------------------------------
def cur_region
if @cur_reg.size < 2
if @cur_reg[0] == nil
return nil
else
return @cur_reg[0]+1
end
else
return sprintf("%d, and %d",@cur_reg[0]+1, @cur_reg[1]+1)
end
end
#--------------------------------------------------------------------------
# Check Region
# This checks what region you are currently in. You can be in more than one.
#--------------------------------------------------------------------------
def check_current_region
@cur_reg = []
unless @regions.size == 0
for i in 0...@regions.size
region = @regions[i]
if (region[1]-1 <= $game_player.x and region[2] >= $game_player.x) and (region[3]-1 <= $game_player.y and region[4] >= $game_player.y)
@cur_reg.push(i)
end
end
end
end
#--------------------------------------------------------------------------
# Get Encounter List
# This is replacing the existing method for encounter list. Basically it
# returns the default list if a region is not defined, and when defined
#--------------------------------------------------------------------------
def encounter_list
if @cur_reg.size == 0
return @map.encounter_list
elsif @cur_reg.size == 1
return @regions[@cur_reg[0]][5]
elsif @cur_reg.size > 1
@list = []
for i in 0...@cur_reg.size
troops = @regions[@cur_reg[i]][5]
@list += troops
end
return @list
end
end
end
#----------------------------------------------------------------------
# Module:: REGIONS
# This is the section where you can add new regions to an exiting map or
# to a new map. Use the below diagram to determine varibles you should set.
# Regions can overlap so go ahead and play with it.
#----------------------------------------------------------------------
# [Name, starting_x, ending_x, starting_y, ending_y, [TroopID_1, TroopID_2..]]
#----------------------------------------------------------------------
module REGIONS
def self.regions(map_id)
regions = []
case map_id
when 1
name = "Halase" #region1
sx = 1
ex = 9
sy = 1
ey = 7
troops = [1,2] #Ghost
regions.push([name,sx,ex,sy,ey,troops])
name = "Belasten" #region2
sx = 6
ex = 15
sy = 1
ey = 7
troops = [3,4] #Basilisk
regions.push([name,sx,ex,sy,ey,troops])
when 2 #This method is the same as just setting them in RMXP on the map.
name = "Jimco"
sx = 1
ex = $game_map.width
sy = 1
ey = $game_map.height
troops = [5,6] #Shaglins
regions.push([name,sx,ex,sy,ey,troops])
end
return regions
end
end