Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - Rymdpotatis

1
Resource Requests / Help resizing image.
September 01, 2008, 03:15:45 pm
I've tried to resize this 21x43 image so it could fit in a 32x32 field with no success. I'm not great at pixel graphics so I was hoping that someone with time could take a look and see if they could pull it off. When I do it it gets all destorted^^

Image:
2
I'm having trouble with my random treasure chest event. I want it to be a random event that determines if the chest will appear or not, and a random event to determine what is in the chest.

This is my Chest event:
Page 1:
@>Control variables:[001:Chest Appear] = Random NO. (0...1)
@>
Page 2:
Variable>0001:Chest Appear is 1 or above
@>Conditional Branch: Variable:[001:Chest Appear] ==0
@>Erase Event
@>
Branch End
@>Conditional Branch:Variable [0001: Chest Appear ==1
@>Control Variables: [0002: Chest Loot] = Random No. (0...3)
@>Conditional Branch:Variable [0002: Chest Loot ==0
@>Change Items: [Red Potion], +1
@>Erase Event
@>
Branch End
@>Conditional Branch: Variable:[001:Chest Appear] ==0
@>Erase Event
@>
Branch End
@>Conditional Branch:Variable [0001: Chest Appear ==1
@>Control Variables: [0002: Chest Loot] = Random No. (0...3)
@>Conditional Branch:Variable [0002: Chest Loot ==1
@>Change Items: [Sword], +1
@>Erase Event
@>
Branch End

(Repeat 2 with changed item name and Chest Loot number.)

What happens is that it's always visible and it deals out items depending on where I stand relative to the chest. If I stand to the right I get the Sword, if I stand to the left I get the potion. And so on and so on. Any tip on what I've done wrong?
3
Script Requests / Line of sight/fog of war? [RESOLVED]
August 28, 2008, 03:58:35 pm
I would like to ask for a line of sight script that limits the players view so that the player can only see what's infront of him.

And a fog of war script that covers the map with darkness that gradually dissapear as the player moves around and explores. Capable of concealing events if possible.


Edit:
I found this script. And it works with Blizz-ABS!

#==============================================================================
# ** Fog of War
#------------------------------------------------------------------------------
# Version 2.0, 2005-11-21
# by Wachunga
#==============================================================================
=begin
0.8 - original release
0.85
- added colour parameter to map names
- fixed bug where map grids overlapped
0.9
- switched over to a tilemap (from a sprite)
- now more compatible with minimap scripts (but they'll have to take
extra tilemap into account)
1.0
- switched over to an autotile instead of using a custom tileset
* edges looks nicer, but gradual fading had to be removed
* colour parameter no longer possible (set by autotile)
- move event (including jumping and speed changes) bug fixed
- teleportation bug fixed
- some optimization
- made compatible with Cogwheel's Pixel Movement script
(see http://www.rmxp.net/forums/index.php?showtopic=24716 for details)
1.01
- fixed bug when teleporting from map without fow to a map with fow
2.0
- now two independent types of fog of war:
* static, which never returns (i.e. typical RTS "terrain" fog)
* dynamic, which returns once out of visual range and can optionally
hide map events (i.e. typical RTS "unit" fog)
- now using a compact version of Near's Dynamic Maps script
- fog of war is now above weather and normal fog
- added support for much larger visual ranges (0 - 9)
- added support for option to set up fog of war from a call script event
command
- optimization

A map specified as having "fog of war" (fow) has tiles that are (fully or
partially) obscured until the player gets within visual range. The amount of
fow to disappear as the player moves depends on the visual range specified.
Gamers with experience playing Real Time Strategy games like Warcraft, Age of
Empires, etc. should be quite familiar with the concept.

This script supports two kinds of fog of war: static and dynamic.

Static fow is the kind that typically hides terrain in RTS games. It covers
the entire map until the player explores the area, discovering the underlying
terrain. Once static fow disappears from an area of the map, it stays gone
indefinitely (even if loading a saved game, leaving the map and returning
later, going to the menu, etc).

Dynamic fow is identical to the static kind except that it doesn't stay gone
forever: as soon as the player leaves visual range of an explored tile,
dynamic fow covers it again. This kind of fow is typically used to hide enemy
units in RTS games.

SETUP:

There's no need to add the autotile via the database. Just place the
file in the autotile folder, import it, and change the FOW_AT_NAME constant
to the appropriate filename. To change the colour of the fog of war you must
create a new autotile. (However, opacity is customizable by constants below.)

To indicate a map is to have either (or both) of these kinds of fog of war,
include <fow> in its name (via "Map properties"). To enable both static and
dynamic fow, you can either add nothing more (since it's the default), or
add <s><d> (or <d><s>). To enable one or the other, just add the appropriate
one (e.g. <s> for static, <d> for dynamic). You may also optionally specify a
visual range between 0 and 9 in the map name (e.g. <5>), noting that 3 is
the default. Here are some example map names:
"your-map-name <fow><2>" (defaults to static&dynamic on; range specified as 2)
"your-map-name <fow><s>" (only static fow is on; range defaults to 3)
"your-map-name <fow><d><8>" (only dynamic fow is on; range specified as 8)

Alternatively, fog of war can be setup via a call script event command using
the fog_of_war global method. Detailed instructions are just before
the method itself.

Finally, an edited version of Near Fantastica's Dynamic Maps script needs
to be below this one. You may find it at the following URL:
http://www.rmxp.net/forums/index.php?showtopic=24716

The ranges work as follows:
range = 0 reveals just the square on which the player stands

range = 1 is the same as range 0 plus four adjacent tiles
i.e. @
@P@
@

range = 2 is the same as range 1 plus eight additional tiles
i.e. @
@@@
@@P@@
@@@
@

range = 3 (default) is the same as range 2 plus twelve additional tiles
i.e. @
@@@
@@@@@
@@@P@@@
@@@@@
@@@
@

etc.

Note: I've taken great pains to optimize this script as much as possible
(which unfortunately reduces the readability of the code). There shouldn't be
much visible effect on frame rate.

=end

#------------------------------------------------------------------------------
# filename of the fog of war autotile (used for both):
FOW_AT_NAME = 'FOG'
# the opacity of static (non-returning) and dynamic (returning) fog of war
# (value between 0 and 255)
# note that static fow appears on top of its dynamic counterpart (if both on)
FOW_STATIC_OPACITY = 255
FOW_DYNAMIC_OPACITY = 100
# whether or not dynamic fow hides map events
FOW_DYNAMIC_HIDES_EVENTS = true
# default range of fog of war (if not specified in map name)
FOW_RANGE_DEFAULT = 3
#------------------------------------------------------------------------------
# internal constants - no need to edit
FOW = 0b00
REVEALED = 0b01
# tiles with no surrounding fog are flagged "SKIP" for efficiency
SKIP = 0b10
#------------------------------------------------------------------------------

=begin
Setup fog of war.

This method is an alternative to using the default map name method, and
is designed to be called from a call script event command. This allows
fog of war to be dynamically enabled or disabled during gameplay.

Parameters:
static - if true, static fow enabled
dynamic - if true, dynamic fow enabled
(if both of the above are false, fow is totally disabled)
range (optional) - the visual range of the player
* default is FOW_RANGE_DEFAULT
reset (optional) - if true, fow for this map resets entirely (i.e. previously
explored areas are covered again)
* default is false

Sample calls:
fog_of_war(true,true,5) - enable both static and dynamic fow with range of 5
fog_of_war(false,false,3,true) - disable and reset both types of fow
=end
def fog_of_war(static, dynamic, range = FOW_RANGE_DEFAULT, reset = false)
if static == nil or dynamic == nil
print 'Two true/false parameters are required in call to fog_of_war.'
exit
elsif range < 0 or range > 9
print 'Invalid range in call to fog_of_war (only 0-9 is valid).'
exit
end
$game_map.fow_static = static
$game_map.fow_dynamic = dynamic
$game_map.fow_range = range
if reset
$game_map.fow_grid = nil
end
if not $game_map.fow_static and not $game_map.fow_dynamic
$game_map.fow = false
$scene.spriteset.fow_tilemap.dispose
# set all events back to visible
for i in $game_map.events.keys
$game_map.events[i].transparent = false
end
else
# static or dynamic fow (or both) are on
$game_map.fow = true
if $game_map.fow_grid == nil # only if not already defined
$game_map.fow_grid = Table.new($game_map.width, $game_map.height, 2)
for i in 0...$game_map.fow_grid.xsize
for j in 0...$game_map.fow_grid.ysize
$game_map.fow_grid[i,j,1] = $game_map.fow_grid[i,j,0] = FOW
end
end
end
if $game_map.fow_dynamic
$game_map.fow_revealed = $game_map.fow_last_revealed = []
end
$scene.spriteset.initialize_fow
end
end

class Game_Map
attr_accessor :fow
attr_accessor :fow_static
attr_accessor :fow_dynamic
attr_accessor :fow_grid
attr_accessor :fow_range
attr_accessor :fow_revealed
attr_accessor :fow_last_revealed

alias wachunga_fow_gm_setup setup
def setup(map_id)
wachunga_fow_gm_setup(map_id)
@fow = false
@fow_dynamic = false
@fow_static = false
@fow_grid = nil
@fow_range = nil
# get any tags from the map name
tags = $game_map.map_name.delete(' ').scan(/<[A-Za-z0-9_.,]+>/)
if not tags.empty? and tags[0].upcase == ('<FOW>')
tags.shift # remove FOW tag
@fow = true
if @fow_grid == nil # only if not already defined
@fow_grid = Table.new(@map.width, @map.height, 2)
for i in 0...@fow_grid.xsize
for j in 0...@fow_grid.ysize
@fow_grid[i,j,1] = @fow_grid[i,j,0] = FOW
end
end
end
# check if types of fog of war specified
while not tags.empty?
case tags[0].upcase
when '<S>'
@fow_static = true
when '<D>'
@fow_dynamic = true
else
x = tags[0].delete('<>').to_i
@fow_range = x if x >= 0 and x <= 9
end
tags.shift
end
# if <FOW> tag found but neither static nor dynamic specified, assume both
if @fow and not @fow_static and not @fow_dynamic
@fow_static = true
@fow_dynamic = true
end
# if no range specified, set to default
if @fow_range == nil
@fow_range = FOW_RANGE_DEFAULT
end
@fow_revealed = @fow_last_revealed = [] if @fow_dynamic
end
end

def map_name
return load_data('Data/MapInfos.rxdata')[@map_id].name
end

=begin
Updates the map's grid which keeps track of one or both of the following
(depending on what is enabled for the current map):
1) which tiles have been "discovered" (i.e. no static fog of war) based on
where the player has already explored
2) which tiles are currently not covered by dynamic fog of war (i.e. not in
visual range)
=end
def update_fow_grid
px = $game_player.x
py = $game_player.y
x = px - @fow_range
start_y = py
y = start_y
count = 1
mod = 1
# loop through all tiles in visible range
until x == (px + @fow_range+1)
i = count
while i > 0
if valid?(x,y)
if @fow_static
@fow_grid[x,y,1] |= REVEALED
end
if @fow_dynamic
@fow_grid[x,y,0] = REVEALED if @fow_grid[x,y,0] == FOW
@fow_revealed.push([x,y])
end
end
y -= 1
i -= 1
end
if x == px
mod = -1
end
x += 1
start_y += 1*mod
y = start_y
count += 2*mod
end
if @fow_dynamic
if @fow_last_revealed != []
# make dynamic fog return once out of visual range
for t in @fow_last_revealed - @fow_revealed
@fow_grid[t[0],t[1],0] = FOW
end
end
@fow_last_revealed = @fow_revealed
@fow_revealed = []
end
end

end

#------------------------------------------------------------------------------

class Spriteset_Map

attr_reader :fow_tilemap

alias wachunga_fow_ssm_initialize initialize
def initialize
initialize_fow if $game_map.fow
wachunga_fow_ssm_initialize
end

=begin
Initializes fog of war.
=end
def initialize_fow
@fow_tilemap = Tilemap.new
@fow_tilemap.map_data = Table.new($game_map.width, $game_map.height, 3)
@fow_tilemap.priorities = Table.new(144)
@fow_autotiles = Hash.new(0)
j = 48 # starting autotile index
for i in Autotile_Keys
@fow_autotiles[i] = j
j += 1
end
# add duplicates
for i in Duplicate_Keys.keys
@fow_autotiles[i] = @fow_autotiles[Duplicate_Keys[i]]
end
if $game_map.fow_static
for m in 0...$game_map.fow_grid.xsize
for n in 0...$game_map.fow_grid.ysize
# reset SKIP flag
$game_map.fow_grid[m,n,1] &= ~SKIP
end
end
at = Bitmap.new(96,128)
at.blt(0,0,RPG::Cache.autotile(FOW_AT_NAME),\
Rect.new(0,0,96,128),FOW_STATIC_OPACITY)
@fow_tilemap.autotiles[0] = at
# set everything to fog
for x in 0...$game_map.width
for y in 0...$game_map.height
@fow_tilemap.map_data[x,y,2] = 48 # fog
end
end
# set to highest priority
for i in 48...96
@fow_tilemap.priorities[i] = 5
end
end
if $game_map.fow_dynamic
bm = Bitmap.new(96,128)
bm.blt(0,0,RPG::Cache.autotile(FOW_AT_NAME),\
Rect.new(0,0,96,128),FOW_DYNAMIC_OPACITY)
@fow_tilemap.autotiles[1] = bm
# unlike tilemap for static, set everything to clear
for x in 0...$game_map.width
for y in 0...$game_map.height
@fow_tilemap.map_data[x,y,1] = 0
end
end
# set to highest priority
for i in 96...144
@fow_tilemap.priorities[i] = 5
end
end
$game_map.update_fow_grid
update_fow_tilemap
update_event_transparency if $game_map.fow_dynamic
end


=begin
Updates the (static and/or dynamic) fog of war tilemap based on the map's
underlying grid.
=end
def update_fow_tilemap
if $game_map.fow_static
checked = Table.new($game_map.width,$game_map.height)
for j in 0...$game_map.width
for k in 0...$game_map.height
checked[j,k] = 0
end
end
end
dx = ($game_map.display_x/128).round
dy = ($game_map.display_y/128).round
# to increase performance, only process fow currently on the screen
for x in dx-1 .. dx+21
for y in dy-1 .. dy+16
# check boundaries
if not $game_map.valid?(x,y) then next end
if $game_map.fow_dynamic
if $game_map.fow_grid[x,y,0] == REVEALED
@fow_tilemap.map_data[x,y,1] = 0 if @fow_tilemap.map_data[x,y,1]!=0
else
@fow_tilemap.map_data[x,y,1]=96 if @fow_tilemap.map_data[x,y,1]!=96
end
end
if $game_map.fow_static
if $game_map.fow_grid[x,y,1] == REVEALED # (but not SKIP)
others = false;
@fow_tilemap.map_data[x,y,2] = 0 if @fow_tilemap.map_data[x,y,2]!=0
for i in x-1 .. x+1
for j in y-1 .. y+1
# check new boundaries
if not $game_map.valid?(i,j) then next end
if $game_map.fow_grid[i,j,1] == FOW
others = true # can't flag as SKIP because there's nearby fog
if checked[i,j] == 0
checked[i,j] = 1
# only fill if not already revealed
if @fow_tilemap.map_data[i,j,2] != 0
adj = check_adjacent(i,j,1,$game_map.fow_grid,REVEALED)
if adj != nil
@fow_tilemap.map_data[i,j,2] =
eval '@fow_autotiles[adj.to_i]'
end
end
end
end
end
end
if not others
# no adjacent static fog found, so flag tile to avoid reprocessing
$game_map.fow_grid[x,y,1] |= SKIP
end
end
end # fow_static
end # for
end # for
if $game_map.fow_dynamic
if $game_map.fow_static
for x in dx-1 .. dx+21
for y in dy-1 .. dy+16
# erase dynamic fow if static fow is above it anyway
if @fow_tilemap.map_data[x,y,2] == 48
@fow_tilemap.map_data[x,y,1]=0 if @fow_tilemap.map_data[x,y,1]!=0
end
end
end
end
# calculate autotiles for dynamic fow (around player)
px = $game_player.x
py = $game_player.y
tiles = []
x = px - ($game_map.fow_range+1)
y_top = py
mod_top = -1
y_bot = py
mod_bot = 1
until x == px + ($game_map.fow_range+2)
tiles.push([x,y_top]) if $game_map.valid?(x,y_top)
tiles.push([x,y_bot]) if $game_map.valid?(x,y_bot)
if x == px
mod_top = 1
mod_bot = -1
x+=1
next
end
y_top+=1*mod_top
y_bot+=1*mod_bot
tiles.push([x,y_top]) if $game_map.valid?(x,y_top)
tiles.push([x,y_bot]) if $game_map.valid?(x,y_bot)
x+=1
end
tiles.uniq.each do |t|
adj = check_adjacent(t[0],t[1],0,$game_map.fow_grid,REVEALED)
if adj != nil
@fow_tilemap.map_data[t[0],t[1],1] =
(eval '@fow_autotiles[adj.to_i]') + 48
end
end
end
end

=begin
Update event transparency based on dynamic fog.

Note that if a specific character is passed as a parameter then only
its transparency is updated; otherwise, all events are processed.
=end
def update_event_transparency(pChar = nil)
return if not FOW_DYNAMIC_HIDES_EVENTS
if pChar == nil
# check them all
for i in $game_map.events.keys
event = $game_map.events[i]
if $game_map.fow_grid[event.x,event.y,0] == FOW
event.transparent = true
else
event.transparent = false
end
end
else
# just check the one
pChar.transparent=($game_map.fow_grid[pChar.x,pChar.y,0]==FOW) ?true:false
end
end

# create a list of tiles adjacent to a specific tile that don't match a flag
# (used for calculating tiles within an autotile)
def check_adjacent(i,j,k,grid,flag)
return if not $game_map.valid?(i,j) or grid == nil or flag == nil
adj = ''
if (i == 0)
adj << '147'
else
if (j == 0) then adj << '1'
else
if (grid[i-1,j-1,k] != flag) then adj << '1' end
end
if (grid[i-1,j,k] != flag) then adj << '4' end
if (j == $game_map.height-1) then adj << '7'
else
if (grid[i-1,j+1,k] != flag) then adj << '7' end
end
end
if (i == $game_map.width-1)
adj << '369'
else
if (j == 0) then adj << '3'
else
if (grid[i+1,j-1,k] != flag) then adj << '3' end
end
if (grid[i+1,j,k] != flag) then adj << '6' end
if (j == $game_map.height-1) then adj << '9'
else
if (grid[i+1,j+1,k] != flag) then adj << '9' end
end
end
if (j == 0)
adj << '2'
else
if (grid[i,j-1,k] != flag) then adj << '2' end
end
if (j == $game_map.height-1)
adj << '8'
else
if (grid[i,j+1,k] != flag) then adj << '8' end
end
# if no adjacent fog, set it as 0
if (adj == '') then adj = '0' end
# convert to an array, sort, and then back to a string
return adj.split(//).sort.join
end

alias wachunga_fow_ssm_dispose dispose
def dispose
@fow_tilemap.dispose if @fow_tilemap != nil
wachunga_fow_ssm_dispose
end

alias wachunga_fow_ssm_update update
def update
if $game_map.fow
@fow_tilemap.ox = $game_map.display_x / 4
@fow_tilemap.oy = $game_map.display_y / 4
@fow_tilemap.update
end
wachunga_fow_ssm_update
end
end

#------------------------------------------------------------------------------

class Game_Character
alias wachunga_fow_gch_initialize initialize
def initialize
wachunga_fow_gch_initialize
@last_x = @x
@last_y = @y
end

alias wachunga_fow_gch_update_move update_move
def update_move
wachunga_fow_gch_update_move
if $game_map.fow
if $game_map.fow_dynamic and (@x != @last_x or @y != @last_y)\
and self != $game_player
# check if character entered/left player's visual range
$scene.spriteset.update_event_transparency(self)
end
end
@last_x = @x
@last_y = @y
end
end

#------------------------------------------------------------------------------

class Game_Player

def update_jump
super
# only update when about to land, not revealing anything jumped over
if $game_map.fow and @jump_count == 0
$game_map.update_fow_grid
$scene.spriteset.update_event_transparency if $game_map.fow_dynamic
$scene.spriteset.update_fow_tilemap
end
end

def update_move
if $game_map.fow and (@x != @last_x or @y != @last_y)
unless jumping?
$game_map.update_fow_grid
$scene.spriteset.update_event_transparency if $game_map.fow_dynamic
$scene.spriteset.update_fow_tilemap
end
end
super
end

end

#------------------------------------------------------------------------------

class Scene_Map
attr_reader :spriteset
end

=begin
Autotile in column 2:

row\col| 1 2 3 4 5 6 7 8
---------------------------
1 | 48 49 50 51 52 53 54 55
2 | 56 57 58 59 60 61 62 63
3 | 64 65 66 67 68 69 70 71
4 | 72 73 74 75 76 77 78 79
5 | 80 81 82 83 84 85 86 87
6 | 88 89 90 91 92 93 94 95

The function to return the index of a single tile within an autotile
(given by at_index) is (at_index-1)*48 + col-1 + (row-1)*8
(where row, col, and at_index are again NOT zero-indexed)
=end

=begin
The following array lists systematic keys which are based on adjacent
walls (where 'W' is the wall itself):
1 2 3
4 W 6
7 8 9
e.g. 268 is the key that will be used to refer to the autotile
which has adjacent walls north, east, and south. For the Castle Prison
tileset (autotile #1), this is 67.

(It's a bit unwieldy, but it works.)
=end

Autotile_Keys = [
12346789,
2346789,
1246789,
246789,
1234678,
234678,
124678,
24678,

1234689,
234689,
124689,
24689,
123468,
23468,
12468,
2468,

23689,
2689,
2368,
268,
46789,
4678,
4689,
468,

12478,
1248,
2478,
248,
12346,
2346,
1246,
246,

28,
46,
689,
68,
478,
48,
124,
24,

236,
26,
8,
6,
2,
4,
0 ]

# many autotiles handle multiple situations
# this hash keeps track of which keys are identical
# to ones already defined above
Duplicate_Keys = {
123689 => 23689,
236789 => 23689,
1236789 => 23689,
34689 => 4689,
14689 => 4689,
134689 => 4689,
14678 => 4678,
34678 => 4678,
134678 => 4678,
146789 => 46789,
346789 => 46789,
1346789 => 46789,
23467 => 2346,
23469 => 2346,
234679 => 2346,
123467 => 12346,
123469 => 12346,
1234679 => 12346,
12467 => 1246,
12469 => 1246,
124679 => 1246,
124789 => 12478,
123478 => 12478,
1234789 => 12478,
146 => 46,
346 => 46,
467 => 46,
469 => 46,
1346 => 46,
1467 => 46,
1469 => 46,
3467 => 46,
3469 => 46,
4679 => 46,
13467 => 46,
13469 => 46,
14679 => 46,
34679 => 46,
134679 => 46,
128 => 28,
238 => 28,
278 => 28,
289 => 28,
1238 => 28,
1278 => 28,
1289 => 28,
2378 => 28,
2389 => 28,
2789 => 28,
12378 => 28,
12389 => 28,
12789 => 28,
23789 => 28,
123789 => 28,

1247 => 124,
2369 => 236,
147 => 4,
247 => 24,
14 => 4,
47 => 4,
1478 => 478,
3478 => 478,
4789 => 478,
134789 => 478,
14789 => 478,
13478 => 478,
34789 => 478,
1234 => 124,
1247 => 124,
1249 => 124,
12347 => 124,
12349 => 124,
12479 => 124,
123479 => 124,
1236 => 236,
2367 => 236,
2369 => 236,
12367 => 236,
12369 => 236,
23679 => 236,
123679 => 236,
12368 => 2368,
23678 => 2368,
123678 => 2368,
12348 => 1248,
12489 => 1248,
123489 => 1248,
1689 => 689,
3689 => 689,
6789 => 689,
13689 => 689,
16789 => 689,
36789 => 689,
136789 => 689,
12689 => 2689,
26789 => 2689,
126789 => 2689,
23478 => 2478,
24789 => 2478,
234789 => 2478,

12 => 2,
23 => 2,
27 => 2,
29 => 2,
123 => 2,
127 => 2,
129 => 2,
237 => 2,
239 => 2,
279 => 2,
1237 => 2,
1239 => 2,
1279 => 2,
2379 => 2,
12379 => 2,


14 => 4,
47 => 4,
34 => 4,
49 => 4,
147 => 4,
134 => 4,
347 => 4,
349 => 4,
149 => 4,
479 => 4,
1347 => 4,
1479 => 4,
1349 => 4,
3479 => 4,
13479 => 4,

16 => 6,
36 => 6,
67 => 6,
69 => 6,
136 => 6,
167 => 6,
169 => 6,
367 => 6,
369 => 6,
679 => 6,
1369 => 6,
3679 => 6,
1367 => 6,
1679 => 6,
13679 => 6,

78 => 8,
89 => 8,
18 => 8,
38 => 8,
138 => 8,
789 => 8,
178 => 8,
189 => 8,
378 => 8,
389 => 8,
1789 => 8,
3789 => 8,
1378 => 8,
1389 => 8,
13789 => 8,

1468 => 468,
3468 => 468,
13468 => 468,

2467 => 246,
2469 => 246,
24679 => 246,

2348 => 248,
2489 => 248,
23489 => 248,

1268 => 268,
2678 => 268,
12678 => 268,

148 => 48,
348 => 48,
489 => 48,
1348 => 48,
1489 => 48,
3489 => 48,
13489 => 48,

168 => 68,
368 => 68,
678 => 68,
1368 => 68,
1678 => 68,
3678 => 68,
13678 => 68,

234 => 24,
247 => 24,
249 => 24,
2347 => 24,
2349 => 24,
2479 => 24,
23479 => 24,

126 => 26,
267 => 26,
269 => 26,
1267 => 26,
1269 => 26,
2679 => 26,
12679 => 26,
}


#================================
# ? Dynamic Maps
#================================
# ?By: Near Fantastica
# Date: 05.09.05
# Version: 1
#================================

# updated 2005-11-07 by Wachunga
# generalized to work for modified versions of Game_Map,
# e.g. even if more instance variables are added

module Map
#--------------------------------------------------------------
@map_data = {}
#--------------------------------------------------------------------------
def Map.set_map(map, map_id)
@map_data[map_id] = map
end
#--------------------------------------------------------------------------
def Map.data(map_id)
return @map_data[map_id]
end
end

class Game_Map
#--------------------------------------------------------------
alias dm_orig_setup setup
def setup(map_id)
save_map(@map_id)
if Map.data(map_id) == nil
dm_orig_setup(map_id)
else
load_map(map_id)
end
end
#-----------------------------------------------------------
def load_map(map_id)
$game_map = Map.data(map_id)
end
#--------------------------------------------------------------
def save_map(map_id)
return if map_id == 0
Map.set_map(self.dup, map_id)
end
end
4
RPG Maker Scripts / Permadeath?
August 28, 2008, 01:53:13 pm
Is it possible to make permadeath? That is, when the player dies the savefile he uses gets deleted and he is forced to make a new character.
5
General Discussion / Porting RMXP games to consoles?
August 28, 2008, 06:19:48 am
Is it possible to port games made in RMXP to consoles by using scripts or by editing something else?
6
I'm not sure if anyone here is playing around with RM2K3 but this is the only forum I know off with people that actually knows what they are talking about so I figured I would try asking.
I've been experimenting with RM2K3 for a while and I actually found it to be a bit easier then RMXP.
Anyway, this is the bit I'm having trouble with. I'm experimenting with a custom inventory system by using a map, there are 40 invisible events on that map, and as the player pick things up they check to see if the player has an item in the inventory, if he does one of them changes charset to match that item, when the player moves over the item in the inventory map he can choose to equip, discard or read about the item. However I've only managed to get it to work with 1 item, I'm not sure how to make the conditional branches and all the variables so they check if an inventory slot is taken so the item ends up next to it.
7
Resources / Rymdpotatis Roguelike graphics.
August 20, 2008, 05:26:53 am
I've recently been experimenting with making my roguelike with other engines then RMXP. RM2K3 seemed more then capable of producing adequate results. Although I would have to skip some features if I where to use it. I even tried learning C# that was very hard but quite alot of fun actually. Anyway, I drew up a couple of 16*16 sprites so I could test things out. I don't know if they are any good or if anyone would want them. But I'll upload  a small showcase with them anyway. If nothing else, it's nice to see what people think. If it turns out that someone likes them and would want more I would be happy to share them.

8
I got my hands on a japanese dungeon generating script for RMVX that generates dungeons each time you enter a map instead of having a static and boring dungeon. However there are some bugs in it, like the stairs or the player ending up in walls etc.  I will post it incase someone wants to tinker with it and use it for them selves. I'm using it myself and it's quite nice. Hope you enjoy my find.^^

Original link is http://racanhack.sourceforge.jp/rhdoc/index.html

#-------------------------------------------------------------------------------
# ??????????????

# roguelike??????????????????????Game_Map????
# ??????
# ????????????????
# ??????????????????????????????
# ?????????????????????????????????????
#
# ?????????
#   Racanhack ????? [ http://racanhack.sourceforge.jp/rhdoc/index.html ]
#     ????????????????????

# ????
# ???ROGUELIKE_MAP_ID???????ID??? or
# ????????????????$game_map.make_dungeon?????
#
#----------------------------------------------------------------------------
# ??
#----------------------------------------------------------------------------
module ROGUELIKE_MAP
  # ?????????ID???
  # ?.???ID003?005???????? ? ROGUELIKE_MAP_ID = [3,5]
  ROGUELIKE_MAP_ID = []
  # VX????ID????????????????????
  # ????????ID
  SPACE_TILE_ID = 5888
  # ?????ID
  FLOOR_TILE_ID = 1552
  # ?????ID
  WALL_TILE_ID = 6280
  # ???????????(??????64, 1/????????????)
  # ??????????????????????1????
  # ??????????????????????????(nil???)
  BIG_ROOM = 64
  BIG_ROOM_SWITCH = nil
  # ??????????(??????96, 1/????????)
  ADD_COUPLE = 96
  # ?????????
  MIN_ROOM_SIZE = 2
  # ????????(3??????????????)
  MIN_BTWN_RECT_ROOM = 3
  # ?????????(??????2 + 3 * 2 = 8)
  MIN_RECT_SIZE = MIN_ROOM_SIZE + (MIN_BTWN_RECT_ROOM * 2)
  #--------------------------------------------------------------------------
  R_VERTICAL = 0
  R_HORIZONAL = 1
  # ?????????
  # min??max??????int??????
  def rand_range(min, max)
    return((min + rand(max - min)).round)
  end
#-------------------------------------------------------------------------------
  #R_Couple??? ????????
  class R_Couple
    attr_accessor :v_or_h
    attr_accessor :rect0
    attr_accessor :rect1
    def initialize(v_or_h, rect0, rect1)
      @v_or_h = v_or_h
      @rect0 = rect0
      @rect1 = rect1
    end
  end
  #R_Room??? ????????
  class R_Room
    attr_accessor :lx
    attr_accessor :ly
    attr_accessor :hx
    attr_accessor :hy
    def initialize(lx, ly, hx, hy)
      @lx = lx
      @ly = ly
      @hx = hx
      @hy = hy
    end
  end
  #R_Rect??? ????????
  class R_Rect < R_Room
    attr_accessor :done_v
    attr_accessor :done_h
    attr_accessor :room
    def initialize(lx, ly, hx, hy, done_v = false, done_h = false, room = nil)
      super(lx, ly, hx, hy)
      @done_v = done_v
      @done_h = done_h
      @room = room
    end
  end
end
#-------------------------------------------------------------------------------
# ? Game_Map
#-------------------------------------------------------------------------------
# ??????????????????????????????????????
# ????????????? $game_map ????????
#-------------------------------------------------------------------------------
class Game_Map
  include ROGUELIKE_MAP
  #--------------------------------------------------------------------------
  # ? ??????
  #     map_id : ??? ID
  #--------------------------------------------------------------------------
  alias randmap_setup setup
  def setup(map_id)
    #????
    randmap_setup(map_id)
    #???ID?????????ID?????????????????
    make_dungeon if(ROGUELIKE_MAP_ID.include?(map_id))
  end
  #--------------------------------------------------------------------------
  # ? ??????????????????
  #    ???????$game_map.make_dungeon??????setup???????
  #--------------------------------------------------------------------------
  def make_dungeon
    @rect_list = []   # ?????
    @room_list = []   # ?????
    @couple_list = [] # ??????
    # ???????????????????
    for i in 0...@map.width
      for j in 0...@map.height
        @map.data[i,j,0] = SPACE_TILE_ID
      end
    end
    # ?????(split_rect????????????)
    split_rect(add_rect(0,0,@map.width - 1, @map.height - 1), true)
    # ?????
    make_room
    # ???????
    for n in 0...@room_list.size
      for i in @room_list[n].lx..@room_list[n].hx
        for j in @room_list[n].ly..@room_list[n].hy
          @map.data[i,j,0] = FLOOR_TILE_ID
        end
      end
    end
    # ????????????????????
    rect_map = Array.new(@map.width)
    for i in 0...rect_map.size
      rect_map[i] = Array.new(@map.height)
    end
    for i in 0...@rect_list.size
      for j in @rect_list[i].lx..@rect_list[i].hx
        for k in @rect_list[i].ly..@rect_list[i].hy
          rect_map[j][k] = @rect_list[i]
        end
      end
    end
    for i in 0...(@map.width - 1)
      for j in 0...(@map.height - 1)
        break unless(rect_map[i][j] != nil)
        break unless(rect_map[i + 1][j] != nil)
        break unless(rect_map[i][j + 1] != nil)
        if(rect_map[i][j] != rect_map[i][j + 1])
          add_couple(R_VERTICAL, rect_map[i][j], rect_map[i][j + 1]) if (rand(ADD_COUPLE) == 0)
        end
        if(rect_map[i][j] != rect_map[i + 1][j])
          add_couple(R_HORIZONAL, rect_map[i][j], rect_map[i + 1][j]) if (rand(ADD_COUPLE) == 0)
        end
      end
    end
    # ????????????????
    for i in 0...@couple_list.size
      # ???????????
      if(@couple_list[i].v_or_h == R_HORIZONAL)
        break unless(@couple_list[i].rect0.hx == @couple_list[i].rect1.lx)
        c0x = @couple_list[i].rect0.hx
        c0y = rand_range(@couple_list[i].rect0.room.ly + 1,
                @couple_list[i].rect0.room.hy)
        c1x = @couple_list[i].rect1.lx
        c1y = rand_range(@couple_list[i].rect1.room.ly + 1,
                @couple_list[i].rect1.room.hy)
        make_line(c0x, c0y, c1x, c1y)
        make_line(@couple_list[i].rect0.room.hx, c0y, c0x, c0y)
        make_line(@couple_list[i].rect1.room.lx, c1y, c1x, c1y)
      # ???????????
      elsif(@couple_list[i].v_or_h == R_VERTICAL)
        break unless(@couple_list[i].rect0.hy == @couple_list[i].rect1.ly)
        c0x = rand_range(@couple_list[i].rect0.room.lx + 1,
                @couple_list[i].rect0.room.hx)
        c0y = @couple_list[i].rect0.hy
        c1x = rand_range(@couple_list[i].rect1.room.lx + 1,
                @couple_list[i].rect1.room.hx)
        c1y = @couple_list[i].rect1.ly
        make_line(c0x, c0y, c1x, c1y)
        make_line(c0x, @couple_list[i].rect0.room.hy, c0x, c0y)
        make_line(c1x, @couple_list[i].rect1.room.ly, c1x, c1y)
      end
    end
    # ???(????????????????????????????????)
    for i in 0...@map.width
      for j in 1...@map.height
        if(@map.data[i, j, 0] == FLOOR_TILE_ID &&
          @map.data[i, j - 1, 0] == SPACE_TILE_ID)
          @map.data[i, j - 1, 0] = WALL_TILE_ID
        end
      end
    end
    # ??
  end
  # ????????????????????
  def add_rect(lx, ly, hx, hy)
    @rect_list.push(R_Rect.new(lx, ly, hx, hy))
    return(@rect_list.last)
  end
  # ???????????(??)
  def split_rect(rect_par, flag = false)
    # ?????????????????????????????????
    if(rect_par.hx - rect_par.lx <= MIN_RECT_SIZE * 2)
rect_par.done_v = true
end
if(rect_par.hy - rect_par.ly <= MIN_RECT_SIZE * 2)
rect_par.done_h = true
end
    # ?????????(?????????????????)
    if (rand(BIG_ROOM) == 0 && flag == true)
      rect_par.done_v = true
      rect_par.done_h = true
    end
    # ????????????????
if((rect_par.done_v == true) && (rect_par.done_h == true))
return
end
    # ?????
    rect_child = add_rect(rect_par.lx, rect_par.ly, rect_par.hx, rect_par.hy)
    # ?????????????
if(rect_par.done_v == false)
split_coord_y = rand_range(rect_par.ly + MIN_RECT_SIZE,
                        rect_par.hy - MIN_RECT_SIZE)
rect_par.hy = split_coord_y;
rect_child.ly = split_coord_y;
      # ???????
rect_par.done_v = true
rect_child.done_v = true
      # ???????
      add_couple(R_VERTICAL, rect_par, rect_child);
      # ??
split_rect(rect_par)
split_rect(rect_child)
return
end
    # ?????????????
if(rect_par.done_h == false)
split_coord_x = rand_range(rect_par.lx + MIN_RECT_SIZE,
                        rect_par.hx - MIN_RECT_SIZE)
rect_par.hx = split_coord_x;
rect_child.lx = split_coord_x;
      # ???????
rect_par.done_h = true
rect_child.done_h = true
      # ???????
      add_couple(R_HORIZONAL, rect_par, rect_child);
      # ??
split_rect(rect_par)
split_rect(rect_child)
return
end
  end
  # ????????????????????
  def add_room(lx, ly, hx, hy)
    @room_list.push(R_Room.new(lx, ly, hx, hy))
    return(@room_list.last)
  end
  # ???????????
  def make_room()
    for i in 0...@rect_list.size
      #?????????X
w = rand_range(MIN_ROOM_SIZE,
            (@rect_list[i].hx - @rect_list[i].lx - (MIN_BTWN_RECT_ROOM * 2) + 1))
      #?????????Y
h = rand_range(MIN_ROOM_SIZE,
            (@rect_list[i].hy - @rect_list[i].ly - (MIN_BTWN_RECT_ROOM * 2) + 1))
      #?????
x = rand_range(@rect_list[i].lx + MIN_BTWN_RECT_ROOM,
            @rect_list[i].hx - MIN_BTWN_RECT_ROOM - w + 1)
      #?????
y = rand_range(@rect_list[i].ly + MIN_BTWN_RECT_ROOM,
            @rect_list[i].hy - MIN_BTWN_RECT_ROOM - h + 1)
      #?????????????
@rect_list[i].room = add_room(x, y, x + w, y + h)
end
  end
  #--------------------------------------------------------------------------
  # ? split_rect?????????????????????????
  #    ??split_rect???????????????
  #     v_or_h : ????????
  #     rect0  : ??1
  #     rect1  : ??2
  #--------------------------------------------------------------------------
  def add_couple(v_or_h, rect0, rect1)
    @couple_list.push(R_Couple.new(v_or_h, rect0, rect1))
    return(@couple_list.last)
  end
  #--------------------------------------------------------------------------
  # ? ??????????????????????
  #     x0     : ?1?X??
  #     y0     : ?1?Y??
  #     x1     : ?2?X??
  #     y1     : ?2?Y??
  #--------------------------------------------------------------------------
  def make_line(x0, y0, x1, y1)
    min_x = [x0, x1].min
    max_x = [x0, x1].max
    min_y = [y0, y1].min
    max_y = [y0, y1].max
    unless((min_x >= 0) && (max_x < @map.width) &&
      (min_y >= 0) && (max_y < @map.height))
      return
    end
    if((x0 <= x1) && (y0 >= y1))
      for i in min_x..max_x
        @map.data[i, max_y, 0] = FLOOR_TILE_ID
      end
      for j in min_y..max_y
        @map.data[max_x, j, 0] = FLOOR_TILE_ID
      end
      return
    end
    if((x0 > x1) && (y0 > y1))
      for i in min_x..max_x
        @map.data[i, min_y, 0] = FLOOR_TILE_ID
      end
      for j in min_y..max_y
        @map.data[max_x, j, 0] = FLOOR_TILE_ID
      end
      return
    end
    if((x0 > x1) && (y0 <= y1))
      for i in min_x..max_x
        @map.data[i, min_y, 0] = FLOOR_TILE_ID
      end
      for j in min_y..max_y
        @map.data[min_x, j, 0] = FLOOR_TILE_ID
      end
      return
    end
    if((x0 <= x1) && (y0 < y1))
      for i in min_x..max_x
        @map.data[i, max_y, 0] = FLOOR_TILE_ID
      end
      for j in min_y..max_y
        @map.data[min_x, j, 0] = FLOOR_TILE_ID
      end
      return
    end
  end
end
#-------------------------------------------------------------------------------
# ? Game_Interpreter
#-------------------------------------------------------------------------------
# ????????????????????????????? Game_Map ????
# Game_Troop ????Game_Event ??????????????
#-------------------------------------------------------------------------------
class Game_Interpreter
  #--------------------------------------------------------------------------
  # ? ???????
  #    $game_map.make_dungeon??????????
  #--------------------------------------------------------------------------
  def make_dungeon
    $game_map.make_dungeon
  end
end
9
http://www.kamain.com/tutorials.php?subaction=showfull&id=1175305235&archive=&start_from=&ucat=6&;

QuoteIf you're making a forest that randomizes and you have a tree character sprite, you're set.

Requires

2 maps. (One for the entry to the forest and the other for the forest.)
Number of trees you want in your forest times 2 = the variables you need. (In other words, 2n.)

Let's start off very simple...three trees.

Make 6 variables.

Tree 1x
Tree 1y
Tree 2x
Tree 2y
Tree 3x
Tree 3y

Don't do anything to those variables and I mean anything!

Next, make some sort of an entry to the forest.
When the player is about to teleport to the forest, do this.

Go to each variable and make it randomize by the numbers you want.

Next, go to the forest map.

Make an event.
Make the event a tree charset.
Make the event parallel process
Then next, find the command called change event location, click it.
Then make the event teleport through variables
Make Tree 1x, the X and tree 1y, the Y.

Make another event, do the same thing
Tree 2x, the X, Tree 2y, the Y.

Make another, same process, different variables.



That didn't make much sense to me since I could not come up with how to make those variables.
Perhaps someone with more experience could take a look at this and explain it in a way a dumb person like me could understand? :^_^':
10
Question 1: I noticed that the exp meter and the gold counter that was in version 1.98 is gone and I was wondering if it's possible to get it back, and if it is I'd like to know how^^

Question 2: I also read through the Configuration Document I found something about corpses whitch I would like to know more about it and how it works.
11
New Projects / Dungeon of Destiny.
August 06, 2008, 04:42:37 am
I've been working on a game for around two months called Dungeon of Destiny. It's basically a roguelike.
http://en.wikipedia.org/wiki/Roguelike (For those that are not familiar with roguelikes)

The general idea of the game is that you are an adventurer who've heard of a town with an interesting quest, you ventured there, get a briefing at the Adventurer's Guildhall by the headmaster. Armed with this information you undertake the quest of ridding the temple of the demon that has built it's nest in it. That nest is a 100 floor dungeon. Divided into 4 areas with 25 dungeons each. The first theme is crypts, then caves, then another variety of the cave, and then Hell. Since I can't get a hold of a script that randomly generates a dungeon I plan on having 4 varieties of each floor that is randomly selected as the player enters.


Early image of a crypt dungeon.

When you begin the game you get to choose your gender and your class whitch consists of male, female. Warrior and Wizard. When you decide upon a class you get to select your appearance, this I plan on having around 10 different clothings for both wizards and warriors. A thing I also plan on adding is sidequests that you can pick up at the guildhall. Different job requests that the villagers have left. A few examples:
A goblin that inhabits dungeon floor 23 has stolen my bag of apples, please retrieve them.
My cat has ran down the dungeon, he should be around dungeon floor 5, please save him.
Now these, like the dungeon floors would be randomly listed at the guild by an event.


What I have done so far:
Character creation system is up and running, graphics are not quite done yet.
1 Dungeon floor, need to put out decorations.
Basic structure of the town.

12
Event Systems / Strange door problem. [RESOLVED]
August 05, 2008, 04:17:27 pm
For some strange reason my doors won't work correctly.

This is the door sprite I'm using for when the door is closed, it works fine:


This is the sprite I want for when the door is open:


This is the problem: It skips the sprite I choose and jumps to this sprite instead:



This is the event I used for the door:
@>Set move route:This event
                         :$>Graphic:"Name', 0,4,1


I'm not that experienced with making actual doors. I've mostly made none animated teleporters.





Figured it out on my own, yay me. -_-

13

I find it very hard to make sheets and was hoping some kindhearted person could help me create a character sheet of these doorsprites.



Click here to get the image:
http://i308.photobucket.com/albums/kk355/Zambaku/doorsheet.png
14
Tutorial Requests / Larger item icons?
August 04, 2008, 01:37:03 pm
I didn't see any thread about how enlarge the item icons so I'll make one.

I was wondering how you make the item icons 32*32 in size.
15
I'm having trouble making character sets out of these sprites and I was wondering if perhaps there is a tool that can handle that process, or atleast make it easier. Or perhaps someone knows of some template that can be used as a guideline?

16
Event Systems / Event problem.
August 03, 2008, 10:27:39 am
I've made an even so that when the player dies he gets teleported to a bed at a guild, and loses one level. The problem is that when the player wakes up in the bed a person will stand next to him and say a small dialog, this does not happen.

This is my event for the custom death:
@>Conditional Branch[Player] is [Knockout] inflicted
@>Change state:Entire Party, -[Knockout]
@>Change screen tone: (-255,-255,-255, @1
@>Wait: 1 frame(s)
@>Change level:entire party -1
@>Recover all: Entire party
@>Transfer player[location]
@>Control switches: [0005:Defeated] = ON
@>
@> Branch End


And this is my event for the bed:
First page is blank with no graphics since I don't want the person to appear when I haven't died.

Second page.
Conditions: Switch 0005:Defeated is ON.

And the event commands:
@>Conditional branch:Switch [0005:Defeated] ==ON
Set Move Route:This event
:                   :$>Graphic: "025-Cleric01',0,6,0
@>Text: (yadayada)
@>Text: (yadayada)
@>Erase event.
Branch End.
17
Event System Requests / [RESOLVED] Random jobs?
July 20, 2008, 11:33:09 am
Is it possible to make a script, or a set of events that would allow random quests?
Like: There is an adventurers guild. When you enter the guildhall and talk to the person in there he presents you with a few random quests that you can undertake. Everytime you enter the guildhall there will be different quests.
Pretty much like in Children of Mana for NDS.
18
Tutorial Requests / Change the game icon?
July 20, 2008, 10:24:53 am
I remember seeing a topic somewhere a while ago that explained how one could change the icon of the game you've made and I can't remember where I saw it., anyone know how to do this?
19
Is it possible to make enemies drop moneybags that when you pick them up you get cash?
20
Resource Requests / Weapon, item and armor icons?
July 19, 2008, 11:44:34 am
I was hoping someone knew of some nifty icons: Swords, axes, hammers, maces, flails, different kinds of armors such as body armor, helmets, shields, accesories.
21
I'm not a big fan of using pictures to illustrate enlightened areas. Mostly becouse I can never get them to work properly XD

So I was wondering if there is a script that could do the job, to create a lighter area around events with certain names. In this case: Torches so it would appear that they radiate light. I'm sure it is possible to make something like that since scripting can create mini maps without pictures. =3
22
I've created a dungeon 100*100 in size. I decided to try it out with some enemies, worked out great! However, I decided to increase the amount of enemies to 7 and that's where the error: Line 6241:SystemStackError occured. Saying the stack level is too deep. =/


This is the line of code:
    return (@lead != nil ? @lead.AI_data.sight : @sight)


Do I need to lower the A.I's line of sight or something like that?
23
I'm using Blizz-ABS 1.98 5E and I can't get the Tons of Add-ons script to work.
This is the error message I keep getting: Script 'Blizz-ABS' line 7693: SystemStackError occured. Stack level to deep.

This is the codeline:
    return (($game_system.caterpillar || self == $game_player || flag) ?
24
Request for a script that allows random placements of events such as treasure chests and monsters that manages so they don't end up in walls. =3
25
Tutorial Requests / [RESOLVED] Clouds?
July 18, 2008, 05:26:01 am
Do anyone have a tutorial for making clouds?
26
Is it possible for weapons to be able to use magic a set number of time and then "refill" them?
I'm thinking of Wands that can fire a spell a total of 5 times before having to be reloaded by magic. (Another item that's used as the ammo)
27
Is it possible to give the enemies more then one attack, for instance: A Gorgon can attack normaly or turn you to stone. A plant monster could attack normally, poison and stun?
28
Script Requests / Menu for things with long names?
July 14, 2008, 07:23:30 pm
Is anyone up for creating or pointing me in the direction of a script that can handle really long name of items and still look stylish? (Long names as in: War-axe of the Studious Bear) At the moment I use the ST CMs -Hybrid and things with long names often get their names cut in half^^'
29
This is a script for a random dungeon generator, whenever I use it I get these two error messages from Blizz-ABS. Anyone know how to make them work together?

=begin

Random Map Script, by "tonbi", adapted by Peter O.

--------------------


Names of random maps have the following syntax:

[MapName],Random,[Type],[ObjCnt],[Connect]

MapName - Name of the map
Type - Map type:
0 - 2 layers, natural
1 - 2 layers, artificial
2 - 2 layers, natural, convex
3 - 2 layers, artificial, convex
4 - 2 layers, natural, hole/land/wall
5 - 2 layers, artificial, hole/land/wall
6 - 2 layers, natural, hole/land/wall
7 - 2 layers, artificial, hole/land/wall
ObjCnt - Density of objects on the map.  Generally a number divisible by 100.
Connect - If this is equal to "false", the parts of the generated map can be disjoint.
  This setting is optional.

------------------
In addition, the tiles used in the random map must be arranged in a certain way, depending
on the map type; please see the Random Map Sample for details:

http://www.mc.ccnw.ne.jp/sarada/toshi/down/RandomMapSample.exe

------------------

Events can be labeled with one of the following:


Each event on the map can be marked with these features.

Checkpoint - There will always be ground wherever this event is placed.
To Use:  Name the event "MyEvent,Checkpoint" or use a Comment event
command consisting of the text "Checkpoint". ("MyEvent" is arbitrary.)
Fixed - This event will appear at a ground tile next to where this event is located.
To Use:  Name the event "MyEvent,Fixed" or use a Comment event
command consisting of the text "Fixed". ("MyEvent" is arbitrary.)
TotallyFixed - This event will always remain at its position defined on the map.
To Use:  Name the event "MyEvent,TotallyFixed" or use a Comment event
command consisting of the text "TotallyFixed". ("MyEvent" is arbitrary.)
WallFixture - Appears attached to a wall.  May be followed by a comma and either
1 or 0 (0 means the object takes 1 tile space; 1 means 3 tiles).
To Use:  Use a Comment event command consisting of the text "WallFixture,1"
WallFixtureFixed - Appears attached to a wall next to where this event is located.
May be followed by a comma and either 1 or 0 (0 means the object takes 1 tile space;
1 means 3 tiles).
To Use:  Use a Comment event command consisting of the text "WallFixtureFixed,1"

Events without these features will be placed at a random spot on the generated map.

-------------------
=end

 
  USE_TRAIN_ACTOR = false
class Game_Character
 
  DRAWRANGEX = 1920     
  DRAWRANGEY = 1664     
end
class Game_Map
 
  AUTO_MAP_SAVE = true   
                         
                         
end

class Game_Temp
  alias initialize_tonbi1 initialize
  def initialize
    initialize_tonbi1
   
    $onscreen = []                       
  end
end

class Game_Character
  alias update_tonbi1 update
  def update
    sx = @real_x - $game_map.display_x - 1280
    sy = @real_y - $game_map.display_y - 960
    abs_sx = sx > 0 ? sx : -sx
    abs_sy = sy > 0 ? sy-3 : -sy
    if abs_sx > DRAWRANGEX or abs_sy > DRAWRANGEY
      $onscreen[@id]=false
    else
      $onscreen[@id]=true
    end
   
    update_tonbi1
  end
end

class Spriteset_Map
  attr_accessor :character_sprites
  def initialize
   
    $onscreen = []
    @viewport1 = Viewport.new(0, 0, 640, 480)
    @viewport2 = Viewport.new(0, 0, 640, 480)
    @viewport3 = Viewport.new(0, 0, 640, 480)
    @viewport2.z = 200
    @viewport3.z = 5000
    @tilemap = Tilemap.new(@viewport1)
    @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
    for i in 0..6
      autotile_name = $game_map.autotile_names[i]
      @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
    end
    @tilemap.map_data = $game_map.data
    @tilemap.priorities = $game_map.priorities
    @panorama = Plane.new(@viewport1)
    @panorama.z = -1000
    @fog = Plane.new(@viewport1)
    @fog.z = 3000
    @character_sprites = []
    @party_sprites = []
    for i in $game_map.events.keys.sort
      sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
      @character_sprites[i]=sprite
      $onscreen[i] = true
    end
    @party_sprites.push(Sprite_Character.new(@viewport1, $game_player))
   
    @weather = RPG::Weather.new(@viewport1)
    @picture_sprites = []
    for i in 1..50
      @picture_sprites.push(Sprite_Picture.new(@viewport2,
        $game_screen.pictures[i]))
    end
    @timer_sprite = Sprite_Timer.new
    update
  end
  def dispose
    @tilemap.tileset.dispose
    for i in 0..6
      @tilemap.autotiles[i].dispose
    end
    @tilemap.dispose
    @panorama.dispose
    @fog.dispose
    for i in @character_sprites
      if i != nil
        i.dispose
      end
    end
    for i in @party_sprites
      if i != nil
        i.dispose
      end
    end
    @weather.dispose
    for sprite in @picture_sprites
      sprite.dispose
    end
    @timer_sprite.dispose
    @viewport1.dispose
    @viewport2.dispose
    @viewport3.dispose
  end
  def update
    if @panorama_name != $game_map.panorama_name or
       @panorama_hue != $game_map.panorama_hue
      @panorama_name = $game_map.panorama_name
      @panorama_hue = $game_map.panorama_hue
      if @panorama.bitmap != nil
        @panorama.bitmap.dispose
        @panorama.bitmap = nil
      end
      if @panorama_name != ""
        @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
      end
      Graphics.frame_reset
    end
    if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
      @fog_name = $game_map.fog_name
      @fog_hue = $game_map.fog_hue
      if @fog.bitmap != nil
        @fog.bitmap.dispose
        @fog.bitmap = nil
      end
      if @fog_name != ""
        @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
      end
      Graphics.frame_reset
    end
    @tilemap.ox = $game_map.display_x / 4
    @tilemap.oy = $game_map.display_y / 4
    @tilemap.update
    @panorama.ox = $game_map.display_x / 8
    @panorama.oy = $game_map.display_y / 8
    @fog.zoom_x = $game_map.fog_zoom / 100.0
    @fog.zoom_y = $game_map.fog_zoom / 100.0
    @fog.opacity = $game_map.fog_opacity
    @fog.blend_type = $game_map.fog_blend_type
    @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
    @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
    @fog.tone = $game_map.fog_tone
    for i in $game_map.events.keys
      if $onscreen[i]
        @character_sprites[i].update
      end
    end
    for i in @party_sprites
      i.update
    end
 
    @weather.type = $game_screen.weather_type
    @weather.max = $game_screen.weather_max
    @weather.ox = $game_map.display_x / 4
    @weather.oy = $game_map.display_y / 4
    @weather.update
    for sprite in @picture_sprites
      sprite.update
    end
    @timer_sprite.update
    @viewport1.tone = $game_screen.tone
    @viewport1.ox = $game_screen.shake
    @viewport3.color = $game_screen.flash_color
    @viewport1.update
    @viewport3.update
  end
end

if USE_TRAIN_ACTOR == true
  module Train_Actor
    module Spriteset_Map_Module
      def setup_actor_character_sprites(characters)
        if !setup_actor_character_sprites?
          for character in characters.reverse
            @party_sprites.unshift(
              Sprite_Character.new(@viewport1, character)
            )
          end
          @setup_actor_character_sprites_flag = true
        end
      end
    end
  end
end
class Game_Map
  def setup(map_id)
    @map_id = map_id
    @map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
    tileset = $data_tilesets[@map.tileset_id]
    @tileset_name = tileset.tileset_name
    @autotile_names = tileset.autotile_names
    @panorama_name = tileset.panorama_name
    @panorama_hue = tileset.panorama_hue
    @fog_name = tileset.fog_name
    @fog_hue = tileset.fog_hue
    @fog_opacity = tileset.fog_opacity
    @fog_blend_type = tileset.fog_blend_type
    @fog_zoom = tileset.fog_zoom
    @fog_sx = tileset.fog_sx
    @fog_sy = tileset.fog_sy
    @battleback_name = tileset.battleback_name
    @passages = tileset.passages
    @priorities = tileset.priorities
    @terrain_tags = tileset.terrain_tags
    @display_x = 0
    @display_y = 0
   
    check_special_map
    @need_refresh = false
    @events = {}
    for i in @map.events.keys
      @events[i] = Game_Event.new(@map_id, @map.events[i])
    end
    @common_events = {}
    for i in 1...$data_common_events.size
      @common_events[i] = Game_CommonEvent.new(i)
    end
    @fog_ox = 0
    @fog_oy = 0
    @fog_tone = Tone.new(0, 0, 0, 0)
    @fog_tone_target = Tone.new(0, 0, 0, 0)
    @fog_tone_duration = 0
    @fog_opacity_duration = 0
    @fog_opacity_target = 0
    @scroll_direction = 2
    @scroll_rest = 0
    @scroll_speed = 4
  end
  def check_special_map
    mapinfo  = load_data("Data/MapInfos.rxdata")
    if mapinfo[@map_id].subname == "Random"
      if mapinfo[@map_id].subname(3)=="" or mapinfo[@map_id].subname(3) == nil
        p3 = 0
      else
        p3 = mapinfo[@map_id].subname(3).to_i
      end
      if mapinfo[@map_id].subname(4)=="false"
        p4 = false
      end
     
      make_random_map(2,mapinfo[@map_id].subname(2).to_i,p3,p4)
    end
  end
  def make_random_map(wall = 2, type = 0, objcnt = 0, connect = true)
    wall = 0 if wall == nil
    type = 0 if type == nil
    objcnt = 0 if objcnt == nil
    unless objcnt.is_a?(Numeric)
      objcnt = 0
    end
    if objcnt < 0
      objcnt = 0
    end
    connect = true if connect != false
    @heightdata = Table.new(@map.width,@map.height)
    @maskdata = Table.new(@map.width,@map.height)
    @oneventdata = Table.new(@map.width,@map.height)
    @masksetting = []
    @makedata = []
    @targettype=0
    @chgtype=0
   
    time = -1
    for i in 0...@map.width
      for j in 0...@map.height
        time += 1
        if time%2000 == 0
          Graphics.update
        end
        @heightdata[i,j] = 0
        @maskdata[i,j] = 0
      end
    end
    for i in 0...100
      @masksetting[i] = true
    end
    needposx = []
    needposy = []
    for i in @map.events.keys.sort
      time += 1
      if time%200 == 0
        Graphics.update
      end
      if event_settype(i) == 1
        if connect == true
          needposx.push(@map.events[i].x)
          needposy.push(@map.events[i].y)
          needposx.push(@map.events[i].x)
          needposy.push(@map.events[i].y)
        else
          needposx.push(@map.events[i].x)
          needposy.push(@map.events[i].y)
        end
      end
    end
    if connect == true
      needposx.shift
      needposy.shift
    end
    loop do
      if needposx.size <= 2
        needposx.push(rand(@map.width))
        needposy.push(rand(@map.height))
      else
        break
      end
    end
    case type
    when 0
      @makedata.push([0,1,0])
      @makedata.push([5,1])
      for i in 0...(needposx.size/2)
        @makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
        @makedata.push([3,0,-15,4,0])
        @makedata.push([1,1,1,1,1])
        @makedata.push([6,0,needposx[i*2],needposy[i*2]])
        @makedata.push([6,0,needposx[i*2+1],needposy[i*2+1]])
      end
     
      @makedata.push([4,0,1,1,1])
      @makedata.push([4,0,1,1,1])
      @makedata.push([4,1,1,1,1])
     
      @makedata.push([0,0,0])
      @makedata.push([2,0,2])
      @makedata.push([5,0])
      @makedata.push([2,1,2])
      @makedata.push([5,1])
    when 1
      @makedata.push([0,1,0])
      @makedata.push([5,1])
      for i in 0...(needposx.size/2)
        @makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
        @makedata.push([3,0,-6,4,1,10])
        @makedata.push([1,1,1,1,1])
        @makedata.push([6,0,needposx[i*2],needposy[i*2]])
        @makedata.push([6,0,needposx[i*2+1],needposy[i*2+1]])
      end
     
      @makedata.push([4,0,2,3,1])
      @makedata.push([4,1,2,2,1])
      @makedata.push([4,0,1,1,1])
     
      @makedata.push([0,0,0])
      @makedata.push([2,0,2])
      @makedata.push([5,0])
      @makedata.push([2,1,2])
      @makedata.push([5,1])
    when 2
      @makedata.push([0,1,0])
      @makedata.push([5,1])
      for i in 0...(needposx.size/2)
        @makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
        @makedata.push([3,0,-15,4,0])
        @makedata.push([1,1,1,1,1])
        @makedata.push([6,0,needposx[i*2],needposy[i*2]])
        @makedata.push([6,0,needposx[i*2+1],needposy[i*2+1]])
      end
     
      @makedata.push([4,0,2,2,1])
      @makedata.push([4,1,1,1,1])
     
      @makedata.push([0,0,0])
      @makedata.push([2,0,2])
      @makedata.push([5,0])
      @makedata.push([2,1,2])
      @makedata.push([5,-1])
    when 3
      @makedata.push([0,1,0])
      @makedata.push([5,1])
      for i in 0...(needposx.size/2)
        @makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
        @makedata.push([3,0,-15,4,1,10])
        @makedata.push([1,1,1,1,1])
        @makedata.push([6,0,needposx[i*2],needposy[i*2]])
        @makedata.push([6,0,needposx[i*2+1],needposy[i*2+1]])
      end
     
      @makedata.push([4,0,2,2,1])
      @makedata.push([4,1,1,1,1])
     
      @makedata.push([0,0,0])
      @makedata.push([2,0,2])
      @makedata.push([5,0])
      @makedata.push([2,1,2])
      @makedata.push([5,-1])
    when 4
      @makedata.push([0,1,0])
      @makedata.push([5,0])
      @makedata.push([1,0,0,-1,0])
      @makedata.push([3,2,-6,1,0])
      @makedata.push([1,-1,0,-1,-1])
      @makedata.push([3,2,-6,1,0])
      @makedata.push([1,-1,-1,0,-1])
      @makedata.push([3,2,-6,1,0])
      @makedata.push([1,0,-1,0,0])
      @makedata.push([3,2,-6,1,0])
      @makedata.push([4,2,2,2,1])
      for i in 0...(rand(12*@map.width*@map.height/40/40)+(5*@map.width*@map.height/40/40))
        @makedata.push([1,3,3,8,8])
        @makedata.push([6,0,rand(@map.width-10)+5,rand(@map.height-10)+5])
      end
      @makedata.push([7,2])
      @makedata.push([4,2,1,1,1])
      for i in 0...(needposx.size/2)
        @makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
        @makedata.push([3,1,-8,4,0,5])
        @makedata.push([1,1,1,1,1])
        @makedata.push([6,1,needposx[i*2],needposy[i*2]])
        @makedata.push([6,1,needposx[i*2+1],needposy[i*2+1]])
      end
      @makedata.push([4,1,1,1,1])
      @makedata.push([4,1,0,1,1])
      @makedata.push([2,0,0])
      @makedata.push([4,1,1,0,1])
      @makedata.push([2,-1,1])
      @makedata.push([4,2,1,1,1])
      @makedata.push([0,0,0])
      @makedata.push([2,0,2])
      @makedata.push([5,-1])
      @makedata.push([2,1,2])
      @makedata.push([5,0])
      @makedata.push([2,2,2])
      @makedata.push([5,1])
     
    when 5
      @makedata.push([0,1,0])
      @makedata.push([5,0])
      @makedata.push([1,0,0,-1,0])
      @makedata.push([3,2,-6,1,0])
      @makedata.push([1,-1,0,-1,-1])
      @makedata.push([3,2,-6,1,0])
      @makedata.push([1,-1,-1,0,-1])
      @makedata.push([3,2,-6,1,0])
      @makedata.push([1,0,-1,0,0])
      @makedata.push([3,2,-6,1,0])
      @makedata.push([4,2,2,2,1])
      for i in 0...(rand(12*@map.width*@map.height/40/40)+(5*@map.width*@map.height/40/40))
        @makedata.push([1,3,3,8,8])
        @makedata.push([6,0,rand(@map.width-10)+5,rand(@map.height-10)+5])
      end
      @makedata.push([7,2])
      @makedata.push([4,2,1,1,1])
      for i in 0...(needposx.size/2)
        @makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
        @makedata.push([3,1,-8,4,1,5])
        @makedata.push([1,1,1,1,1])
        @makedata.push([6,1,needposx[i*2],needposy[i*2]])
        @makedata.push([6,1,needposx[i*2+1],needposy[i*2+1]])
      end
      @makedata.push([4,1,1,1,1])
      @makedata.push([4,1,0,1,1])
      @makedata.push([2,0,0])
      @makedata.push([4,1,1,0,1])
      @makedata.push([2,-1,1])
      @makedata.push([4,2,1,1,1])
      @makedata.push([0,0,0])
      @makedata.push([2,0,2])
      @makedata.push([5,-1])
      @makedata.push([2,1,2])
      @makedata.push([5,0])
      @makedata.push([2,2,2])
      @makedata.push([5,1])
     
     
     
    when 6
      @makedata.push([0,1,0])
      @makedata.push([5,0])
      @makedata.push([1,0,0,-1,0])
      @makedata.push([3,2,-6,1,0])
      @makedata.push([1,-1,0,-1,-1])
      @makedata.push([3,2,-6,1,0])
      @makedata.push([1,-1,-1,0,-1])
      @makedata.push([3,2,-6,1,0])
      @makedata.push([1,0,-1,0,0])
      @makedata.push([3,2,-6,1,0])
      @makedata.push([4,2,2,2,1])
      for i in 0...(rand(12*@map.width*@map.height/40/40)+(5*@map.width*@map.height/40/40))
        @makedata.push([1,1,1,3,3])
        @makedata.push([6,0,rand(@map.width-10)+5,rand(@map.height-10)+5])
      end
      @makedata.push([4,0,2,2,0])
      @makedata.push([4,0,1,2,1])
      @makedata.push([7,2])
      @makedata.push([4,2,1,1,1])
      for i in 0...(needposx.size/2)
        @makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
        @makedata.push([3,1,-15,4,0,5])
        @makedata.push([1,1,1,1,1])
        @makedata.push([6,1,needposx[i*2],needposy[i*2]])
        @makedata.push([6,1,needposx[i*2+1],needposy[i*2+1]])
      end
      @makedata.push([4,1,1,1,1])
      @makedata.push([4,1,0,1,1])
      @makedata.push([2,0,0])
      @makedata.push([4,1,1,0,1])
      @makedata.push([2,-1,1])
      @makedata.push([4,2,1,1,1])
      @makedata.push([0,0,0])
      @makedata.push([2,0,2])
      @makedata.push([5,-1])
      @makedata.push([2,1,2])
      @makedata.push([5,0])
      @makedata.push([2,2,2])
      @makedata.push([5,1])
     
    when 7
      @makedata.push([0,1,0])
      @makedata.push([5,0])
      @makedata.push([1,0,0,-1,0])
      @makedata.push([3,2,-6,1,0])
      @makedata.push([1,-1,0,-1,-1])
      @makedata.push([3,2,-6,1,0])
      @makedata.push([1,-1,-1,0,-1])
      @makedata.push([3,2,-6,1,0])
      @makedata.push([1,0,-1,0,0])
      @makedata.push([3,2,-6,1,0])
      @makedata.push([4,2,2,2,1])
      for i in 0...(rand(12*@map.width*@map.height/40/40)+(5*@map.width*@map.height/40/40))
        @makedata.push([1,1,1,3,3])
        @makedata.push([6,0,rand(@map.width-10)+5,rand(@map.height-10)+5])
      end
      @makedata.push([4,0,2,2,0])
      @makedata.push([4,0,1,2,1])
      @makedata.push([7,2])
      @makedata.push([4,2,1,1,1])
      for i in 0...(needposx.size/2)
        @makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
        @makedata.push([3,1,-15,4,1,5])
        @makedata.push([1,1,1,1,1])
        @makedata.push([6,1,needposx[i*2],needposy[i*2]])
        @makedata.push([6,1,needposx[i*2+1],needposy[i*2+1]])
      end
      @makedata.push([4,1,1,1,1])
      @makedata.push([4,1,0,1,1])
      @makedata.push([2,0,0])
      @makedata.push([4,1,1,0,1])
      @makedata.push([2,-1,1])
      @makedata.push([4,2,1,1,1])
      @makedata.push([0,0,0])
      @makedata.push([2,0,2])
      @makedata.push([5,-1])
      @makedata.push([2,1,2])
      @makedata.push([5,0])
      @makedata.push([2,2,2])
      @makedata.push([5,1])
    end
    for make_stat in @makedata
      time += 1
      if time%2 == 0
        Graphics.update
      end
      case make_stat[0]
      when 0   
        rndmap_chtarget(make_stat[1],make_stat[2])
      when 1   
        rndmap_setstat(make_stat[1],make_stat[2],make_stat[3],make_stat[4])
      when 2   
        rndmap_chmask(make_stat[1],make_stat[2])
      when 3   
        rndmap_mkroad(make_stat[1],make_stat[2],make_stat[3],make_stat[4],make_stat[5])
      when 4   
        rndmap_plus(make_stat[1],make_stat[2],make_stat[3],make_stat[4])
      when 5   
        rndmap_allchg(make_stat[1])
      when 6   
        rndmap_putpos(make_stat[1],make_stat[2],make_stat[3])
      when 7   
        rndmap_edge(make_stat[1])
      end
    end
    @tilesetting = Table.new(3,40,3)
    for i in [0,1,2]
      for k in 0...40
        for j in [0,1,2]
          @tilesetting[j,k,i] = @map.data[j,k,i]
        end
      end
    end
    time = 0
    for k in 0...@map.height
      for j in 0...@map.width
        time += 1
        if time%500 == 0
          Graphics.update
        end
        if @heightdata[j,k] == 1
          if @heightdata[j,k+1]==-1
            @heightdata[j,k+1] = 0
            if @heightdata[j,k+2]==-1 and
              @heightdata[j,k+3] == 0
              @heightdata[j,k+2] = 0
            end
          end
        end
       
      end
    end
    time = 0
    for k in 0...@map.height
      for j in 0...@map.width
        time += 1
        if time%500 == 0
          Graphics.update
        end
        if @heightdata[j,k] == 0
          if @heightdata[j,k+1] == -1 or
            @heightdata[j,k-1] == -1 or
            @heightdata[j+1,k] == -1 or
            @heightdata[j-1,k] == -1
            set_mapdata2(j,k,0,8)
          else
            set_mapdata2(j,k,0,0)
          end
        elsif @heightdata[j,k] == 1
          if @heightdata[j,k+1] == -1 or
            @heightdata[j,k-1] == -1 or
            @heightdata[j+1,k] == -1 or
            @heightdata[j-1,k] == -1
            set_mapdata2(j,k,0,8)
          elsif @heightdata[j,k+1] == 0 or
            @heightdata[j,k-1] == 0 or
            @heightdata[j+1,k] == 0 or
            @heightdata[j-1,k] == 0
            set_mapdata2(j,k,0,0)
          else
            set_mapdata2(j,k,1,4)
          end
        else
          set_mapdata2(j,k,0,8)
        end
      end
    end
    time = 0
    for k in 0...@map.height
      for j in 0...@map.width
        time += 1
        if time%500 == 0
          Graphics.update
        end
        if @heightdata[j,k] == 0
          if @heightdata[j,k+1] == -1
            if @heightdata[j-1,k] == -1
              for i in [0,1,2]
                set_mapdata(j,k+i,0,13+i,1)
              end
            elsif @heightdata[j+1,k] == -1
              for i in [0,1,2]
                set_mapdata(j,k+i,2,13+i,1)
              end
            else
              for i in [0,1,2]
                set_mapdata(j,k+i,1,13+i,1)
              end
            end
          elsif @heightdata[j,k-1] == -1
            if @heightdata[j-1,k] == -1 or
            (@heightdata[j-1,k] == 1 and
            @heightdata[j-1,k-1] == -1)
              set_mapdata(j,k,0,11,2)
            elsif @heightdata[j+1,k] == -1 or
            (@heightdata[j+1,k] == 1 and
            @heightdata[j+1,k-1] == -1)
              set_mapdata(j,k,2,11,2)
            else
              set_mapdata(j,k,1,11,2)
            end
          elsif @heightdata[j-1,k] == -1 or
            (@heightdata[j-1,k] == 1 and
            @heightdata[j-1,k-1] == -1)
            set_mapdata(j,k,0,12,1)
          elsif @heightdata[j+1,k] == -1 or
            (@heightdata[j+1,k] == 1 and
            @heightdata[j+1,k-1] == -1)
            set_mapdata(j,k,2,12,1)
          elsif @heightdata[j-1,k-1] == -1
            set_mapdata(j,k,0,9,1)
          elsif @heightdata[j-1,k+1] == -1
            set_mapdata(j,k,0,10,1)
          elsif @heightdata[j+1,k-1] == -1
            set_mapdata(j,k,1,9,1)
          elsif @heightdata[j+1,k+1] == -1
            set_mapdata(j,k,1,10,1)
          end
        end
        if @heightdata[j,k] == 1 and
          @heightdata[j,k-1] != -1
         
          if @heightdata[j,k+1] == -1
            if @heightdata[j-1,k] == -1
              for i in [0,1,2]
              end
            elsif @heightdata[j+1,k] == -1
              for i in [0,1,2]
              end
            else
              for i in [0,1,2]
              end
            end
          elsif @heightdata[j,k-1] == -1
            if @heightdata[j-1,k] == -1
              set_mapdata(j,k,0,11,2)
            elsif @heightdata[j+1,k] == -1
              set_mapdata(j,k,2,11,2)
            else
              set_mapdata(j,k,1,11,2)
            end
          elsif @heightdata[j-1,k] == -1
            set_mapdata(j,k,0,12,1)
          elsif @heightdata[j+1,k] == -1
            set_mapdata(j,k,2,12,1)
          elsif @heightdata[j-1,k-1] == -1
            set_mapdata(j,k,0,9,1)
          elsif @heightdata[j-1,k+1] == -1
            set_mapdata(j,k,0,10,1)
          elsif @heightdata[j+1,k-1] == -1
            set_mapdata(j,k,1,9,1)
          elsif @heightdata[j+1,k+1] == -1
            set_mapdata(j,k,1,10,1)
          end
        end
      end
    end
    time = 0
    for k in 0...@map.height
      for j in 0...@map.width
        time += 1
        if time%500 == 0
          Graphics.update
        end
        if @heightdata[j,k] == 1
          if @heightdata[j,k+1] == 0 or
            @heightdata[j,k+1] == -1
            if @heightdata[j-1,k] == 0 or
              @heightdata[j-1,k] == -1
              set_mapdata(j,k+0,0,5+0,5)
              set_mapdata(j,k+1,0,5+1,5)
              set_mapdata(j,k+2,0,5+2,4)
              if @heightdata[j,k+3] != 0 and
                @heightdata[j,k+2] != 1 and
                (@heightdata[j,k+2] != 0 or @heightdata[j-1,k+2] != 0)
                set_mapdata(j,k+2,0,16,5)
                for i in [0,1]
                  set_mapdata(j,k+3+i,0,14+i,1)
                  if @heightdata[j,k+3+i] != -1
                    break
                  end
                end
              end
            elsif @heightdata[j+1,k] == 0 or
              @heightdata[j+1,k] == -1
              set_mapdata(j,k+0,2,5+0,5)
              set_mapdata(j,k+1,2,5+1,5)
              set_mapdata(j,k+2,2,5+2,4)
              if @heightdata[j,k+3] != 0 and
                @heightdata[j,k+2] != 1 and
                (@heightdata[j,k+2] != 0 or @heightdata[j+1,k+2] != 0)
                set_mapdata(j,k+2,2,16,5)
                for i in [0,1]
                  set_mapdata(j,k+3+i,2,14+i,1)
                  if @heightdata[j,k+3+i] != -1
                    break
                  end
                end
              end
            else
              set_mapdata(j,k+0,1,5+0,5)
              set_mapdata(j,k+1,1,5+1,5)
              set_mapdata(j,k+2,1,5+2,4)
              if @heightdata[j,k+3] != 0 and
                 @heightdata[j,k+2] != 1
                set_mapdata(j,k+2,1,16,5)
                for i in [0,1]
                  set_mapdata(j,k+3+i,1,14+i,1)
                  if @heightdata[j,k+3+i] != -1
                    break
                  end
                end
              end
            end
          elsif @heightdata[j,k-1] == 0 or
              @heightdata[j,k-1] == -1
            if @heightdata[j-1,k] == 0 or
              @heightdata[j-1,k] == -1
              set_mapdata(j,k,0,3,4)
            elsif @heightdata[j+1,k] == 0 or
              @heightdata[j+1,k] == -1
              set_mapdata(j,k,2,3,4)
            else
              set_mapdata(j,k,1,3,4)
            end
          elsif @heightdata[j-1,k] == 0 or
              @heightdata[j-1,k] == -1
            set_mapdata(j,k,0,4,4)
          elsif @heightdata[j+1,k] == 0 or
              @heightdata[j+1,k] == -1
            set_mapdata(j,k,2,4,4)
          elsif @heightdata[j-1,k-1] == 0 or
              @heightdata[j-1,k-1] == -1
            set_mapdata(j,k,0,1,4)
          elsif @heightdata[j-1,k+1] == 0 or
              @heightdata[j-1,k+1] == -1
            set_mapdata(j,k,0,2,4)
          elsif @heightdata[j+1,k-1] == 0 or
              @heightdata[j+1,k-1] == -1
            set_mapdata(j,k,1,1,4)
          elsif @heightdata[j+1,k+1] == 0 or
              @heightdata[j+1,k+1] == -1
            set_mapdata(j,k,1,2,4)
          end
        end
      end
    end
    playerpos_reset($game_temp.player_new_x,$game_temp.player_new_y)
    @oneventdata[$game_temp.player_new_x,$game_temp.player_new_y] = 1
   
    time = 0
    for i in @map.events.keys.sort
      time += 1
      if time%100 == 0
        Graphics.update
      end
      case event_settype(i)
      when 3
        @oneventdata[@map.events[i].x,@map.events[i].y] = 1
      end
    end
    for i in @map.events.keys.sort
      time += 1
      if time%100 == 0
        Graphics.update
      end
      case event_settype(i)
      when 1
        set_defeventpos(i,@map.events[i].x,@map.events[i].y)
        @oneventdata[@map.events[i].x,@map.events[i].y] = 1
      end
    end
    for i in @map.events.keys.sort
      time += 1
      if time%100 == 0
        Graphics.update
      end
      j = event_settype(i)
      case j
      when 0 
        set_defeventpos(i,rand(@map.width-4)+2,rand(@map.width-4)+2)
        @oneventdata[@map.events[i].x,@map.events[i].y] = 1
      when 2 
        set_defeventpos(i,@map.events[i].x,@map.events[i].y)
        @oneventdata[@map.events[i].x,@map.events[i].y] = 1
      when 100..199 
        set_defeventpos_wall(i,rand(@map.width-4)+2,rand(@map.width-4)+2,j-100)
        @oneventdata[@map.events[i].x,@map.events[i].y] = 1
        @oneventdata[@map.events[i].x,@map.events[i].y-1] = 1
        for k in 1..(j-100)
          @oneventdata[@map.events[i].x+k,@map.events[i].y] = 1
          @oneventdata[@map.events[i].x+k,@map.events[i].y-1] = 1
          @oneventdata[@map.events[i].x-k,@map.events[i].y] = 1
          @oneventdata[@map.events[i].x-k,@map.events[i].y-1] = 1
        end
      when 200..299 
        set_defeventpos_wall(i,@map.events[i].x,@map.events[i].y,j-200)
        @oneventdata[@map.events[i].x,@map.events[i].y] = 1
        @oneventdata[@map.events[i].x,@map.events[i].y-1] = 1
        for k in 1..(j-200)
          @oneventdata[@map.events[i].x+k,@map.events[i].y] = 1
          @oneventdata[@map.events[i].x+k,@map.events[i].y-1] = 1
          @oneventdata[@map.events[i].x-k,@map.events[i].y] = 1
          @oneventdata[@map.events[i].x-k,@map.events[i].y-1] = 1
        end
      end
    end
    for i in 0...(rand(objcnt)+objcnt/2)
      time += 1
      if time%500 == 0
        Graphics.update
      end
      j = rand(@map.width)
      k = rand(@map.width)
      case rand(10)
      when 0..4
        if standable_newtile?(1,0)
          if standable?(j,k)
            set_mapdata(j,k,1,0,6)
          end
        else
          if standable2?(j,k)
            set_mapdata(j,k,1,0,6)
          end
        end
      when 5..7
        if standable_newtile?(2,0)
          if standable?(j,k)
            set_mapdata(j,k,2,0,6)
          end
        else
          if standable2?(j,k)
            set_mapdata(j,k,2,0,6)
          end
        end
      when 8..9
        if standable2?(j,k)
          if @map.data[j,k-1,2]==0 and
            (@map.data[j,k,1]==0 or @map.data[j,k,2]==0)
            set_mapdata(j,k,2,2,4)   
            set_mapdata(j,k-1,2,1,4) 
          end
        end
      end
    end
    @heightdata.resize(0,0)
    @maskdata.resize(0,0)
    @oneventdata.resize(0,0)
    @masksetting.clear
    @makedata.clear
    @tilesetting.resize(0,0,0)
   
    if AUTO_MAP_SAVE
      save_data(@map,sprintf("Data/Map%03d.rxdata", 999))
      maplist  = load_data("Data/MapInfos.rxdata")
     
      mapinfo = RPG::MapInfo.new
      mapinfo.name = sprintf("Auto-saved random map (%s)", maplist[@map_id].name)
      mapinfo.parent_id = 0
      mapinfo.order = 999
      mapinfo.expanded = true
      mapinfo.scroll_x = 0
      mapinfo.scroll_y = 0
     
      maplist[999]=mapinfo
      save_data(maplist,"Data/MapInfos.rxdata")
    end
  end
  def event_settype(i)
    if @map.events[i].subname == "Checkpoint"
      return 1
    end
    if @map.events[i].subname == "Fixed"
      return 2
    end
    if @map.events[i].subname == "TotallyFixed"
      return 3
    end
    for j in 0..1000
      if @map.events[i].pages[0].list[j].code != 108
        break
      end
      if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[0] == "Checkpoint"
        return 1
      end
      if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[0] == "TotallyFixed"
        return 3
      end
      if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[0] == "Fixed"
        return 2
      end
      if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[0] == "WallFixture"
        if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[1] == nil
          return 100
        else
          k = @map.events[i].pages[0].list[j].parameters[0].split(/,/)[1]
          k = k.to_i
          return 100+k
        end
      end
      if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[0] == "WallFixtureFixed"
        if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[1] == nil
          return 200
        else
          k = @map.events[i].pages[0].list[j].parameters[0].split(/,/)[1]
          k = k.to_i
          return 200+k
        end
      end
    end
    return 0
  end
  def set_defeventpos(id,x,y)
    if standable2?(x,y)
      @map.events[id].x=x
      @map.events[id].y=y
      return
    end
    for i in 1..([@map.width,@map.height].max)
      if standable2?(x,y+i)
        @map.events[id].x=x
        @map.events[id].y=y+i
        return
      end
      for j in 1..i
        if standable2?(x-j,y+i)
          @map.events[id].x=x-j
          @map.events[id].y=y+i
          return
        end
        if standable2?(x+j,y+i)
          @map.events[id].x=x+j
          @map.events[id].y=y+i
          return
        end
        if standable2?(x-j,y-i)
          @map.events[id].x=x-j
          @map.events[id].y=y-i
          return
        end
        if standable2?(x+j,y-i)
          @map.events[id].x=x+j
          @map.events[id].y=y-i
          return
        end
      end
    end
  end
  def set_defeventpos_wall(id,x,y,p4)
    if standable3?(x,y,p4)
      @map.events[id].x=x
      @map.events[id].y=y
      return
    end
    for i in 1..([@map.width,@map.height].max)
      if standable3?(x,y+i,p4)
        @map.events[id].x=x
        @map.events[id].y=y+i
        return
      end
      for j in 1..i
        if standable3?(x-j,y+i,p4)
          @map.events[id].x=x-j
          @map.events[id].y=y+i
          return
        end
        if standable3?(x+j,y+i,p4)
          @map.events[id].x=x+j
          @map.events[id].y=y+i
          return
        end
        if standable3?(x-j,y-i,p4)
          @map.events[id].x=x-j
          @map.events[id].y=y-i
          return
        end
        if standable3?(x+j,y-i,p4)
          @map.events[id].x=x+j
          @map.events[id].y=y-i
          return
        end
      end
    end
  end
  def playerpos_reset(x,y)
    if standable?(x,y)
      $game_temp.player_new_x=x
      $game_temp.player_new_y=y
      return
    end
    for i in 1..([@map.width,@map.height].max)
      if standable?(x,y+i)
        $game_temp.player_new_x=x
        $game_temp.player_new_y=y+i
        return
      end
      for j in 0..i
        if standable?(x-j,y+i)
          $game_temp.player_new_x=x-j
          $game_temp.player_new_y=y+i
          return
        end
        if standable?(x+j,y+i)
          $game_temp.player_new_x=x+j
          $game_temp.player_new_y=y+i
          return
        end
        if standable?(x-j,y-i)
          $game_temp.player_new_x=x-j
          $game_temp.player_new_y=y-i
          return
        end
        if standable?(x+j,y-i)
          $game_temp.player_new_x=x+j
          $game_temp.player_new_y=y-i
          return
        end
      end
    end
  end
  def standable_newtile?(p1,p2)
    for i in [2, 1, 0]
      tile_id = @tilesetting[p1, p2, i]
      if tile_id == nil
        return false
      elsif @passages[tile_id] & 0x0f == 0x0f
        return false
      elsif @priorities[tile_id] == 0
        return true
      end
    end
    return true
  end
  def standable?(p1,p2)
    if @heightdata[p1,p2] != 0
      return false
    end
    if @oneventdata[p1,p2] ==1
      return false
    end
    for i in [2, 1, 0]
      tile_id = @map.data[p1, p2, i]
      if tile_id == nil
        return false
      elsif @passages[tile_id] & 0x0f == 0x0f
        return false
      elsif @priorities[tile_id] == 0
        return true
      end
    end
    return true
  end
  def standable2?(p1,p2)
    unless standable?(p1,p2)
      return false
    end
    if standable?(p1+1,p2-1) == false or
      standable?(p1+1,p2) == false or
      standable?(p1+1,p2+1) == false
      if standable?(p1-1,p2-1) == false or
        standable?(p1-1,p2) == false or
        standable?(p1-1,p2+1) == false
        if standable?(p1,p2-1) == true and
          standable?(p1,p2+1) == true
          return false
        end
      end
    end
    if standable?(p1+1,p2+1) == false or
      standable?(p1,p2+1) == false or
      standable?(p1-1,p2+1) == false
      if standable?(p1+1,p2-1) == false or
        standable?(p1,p2-1) == false or
        standable?(p1-1,p2-1) == false
        if standable?(p1-1,p2) == true and
          standable?(p1+1,p2) == true
          return false
        end
      end
    end
    if standable?(p1,p2-1) == false and
      (standable?(p1-1,p2+1) == false or
      standable?(p1,p2+1) == false or
      standable?(p1+1,p2+1) == false)
      return false
    end
    if standable?(p1,p2+1) == false and
      (standable?(p1-1,p2-1) == false or
      standable?(p1+1,p2-1) == false or
      standable?(p1+1,p2-1) == false)
      return false
    end
    if standable?(p1-1,p2) == false and
      (standable?(p1+1,p2-1) == false or
      standable?(p1+1,p2) == false or
      standable?(p1+1,p2+1) == false)
      return false
    end
    if standable?(p1+1,p2) == false and
      (standable?(p1-1,p2-1) == false or
      standable?(p1-1,p2) == false or
      standable?(p1-1,p2+1) == false)
      return false
    end
     
    return true
  end
  def standable3?(p1,p2,p3)
    unless standable?(p1,p2+1)
      return false
    end
    if @oneventdata[p1,p2] == 1 or
      @oneventdata[p1,p2-1] == 1 or
   
30
Resource Requests / RMVX monster character request.
July 12, 2008, 07:34:13 pm
I would like to form a request for monster characters. Examples are: Skeletons, trolls, goblins, chimeras etc. The standard rpg monsters. Perhaps even something from Dragon Quest?=3