Multi Layer Fog

As Quickdraws said, yeah. The show_fog function (which i tried so far) doesn't work in the battle scene, but otherwise works outside of it, which is a shame since I wanted to use the fog system as a, uh... "Ultimate Skill" background or something to that effect.

I ticked BATTLE_FOGS on and clarified the rest of the events (both in a troop event and as a common event) are working properly. Are there any solutions to this so far?
I'm sorry, but yet again I prove that nothing is "dummy proof."


first script in the project and first call and first script error. =/


Thought I was starting simple. But I can add the file as a show picture (when the file is in my pictures folder)


but I cannot get anything to show up when I use the show fogs script.


fog script.PNG


I don't need a wait or something to let it work, do I?


Here's the folder with the file.


fog script2.PNG


Halp.
@GrandmaDeb Shouldn't you remove the png so it will be "show_fog(1,"Agib Historic House Fog")" ?
Hello GrandmaDeb! Try removing the ".png" part when you do the script call.
my script call:

show_fog(1, "wolken", 0, 255, 0, 100, 1, 1, 200)
 
@GrandmaDeb Shouldn't you remove the png so it will be "show_fog(1,"Agib Historic House Fog")" ?
 
Hello GrandmaDeb! Try removing the ".png" part when you do the script call.
I tried changing the filename extension issue and it didn't fix it. =/

Still no picture at all.

So I started using everyone else's parameters, just in case. lol

Cadacis' worked, but now my wall shadows are moving across the screen.

So I assume I need to tinker with the seventh and eighth parameters now. =]

*******************edited parameters*********************

How do I get the fog to stay still on the screen? I set the 7th and 8th parameters to zero but it follows the player.

I'm using this now:

Code:
show_fog(1, "Agib Historic House Fog", 0, 255, 0, 100, 0, 0, 200)
@GrandmaDeb If I'm reading it right, Shaz give the fix at post #37

in case you're lazy to check it :

Spoiler
Code:
#============================================================================# Multi Layer Fog# v1.0 by Shaz#----------------------------------------------------------------------------# This script lets you add one or more layers of fog to a map.# You can add vertical and/or horizontal scrolling to each fog layer.# You can have fog appear on top of the map or behind the map (above the# parallax layer).# You can adjust the fog's opacity and tone over time.#----------------------------------------------------------------------------# To Install:# Copy and paste into a new script slot in Materials.  This script aliases# existing methods, so can go below all other custom scripts.#----------------------------------------------------------------------------# To Use:# Create a Fogs folder inside your game's Graphics folder, and paste your# fog png files there.## To add fog to a map, use the following in a Call Script event command:#    show_fog(number, "filename", hue, opacity, blend_type, zoom, #      speed-x, speed-y, z)# - only number and filename are mandatory# - fog is added like pictures - the number is simply an id (an array index),#   and if you don't specify the z value, fog with a higher number/id is drawn#   over fog with a lower number/id# - z position defaults to above the player.  If you want to show fog above the #   parallax layer but behind the map, use a negative value for z.  The #   parallax is drawn at -100## To change fog tone, use the following in a Call Script event command:#    tint_fog(number, red, green, blue, gray, duration)## To change the fog opacity, use the following in a Call Script event command:#    fade_fog(number, opacity, duration)## To remove fog, use the following in a Call Script event command:#    erase_fog(number)## By default fog will be removed when you change maps, and battle screens # will have the same fog as the map.  Change the CUSTOMIZATION options below# if you do not want this.#----------------------------------------------------------------------------# Terms:# Use in free or commercial games# Credit Shaz#============================================================================#============================================================================# CUSTOMIZATION## Set this to true or false to show (or not show) fog in the battle screenBATTLE_FOGS = true# Set this to true or false to clear (or not clear) fogs on transfer to new mapCLEAR_ON_TRANSFER = true# DO NOT CHANGE ANYTHING BELOW THIS LINE#============================================================================module Cache  #--------------------------------------------------------------------------  # * Get Fog  #--------------------------------------------------------------------------  def self.fog(filename, hue)    load_bitmap("Graphics/Fogs/", filename, hue)  endendclass Game_Screen  #--------------------------------------------------------------------------  # * Public Instance Variables  #--------------------------------------------------------------------------  attr_reader   :fogs  #--------------------------------------------------------------------------  # * Object Initialization  #--------------------------------------------------------------------------  alias shaz_multi_fog_game_screen_initialize initialize  def initialize    @fogs = Game_Fogs.new    shaz_multi_fog_game_screen_initialize  end  #--------------------------------------------------------------------------  # * Clear  #--------------------------------------------------------------------------  alias shaz_multi_fog_game_screen_clear clear  def clear    shaz_multi_fog_game_screen_clear    clear_fogs  end  #--------------------------------------------------------------------------  # * Clear Fogs  #--------------------------------------------------------------------------  def clear_fogs    @fogs.each {|fog| fog.erase}  end  #--------------------------------------------------------------------------  # * Frame Update  #--------------------------------------------------------------------------  alias shaz_multi_fog_game_screen_update update  def update    shaz_multi_fog_game_screen_update    update_fogs  end  #--------------------------------------------------------------------------  # * Object Initialization  #--------------------------------------------------------------------------  def update_fogs    @fogs.each {|fog| fog.update}  endend  class Game_Fog  #--------------------------------------------------------------------------  # * Public Instance Variables  #--------------------------------------------------------------------------  attr_reader   :number  attr_reader   :name  attr_reader   :hue  attr_reader   :opacity  attr_reader   :blend_type  attr_reader   :zoom  attr_reader   :sx  attr_reader   :sy  attr_reader   :ox  attr_reader   :oy  attr_reader   :tone  attr_reader   :z  #--------------------------------------------------------------------------  # * Object Initialization  #--------------------------------------------------------------------------  def initialize(number)    @number = number    init_basic    init_movement    init_tone    init_opacity  end  #--------------------------------------------------------------------------  # * Initialize Basic Variable  #--------------------------------------------------------------------------  def init_basic    @name = ""    @hue = 90    @blend_type = 0    @zoom = 200    @sx = @sy = 0  end  #--------------------------------------------------------------------------  # * Initialize Movement Variable  #--------------------------------------------------------------------------  def init_movement    @ox = @oy = 0  end  #--------------------------------------------------------------------------  # * Initialize Tone  #--------------------------------------------------------------------------  def init_tone    @tone = Tone.new    @tone_target = Tone.new    @tone_duration = 0  end  #--------------------------------------------------------------------------  # * Initialize Opacity  #--------------------------------------------------------------------------  def init_opacity    @opacity = 64.0    @opacity_target = 64.0    @opacity_duration = 0  end  #--------------------------------------------------------------------------  # * Show Fog  #--------------------------------------------------------------------------  def show(name, hue, opacity, blend_type, zoom, sx, sy, z)    @name = name    @hue = hue    @opacity = opacity    @blend_type = blend_type    @zoom = zoom    @sx = @sx2 = sx    @sy = @sy2 = sy    @z = z.nil? ? 300 + @number : z    init_movement  end  #--------------------------------------------------------------------------  # * Start Changing Tone  #--------------------------------------------------------------------------  def start_tone_change(tone, duration)    @tone_target = tone.clone    @tone_duration = duration    @tone = @tone_target.clone if @tone_duration == 0  end  #--------------------------------------------------------------------------  # * Start Opacity Change  #--------------------------------------------------------------------------  def start_opacity_change(opacity, duration)    @opacity_target = opacity * 1.0    @opacity_duration = duration    @opacity = @opacity_target if @opacity_duration == 0  end  #--------------------------------------------------------------------------  # * Erase Fog  #--------------------------------------------------------------------------  def erase    @name = ""  end  #--------------------------------------------------------------------------  # * Frame Update  #--------------------------------------------------------------------------  def update    update_move    update_tone_change    update_opacity_change  end  #--------------------------------------------------------------------------  # * Update Fog Move  #--------------------------------------------------------------------------  def update_move    @sx2 -= @sx / 8.0    @sy2 -= @sy / 8.0        @ox = $game_map.display_x * 32 + @sx2    @oy = $game_map.display_y * 32 + @sy2    return  end  #--------------------------------------------------------------------------  # * Update Fog Tone Change  #--------------------------------------------------------------------------  def update_tone_change    return if @tone_duration == 0    d = @tone_duration    target = @tone_target    @tone.red = (@tone.red * (d - 1) + target.red) / d    @tone.green = (@tone.green * (d - 1) + target.green) / d    @tone.blue = (@tone.blue * (d - 1) + target.blue) / d    @tone.gray = (@tone.gray * (d - 1) + target.gray) / d    @tone_duration -= 1  end  #--------------------------------------------------------------------------  # * Update Fog Opacity Change  #--------------------------------------------------------------------------  def update_opacity_change    return if @opacity_duration == 0    d = @opacity_duration    @opacity = (@opacity * (d - 1) + @opacity_target) / d    @opacity_duration -= 1  endendclass Game_Fogs  #--------------------------------------------------------------------------  # * Object Initialization  #--------------------------------------------------------------------------  def initialize    @data = []  end  #--------------------------------------------------------------------------  # * Get Picture  #--------------------------------------------------------------------------  def [](number)    @data[number] ||= Game_Fog.new(number)  end  #--------------------------------------------------------------------------  # * Iterator  #--------------------------------------------------------------------------  def each    @data.compact.each {|fog| yield fog } if block_given?  endendif CLEAR_ON_TRANSFER  class Game_Player < Game_Character    #--------------------------------------------------------------------------    # * Execute Player Transfer    #--------------------------------------------------------------------------    alias shaz_multi_fog_game_player_perform_transfer perform_transfer    def perform_transfer      if transfer? && @new_map_id != $game_map.map_id        $game_map.screen.fogs.each { |fog| fog.erase }      end      shaz_multi_fog_game_player_perform_transfer    end  endendclass Game_Interpreter  #--------------------------------------------------------------------------  # * Show Fog  #--------------------------------------------------------------------------  def show_fog(number, name, hue = 90, opacity = 64.0, blend_type = 0, zoom = 200,     sx = 0, sy = 0, z = nil)    screen.fogs[number].show(name, hue, opacity, blend_type, zoom, sx, sy, z)  end  #--------------------------------------------------------------------------  # * Tint Fog  #--------------------------------------------------------------------------  def tint_fog(number, red, green, blue, gray, duration)    screen.fogs[number].start_tone_change(Tone.new(red, green, blue, gray),      duration)  end  #--------------------------------------------------------------------------  # * Change Fog Opacity  #--------------------------------------------------------------------------  def fade_fog(number, opacity, duration)    screen.fogs[number].start_opacity_change(opacity, duration)  end  #--------------------------------------------------------------------------  # * Erase Fog  #--------------------------------------------------------------------------  def erase_fog(number)    screen.fogs[number].erase  endendclass Plane_Fog < Plane  #--------------------------------------------------------------------------  # * Object Initialization  #--------------------------------------------------------------------------  def initialize(viewport, fog)    super(viewport)    @fog = fog    self.z = @fog.z    self.zoom_x = @fog.zoom / 100    self.zoom_y = @fog.zoom / 100    self.blend_type = @fog.blend_type    update  end  #--------------------------------------------------------------------------  # * Free  #--------------------------------------------------------------------------  def dispose    bitmap.dispose if bitmap    super  end  #--------------------------------------------------------------------------  # * Frame Update  #--------------------------------------------------------------------------  def update    update_bitmap    update_move    update_tone    update_opacity  end  #--------------------------------------------------------------------------  # * Update Bitmap  #--------------------------------------------------------------------------  def update_bitmap    if @fog.name.empty?      self.bitmap = nil    else      self.bitmap = Cache.fog(@fog.name, @fog.hue)    end  end  #--------------------------------------------------------------------------  # * Update Move  #--------------------------------------------------------------------------  def update_move    self.ox = @fog.ox    self.oy = @fog.oy  end  #--------------------------------------------------------------------------  # * Update Tone  #--------------------------------------------------------------------------  def update_tone    self.tone = @fog.tone  end  #--------------------------------------------------------------------------  # * Update Opacity  #--------------------------------------------------------------------------  def update_opacity    self.opacity = @fog.opacity  endend  class Spriteset_Map  #--------------------------------------------------------------------------  # * Object Initialization  #--------------------------------------------------------------------------  alias shaz_multi_fog_spriteset_map_initialize initialize  def initialize    shaz_multi_fog_spriteset_map_initialize    create_fogs    update  end  #--------------------------------------------------------------------------  # * Create Fog Plane  #--------------------------------------------------------------------------  def create_fogs    @fog_planes = []  end  #--------------------------------------------------------------------------  # * Free  #--------------------------------------------------------------------------  alias shaz_multi_fog_spriteset_map_dispose dispose  def dispose    dispose_fogs    shaz_multi_fog_spriteset_map_dispose  end  #--------------------------------------------------------------------------  # * Free Fog Plane  #--------------------------------------------------------------------------  def dispose_fogs    @fog_planes.compact.each {|fog| fog.dispose }  end  #--------------------------------------------------------------------------  # * Frame Update  #--------------------------------------------------------------------------  alias shaz_multi_fog_spriteset_map_update update  def update    update_fogs    shaz_multi_fog_spriteset_map_update  end  #--------------------------------------------------------------------------  # * Update Fogs  #--------------------------------------------------------------------------  def update_fogs    return if !@fog_planes    $game_map.screen.fogs.each do |fog|      @fog_planes[fog.number] ||= Plane_Fog.new(@viewport1, fog)      @fog_planes[fog.number].update    end  endendif BATTLE_FOGS  class Spriteset_Battle    #--------------------------------------------------------------------------    # * Object Initialization    #--------------------------------------------------------------------------    alias shaz_multi_fog_spriteset_battle_initialize initialize    def initialize      shaz_multi_fog_spriteset_battle_initialize      create_fogs      update    end    #--------------------------------------------------------------------------    # * Create Fog Plane    #--------------------------------------------------------------------------    def create_fogs      @fog_planes = []    end    #--------------------------------------------------------------------------    # * Free    #--------------------------------------------------------------------------    alias shaz_multi_fog_spriteset_map_dispose dispose    def dispose      dispose_fogs      shaz_multi_fog_spriteset_map_dispose    end    #--------------------------------------------------------------------------    # * Free Fog Plane    #--------------------------------------------------------------------------    def dispose_fogs      @fog_planes.compact.each {|fog| fog.dispose }    end    #--------------------------------------------------------------------------    # * Frame Update    #--------------------------------------------------------------------------    alias shaz_multi_fog_spriteset_map_update update    def update      update_fogs      shaz_multi_fog_spriteset_map_update    end    #--------------------------------------------------------------------------    # * Update Fogs    #--------------------------------------------------------------------------    def update_fogs      return if !@fog_planes      $game_map.screen.update_fogs      $game_map.screen.fogs.each do |fog|        @fog_planes[fog.number] ||= Plane_Fog.new(@viewport1, fog)        @fog_planes[fog.number].update      end    end  endend # BATTLE_FOGS
@GrandmaDeb If I'm reading it right, Shaz give the fix at post #37


in case you're lazy to check it :
I had seen that, but I had the impression that the "fix" was only for slow moving fogs. Mine is a "no" moving fog.


I guess I was hoping that the original version was going to work... maybe I just don't understand how this script is supposed to be implemented quite yet...


I have no saved files, no other scripts, no common events... =]
Can you send me the image you're using please? If I can reproduce the issue, I'll work on a fix for you.
pm sent. =] Thank you. Please don't go to excess trouble. I probably did something stoopid.
I see what you're trying to do - use the fog script to make multiple parallaxes.


This is exactly one of the things I had in mind when I wrote it - I just never used it for that purpose yet. So I'll see if I can figure out what needs to be done to get it working properly.


In the meantime, if you're desperate, Yami's overlay script should be able to do this for you.
Not desperate. =] Just learning. Glad to be part of the process.
Hi! First of all, great script, thanks for making it

anyway i've got a few questions

Basically, i'm thinking of using this script as a replacement for parallax maps, however the screen gets kind of laggy on even a tiny map, in the sense that the screen's redraw-lines are prominent and creates visible ''breaks'' in the screen when the map scrolls. I was wondering if its a bad idea to use this script as replacement for parallax mapping, if it wasn't intended for that and would cause graphics issues.

EDIT: ignore that, upon closer observation it turns out the lag is inherent to my RPG Maker and not to your script. sorry.

the reason I like this script is because I want to fade in/out  multiple full-map .png's, like one for day, night, sunset, weather, etc. to give it a smooth, natural transition.

my other question is, if its possible to have these Fogs in a viewport that isn't affected by Screen Tint, while still being underneath characters and events?

EDIT 2: it also drags behind event graphics when used this way. perhaps I should find another method...
Lag would not be caused by your RPG Maker. IT would be caused by something you have done. If you need help, post a new thread in Ace Support describing the conditions and your map(s) and we'll help you locate and fix the cause.


Unfortunately screen tint is above characters and events, so anything that's below them MUST be affected by it as well.


Not sure what your "drags behind event graphics" means. You will need to explain it more clearly.
lag was the wrong word to use maybe, its more like a screen-stutter/break caused by framerate discrepancies between the game and my monitor

it happens with any VXA game i play

i'll try to explain it better, if not i'll just make you a .gif to show:

I use a picture of a map based on a 32x32 grid exactly the same as normal parallax mapping except with your Fog script.

so the background map is not actually any tiles, but instead a picture beneath the characters.

I then place a 32x32 event graphic on the actual map grid.

everything's fine when the player is still. the event is aligned on the map the same way as when i placed it in the map editor.

but when the player moves, it seems that the .png map (displayed using the Fog script) temporarily becomes disaligned with the event, dragging 1 or 2 pixels behind, specifically in the opposite direction that the player is moving.

when the player stops moving, the two align themselves once again and it looks normal.

here's a picture to help: 

[IMG]http://i60.tinypic.com/35je1ia.jpg[/IMG]

red is the event on the actual map.

the grid is the Fog image supposed to be fixed to the map (pseudo-parallax .png)

I double checked and made sure the Fog wasn't just following the player. its perfectly fixed to the map the rest of the time
There's a fix for that in the middle of this thread somewhere. I had the same problem, and once I installed the version in the middle of the thread it went away.
There's a fix for that in the middle of this thread somewhere. I had the same problem, and once I installed the version in the middle of the thread it went away.
i'm already using that one  🤘
very interesting. And if you actually do some mapping around the event, the event stays with the mapped areas?
very interesting. And if you actually do some mapping around the event, the event stays with the mapped areas?
yep!

its only a slight annoyance but I though I'd let you know about it
Yeah, thanks. I'm not sure when I'll have time to look at it, but at least you've given good instructions to help me reproduce it, and that's half the battle 🙂
I plan to use this script, but I wanted when to change the screen tint, the fogs were not affected. Has a way of doing this?

I tried changing the values in z, but it not worked.

Original thread: https://forums.rpgmakerweb.com/threads/multi-layer-fog.18835/