Hey guys. This is my first actual script, so go easy on me.
This is for RPG Maker XP.
Demo 0.9 Beta
http://www.mediafire.com/file/wotgymjzayz/MLA.rar
Script: (Warning: Massive)
This script increases the amount of layers and options available to mappers.
For details on what this script does, see the introduction in the script itself.
Oh, and credit goes to SephirothSpawn because without his hint about rendering tiles over fog, this script wouldn't have been nearly as good.
Feedback, people, please! It's appreciated and I will be listening for any suggestions or critique. Even if it's negative.
Edit:
Thanks for not yelling at me for submitting something so choppy- I hadn't had much sleep. I slept for 5 hours and it's *much* better now. Removed the crash-related bugs. All that's left to fix is the overfog and midfog layers- they still don't quite display right. The overfog layer is displaying under fog 2...
and the midfog layer tiles aren't showing up right. I'll work on it when I get home from work.
Screens : :
This is for RPG Maker XP.
Demo 0.9 Beta
http://www.mediafire.com/file/wotgymjzayz/MLA.rar
Script: (Warning: Massive)
=begin
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++ theory's advanced map layers
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Version 0.9 Beta
October 15th, 2008
Introduction:
The purpose of this script is to grant mappers more layers to work with,
in hopes of seeing some higher quality maps made from this.
First off, added the ability to scroll the panorama. Don't know why this wasn't
included. Makes boat scenes sooo much easier. (scrolling water...)
I've added a second panorama layer- this layer is *below* the default layer
due to my inability to get priorities to cooperate.
There's also a second fog layer now. This layer is *above* the default layer,
again because the priorities hate me.
And then the fun part. Based on terrain tags, tiles can be displayed above the
lower fog, and then additionally above the upper fog. This is to add depth.
Better yet, the player can ascend and descend through these fogs dynamically.
This should allow mappers a few more options for their maps. I tried to make it
easy to use, but I haven't slept in 38 hours and I'm a zombie at this point...
so I hope you can figure it out.
In tests, large images produced a minimal amount of lag; but RTP-sized fogs
and panoramas didn't produce any noticable lag.
Credit goes to SephirothSpawn for his work in bringing tiles over the fog
layer. This allowed for depth of this script. He scripted the original Sprite_FogCover class, which is a heavily used inside this script.
Usage is pretty simple and straightforward. The script itself, on the other
hand, took me over 8 hours to hack out and is still choppy. I'll touch it up
over the next few days.
EDIT : :
Known Bugs:
Somehow, I lost control of the Fog_2_Priority. I can put it under everything,
or above everything. I can't seem to make the player move through it correctly.
If anyone can fix this, please, please help. I can't think anymore XD
To-Do:
Get the upper OVERFOG layer support working
Fix the subfog pindown (it's not working how I'd hoped...)
=end
# What terrain tag do you want to be the overfog layer?
$overfog_tag = 7
# Do you want to use the overfog ascension fix?
# (This makes it so that if you are standing 1 tile *below* an overfog tile,
# you are still on top. Keeps it from looking funny when climbing up or down)
$overfog_ascend_fix = true
# What terrain tag do you want to be the midfog layer? (Above the lower fog,
# below the upper fog)
$midfog_tag = 6
# Ascend fix this one?
$midfog_ascend_fix = true
#Pin down subfog events?
$subfog_fix = true
# How fast would you like the normal panorama to scroll?
$Map_Panorama_Speed = {
1 => {'x' => 3, 'y' => 0},
2 => {'x' => 0, 'y' => 5}
}
# What is the name of your panorama file?
# MAP ID => {'img' => 'FILENAME'}... etc. Should be under Graphics\Panoramas
$Panorama_2_File = {
1 => {'img' => "Sunset"},
2 => {'img' => "stripe"}
}
# How fast would you like your second (beneath) Panorama to scroll?
$Map_Panorama_2_Speed = {
1 => {'x' => -3, 'y' => 0},
2 => {'x' => 0, 'y' => 6}
}
# DEBUG SETTING - If you don't know what this is, don't touch it.
$Panorama_2_Priority = -1001
# DEBUG SETTING - If you don't know what this does, don't touch it.
# If you can fix the problem I mentioned above, dig in.
$Fog_2_Priority = 1
# Name of the second fog layer file (should be under Graphics\Fogs)
# MAP ID => {'img' => "FILENAME"}, MAP ID...
$Fog_2_File = {
1 => {'img' => "clouded"},
2 => {'img' => "stars"}
}
# How fast do you want the second fog layer to scroll?
# MAP ID => {'x' => X SPEED, 'y' => Y SPEED}, MAP ID...
$Map_Fog_2_Speed = {
1 => {'x' => -1, 'y' => 1},
2 => {'x' => 0, 'y' => 7}
}
###############################################################################
## END SETTINGS################################################################
###############################################################################
class Game_Character
alias zztheory_hack_priority screen_z
def screen_z(height = 0)
#Ascension Fix
if $overfog_ascend_fix = true
if $game_map.terrain_tag(@x, @y-1) == $overfog_tag
return 9999
end
end
if $game_player.terrain_tag == $overfog_tag
#set player priority for overfog tiles
return 9999
end
if $midfog_ascend_fix = true
if $game_map.terrain_tag(@x, @y-1) == $midfog_tag
return 3003
end
end
#This is a tricky one here.
if $subfog_fix = true
if $game_map.terrain_tag(@x, @y-1) != $midfog_tag
if $game_map.terrain_tag(@x, @y-1) != $overfog_tag
if $game_player.terrain_tag != $overfog_tag
if $game_player.terrain_tag != $midfog_tag
# Get screen coordinates from real coordinates and map display position
z = (@real_y - $game_map.display_y + 3) / 4 + 32
# If tile
if @tile_id > 0
# Add tile priority * 32
return z + $game_map.priorities[@tile_id] * 32
# If character
else
# If height exceeds 32, then add 31
return z + ((height > 32) ? 31 : 0)
end
end
end
end
end
end
if $game_player.terrain_tag == $midfog_tag
#set player priority for overfog tiles
return 3003
end
# If display flag on closest surface is ON
if @always_on_top
# 999, unconditional
return 999
end
# Get screen coordinates from real coordinates and map display position
z = (@real_y - $game_map.display_y + 3) / 4 + 32
# If tile
if @tile_id > 0
# Add tile priority * 32
return z + $game_map.priorities[@tile_id] * 32
# If character
else
# If height exceeds 32, then add 31
return z + ((height > 32) ? 31 : 0)
end
end
end
class Sprite_FogCover < Sprite
attr_accessor :tileset_name
attr_accessor :autotiles
attr_accessor :autotiles_name
attr_accessor :terrain_tags
attr_accessor :priorities
attr_reader :map_data
def initialize(viewport = nil)
super(viewport)
@refresh_data = nil
@autotiles_name = []
end
def map_data=(map_data)
@map_data = map_data
if self.bitmap != nil
self.bitmap.dispose
end
self.bitmap = Bitmap.new(@map_data.xsize * 32, @map_data.ysize * 32)
refresh
end
def refresh
@refresh_data = @map_data
for z in 0...@map_data.zsize
for x in 0...@map_data.xsize
for y in 0...@map_data.ysize
id = @map_data[x, y, z]
next if id == 0
next if terrain_tag(x, y) != $overfog_tag
id < 384 ? draw_autotile(x, y, id) : draw_tile(x, y, id)
end
end
end
end
def draw_tile(x, y, id)
bit = RPG::Cache.tile(@tileset_name, id, 0)
self.bitmap.blt(x * 32, y * 32, bit, Rect.new(0, 0, 32, 32))
end
def draw_autotile(x, y, tile_id)
filename = @autotiles_name[tile_id / 48 - 1]
bit = RPG::Cache.autotile_tile(filename, tile_id % 48)
self.bitmap.blt(x * 32, y * 32, bit, Rect.new(0, 0, 32, 32))
end
def update
if @refresh_data != @map_data || Graphics.frame_count % 16 == 0
refresh
end
end
def terrain_tag(x, y)
for i in [2, 1, 0]
tile_id = @map_data[x, y, i]
if tile_id == nil
return 0
elsif @terrain_tags[tile_id] > 0
return @terrain_tags[tile_id]
end
end
end
end
class Spriteset_Map
attr_accessor
panorama2
attr_accessor :fog2
alias_method :zzhack_old_init, :initialize
alias_method :seph_tilefogcover_scnmap_updt, :update
def initialize
@viewport0 = Viewport.new(0, 0, 640, 480) #
@viewport4 = Viewport.new(0, 0, 640, 480) #
@viewport4.z = $Fog_2_Priority
@fog2 = Plane.new(@viewport4)
$panoramamove_x = 0
$panoramamove_y = 0
$panoramaspeed_x = 0
$panoramaspeed_y = 0
$panorama2move_x = 0
$panorama2move_y = 0
$panorama2speed_x = 0
$panorama2speed_y = 0
$fog2move_x = 0
$fog2move_y = 0
$fog2speed_x = 0
$fog2speed_y = 0
@viewport0.z = $Panorama_2_Priority
@panorama2 = Plane.new(@viewport0) #
@panorama2.z = $Panorama_2_Priority
zzhack_old_init
@fog_cover_sprite = Sprite_FogCover.new(@viewport1)
@fog_cover_sprite.tileset_name = $game_map.tileset_name
@fog_cover_sprite.autotiles = @tilemap.autotiles
for i in 0..6
@fog_cover_sprite.autotiles_name = $game_map.autotile_names
end
@fog_cover_sprite.terrain_tags = $game_map.terrain_tags
@fog_cover_sprite.priorities = $game_map.priorities
@fog_cover_sprite.map_data = $game_map.data
@fog_cover_sprite.z = 3002
end
def update
if $Panorama_2_File[$game_map.map_id] != nil #
if $Panorama_2_Color == nil
$Panorama_2_Color = 0
end
$zz_h4x0rTEMP = $Panorama_2_File[$game_map.map_id]
@panorama2.bitmap = RPG::Cache.panorama($zz_h4x0rTEMP['img'], $Panorama_2_Color) #
end #
seph_tilefogcover_scnmap_updt
unless @fog_cover_sprite.nil?
@fog_cover_sprite.update
@fog_cover_sprite.ox = @tilemap.ox
@fog_cover_sprite.oy = @tilemap.oy
end
@panorama.ox = $game_map.display_x / 8 + $panoramamove_x
@panorama.oy = $game_map.display_y / 8 + $panoramamove_y
@panorama2.ox = $game_map.display_x / 8 + $panorama2move_x
@panorama2.oy = $game_map.display_y / 8 + $panorama2move_y
@viewport0.update #
@viewport0.tone = $game_screen.tone #
@viewport0.ox = $game_screen.shake #
if $Fog_2_File[$game_map.map_id] != nil #
fog2temp2 = $Fog_2_File[$game_map.map_id]
fog2temp = "Graphics/Fogs/" + fog2temp2['img']
fog2temp3 = fog2temp['img']
@fog2.bitmap = RPG::Cache.fog(fog2temp2['img'], 0)
end #
@fog2.ox = $game_map.display_x / 8 + $fog2move_x
@fog2.oy = $game_map.display_y / 8 + $fog2move_y
end
alias_method :zz_hack_pandispose, :dispose
def dispose
zz_hack_pandispose
@panorama2.dispose #
@viewport0.dispose #
@fog2.dispose
@viewport4.dispose
end
end
module RPG::Cache
#--------------------------------------------------------------------------
# * Auto-Tiles
#--------------------------------------------------------------------------
Autotiles = [
[[27, 28, 33, 34], [ 5, 28, 33, 34], [27, 6, 33, 34], [ 5, 6, 33, 34],
[27, 28, 33, 12], [ 5, 28, 33, 12], [27, 6, 33, 12], [ 5, 6, 33, 12]],
[[27, 28, 11, 34], [ 5, 28, 11, 34], [27, 6, 11, 34], [ 5, 6, 11, 34],
[27, 28, 11, 12], [ 5, 28, 11, 12], [27, 6, 11, 12], [ 5, 6, 11, 12]],
[[25, 26, 31, 32], [25, 6, 31, 32], [25, 26, 31, 12], [25, 6, 31, 12],
[15, 16, 21, 22], [15, 16, 21, 12], [15, 16, 11, 22], [15, 16, 11, 12]],
[[29, 30, 35, 36], [29, 30, 11, 36], [ 5, 30, 35, 36], [ 5, 30, 11, 36],
[39, 40, 45, 46], [ 5, 40, 45, 46], [39, 6, 45, 46], [ 5, 6, 45, 46]],
[[25, 30, 31, 36], [15, 16, 45, 46], [13, 14, 19, 20], [13, 14, 19, 12],
[17, 18, 23, 24], [17, 18, 11, 24], [41, 42, 47, 48], [ 5, 42, 47, 48]],
[[37, 38, 43, 44], [37, 6, 43, 44], [13, 18, 19, 24], [13, 14, 43, 44],
[37, 42, 43, 48], [17, 18, 47, 48], [13, 18, 43, 48], [ 1, 2, 7, 8]]
]
#--------------------------------------------------------------------------
# * Autotile Cache
#
# @autotile_cache = {
# filename => { [autotile_id, frame_id, hue] => bitmap, ... },
# ...
# }
#--------------------------------------------------------------------------
@autotile_cache = {}
#--------------------------------------------------------------------------
# * Autotile Tile
#--------------------------------------------------------------------------
def self.autotile_tile(filename, tile_id, hue = 0, frame_id = nil)
# Gets Autotile Bitmap
autotile = self.autotile(filename)
# Configures Frame ID if not specified
if frame_id.nil?
# Animated Tiles
frames = autotile.width / 96
# Configures Animation Offset
fc = Graphics.frame_count / 16
frame_id = (fc) % frames * 96
end
# Creates list if already not created
@autotile_cache[filename] = {} unless @autotile_cache.has_key?(filename)
# Gets Key
key = [tile_id, frame_id, hue]
# If Key Not Found
unless @autotile_cache[filename].has_key?(key)
# Reconfigure Tile ID
tile_id %= 48
# Creates Bitmap
bitmap = Bitmap.new(32, 32)
# Collects Auto-Tile Tile Layout
tiles = Autotiles[tile_id / 8][tile_id % 8]
# Draws Auto-Tile Rects
for i in 0...4
tile_position = tiles - 1
src_rect = Rect.new(tile_position % 6 * 16 + frame_id,
tile_position / 6 * 16, 16, 16)
bitmap.blt(i % 2 * 16, i / 2 * 16, autotile, src_rect)
end
# Saves Autotile to Cache
@autotile_cache[filename][key] = bitmap
# Change Hue
@autotile_cache[filename][key].hue_change(hue)
end
# Return Autotile
return @autotile_cache[filename][key]
end
end
class Scene_Map
def update
$zz_mapID = $game_map.map_id
if $Map_Panorama_Speed.has_key?($zz_mapID)
settings = $Map_Panorama_Speed[$zz_mapID]
settings_x = settings['x']
settings_y = settings['y']
# If Setting Is Nil
if settings_y.nil?
# Set Speeds to Zero
$settings_y = 0
end
if settings_x.nil?
# Set Speeds to Zero
$settings_x = 0
end
# Sets Defined Parameters
$panoramaspeed_x = settings_x
$panoramaspeed_y = settings_y
end
####Begin Pano 2 speed
if $Map_Panorama_2_Speed.has_key?($zz_mapID)
settings2 = $Map_Panorama_2_Speed[$zz_mapID]
settings2_x = settings2['x']
settings2_y = settings2['y']
# If Setting Is Nil
if settings2_y.nil?
# Set Speeds to Zero
$settings2_y = 0
end
if settings2_x.nil?
# Set Speeds to Zero
$settings2_x = 0
end
# Sets Defined Parameters
$panorama2speed_x = settings2_x
$panorama2speed_y = settings2_y
end
####Begin Fog 2 speed
if $Map_Fog_2_Speed.has_key?($zz_mapID)
fsettings2 = $Map_Fog_2_Speed[$zz_mapID]
fsettings2_x = fsettings2['x']
fsettings2_y = fsettings2['y']
# If Setting Is Nil
if fsettings2_y.nil?
# Set Speeds to Zero
$fsettings2_y = 0
end
if fsettings2_x.nil?
# Set Speeds to Zero
$fsettings2_x = 0
end
# Sets Defined Parameters
$fog2speed_x = fsettings2_x
$fog2speed_y = fsettings2_y
end
$panoramamove_x -= $panoramaspeed_x
$panoramamove_y -= $panoramaspeed_y
$panorama2move_x -= $panorama2speed_x
$panorama2move_y -= $panorama2speed_y
$fog2move_x -= $fog2speed_x
$fog2move_y -= $fog2speed_y
# 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
# If encounter list isn't empty, and encounter count is 0
if $game_player.encounter_count == 0 and $game_map.encounter_list != []
# If event is running or encounter is not forbidden
unless $game_system.map_interpreter.running? or
$game_system.encounter_disabled
# Confirm troop
n = rand($game_map.encounter_list.size)
troop_id = $game_map.encounter_list[n]
# If troop is valid
if $data_troops[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
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++ theory's advanced map layers
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Version 0.9 Beta
October 15th, 2008
Introduction:
The purpose of this script is to grant mappers more layers to work with,
in hopes of seeing some higher quality maps made from this.
First off, added the ability to scroll the panorama. Don't know why this wasn't
included. Makes boat scenes sooo much easier. (scrolling water...)
I've added a second panorama layer- this layer is *below* the default layer
due to my inability to get priorities to cooperate.
There's also a second fog layer now. This layer is *above* the default layer,
again because the priorities hate me.
And then the fun part. Based on terrain tags, tiles can be displayed above the
lower fog, and then additionally above the upper fog. This is to add depth.
Better yet, the player can ascend and descend through these fogs dynamically.
This should allow mappers a few more options for their maps. I tried to make it
easy to use, but I haven't slept in 38 hours and I'm a zombie at this point...
so I hope you can figure it out.
In tests, large images produced a minimal amount of lag; but RTP-sized fogs
and panoramas didn't produce any noticable lag.
Credit goes to SephirothSpawn for his work in bringing tiles over the fog
layer. This allowed for depth of this script. He scripted the original Sprite_FogCover class, which is a heavily used inside this script.
Usage is pretty simple and straightforward. The script itself, on the other
hand, took me over 8 hours to hack out and is still choppy. I'll touch it up
over the next few days.
EDIT : :
Known Bugs:
Somehow, I lost control of the Fog_2_Priority. I can put it under everything,
or above everything. I can't seem to make the player move through it correctly.
If anyone can fix this, please, please help. I can't think anymore XD
To-Do:
Get the upper OVERFOG layer support working
Fix the subfog pindown (it's not working how I'd hoped...)
=end
# What terrain tag do you want to be the overfog layer?
$overfog_tag = 7
# Do you want to use the overfog ascension fix?
# (This makes it so that if you are standing 1 tile *below* an overfog tile,
# you are still on top. Keeps it from looking funny when climbing up or down)
$overfog_ascend_fix = true
# What terrain tag do you want to be the midfog layer? (Above the lower fog,
# below the upper fog)
$midfog_tag = 6
# Ascend fix this one?
$midfog_ascend_fix = true
#Pin down subfog events?
$subfog_fix = true
# How fast would you like the normal panorama to scroll?
$Map_Panorama_Speed = {
1 => {'x' => 3, 'y' => 0},
2 => {'x' => 0, 'y' => 5}
}
# What is the name of your panorama file?
# MAP ID => {'img' => 'FILENAME'}... etc. Should be under Graphics\Panoramas
$Panorama_2_File = {
1 => {'img' => "Sunset"},
2 => {'img' => "stripe"}
}
# How fast would you like your second (beneath) Panorama to scroll?
$Map_Panorama_2_Speed = {
1 => {'x' => -3, 'y' => 0},
2 => {'x' => 0, 'y' => 6}
}
# DEBUG SETTING - If you don't know what this is, don't touch it.
$Panorama_2_Priority = -1001
# DEBUG SETTING - If you don't know what this does, don't touch it.
# If you can fix the problem I mentioned above, dig in.
$Fog_2_Priority = 1
# Name of the second fog layer file (should be under Graphics\Fogs)
# MAP ID => {'img' => "FILENAME"}, MAP ID...
$Fog_2_File = {
1 => {'img' => "clouded"},
2 => {'img' => "stars"}
}
# How fast do you want the second fog layer to scroll?
# MAP ID => {'x' => X SPEED, 'y' => Y SPEED}, MAP ID...
$Map_Fog_2_Speed = {
1 => {'x' => -1, 'y' => 1},
2 => {'x' => 0, 'y' => 7}
}
###############################################################################
## END SETTINGS################################################################
###############################################################################
class Game_Character
alias zztheory_hack_priority screen_z
def screen_z(height = 0)
#Ascension Fix
if $overfog_ascend_fix = true
if $game_map.terrain_tag(@x, @y-1) == $overfog_tag
return 9999
end
end
if $game_player.terrain_tag == $overfog_tag
#set player priority for overfog tiles
return 9999
end
if $midfog_ascend_fix = true
if $game_map.terrain_tag(@x, @y-1) == $midfog_tag
return 3003
end
end
#This is a tricky one here.
if $subfog_fix = true
if $game_map.terrain_tag(@x, @y-1) != $midfog_tag
if $game_map.terrain_tag(@x, @y-1) != $overfog_tag
if $game_player.terrain_tag != $overfog_tag
if $game_player.terrain_tag != $midfog_tag
# Get screen coordinates from real coordinates and map display position
z = (@real_y - $game_map.display_y + 3) / 4 + 32
# If tile
if @tile_id > 0
# Add tile priority * 32
return z + $game_map.priorities[@tile_id] * 32
# If character
else
# If height exceeds 32, then add 31
return z + ((height > 32) ? 31 : 0)
end
end
end
end
end
end
if $game_player.terrain_tag == $midfog_tag
#set player priority for overfog tiles
return 3003
end
# If display flag on closest surface is ON
if @always_on_top
# 999, unconditional
return 999
end
# Get screen coordinates from real coordinates and map display position
z = (@real_y - $game_map.display_y + 3) / 4 + 32
# If tile
if @tile_id > 0
# Add tile priority * 32
return z + $game_map.priorities[@tile_id] * 32
# If character
else
# If height exceeds 32, then add 31
return z + ((height > 32) ? 31 : 0)
end
end
end
class Sprite_FogCover < Sprite
attr_accessor :tileset_name
attr_accessor :autotiles
attr_accessor :autotiles_name
attr_accessor :terrain_tags
attr_accessor :priorities
attr_reader :map_data
def initialize(viewport = nil)
super(viewport)
@refresh_data = nil
@autotiles_name = []
end
def map_data=(map_data)
@map_data = map_data
if self.bitmap != nil
self.bitmap.dispose
end
self.bitmap = Bitmap.new(@map_data.xsize * 32, @map_data.ysize * 32)
refresh
end
def refresh
@refresh_data = @map_data
for z in 0...@map_data.zsize
for x in 0...@map_data.xsize
for y in 0...@map_data.ysize
id = @map_data[x, y, z]
next if id == 0
next if terrain_tag(x, y) != $overfog_tag
id < 384 ? draw_autotile(x, y, id) : draw_tile(x, y, id)
end
end
end
end
def draw_tile(x, y, id)
bit = RPG::Cache.tile(@tileset_name, id, 0)
self.bitmap.blt(x * 32, y * 32, bit, Rect.new(0, 0, 32, 32))
end
def draw_autotile(x, y, tile_id)
filename = @autotiles_name[tile_id / 48 - 1]
bit = RPG::Cache.autotile_tile(filename, tile_id % 48)
self.bitmap.blt(x * 32, y * 32, bit, Rect.new(0, 0, 32, 32))
end
def update
if @refresh_data != @map_data || Graphics.frame_count % 16 == 0
refresh
end
end
def terrain_tag(x, y)
for i in [2, 1, 0]
tile_id = @map_data[x, y, i]
if tile_id == nil
return 0
elsif @terrain_tags[tile_id] > 0
return @terrain_tags[tile_id]
end
end
end
end
class Spriteset_Map
attr_accessor
attr_accessor :fog2
alias_method :zzhack_old_init, :initialize
alias_method :seph_tilefogcover_scnmap_updt, :update
def initialize
@viewport0 = Viewport.new(0, 0, 640, 480) #
@viewport4 = Viewport.new(0, 0, 640, 480) #
@viewport4.z = $Fog_2_Priority
@fog2 = Plane.new(@viewport4)
$panoramamove_x = 0
$panoramamove_y = 0
$panoramaspeed_x = 0
$panoramaspeed_y = 0
$panorama2move_x = 0
$panorama2move_y = 0
$panorama2speed_x = 0
$panorama2speed_y = 0
$fog2move_x = 0
$fog2move_y = 0
$fog2speed_x = 0
$fog2speed_y = 0
@viewport0.z = $Panorama_2_Priority
@panorama2 = Plane.new(@viewport0) #
@panorama2.z = $Panorama_2_Priority
zzhack_old_init
@fog_cover_sprite = Sprite_FogCover.new(@viewport1)
@fog_cover_sprite.tileset_name = $game_map.tileset_name
@fog_cover_sprite.autotiles = @tilemap.autotiles
for i in 0..6
@fog_cover_sprite.autotiles_name = $game_map.autotile_names
end
@fog_cover_sprite.terrain_tags = $game_map.terrain_tags
@fog_cover_sprite.priorities = $game_map.priorities
@fog_cover_sprite.map_data = $game_map.data
@fog_cover_sprite.z = 3002
end
def update
if $Panorama_2_File[$game_map.map_id] != nil #
if $Panorama_2_Color == nil
$Panorama_2_Color = 0
end
$zz_h4x0rTEMP = $Panorama_2_File[$game_map.map_id]
@panorama2.bitmap = RPG::Cache.panorama($zz_h4x0rTEMP['img'], $Panorama_2_Color) #
end #
seph_tilefogcover_scnmap_updt
unless @fog_cover_sprite.nil?
@fog_cover_sprite.update
@fog_cover_sprite.ox = @tilemap.ox
@fog_cover_sprite.oy = @tilemap.oy
end
@panorama.ox = $game_map.display_x / 8 + $panoramamove_x
@panorama.oy = $game_map.display_y / 8 + $panoramamove_y
@panorama2.ox = $game_map.display_x / 8 + $panorama2move_x
@panorama2.oy = $game_map.display_y / 8 + $panorama2move_y
@viewport0.update #
@viewport0.tone = $game_screen.tone #
@viewport0.ox = $game_screen.shake #
if $Fog_2_File[$game_map.map_id] != nil #
fog2temp2 = $Fog_2_File[$game_map.map_id]
fog2temp = "Graphics/Fogs/" + fog2temp2['img']
fog2temp3 = fog2temp['img']
@fog2.bitmap = RPG::Cache.fog(fog2temp2['img'], 0)
end #
@fog2.ox = $game_map.display_x / 8 + $fog2move_x
@fog2.oy = $game_map.display_y / 8 + $fog2move_y
end
alias_method :zz_hack_pandispose, :dispose
def dispose
zz_hack_pandispose
@panorama2.dispose #
@viewport0.dispose #
@fog2.dispose
@viewport4.dispose
end
end
module RPG::Cache
#--------------------------------------------------------------------------
# * Auto-Tiles
#--------------------------------------------------------------------------
Autotiles = [
[[27, 28, 33, 34], [ 5, 28, 33, 34], [27, 6, 33, 34], [ 5, 6, 33, 34],
[27, 28, 33, 12], [ 5, 28, 33, 12], [27, 6, 33, 12], [ 5, 6, 33, 12]],
[[27, 28, 11, 34], [ 5, 28, 11, 34], [27, 6, 11, 34], [ 5, 6, 11, 34],
[27, 28, 11, 12], [ 5, 28, 11, 12], [27, 6, 11, 12], [ 5, 6, 11, 12]],
[[25, 26, 31, 32], [25, 6, 31, 32], [25, 26, 31, 12], [25, 6, 31, 12],
[15, 16, 21, 22], [15, 16, 21, 12], [15, 16, 11, 22], [15, 16, 11, 12]],
[[29, 30, 35, 36], [29, 30, 11, 36], [ 5, 30, 35, 36], [ 5, 30, 11, 36],
[39, 40, 45, 46], [ 5, 40, 45, 46], [39, 6, 45, 46], [ 5, 6, 45, 46]],
[[25, 30, 31, 36], [15, 16, 45, 46], [13, 14, 19, 20], [13, 14, 19, 12],
[17, 18, 23, 24], [17, 18, 11, 24], [41, 42, 47, 48], [ 5, 42, 47, 48]],
[[37, 38, 43, 44], [37, 6, 43, 44], [13, 18, 19, 24], [13, 14, 43, 44],
[37, 42, 43, 48], [17, 18, 47, 48], [13, 18, 43, 48], [ 1, 2, 7, 8]]
]
#--------------------------------------------------------------------------
# * Autotile Cache
#
# @autotile_cache = {
# filename => { [autotile_id, frame_id, hue] => bitmap, ... },
# ...
# }
#--------------------------------------------------------------------------
@autotile_cache = {}
#--------------------------------------------------------------------------
# * Autotile Tile
#--------------------------------------------------------------------------
def self.autotile_tile(filename, tile_id, hue = 0, frame_id = nil)
# Gets Autotile Bitmap
autotile = self.autotile(filename)
# Configures Frame ID if not specified
if frame_id.nil?
# Animated Tiles
frames = autotile.width / 96
# Configures Animation Offset
fc = Graphics.frame_count / 16
frame_id = (fc) % frames * 96
end
# Creates list if already not created
@autotile_cache[filename] = {} unless @autotile_cache.has_key?(filename)
# Gets Key
key = [tile_id, frame_id, hue]
# If Key Not Found
unless @autotile_cache[filename].has_key?(key)
# Reconfigure Tile ID
tile_id %= 48
# Creates Bitmap
bitmap = Bitmap.new(32, 32)
# Collects Auto-Tile Tile Layout
tiles = Autotiles[tile_id / 8][tile_id % 8]
# Draws Auto-Tile Rects
for i in 0...4
tile_position = tiles - 1
src_rect = Rect.new(tile_position % 6 * 16 + frame_id,
tile_position / 6 * 16, 16, 16)
bitmap.blt(i % 2 * 16, i / 2 * 16, autotile, src_rect)
end
# Saves Autotile to Cache
@autotile_cache[filename][key] = bitmap
# Change Hue
@autotile_cache[filename][key].hue_change(hue)
end
# Return Autotile
return @autotile_cache[filename][key]
end
end
class Scene_Map
def update
$zz_mapID = $game_map.map_id
if $Map_Panorama_Speed.has_key?($zz_mapID)
settings = $Map_Panorama_Speed[$zz_mapID]
settings_x = settings['x']
settings_y = settings['y']
# If Setting Is Nil
if settings_y.nil?
# Set Speeds to Zero
$settings_y = 0
end
if settings_x.nil?
# Set Speeds to Zero
$settings_x = 0
end
# Sets Defined Parameters
$panoramaspeed_x = settings_x
$panoramaspeed_y = settings_y
end
####Begin Pano 2 speed
if $Map_Panorama_2_Speed.has_key?($zz_mapID)
settings2 = $Map_Panorama_2_Speed[$zz_mapID]
settings2_x = settings2['x']
settings2_y = settings2['y']
# If Setting Is Nil
if settings2_y.nil?
# Set Speeds to Zero
$settings2_y = 0
end
if settings2_x.nil?
# Set Speeds to Zero
$settings2_x = 0
end
# Sets Defined Parameters
$panorama2speed_x = settings2_x
$panorama2speed_y = settings2_y
end
####Begin Fog 2 speed
if $Map_Fog_2_Speed.has_key?($zz_mapID)
fsettings2 = $Map_Fog_2_Speed[$zz_mapID]
fsettings2_x = fsettings2['x']
fsettings2_y = fsettings2['y']
# If Setting Is Nil
if fsettings2_y.nil?
# Set Speeds to Zero
$fsettings2_y = 0
end
if fsettings2_x.nil?
# Set Speeds to Zero
$fsettings2_x = 0
end
# Sets Defined Parameters
$fog2speed_x = fsettings2_x
$fog2speed_y = fsettings2_y
end
$panoramamove_x -= $panoramaspeed_x
$panoramamove_y -= $panoramaspeed_y
$panorama2move_x -= $panorama2speed_x
$panorama2move_y -= $panorama2speed_y
$fog2move_x -= $fog2speed_x
$fog2move_y -= $fog2speed_y
# 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
# If encounter list isn't empty, and encounter count is 0
if $game_player.encounter_count == 0 and $game_map.encounter_list != []
# If event is running or encounter is not forbidden
unless $game_system.map_interpreter.running? or
$game_system.encounter_disabled
# Confirm troop
n = rand($game_map.encounter_list.size)
troop_id = $game_map.encounter_list[n]
# If troop is valid
if $data_troops[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
This script increases the amount of layers and options available to mappers.
For details on what this script does, see the introduction in the script itself.
Oh, and credit goes to SephirothSpawn because without his hint about rendering tiles over fog, this script wouldn't have been nearly as good.
Feedback, people, please! It's appreciated and I will be listening for any suggestions or critique. Even if it's negative.
Edit:
Thanks for not yelling at me for submitting something so choppy- I hadn't had much sleep. I slept for 5 hours and it's *much* better now. Removed the crash-related bugs. All that's left to fix is the overfog and midfog layers- they still don't quite display right. The overfog layer is displaying under fog 2...
Screens : :
http://hosting07.imagecross.com/image-hosting-05/6031s1.jpg[/img]
The mountain demo - shows all 10 layers in action
(Panorama 2, Panorama 1, Tile 1, Tile 2, Tile 3, Events, Fog 1, Midfog, Fog 2, Overfog)
(Midfog and Overfog are Psuedolayers)
http://hosting07.imagecross.com/image-h ... 5800s2.jpg[/img]
This shows the starlight demo. This just demonstrates one application of this script.
http://hosting07.imagecross.com/image-h ... 6305s3.jpg[/img]
This is the water demo, a powerful use of this script. In this shot, he's on the Overfog layer.
http://hosting07.imagecross.com/image-h ... 7188s4.png[/img]
Another water demo shot, this time on the Subfog Layer.
The mountain demo - shows all 10 layers in action
(Panorama 2, Panorama 1, Tile 1, Tile 2, Tile 3, Events, Fog 1, Midfog, Fog 2, Overfog)
(Midfog and Overfog are Psuedolayers)
http://hosting07.imagecross.com/image-h ... 5800s2.jpg[/img]
This shows the starlight demo. This just demonstrates one application of this script.
http://hosting07.imagecross.com/image-h ... 6305s3.jpg[/img]
This is the water demo, a powerful use of this script. In this shot, he's on the Overfog layer.
http://hosting07.imagecross.com/image-h ... 7188s4.png[/img]
Another water demo shot, this time on the Subfog Layer.