Jump to content
Lil' Yami

Overlay Mapping

Recommended Posts

Introduction:

 

Since some people like the overlay mapping (aka parallax mapping), I have code this thing to Ace. I have used Hanzo Kimura’s idea to make this, of course this script have a new feature to make each layer in a map can be swapped to another image by variable. This means you can make day/night, etc… in ONE map.

 

Features:

 

- Have 4 layer: Ground, Parallax, Light, Shadow (Ground is under Character + Event)

- Easily make day/night or change overlay after event occuring.

 

Download:

 

Check my blog

or Direct Link here & Demo

Edited by Yami

Share this post


Link to post
Share on other sites

Hanzo isn't the only one who thought of it but at least Yami posted that s/he did get inspired by Hanzo's idea from the topic. So I think a credit on the script itself is optional?

Edited by Archeia Nessiah

Share this post


Link to post
Share on other sites

So let me get this right, you can use maps as layers?

So like one layer can be one map, then another map can be the middle layer, and then another can be the upper layer?

So in a way you can have 3 layers by way of maps with this?

Share this post


Link to post
Share on other sites

@Ponder

In a way, yes. An image similar to a parallax map acts like a layer in itself, and the script lets you to have a shadow layer, etc. via transparent images. Think of it like parallax mapping but with more ease.

 

It's worth using! Try the script.. ;3

 

Share this post


Link to post
Share on other sites

Do you can make a way that we can change de RGB collor ingame of the images in the overlay directory?

I assume you meant the Tint? It of course can and should be changed in the editor ;)

Share this post


Link to post
Share on other sites

Thanks a lot Yami ^^

 

I want to use this script for colouring the screen for dawn/day/night etc. but the transition betwen two layer (by the variable) is very abrupt. Do you have an idea to resolve the problem ?

Share this post


Link to post
Share on other sites

Nice idea ^^ I prefer progressive changement (like morrowind or skyrim style) so i think i will test to use screen tone 120 sec => change the variable => change tone 1sec but i'm not satisfied by this idea. Mmmmh...

Share this post


Link to post
Share on other sites

Yami, I started using your Overlay Mapping and got a weird issue with Victors Fog script. :s

(Using the columns and such that appear over the fog as parallaxes in the picture below.)

fogissue.png

Is there a quick fix to somehow set the parallax layer under the fogs level, or is this something I would need to talk to Victor about?

 

Link to his fog script:

http://www.rpgmakervxace.net/index.php?/topic/411-victor-engine-fog-effects/

Share this post


Link to post
Share on other sites

@Lear: test this edited fog (only edit viewport ~)

 

#==============================================================================
# ** Victor Engine - Fog Effect
#------------------------------------------------------------------------------
# Author : Victor Sant
#
# Version History:
#  v 1.00 - 2011.12.19 - First relase
#  v 1.01 - 2011.12.30 - Faster Regular Expressions
#  v 1.02 - 2012.01.02 - Fixed fog dispose when changing maps
#------------------------------------------------------------------------------
#  This script allows to add varied of effects to the maps. Fos are picutres
# placed above the player layer and loops. Differently from pictures the fog
# follows the map movement instead of the screen (this behavior can be changed)
# You can add various fogs to the map.
#------------------------------------------------------------------------------
# Compatibility
#   Requires the script 'Victor Engine - Basic Module'
#
# * Overwrite methods
#   None
#
# * Alias methods
#   class Game_Screen
#	 def initialize
#	 def clear
#	 def update
#
#   class Game_Map
#	 def setup(map_id)
#
#   class Spriteset_Map
#	 def initialize
#	 def dispose
#	 def update
#
#   class Game_Interpreter
#	 def comment_call
#
#------------------------------------------------------------------------------
# Instructions:
#  To instal the script, open you script editor and paste this script on
#  a new section on bellow the Materials section. This script must also
#  be bellow the script 'Victor Engine - Basic'
#  The fogs must be placed on the folder "Graphics/Fogs". Create a folder
#  named "Fogs" on the Graphics folder.
#
#------------------------------------------------------------------------------
# Maps and Comment calls note tags:
#  Tags to be used on the Maps note box in the database or in events
#  comment box, works like a script call
#
#  <fog effect>
#  settings
#  </fog effect>
#   Create a fog effect on the map, add the following values to the info
#   the ID and name must be added, other values are optional.
#	 id: x	  : fog ID
#	 name: "x"  : fog graphic filename ("filename")
#	 opacity: x : fog opacity (0-255)
#	 move: x    : fog screen movement (32 = fog follows the map)
#	 zoom: x    : fog zoom (100 = default size)
#	 hue: x	 : fog hue (0-360)
#	 blend: x   : fog blend type (0: normal, 1: add, 2: subtract)
#	 depth: x   : fog Z axis (300 = default value)
#
#  <fog opacity id: o, d>
#   This tag allows to change the fog opacity gradually
#	 id : fog ID
#	 o  : new opacity (0-255)
#	 d  : wait until complete change (60 frames = 1 second)
#
#  <fog move id: x, y>
#   This tag adds fog continuous movement
#	 id : fog ID
#	 x  : horizontal movement, can be positive or negative
#	 y  : vertical movement, can be positive or negative
#
#  <fog  tone id: r, g, b, y, d>
#   This tag allows to change the fog opacity gradually
#	 id : fog ID
#	 r  : red tone   (0-255, can be negative)
#	 g  : green tone (0-255, can be negative)
#	 b  : blue tone  (0-255, can be negative)
#	 y  : gray tone  (0-255)
#	 d  : wait until complete change (60 frames = 1 second)
#
#------------------------------------------------------------------------------
# Additional instructions:
#
#   Map note tags commands are called right when enters the map, comment calls
#   are called during the event process.
#
#==============================================================================
#==============================================================================
# ** Victor Engine
#------------------------------------------------------------------------------
#   Setting module for the Victor Engine
#==============================================================================
module Victor_Engine
 #--------------------------------------------------------------------------
 # * Set fogs visibility on battle
 #    When true, fogs are visible on battle
 #--------------------------------------------------------------------------
 VE_BATTLE_FOGS = false
end
$imported[:ve_fog_effects] = true
#==============================================================================
# ** Cache
#------------------------------------------------------------------------------
#  This module loads each of graphics, creates a Bitmap object, and retains it.
# To speed up load times and conserve memory, this module holds the created
# Bitmap object in the internal hash, allowing the program to return
# preexisting objects when the same bitmap is requested again.
#==============================================================================
module Cache
 #--------------------------------------------------------------------------
 # * New method: fogs
 #--------------------------------------------------------------------------
 def self.fogs(filename)
   self.load_bitmap('Graphics/Fogs/', filename)
 end
end
#==============================================================================
# ** Game_Screen
#------------------------------------------------------------------------------
#  This class handles screen maintenance data, such as change in color tone,
# flashes, etc. It's used within the Game_Map and Game_Troop classes.
#==============================================================================
class Game_Screen
 #--------------------------------------------------------------------------
 # * Public Instance Variables
 #--------------------------------------------------------------------------
 attr_reader   :fogs
 #--------------------------------------------------------------------------
 # * Alias method: initialize
 #--------------------------------------------------------------------------
 alias :initialize_ve_fog_effects :initialize
 def initialize
   @fogs = Game_Fogs.new
   initialize_ve_fog_effects
 end
 #--------------------------------------------------------------------------
 # * Alias method: clear
 #--------------------------------------------------------------------------
 alias :clear_ve_fog_effects :clear
 def clear
   clear_ve_fog_effects
   clear_fogs
 end
 #--------------------------------------------------------------------------
 # * Alias method: update
 #--------------------------------------------------------------------------
 alias :update_ve_fog_effects :update
 def update
   update_ve_fog_effects
   update_fogs
 end
 #--------------------------------------------------------------------------
 # * New method: clear_fogs
 #--------------------------------------------------------------------------
 def clear_fogs
   @fogs.each {|fog| fog.erase }
 end
 #--------------------------------------------------------------------------
 # * New method: update_fogs
 #--------------------------------------------------------------------------
 def update_fogs
   @fogs.each {|fog| fog.update }
 end
 #--------------------------------------------------------------------------
 # * New method: create_fog
 #--------------------------------------------------------------------------
 def create_fog(*args)
   @fogs[args.first].show(*args)
 end
 #--------------------------------------------------------------------------
 # * New method: set_fog_move
 #--------------------------------------------------------------------------
 def set_fog_move(id, sx, sy)
   @fogs[id].start_movement(sx, sy)
 end
 #--------------------------------------------------------------------------
 # * New method: set_fog_tone
 #--------------------------------------------------------------------------
 def set_fog_tone(id, red, green, blue, gray, duration = 0)
   tone = Tone.new(red, green, blue, gray)
   @fogs[id].start_tone_change(tone, duration)
 end
 #--------------------------------------------------------------------------
 # * New method: set_fog_opacity
 #--------------------------------------------------------------------------
 def set_fog_opacity(id, opacity, duration = 0)
   @fogs[id].start_opacity_change(opacity, duration)
 end
end
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================
class Game_Map
 #--------------------------------------------------------------------------
 # * Alias method: setup
 #--------------------------------------------------------------------------
 alias :setup_ve_fog_effects :setup
 def setup(map_id)
   setup_ve_fog_effects(map_id)
   setup_fogs_effect
 end
 #--------------------------------------------------------------------------
 # * New method: setup_fogs_effect
 #--------------------------------------------------------------------------
 def setup_fogs_effect
   create_fog(note)
   set_fog_opacity(note)
   set_fog_move(note)
   set_fog_tone(note)
 end
 #--------------------------------------------------------------------------
 # * New method: create_fog
 #--------------------------------------------------------------------------
 def create_fog(note)
   regexp = /<FOG EFFECT>([^><]*)<\/FOG EFFECT>/im
   note.scan(regexp) do |info|
  setup_fog(info.first)
   end
 end
 #--------------------------------------------------------------------------
 # * New method: set_fog_opacity
 #--------------------------------------------------------------------------
 def set_fog_opacity(note)
   regexp = /<FOG OPACITY (\d+): ((?:\d+,?\s*){2})>/i
   note.scan(regexp) do  |id, o, d|
  $game_map.screen.set_fog_opacity(id.to_i, o.to_i, d.to_i)
   end
 end
 #--------------------------------------------------------------------------
 # * New method: set_fog_move
 #--------------------------------------------------------------------------
 def set_fog_move(note)
   regexp = /<FOG MOVE (\d+): ((?:[+-]?\d+,?\s*){2})>/i
   note.scan(regexp) do |id, sx, sy|
  $game_map.screen.set_fog_move(id.to_i, sx.to_i, sy.to_i)
   end
 end
 #--------------------------------------------------------------------------
 # * New method: set_fog_tone
 #--------------------------------------------------------------------------
 def set_fog_tone(note)
   regexp = /<FOG TONE (\d+): ((?:\d+,?\s*){5})>/i
   note.scan(regexp) do |i, r, g, b, a, d|
  info = [i.to_i, r.to_i, g.to_i, b.to_i, a.to_i, d.to_i]
  $game_map.screen.set_fog_tone(*info)
   end
 end
 #--------------------------------------------------------------------------
 # * New method: setup_fog
 #--------------------------------------------------------------------------
 def setup_fog(info)
   id    = info =~ /ID: (\d+)/i	   ? $1.to_i : 0
   name  = info =~ /NAME: \"(.*)\"/i  ? $1.dup  : ""
   op    = info =~ /OPACITY: (\d+)/i  ? $1.to_i : 192
   move  = info =~ /MOVE: (\d+)/i	 ? $1.to_i : 32
   zoom  = info =~ /ZOOM: (\d+)/i	 ? $1.to_f : 100.0
   hue   = info =~ /HUE: (\d+)/i	  ? $1.to_i : 0
   blend = info =~ /BLEND: (\d+)/i    ? $1.to_i : 0
   depth = info =~ /DEPTH: (\-?\d+)/i ? $1.to_i : 300
   $game_map.screen.create_fog(id, name, op, move, zoom, hue, blend, depth)
 end
end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
#  An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================
class Game_Interpreter
 #--------------------------------------------------------------------------
 # * Alias method: comment_call
 #--------------------------------------------------------------------------
 alias :comment_call_ve_fog_effects :comment_call
 def comment_call
   call_create_fog_effect
   comment_call_ve_fog_effects
 end
 #--------------------------------------------------------------------------
 # * New method: call_create_fog_effect
 #--------------------------------------------------------------------------
 def call_create_fog_effect
   $game_map.create_fog(note)
   $game_map.set_fog_opacity(note)
   $game_map.set_fog_move(note)
   $game_map.set_fog_tone(note)
 end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
#  Esta classe reune os sprites da tela de mapa e tilesets. Esta classe é
# usada internamente pela classe Scene_Map.
#==============================================================================
class Spriteset_Map
 #--------------------------------------------------------------------------
 # * Alias method: initialize
 #--------------------------------------------------------------------------
 alias :initialize_ve_fog_effects :initialize
 def initialize
   create_fogs
   initialize_ve_fog_effects
 end
 #--------------------------------------------------------------------------
 # * Alias method: dispose
 #--------------------------------------------------------------------------
 alias :dispose_ve_fog_effects :dispose
 def dispose
   dispose_ve_fog_effects
   dispose_fogs
 end
 #--------------------------------------------------------------------------
 # * Alias method: update
 #--------------------------------------------------------------------------
 alias :update_ve_fog_effects :update
 def update
   update_ve_fog_effects
   update_fogs
 end
 #--------------------------------------------------------------------------
 # * New method: create_fogs
 #--------------------------------------------------------------------------
 def create_fogs
   @fog_sprites = []
 end
 #--------------------------------------------------------------------------
 # * New method: dispose_fogs
 #--------------------------------------------------------------------------
 def dispose_fogs
   if @fog_sprites
  @fog_sprites.compact.each {|sprite| sprite.dispose }
  @fog_sprites.clear
   end
 end
 #--------------------------------------------------------------------------
 # * New method: update_fogs
 #--------------------------------------------------------------------------
 def update_fogs
   $game_map.screen.fogs.each do |fog|
  @fog_sprites[fog.id] ||= Sprite_Fog.new(@light_viewport, fog)
  @fog_sprites[fog.id].update
   end
 end
end
#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
#  This class brings together battle screen sprites. It's used within the
# Scene_Battle class.
#==============================================================================
class Spriteset_Battle
 #--------------------------------------------------------------------------
 # * Alias method: initialize
 #--------------------------------------------------------------------------
 alias :initialize_ve_fog_effects :initialize
 def initialize
   create_fogs if VE_BATTLE_FOGS
   initialize_ve_fog_effects
 end
 #--------------------------------------------------------------------------
 # * Alias method: dispose
 #--------------------------------------------------------------------------
 alias :dispose_ve_fog_effects :dispose
 def dispose
   dispose_fogs if VE_BATTLE_FOGS
   dispose_ve_fog_effects
 end
 #--------------------------------------------------------------------------
 # * Alias method: update
 #--------------------------------------------------------------------------
 alias :update_ve_fog_effects :update
 def update
   update_fogs if VE_BATTLE_FOGS
   update_ve_fog_effects
 end
 #--------------------------------------------------------------------------
 # * New method: create_fogs
 #--------------------------------------------------------------------------
 def create_fogs
   @fog_sprites = []
 end
 #--------------------------------------------------------------------------
 # * New method: dispose_fogs
 #--------------------------------------------------------------------------
 def dispose_fogs
   if @fog_sprite
  $game_map.screen.fogs.clear
  @fog_sprites.compact.each {|sprite| sprite.dispose }
  @fog_sprites.clear
   end
 end
 #--------------------------------------------------------------------------
 # * New method: update_fogs
 #--------------------------------------------------------------------------
 def update_fogs
   $game_map.screen.fogs.each do |fog|
  @fog_sprites[fog.id] ||= Sprite_Fog.new(@viewport1, fog)
  @fog_sprites[fog.id].update
   end
 end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs the map screen processing.
#==============================================================================
class Scene_Map
 #--------------------------------------------------------------------------
 # * Alias method: pre_transfer
 #--------------------------------------------------------------------------
 alias :pre_transfer_ve_fog_effects :pre_transfer
 def pre_transfer
   pre_transfer_ve_fog_effects
   if $game_player.new_map_id !=  $game_map.map_id
  @spriteset.dispose_fogs
  $game_map.screen.clear_fogs
  $game_map.screen.fogs.clear
   end
 end
end
#==============================================================================
# ** Game_Fog
#------------------------------------------------------------------------------
#  This class handles fog data. This class is used within the Game_Fogs class.
#==============================================================================
class Game_Fog
 #--------------------------------------------------------------------------
 # * Public Instance Variables
 #--------------------------------------------------------------------------
 attr_reader   :id
 attr_reader   :name
 attr_reader   :hue
 attr_reader   :sx
 attr_reader   :sy
 attr_reader   :ox
 attr_reader   :oy
 attr_reader   :depth
 attr_reader   :move
 attr_reader   :zoom_x
 attr_reader   :zoom_y
 attr_reader   :opacity
 attr_reader   :blend_type
 attr_reader   :tone
 #--------------------------------------------------------------------------
 # * initialize
 #--------------------------------------------------------------------------
 def initialize(id)
   @id = id
   init_basic
   init_target
   init_tone
 end
 #--------------------------------------------------------------------------
 # * init_basic
 #--------------------------------------------------------------------------
 def init_basic
   @name    = ""
   @depth   = 300
   @zoom_x  = 1.0
   @zoom_y  = 1.0
   @move_x  = 32
   @move_y  = 32
   @opacity = 255.0
   @blend_type = 1
   @sx  = 0
   @sy  = 0
   @ox  = 0
   @oy  = 0
   @hue = 0
   @opacity_duration = 0
   @tone_duration    = 0
 end
 #--------------------------------------------------------------------------
 # * init_target
 #--------------------------------------------------------------------------
 def init_target
   @target_x = @x
   @target_y = @y
   @target_zoom_x  = @zoom_x
   @target_zoom_y  = @zoom_y
   @target_opacity = @opacity
 end
 #--------------------------------------------------------------------------
 # * init_tone
 #--------------------------------------------------------------------------
 def init_tone
   @tone	    = Tone.new
   @tone_target = Tone.new
   @tone_duration = 0
 end
 #--------------------------------------------------------------------------
 # * show
 #--------------------------------------------------------------------------
 def show(id, name, opacity, move, zoom, hue, blend, depth)
   @id	  = id
   @name    = name
   @move    = move
   @zoom_x  = zoom.to_f
   @zoom_y  = zoom.to_f
   @depth   = depth
   @opacity = opacity.to_f
   @blend_type = blend
   init_target
   init_tone
 end
 #--------------------------------------------------------------------------
 # * start_movement
 #--------------------------------------------------------------------------
 def start_movement(sx, sy)
   @sx = sx
   @sy = sy
 end
 #--------------------------------------------------------------------------
 # * start_tone_change
 #--------------------------------------------------------------------------
 def start_tone_change(tone, duration)
   @tone_target   = tone.clone
   @tone_duration = [duration.to_i, 0].max
   @tone = @tone_target.clone if @tone_duration == 0
 end
 #--------------------------------------------------------------------------
 # * start_opacity_change
 #--------------------------------------------------------------------------
 def start_opacity_change(opacity, duration)
   @opacity_target   = opacity
   @opacity_duration = [duration.to_i, 0].max
   @opacity = @opacity_target if @opacity_duration == 0
 end
 #--------------------------------------------------------------------------
 # * erase
 #--------------------------------------------------------------------------
 def erase
   @name = ""
 end
 #--------------------------------------------------------------------------
 # * update
 #--------------------------------------------------------------------------
 def update
   update_move
   update_tone
   update_opacity
 end
 #--------------------------------------------------------------------------
 # * update_move
 #--------------------------------------------------------------------------
 def update_move
   @ox -= @sx / 16.0
   @oy -= @sy / 16.0
 end
 #--------------------------------------------------------------------------
 # * update_opacity
 #--------------------------------------------------------------------------
 def update_opacity
   return if @opacity_duration == 0
   d = @opacity_duration
   @opacity = (@opacity * (d - 1) + @opacity_target) / d
   @opacity_duration -= 1
 end
 #--------------------------------------------------------------------------
 # * update_tone
 #--------------------------------------------------------------------------
 def update_tone
   return if @tone_duration == 0
   d = @tone_duration
   @tone.red   = (@tone.red   * (d - 1) + @tone_target.red)   / d
   @tone.green = (@tone.green * (d - 1) + @tone_target.green) / d
   @tone.blue  = (@tone.blue  * (d - 1) + @tone_target.blue)  / d
   @tone.gray  = (@tone.gray  * (d - 1) + @tone_target.gray)  / d
   @tone_duration -= 1
 end
end
#==============================================================================
# ** Game_Fogs
#------------------------------------------------------------------------------
#  This class handles fogs. This class is used within the Game_Screen class.
#==============================================================================
class Game_Fogs
 #--------------------------------------------------------------------------
 # * initialize
 #--------------------------------------------------------------------------
 def initialize
   @data = []
 end
 #--------------------------------------------------------------------------
 # * []
 #--------------------------------------------------------------------------
 def [](number)
   @data[number] ||= Game_Fog.new(number)
 end
 #--------------------------------------------------------------------------
 # * each
 #--------------------------------------------------------------------------
 def each
   @data.compact.each {|fog| yield fog } if block_given?
 end
 #--------------------------------------------------------------------------
 # * clear
 #--------------------------------------------------------------------------
 def clear
   @data.clear
 end
end
#==============================================================================
# ** Sprite_Fog
#------------------------------------------------------------------------------
#  This sprite is used to display fgos. It observes a instance of the
# Game_Fog class and automatically changes sprite conditions.
#==============================================================================
class Sprite_Fog < Plane
 #--------------------------------------------------------------------------
 # * initialize
 #--------------------------------------------------------------------------
 def initialize(viewport, fog)
   super(viewport)
   @fog = fog
   update
 end
 #--------------------------------------------------------------------------
 # * dispose
 #--------------------------------------------------------------------------
 def dispose
   bitmap.dispose if bitmap
   super
 end
 #--------------------------------------------------------------------------
 # * update
 #--------------------------------------------------------------------------
 def update
   update_bitmap
   update_position
   update_zoom
   update_other
 end
 #--------------------------------------------------------------------------
 # * update bitmap
 #--------------------------------------------------------------------------
 def update_bitmap
   if @fog_name != @fog.name
  self.bitmap = Cache.fogs(@fog.name)
  @fog_name = @fog.name.dup
   end
 end
 #--------------------------------------------------------------------------
 # * update_position
 #--------------------------------------------------------------------------
 def update_position
   self.ox = $game_map.display_x * @fog.move + @fog.ox
   self.oy = $game_map.display_y * @fog.move + @fog.oy
   self.z  = @fog.depth
 end
 #--------------------------------------------------------------------------
 # * update_zoom
 #--------------------------------------------------------------------------
 def update_zoom
   self.zoom_x = @fog.zoom_x / 100.0
   self.zoom_y = @fog.zoom_y / 100.0
 end
 #--------------------------------------------------------------------------
 # * update_other
 #--------------------------------------------------------------------------
 def update_other
   self.opacity    = @fog.opacity
   self.blend_type = @fog.blend_type
   self.tone.set(@fog.tone)
 end
end

 

Share this post


Link to post
Share on other sites

@Lear: test this edited fog (only edit viewport ~)

 

#==============================================================================
# ** Victor Engine - Fog Effect
#------------------------------------------------------------------------------
# Author : Victor Sant
#
# Version History:
#  v 1.00 - 2011.12.19 - First relase
#  v 1.01 - 2011.12.30 - Faster Regular Expressions
#  v 1.02 - 2012.01.02 - Fixed fog dispose when changing maps
#------------------------------------------------------------------------------
#  This script allows to add varied of effects to the maps. Fos are picutres
# placed above the player layer and loops. Differently from pictures the fog
# follows the map movement instead of the screen (this behavior can be changed)
# You can add various fogs to the map.
#------------------------------------------------------------------------------
# Compatibility
#   Requires the script 'Victor Engine - Basic Module'
#
# * Overwrite methods
#   None
#
# * Alias methods
#   class Game_Screen
#	 def initialize
#	 def clear
#	 def update
#
#   class Game_Map
#	 def setup(map_id)
#
#   class Spriteset_Map
#	 def initialize
#	 def dispose
#	 def update
#
#   class Game_Interpreter
#	 def comment_call
#
#------------------------------------------------------------------------------
# Instructions:
#  To instal the script, open you script editor and paste this script on
#  a new section on bellow the Materials section. This script must also
#  be bellow the script 'Victor Engine - Basic'
#  The fogs must be placed on the folder "Graphics/Fogs". Create a folder
#  named "Fogs" on the Graphics folder.
#
#------------------------------------------------------------------------------
# Maps and Comment calls note tags:
#  Tags to be used on the Maps note box in the database or in events
#  comment box, works like a script call
#
#  <fog effect>
#  settings
#  </fog effect>
#   Create a fog effect on the map, add the following values to the info
#   the ID and name must be added, other values are optional.
#	 id: x	  : fog ID
#	 name: "x"  : fog graphic filename ("filename")
#	 opacity: x : fog opacity (0-255)
#	 move: x	: fog screen movement (32 = fog follows the map)
#	 zoom: x	: fog zoom (100 = default size)
#	 hue: x	 : fog hue (0-360)
#	 blend: x   : fog blend type (0: normal, 1: add, 2: subtract)
#	 depth: x   : fog Z axis (300 = default value)
#
#  <fog opacity id: o, d>
#   This tag allows to change the fog opacity gradually
#	 id : fog ID
#	 o  : new opacity (0-255)
#	 d  : wait until complete change (60 frames = 1 second)
#
#  <fog move id: x, y>
#   This tag adds fog continuous movement
#	 id : fog ID
#	 x  : horizontal movement, can be positive or negative
#	 y  : vertical movement, can be positive or negative
#
#  <fog  tone id: r, g, b, y, d>
#   This tag allows to change the fog opacity gradually
#	 id : fog ID
#	 r  : red tone   (0-255, can be negative)
#	 g  : green tone (0-255, can be negative)
#	 b  : blue tone  (0-255, can be negative)
#	 y  : gray tone  (0-255)
#	 d  : wait until complete change (60 frames = 1 second)
#
#------------------------------------------------------------------------------
# Additional instructions:
#
#   Map note tags commands are called right when enters the map, comment calls
#   are called during the event process.
#
#==============================================================================
#==============================================================================
# ** Victor Engine
#------------------------------------------------------------------------------
#   Setting module for the Victor Engine
#==============================================================================
module Victor_Engine
 #--------------------------------------------------------------------------
 # * Set fogs visibility on battle
 #	When true, fogs are visible on battle
 #--------------------------------------------------------------------------
 VE_BATTLE_FOGS = false
end
$imported[:ve_fog_effects] = true
#==============================================================================
# ** Cache
#------------------------------------------------------------------------------
#  This module loads each of graphics, creates a Bitmap object, and retains it.
# To speed up load times and conserve memory, this module holds the created
# Bitmap object in the internal hash, allowing the program to return
# preexisting objects when the same bitmap is requested again.
#==============================================================================
module Cache
 #--------------------------------------------------------------------------
 # * New method: fogs
 #--------------------------------------------------------------------------
 def self.fogs(filename)
self.load_bitmap('Graphics/Fogs/', filename)
 end
end
#==============================================================================
# ** Game_Screen
#------------------------------------------------------------------------------
#  This class handles screen maintenance data, such as change in color tone,
# flashes, etc. It's used within the Game_Map and Game_Troop classes.
#==============================================================================
class Game_Screen
 #--------------------------------------------------------------------------
 # * Public Instance Variables
 #--------------------------------------------------------------------------
 attr_reader   :fogs
 #--------------------------------------------------------------------------
 # * Alias method: initialize
 #--------------------------------------------------------------------------
 alias :initialize_ve_fog_effects :initialize
 def initialize
@fogs = Game_Fogs.new
initialize_ve_fog_effects
 end
 #--------------------------------------------------------------------------
 # * Alias method: clear
 #--------------------------------------------------------------------------
 alias :clear_ve_fog_effects :clear
 def clear
clear_ve_fog_effects
clear_fogs
 end
 #--------------------------------------------------------------------------
 # * Alias method: update
 #--------------------------------------------------------------------------
 alias :update_ve_fog_effects :update
 def update
update_ve_fog_effects
update_fogs
 end
 #--------------------------------------------------------------------------
 # * New method: clear_fogs
 #--------------------------------------------------------------------------
 def clear_fogs
@fogs.each {|fog| fog.erase }
 end
 #--------------------------------------------------------------------------
 # * New method: update_fogs
 #--------------------------------------------------------------------------
 def update_fogs
@fogs.each {|fog| fog.update }
 end
 #--------------------------------------------------------------------------
 # * New method: create_fog
 #--------------------------------------------------------------------------
 def create_fog(*args)
@fogs[args.first].show(*args)
 end
 #--------------------------------------------------------------------------
 # * New method: set_fog_move
 #--------------------------------------------------------------------------
 def set_fog_move(id, sx, sy)
@fogs[id].start_movement(sx, sy)
 end
 #--------------------------------------------------------------------------
 # * New method: set_fog_tone
 #--------------------------------------------------------------------------
 def set_fog_tone(id, red, green, blue, gray, duration = 0)
tone = Tone.new(red, green, blue, gray)
@fogs[id].start_tone_change(tone, duration)
 end
 #--------------------------------------------------------------------------
 # * New method: set_fog_opacity
 #--------------------------------------------------------------------------
 def set_fog_opacity(id, opacity, duration = 0)
@fogs[id].start_opacity_change(opacity, duration)
 end
end
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================
class Game_Map
 #--------------------------------------------------------------------------
 # * Alias method: setup
 #--------------------------------------------------------------------------
 alias :setup_ve_fog_effects :setup
 def setup(map_id)
setup_ve_fog_effects(map_id)
setup_fogs_effect
 end
 #--------------------------------------------------------------------------
 # * New method: setup_fogs_effect
 #--------------------------------------------------------------------------
 def setup_fogs_effect
create_fog(note)
set_fog_opacity(note)
set_fog_move(note)
set_fog_tone(note)
 end
 #--------------------------------------------------------------------------
 # * New method: create_fog
 #--------------------------------------------------------------------------
 def create_fog(note)
regexp = /<FOG EFFECT>([^><]*)<\/FOG EFFECT>/im
note.scan(regexp) do |info|
  setup_fog(info.first)
end
 end
 #--------------------------------------------------------------------------
 # * New method: set_fog_opacity
 #--------------------------------------------------------------------------
 def set_fog_opacity(note)
regexp = /<FOG OPACITY (\d+): ((?:\d+,?\s*){2})>/i
note.scan(regexp) do  |id, o, d|
  $game_map.screen.set_fog_opacity(id.to_i, o.to_i, d.to_i)
end
 end
 #--------------------------------------------------------------------------
 # * New method: set_fog_move
 #--------------------------------------------------------------------------
 def set_fog_move(note)
regexp = /<FOG MOVE (\d+): ((?:[+-]?\d+,?\s*){2})>/i
note.scan(regexp) do |id, sx, sy|
  $game_map.screen.set_fog_move(id.to_i, sx.to_i, sy.to_i)
end
 end
 #--------------------------------------------------------------------------
 # * New method: set_fog_tone
 #--------------------------------------------------------------------------
 def set_fog_tone(note)
regexp = /<FOG TONE (\d+): ((?:\d+,?\s*){5})>/i
note.scan(regexp) do |i, r, g, b, a, d|
  info = [i.to_i, r.to_i, g.to_i, b.to_i, a.to_i, d.to_i]
  $game_map.screen.set_fog_tone(*info)
end
 end
 #--------------------------------------------------------------------------
 # * New method: setup_fog
 #--------------------------------------------------------------------------
 def setup_fog(info)
id	= info =~ /ID: (\d+)/i	   ? $1.to_i : 0
name  = info =~ /NAME: \"(.*)\"/i  ? $1.dup  : ""
op	= info =~ /OPACITY: (\d+)/i  ? $1.to_i : 192
move  = info =~ /MOVE: (\d+)/i	 ? $1.to_i : 32
zoom  = info =~ /ZOOM: (\d+)/i	 ? $1.to_f : 100.0
hue   = info =~ /HUE: (\d+)/i	  ? $1.to_i : 0
blend = info =~ /BLEND: (\d+)/i	? $1.to_i : 0
depth = info =~ /DEPTH: (\-?\d+)/i ? $1.to_i : 300
$game_map.screen.create_fog(id, name, op, move, zoom, hue, blend, depth)
 end
end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
#  An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================
class Game_Interpreter
 #--------------------------------------------------------------------------
 # * Alias method: comment_call
 #--------------------------------------------------------------------------
 alias :comment_call_ve_fog_effects :comment_call
 def comment_call
call_create_fog_effect
comment_call_ve_fog_effects
 end
 #--------------------------------------------------------------------------
 # * New method: call_create_fog_effect
 #--------------------------------------------------------------------------
 def call_create_fog_effect
$game_map.create_fog(note)
$game_map.set_fog_opacity(note)
$game_map.set_fog_move(note)
$game_map.set_fog_tone(note)
 end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
#  Esta classe reune os sprites da tela de mapa e tilesets. Esta classe é
# usada internamente pela classe Scene_Map.
#==============================================================================
class Spriteset_Map
 #--------------------------------------------------------------------------
 # * Alias method: initialize
 #--------------------------------------------------------------------------
 alias :initialize_ve_fog_effects :initialize
 def initialize
create_fogs
initialize_ve_fog_effects
 end
 #--------------------------------------------------------------------------
 # * Alias method: dispose
 #--------------------------------------------------------------------------
 alias :dispose_ve_fog_effects :dispose
 def dispose
dispose_ve_fog_effects
dispose_fogs
 end
 #--------------------------------------------------------------------------
 # * Alias method: update
 #--------------------------------------------------------------------------
 alias :update_ve_fog_effects :update
 def update
update_ve_fog_effects
update_fogs
 end
 #--------------------------------------------------------------------------
 # * New method: create_fogs
 #--------------------------------------------------------------------------
 def create_fogs
@fog_sprites = []
 end
 #--------------------------------------------------------------------------
 # * New method: dispose_fogs
 #--------------------------------------------------------------------------
 def dispose_fogs
if @fog_sprites
  @fog_sprites.compact.each {|sprite| sprite.dispose }
  @fog_sprites.clear
end
 end
 #--------------------------------------------------------------------------
 # * New method: update_fogs
 #--------------------------------------------------------------------------
 def update_fogs
$game_map.screen.fogs.each do |fog|
  @fog_sprites[fog.id] ||= Sprite_Fog.new(@light_viewport, fog)
  @fog_sprites[fog.id].update
end
 end
end
#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
#  This class brings together battle screen sprites. It's used within the
# Scene_Battle class.
#==============================================================================
class Spriteset_Battle
 #--------------------------------------------------------------------------
 # * Alias method: initialize
 #--------------------------------------------------------------------------
 alias :initialize_ve_fog_effects :initialize
 def initialize
create_fogs if VE_BATTLE_FOGS
initialize_ve_fog_effects
 end
 #--------------------------------------------------------------------------
 # * Alias method: dispose
 #--------------------------------------------------------------------------
 alias :dispose_ve_fog_effects :dispose
 def dispose
dispose_fogs if VE_BATTLE_FOGS
dispose_ve_fog_effects
 end
 #--------------------------------------------------------------------------
 # * Alias method: update
 #--------------------------------------------------------------------------
 alias :update_ve_fog_effects :update
 def update
update_fogs if VE_BATTLE_FOGS
update_ve_fog_effects
 end
 #--------------------------------------------------------------------------
 # * New method: create_fogs
 #--------------------------------------------------------------------------
 def create_fogs
@fog_sprites = []
 end
 #--------------------------------------------------------------------------
 # * New method: dispose_fogs
 #--------------------------------------------------------------------------
 def dispose_fogs
if @fog_sprite
  $game_map.screen.fogs.clear
  @fog_sprites.compact.each {|sprite| sprite.dispose }
  @fog_sprites.clear
end
 end
 #--------------------------------------------------------------------------
 # * New method: update_fogs
 #--------------------------------------------------------------------------
 def update_fogs
$game_map.screen.fogs.each do |fog|
  @fog_sprites[fog.id] ||= Sprite_Fog.new(@viewport1, fog)
  @fog_sprites[fog.id].update
end
 end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs the map screen processing.
#==============================================================================
class Scene_Map
 #--------------------------------------------------------------------------
 # * Alias method: pre_transfer
 #--------------------------------------------------------------------------
 alias :pre_transfer_ve_fog_effects :pre_transfer
 def pre_transfer
pre_transfer_ve_fog_effects
if $game_player.new_map_id !=  $game_map.map_id
  @spriteset.dispose_fogs
  $game_map.screen.clear_fogs
  $game_map.screen.fogs.clear
end
 end
end
#==============================================================================
# ** Game_Fog
#------------------------------------------------------------------------------
#  This class handles fog data. This class is used within the Game_Fogs class.
#==============================================================================
class Game_Fog
 #--------------------------------------------------------------------------
 # * Public Instance Variables
 #--------------------------------------------------------------------------
 attr_reader   :id
 attr_reader   :name
 attr_reader   :hue
 attr_reader   :sx
 attr_reader   :sy
 attr_reader   :ox
 attr_reader   :oy
 attr_reader   :depth
 attr_reader   :move
 attr_reader   :zoom_x
 attr_reader   :zoom_y
 attr_reader   :opacity
 attr_reader   :blend_type
 attr_reader   :tone
 #--------------------------------------------------------------------------
 # * initialize
 #--------------------------------------------------------------------------
 def initialize(id)
@id = id
init_basic
init_target
init_tone
 end
 #--------------------------------------------------------------------------
 # * init_basic
 #--------------------------------------------------------------------------
 def init_basic
@name	= ""
@depth   = 300
@zoom_x  = 1.0
@zoom_y  = 1.0
@move_x  = 32
@move_y  = 32
@opacity = 255.0
@blend_type = 1
@sx  = 0
@sy  = 0
@ox  = 0
@oy  = 0
@hue = 0
@opacity_duration = 0
@tone_duration	= 0
 end
 #--------------------------------------------------------------------------
 # * init_target
 #--------------------------------------------------------------------------
 def init_target
@target_x = @x
@target_y = @y
@target_zoom_x  = @zoom_x
@target_zoom_y  = @zoom_y
@target_opacity = @opacity
 end
 #--------------------------------------------------------------------------
 # * init_tone
 #--------------------------------------------------------------------------
 def init_tone
@tone		= Tone.new
@tone_target = Tone.new
@tone_duration = 0
 end
 #--------------------------------------------------------------------------
 # * show
 #--------------------------------------------------------------------------
 def show(id, name, opacity, move, zoom, hue, blend, depth)
@id	  = id
@name	= name
@move	= move
@zoom_x  = zoom.to_f
@zoom_y  = zoom.to_f
@depth   = depth
@opacity = opacity.to_f
@blend_type = blend
init_target
init_tone
 end
 #--------------------------------------------------------------------------
 # * start_movement
 #--------------------------------------------------------------------------
 def start_movement(sx, sy)
@sx = sx
@sy = sy
 end
 #--------------------------------------------------------------------------
 # * start_tone_change
 #--------------------------------------------------------------------------
 def start_tone_change(tone, duration)
@tone_target   = tone.clone
@tone_duration = [duration.to_i, 0].max
@tone = @tone_target.clone if @tone_duration == 0
 end
 #--------------------------------------------------------------------------
 # * start_opacity_change
 #--------------------------------------------------------------------------
 def start_opacity_change(opacity, duration)
@opacity_target   = opacity
@opacity_duration = [duration.to_i, 0].max
@opacity = @opacity_target if @opacity_duration == 0
 end
 #--------------------------------------------------------------------------
 # * erase
 #--------------------------------------------------------------------------
 def erase
@name = ""
 end
 #--------------------------------------------------------------------------
 # * update
 #--------------------------------------------------------------------------
 def update
update_move
update_tone
update_opacity
 end
 #--------------------------------------------------------------------------
 # * update_move
 #--------------------------------------------------------------------------
 def update_move
@ox -= @sx / 16.0
@oy -= @sy / 16.0
 end
 #--------------------------------------------------------------------------
 # * update_opacity
 #--------------------------------------------------------------------------
 def update_opacity
return if @opacity_duration == 0
d = @opacity_duration
@opacity = (@opacity * (d - 1) + @opacity_target) / d
@opacity_duration -= 1
 end
 #--------------------------------------------------------------------------
 # * update_tone
 #--------------------------------------------------------------------------
 def update_tone
return if @tone_duration == 0
d = @tone_duration
@tone.red   = (@tone.red   * (d - 1) + @tone_target.red)   / d
@tone.green = (@tone.green * (d - 1) + @tone_target.green) / d
@tone.blue  = (@tone.blue  * (d - 1) + @tone_target.blue)  / d
@tone.gray  = (@tone.gray  * (d - 1) + @tone_target.gray)  / d
@tone_duration -= 1
 end
end
#==============================================================================
# ** Game_Fogs
#------------------------------------------------------------------------------
#  This class handles fogs. This class is used within the Game_Screen class.
#==============================================================================
class Game_Fogs
 #--------------------------------------------------------------------------
 # * initialize
 #--------------------------------------------------------------------------
 def initialize
@data = []
 end
 #--------------------------------------------------------------------------
 # * []
 #--------------------------------------------------------------------------
 def [](number)
@data[number] ||= Game_Fog.new(number)
 end
 #--------------------------------------------------------------------------
 # * each
 #--------------------------------------------------------------------------
 def each
@data.compact.each {|fog| yield fog } if block_given?
 end
 #--------------------------------------------------------------------------
 # * clear
 #--------------------------------------------------------------------------
 def clear
@data.clear
 end
end
#==============================================================================
# ** Sprite_Fog
#------------------------------------------------------------------------------
#  This sprite is used to display fgos. It observes a instance of the
# Game_Fog class and automatically changes sprite conditions.
#==============================================================================
class Sprite_Fog < Plane
 #--------------------------------------------------------------------------
 # * initialize
 #--------------------------------------------------------------------------
 def initialize(viewport, fog)
super(viewport)
@fog = fog
update
 end
 #--------------------------------------------------------------------------
 # * dispose
 #--------------------------------------------------------------------------
 def dispose
bitmap.dispose if bitmap
super
 end
 #--------------------------------------------------------------------------
 # * update
 #--------------------------------------------------------------------------
 def update
update_bitmap
update_position
update_zoom
update_other
 end
 #--------------------------------------------------------------------------
 # * update bitmap
 #--------------------------------------------------------------------------
 def update_bitmap
if @fog_name != @fog.name
  self.bitmap = Cache.fogs(@fog.name)
  @fog_name = @fog.name.dup
end
 end
 #--------------------------------------------------------------------------
 # * update_position
 #--------------------------------------------------------------------------
 def update_position
self.ox = $game_map.display_x * @fog.move + @fog.ox
self.oy = $game_map.display_y * @fog.move + @fog.oy
self.z  = @fog.depth
 end
 #--------------------------------------------------------------------------
 # * update_zoom
 #--------------------------------------------------------------------------
 def update_zoom
self.zoom_x = @fog.zoom_x / 100.0
self.zoom_y = @fog.zoom_y / 100.0
 end
 #--------------------------------------------------------------------------
 # * update_other
 #--------------------------------------------------------------------------
 def update_other
self.opacity	= @fog.opacity
self.blend_type = @fog.blend_type
self.tone.set(@fog.tone)
 end
end

 

Yami, you keep saving my butt. Thank you so very much!! =)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted