Double Fogs
Version: 1.0
Introduction
This script let's you use two fogs at once. You control it with the "Script..." event command. Instructions are at the beginning of the script.
Screenshots
Demo
None.
Script
Instructions
Place the script in a new script above main, make sure it is below Game_Map and Spriteset_Map. All the instructions on how to use the script are at the beginning of the script.
Credits and Thanks
Shinasura for requesting it.
Author's Notes
If you use the script in your game, please give credit to me. (Daniel3579)
Version: 1.0
Introduction
This script let's you use two fogs at once. You control it with the "Script..." event command. Instructions are at the beginning of the script.
Screenshots
Screenshot
Spoiler
http://img149.imageshack.us/img149/3361/doublefogsscriptscreenshotnw2.png[/img]
Demo
None.
Script
script
Spoiler
#==============================================================================
# ** Double Fogs Script
# By: Daniel3579
#------------------------------------------------------------------------------
# The second fog appears over the first one.
# All of the below commands are done in the "Script..." event command.
# To change the 2nd fog, use $game_map.fog2_name = "filename"
# To change the 2nd fog's hue, use $game_map.fog2_hue = n
# n is equal to 0 through 360.
# To change the 2nd fog's opacity, use $game_map.fog2_opacity = n
# To change the 2nd fog's blend type, use $game_map.fog2_blend_type = n
# n is equal to 0, 1, or 2. 0 is normal.
# To change the 2nd fog's zoom, use $game_map.fog2_zoom = n
# n has to be a decimal, 1.0 is actual size.
# To change the 2nd fog's horizontal scroll, use $game_map.fog2_sx = n
# n is -256 to 256. 0 is still.
# To change the 2nd fog's vertical scroll, use $game_map.fog2_sy = n
# n is -256 to 256. 0 is still.
# To change the 2nd fog's tone, use $game_map.fog2_tone = tone
# tone is Tone.new(red, green, blue[, gray])
# To start a tone change in the 2nd fog, use
# $game_map.start_fog2_tone_change(tone, duration)
# tone is Tone.new(red, green, blue[, gray]) and
# duration is the amount of frames.
# To start an opacity change in the 2nd fog, use
# $game_map.start_fog2_opacity_change(opacity, duration)
# opacity is the opacity you want it to change to, and
# duration is the amount of frames it takes to change.
#==============================================================================
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles the map. It includes scrolling and passable determining
# functions. Refer to "$game_map" for the instance of this class.
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :fog2_name # fog2 file name
attr_accessor :fog2_hue # fog2 hue
attr_accessor :fog2_opacity # fog2 opacity level
attr_accessor :fog2_blend_type # fog2 blending method
attr_accessor :fog2_zoom # fog2 zoom rate
attr_accessor :fog2_sx # fog2 sx
attr_accessor :fog2_sy # fog2 sy
attr_reader :fog2_ox # fog2 x-coordinate starting point
attr_reader :fog2_oy # fog2 y-coordinate starting point
attr_reader :fog2_tone # fog2 color tone
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias daniel_fog2_setup setup
alias daniel_fog2_update update
#--------------------------------------------------------------------------
# * Setup
# map_id : map ID
#--------------------------------------------------------------------------
def setup(map_id)
daniel_fog2_setup(map_id)
@fog2_name = ""
@fog2_hue = 0
@fog2_opacity = 64
@fog2_blend_type = 0
@fog2_zoom = 200
@fog2_sx = 0
@fog2_sy = 0
@fog2_ox = 0
@fog2_oy = 0
@fog2_tone = Tone.new(0, 0, 0, 0)
@fog2_tone_target = Tone.new(0, 0, 0, 0)
@fog2_tone_duration = 0
@fog2_opacity_duration = 0
@fog2_opacity_target = 0
end
#--------------------------------------------------------------------------
# * Start Changing Fog Color Tone
# tone : color tone
# duration : time
#--------------------------------------------------------------------------
def start_fog2_tone_change(tone, duration)
@fog2_tone_target = tone.clone
@fog2_tone_duration = duration
if @fog2_tone_duration == 0
@fog2_tone = @fog2_tone_target.clone
end
end
#--------------------------------------------------------------------------
# * Start Changing Fog Opacity Level
# opacity : opacity level
# duration : time
#--------------------------------------------------------------------------
def start_fog2_opacity_change(opacity, duration)
@fog2_opacity_target = opacity * 1.0
@fog2_opacity_duration = duration
if @fog2_opacity_duration == 0
@fog2_opacity = @fog2_opacity_target
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
daniel_fog2_update
@fog2_ox -= @fog2_sx / 8.0
@fog2_oy -= @fog2_sy / 8.0
if @fog2_tone_duration >= 1
d = @fog2_tone_duration
target = @fog2_tone_target
@fog2_tone.red = (@fog2_tone.red * (d - 1) + target.red) / d
@fog2_tone.green = (@fog2_tone.green * (d - 1) + target.green) / d
@fog2_tone.blue = (@fog2_tone.blue * (d - 1) + target.blue) / d
@fog2_tone.gray = (@fog2_tone.gray * (d - 1) + target.gray) / d
@fog2_tone_duration -= 1
end
if @fog2_opacity_duration >= 1
d = @fog2_opacity_duration
@fog2_opacity = (@fog2_opacity * (d - 1) + @fog2_opacity_target) / d
@fog2_opacity_duration -= 1
end
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc.
# It's used within the Scene_Map class.
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias daniel_fog2_dispose dispose
alias daniel_fog2_update update
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Make viewports
@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
# Make tilemap
@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
# Make panorama plane
@panorama = Plane.new(@viewport1)
@panorama.z = -1000
# Make fog plane
@fog = Plane.new(@viewport1)
@fog.z = 3000
# Make fog2 plane
@fog2 = Plane.new(@viewport1)
@fog2.z = 3050
# Make character sprites
@character_sprites = []
for i in $game_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
@character_sprites.push(sprite)
end
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
# Make weather
@weather = RPG::Weather.new(@viewport1)
# Make picture sprites
@picture_sprites = []
for i in 1..50
@picture_sprites.push(Sprite_Picture.new(@viewport2,
$game_screen.pictures[i]))
end
# Make timer sprite
@timer_sprite = Sprite_Timer.new
# Frame update
update
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
daniel_fog2_dispose
@fog2.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
daniel_fog2_update
if @fog2_name != $game_map.fog2_name or @fog2_hue != $game_map.fog2_hue
@fog2_name = $game_map.fog2_name
@fog2_hue = $game_map.fog2_hue
if @fog2.bitmap != nil
@fog2.bitmap.dispose
@fog2.bitmap = nil
end
if @fog2_name != ""
@fog2.bitmap = RPG::Cache.fog(@fog2_name, @fog2_hue)
end
Graphics.frame_reset
end
# Update fog2 plane
@fog2.zoom_x = $game_map.fog2_zoom / 100.0
@fog2.zoom_y = $game_map.fog2_zoom / 100.0
@fog2.opacity = $game_map.fog2_opacity
@fog2.blend_type = $game_map.fog2_blend_type
@fog2.ox = $game_map.display_x / 4 + $game_map.fog2_ox
@fog2.oy = $game_map.display_y / 4 + $game_map.fog2_oy
@fog2.tone = $game_map.fog2_tone
end
end
# ** Double Fogs Script
# By: Daniel3579
#------------------------------------------------------------------------------
# The second fog appears over the first one.
# All of the below commands are done in the "Script..." event command.
# To change the 2nd fog, use $game_map.fog2_name = "filename"
# To change the 2nd fog's hue, use $game_map.fog2_hue = n
# n is equal to 0 through 360.
# To change the 2nd fog's opacity, use $game_map.fog2_opacity = n
# To change the 2nd fog's blend type, use $game_map.fog2_blend_type = n
# n is equal to 0, 1, or 2. 0 is normal.
# To change the 2nd fog's zoom, use $game_map.fog2_zoom = n
# n has to be a decimal, 1.0 is actual size.
# To change the 2nd fog's horizontal scroll, use $game_map.fog2_sx = n
# n is -256 to 256. 0 is still.
# To change the 2nd fog's vertical scroll, use $game_map.fog2_sy = n
# n is -256 to 256. 0 is still.
# To change the 2nd fog's tone, use $game_map.fog2_tone = tone
# tone is Tone.new(red, green, blue[, gray])
# To start a tone change in the 2nd fog, use
# $game_map.start_fog2_tone_change(tone, duration)
# tone is Tone.new(red, green, blue[, gray]) and
# duration is the amount of frames.
# To start an opacity change in the 2nd fog, use
# $game_map.start_fog2_opacity_change(opacity, duration)
# opacity is the opacity you want it to change to, and
# duration is the amount of frames it takes to change.
#==============================================================================
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles the map. It includes scrolling and passable determining
# functions. Refer to "$game_map" for the instance of this class.
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :fog2_name # fog2 file name
attr_accessor :fog2_hue # fog2 hue
attr_accessor :fog2_opacity # fog2 opacity level
attr_accessor :fog2_blend_type # fog2 blending method
attr_accessor :fog2_zoom # fog2 zoom rate
attr_accessor :fog2_sx # fog2 sx
attr_accessor :fog2_sy # fog2 sy
attr_reader :fog2_ox # fog2 x-coordinate starting point
attr_reader :fog2_oy # fog2 y-coordinate starting point
attr_reader :fog2_tone # fog2 color tone
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias daniel_fog2_setup setup
alias daniel_fog2_update update
#--------------------------------------------------------------------------
# * Setup
# map_id : map ID
#--------------------------------------------------------------------------
def setup(map_id)
daniel_fog2_setup(map_id)
@fog2_name = ""
@fog2_hue = 0
@fog2_opacity = 64
@fog2_blend_type = 0
@fog2_zoom = 200
@fog2_sx = 0
@fog2_sy = 0
@fog2_ox = 0
@fog2_oy = 0
@fog2_tone = Tone.new(0, 0, 0, 0)
@fog2_tone_target = Tone.new(0, 0, 0, 0)
@fog2_tone_duration = 0
@fog2_opacity_duration = 0
@fog2_opacity_target = 0
end
#--------------------------------------------------------------------------
# * Start Changing Fog Color Tone
# tone : color tone
# duration : time
#--------------------------------------------------------------------------
def start_fog2_tone_change(tone, duration)
@fog2_tone_target = tone.clone
@fog2_tone_duration = duration
if @fog2_tone_duration == 0
@fog2_tone = @fog2_tone_target.clone
end
end
#--------------------------------------------------------------------------
# * Start Changing Fog Opacity Level
# opacity : opacity level
# duration : time
#--------------------------------------------------------------------------
def start_fog2_opacity_change(opacity, duration)
@fog2_opacity_target = opacity * 1.0
@fog2_opacity_duration = duration
if @fog2_opacity_duration == 0
@fog2_opacity = @fog2_opacity_target
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
daniel_fog2_update
@fog2_ox -= @fog2_sx / 8.0
@fog2_oy -= @fog2_sy / 8.0
if @fog2_tone_duration >= 1
d = @fog2_tone_duration
target = @fog2_tone_target
@fog2_tone.red = (@fog2_tone.red * (d - 1) + target.red) / d
@fog2_tone.green = (@fog2_tone.green * (d - 1) + target.green) / d
@fog2_tone.blue = (@fog2_tone.blue * (d - 1) + target.blue) / d
@fog2_tone.gray = (@fog2_tone.gray * (d - 1) + target.gray) / d
@fog2_tone_duration -= 1
end
if @fog2_opacity_duration >= 1
d = @fog2_opacity_duration
@fog2_opacity = (@fog2_opacity * (d - 1) + @fog2_opacity_target) / d
@fog2_opacity_duration -= 1
end
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc.
# It's used within the Scene_Map class.
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias daniel_fog2_dispose dispose
alias daniel_fog2_update update
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Make viewports
@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
# Make tilemap
@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
# Make panorama plane
@panorama = Plane.new(@viewport1)
@panorama.z = -1000
# Make fog plane
@fog = Plane.new(@viewport1)
@fog.z = 3000
# Make fog2 plane
@fog2 = Plane.new(@viewport1)
@fog2.z = 3050
# Make character sprites
@character_sprites = []
for i in $game_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
@character_sprites.push(sprite)
end
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
# Make weather
@weather = RPG::Weather.new(@viewport1)
# Make picture sprites
@picture_sprites = []
for i in 1..50
@picture_sprites.push(Sprite_Picture.new(@viewport2,
$game_screen.pictures[i]))
end
# Make timer sprite
@timer_sprite = Sprite_Timer.new
# Frame update
update
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
daniel_fog2_dispose
@fog2.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
daniel_fog2_update
if @fog2_name != $game_map.fog2_name or @fog2_hue != $game_map.fog2_hue
@fog2_name = $game_map.fog2_name
@fog2_hue = $game_map.fog2_hue
if @fog2.bitmap != nil
@fog2.bitmap.dispose
@fog2.bitmap = nil
end
if @fog2_name != ""
@fog2.bitmap = RPG::Cache.fog(@fog2_name, @fog2_hue)
end
Graphics.frame_reset
end
# Update fog2 plane
@fog2.zoom_x = $game_map.fog2_zoom / 100.0
@fog2.zoom_y = $game_map.fog2_zoom / 100.0
@fog2.opacity = $game_map.fog2_opacity
@fog2.blend_type = $game_map.fog2_blend_type
@fog2.ox = $game_map.display_x / 4 + $game_map.fog2_ox
@fog2.oy = $game_map.display_y / 4 + $game_map.fog2_oy
@fog2.tone = $game_map.fog2_tone
end
end
Expand to see the code.
Instructions
Place the script in a new script above main, make sure it is below Game_Map and Spriteset_Map. All the instructions on how to use the script are at the beginning of the script.
Credits and Thanks
Shinasura for requesting it.
Author's Notes
If you use the script in your game, please give credit to me. (Daniel3579)