Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

SEE - Fogs

~ Intro ~

Anyway, this script will allow you to have fogs in your RPG Maker VX game, just like XP!
Just set everything up in the config module, and you're ready to go!

~ Requirements ~

You need this folder inside your Graphics folder: http://www.mediafire.com/?quf57svc05o4332

~ Screenshots ~

2w5lhfb.png


~ Script ~

Code:
#===============================================================================

# * SEE - Fogs                                             * Version 1 *

# * By StormCross

# * [url=http://www.planetdev.co.uk]http://www.planetdev.co.uk[/url]

# * 26/09/2011

# * If you like my scripts, please show your appreciation by checking out

#   my friendly, helpful Game Development Community, PlanetDev. Link above.

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

# * Aliased Methods

#   - initialize (Spriteset_Map)

#   - update (Spriteset_Map)

#   - dispose (Spriteset_Map)

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

# * This script allows you to have fogs, just like in RPG Maker XP!

#===============================================================================

 

$imported = {} if $imported == nil 

$imported["SEE - Fogs"] = true

 

#===============================================================================

# * Main StormCross Engine Evolution Configuration Module

#===============================================================================

module SEE

  #==========================================================================

===

  # * Fogs Configuration Module

  #==========================================================================

===

  module Fogs

    MAPS = []

    #==========================================================================

=

    # * The number after MAPS[1] corresponds to the ID of the map in RMVX.

    #   The values are as follows.

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

    # * Name, Opacity, Movement Direction, Horizontal Speed, Vertical Speed

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

    # * Name - The filename of the fog graphic in Graphics/Fogs

    # * Opacity - The opacity of the fog. 64 is reccomended.

    # * Movement direction of the fog. There are 9 presets.

    #   0 = Static

    #   1 = Left

    #   2 = Right

    #   3 = Up

    #   4 = Down

    #   5 = Upper Left

    #   6 = Upper Right

    #   7 = Lower Left

    #   8 = Lower Right

    # * Speed of the horizontal movement of the fog. 1 is default.

    # * Speed of the vertical movement of the fog. 1 is default.

    #==========================================================================

=

    MAPS[1] = ["001-Fog01", 64, 8, 1, 1]

  end # Fogs

end # SEE

 

#===============================================================================

# * Spriteset_Map edit for fog effects

#===============================================================================

class Spriteset_Map

  include SEE::Fogs

  #==========================================================================

===

  # * Alias the initialize method and create fogs

  #==========================================================================

===

  alias see_fogs_spritesetmap_init initialize

  def initialize

    see_fogs_spritesetmap_init

    if MAPS[$game_map.map_id] != nil

      create_fog

    end

  end # initialize

  #==========================================================================

===

  # * Create the fog graphic

  #==========================================================================

===

  def create_fog

    @fog_sprite = Plane.new(@viewport1)

    @fog_sprite.bitmap = Cache.fogs(MAPS[$game_map.map_id][0])

    @fog_sprite.opacity = MAPS[$game_map.map_id][1]

    @fog_name = MAPS[$game_map.map_id][0]

  end # create_fog

  #==========================================================================

===

  # * Update the fog movement and graphic

  #==========================================================================

===

  def update_fog

    if @fog_name != MAPS[$game_map.map_id][0]

      @fog_name = MAPS[$game_map.map_id][0]

      if @fog_sprite.bitmap != nil

        @fog_sprite.bitmap.dispose

        @fog_sprite.bitmap = nil

      end

      if @fog_name != ""

        @fog_sprite.bitmap = Cache.fogs(MAPS[$game_map.map_id][0])

      end

      Graphics.frame_reset

    end

    case MAPS[$game_map.map_id][2]

    when 0 # Static

      @fog_sprite.ox = $game_map.display_x / 8

      @fog_sprite.oy = $game_map.display_y / 8

    when 1 # Left

      @fog_sprite.ox += MAPS[$game_map.map_id][3]

    when 2 # Right

      @fog_sprite.ox -= MAPS[$game_map.map_id][3]

    when 3 # Up

      @fog_sprite.oy += MAPS[$game_map.map_id][4]

    when 4 # Down

      @fog_sprite.oy -= MAPS[$game_map.map_id][4]

    when 5 # Upper Left

      @fog_sprite.ox += MAPS[$game_map.map_id][3]

      @fog_sprite.oy += MAPS[$game_map.map_id][4]

    when 6 # Upper Right

      @fog_sprite.ox -= MAPS[$game_map.map_id][3]

      @fog_sprite.oy += MAPS[$game_map.map_id][4]

    when 7 # Lower Left

      @fog_sprite.ox += MAPS[$game_map.map_id][3]

      @fog_sprite.oy -= MAPS[$game_map.map_id][4]

    when 8 # Lower Right

      @fog_sprite.ox -= MAPS[$game_map.map_id][3]

      @fog_sprite.oy -= MAPS[$game_map.map_id][4]

    end

  end # update_fog

  #==========================================================================

===

  # * Alias the update method and update fogs

  #==========================================================================

===

  alias see_fogs_spritesetmap_update update

  def update

    if @fog_sprite != nil

      update_fog

    end

    see_fogs_spritesetmap_update

  end # update

  #==========================================================================

===

  # * Alias the dispose method and dispose of fogs

  #==========================================================================

===

  alias see_fogs_spritesetmap_dispose dispose

  def dispose

    dispose_fogs

    see_fogs_spritesetmap_dispose

  end # dispose

  #==========================================================================

===

  # * Dispose the fog graphic

  #==========================================================================

===

  def dispose_fogs

    @fog_sprite.dispose

  end # dispose_fogs

end # Spriteset_Map

 

#===============================================================================

# * Cache edit to support fogs

#===============================================================================

module Cache

  #==========================================================================

===

  # * Load fog graphic

  #==========================================================================

===

  def self.fogs(filename)

    load_bitmap("Graphics/Fogs/", filename)

  end # self.fogs

end # Cache

~ Credits ~

StormCross - Script

~ Commercial Games ~

This script is free for use in commercial games, but credit is required.
 

Atoa

Member

Compared with other fogs systems that already exist, yours lack of features.
There is fog systems that allows in game customization of the fog effects: change opacity, blend type, change fog speed, and even add multiple fogs, everything with script calls.
That way if the user would like to change the fog effect during an event, he could.

Name, Opacity, Movement Direction, Horizontal Speed, Vertical Speed
I don't see a point in have direction and horizontal/vertical speed. With the speed itself you can control the direction.
so this whole code:
Code:
    case MAPS[$game_map.map_id][2]

    when 0 # Static

      @fog_sprite.ox = $game_map.display_x / 8

      @fog_sprite.oy = $game_map.display_y / 8

    when 1 # Left

      @fog_sprite.ox += MAPS[$game_map.map_id][3]

    when 2 # Right

      @fog_sprite.ox -= MAPS[$game_map.map_id][3]

    when 3 # Up

      @fog_sprite.oy += MAPS[$game_map.map_id][4]

    when 4 # Down

      @fog_sprite.oy -= MAPS[$game_map.map_id][4]

    when 5 # Upper Left

      @fog_sprite.ox += MAPS[$game_map.map_id][3]

      @fog_sprite.oy += MAPS[$game_map.map_id][4]

    when 6 # Upper Right

      @fog_sprite.ox -= MAPS[$game_map.map_id][3]

      @fog_sprite.oy += MAPS[$game_map.map_id][4]

    when 7 # Lower Left

      @fog_sprite.ox += MAPS[$game_map.map_id][3]

      @fog_sprite.oy -= MAPS[$game_map.map_id][4]

    when 8 # Lower Right

      @fog_sprite.ox -= MAPS[$game_map.map_id][3]

      @fog_sprite.oy -= MAPS[$game_map.map_id][4]

    end
could be changed to this:
Code:
 

      @fog_ox = @fog_ox.nil? ? 0 : @fog_ox + MAPS[$game_map.map_id][2]

      @fog_oy = @fog_oy.nil? ? 0 : @fog_oy + MAPS[$game_map.map_id][3]

      @fog_sprite.ox = $game_map.display_x / 8 + @fog_ox

      @fog_sprite.oy = $game_map.display_y / 8 + @fog_oy
(you can also set the @fog_ox = 0 and @fog_oy = 0 on the initialize method and just add the plus value, this would make it faster than cheking it every time if it's nil)

That way, if the values are 0, there's no movement, and the direction would change if they're negative or positive.

You could also store the values on an local instance of $game_map, instead of
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top