Notice: fwrite(): Write of 461 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96

Notice: fwrite(): Write of 59 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96

Notice: fwrite(): Write of 1714 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96

Notice: fwrite(): Write of 44 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96

Notice: fwrite(): Write of 8192 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96
Print Page - Relatively Simple Fogs

The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: miget man12 on August 01, 2009, 08:30:55 PM

Title: Relatively Simple Fogs
Post by: miget man12 on August 01, 2009, 08:30:55 PM
Relatively Simple Fogs
Version: 1.5b
Author: Miget man12
Date: August 1, 2009

Version History




Planned Future Versions

n/a

Description



This script takes a different approach to fogs. Instead of having you enter a script call to make a fog appear, it will draw a different fog every time you transfer. In other words, each map has it's own fog that is automatically drawn. I originally made it for use in Twilight1300's Legend of Zelda: Realm of the Gods, then I decided to use it in my own project. I eventually edited it quite a bit, and I did some research, and I found that Woratana's is one of the few working fog scripts. I don't know about every one else, but that script creates a ton of lag for me :D. Anyway, I decided to post this for others. Version 1.5 gives you the ability to use multiple fogs!

Features


Screenshots

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fianrbm.wordpress.com%2Ffiles%2F2009%2F07%2Fscreen01-july4.png&hash=cafde2dfacecf0509d5bfc96c709d3bcf8f56cbc)

Instructions

Refer to script instructions.

Script



#==============================================================================
# Miget man12's Relatively Simple Fogs V 1.5
#
#  This script takes a different approach to fogs. Instead of having you enter
# a script call to make a fog appear, it will draw a different fog every time
# you transfer. In other words, each map has it's own fog that is automatically
# drawn. Version 1.5 allows you to have multiple fogs!
#-----------------------------------------------------------------------------
#Methods you can use::
# To pause a Fog, put a script command:
#  $game_map.fog_frozen[id] = true
#
# To change the Opacity of fog while in a map, put:
#  $game_map.fog[id].opacity = (0~255)
#
# To change the Blend of fog while in a map, put:
#  $game_map.fog[id].blend_type = 0, 1, or 2 (normal, additive, or subtractive)
#
# To change the X movement speed of fog while in a map, put:
#  $game_map.fog[id].sx = number (e.g.: 0.02, 348, 20.7 :P)
#
# To change the Y movement speed of fog while in a map, put:
#  $game_map.fog[id].sy = number (e.g.: 0.4, 4731, 48.29)
#
# To change the Zoom of fog while in a map, put:
#  $game_map.fog_zoom[id] = number (e.g.: 0.1, 674, 381.594)
#
# To change the Filename of a fog while in a map, put:
#  $game_map.fog_filename[id] = "filename" (in quotes!)
#
# To create a Fog in a map that does not have a preset fog or change the fog,
# put:
#  $game_map.setup_fog(See Fog Data Setup)
# Example::
#  $game_map.setup_fog(["BlueSky",95,2,1.5,4,2])
#==============================================================================
module Mm12
 #Customization::
 MAP_FOGS = {} # DO NOT DELETE OR CHANGE THIS! #
#Instructions::
# To set up, put
# MAP_FOGS[map ID]=["fog filename",fog opacity(0~255),
# blend type(0:norm,1:add,2:sub),zoom level(1 is normal),
# move speed on X Axis(1/8 pixel/frame),move speed on Y Axis(1/8 pixel / frame)]
# Example:
#  MAP_FOGS[1] = ["BlueSky",125,0,2,0,0]
#   Explanation:
# MAP001 will have a fog with the BlueSky parallax with 125 opacity that has
#   normal blend. It will be twice as big as the real file, and no movement.
#  MAP_FOGS[2] = ["BlueSky",95,2,1.5,4,2]
#   Explanation:
# MAP002 will have a fog with the BlueSky parallax with 95 opacity that has
#   Sub. blend. It will be 1 1/2 times as big as the real file. It will move 1/2
#   a pixel right every frame, and 1/4 a pixel down every frame.
#(V1.5)
# To have more than one fog per map, just put 2 fogs in brackets, seperated by
# commas:
#  MAP_FOGS[3] = [["CloudySky",45,0,1.3,2,0],["BlueSky",45,2,1.5,3,5]]
################
# Actual Setup::
 MAP_FOGS[1] = ["BlueSky",165,0,2,0,0]
 MAP_FOGS[2] = ["BlueSky",145,2,1.5,4,2]
 MAP_FOGS[3] = [["CloudySky",75,0,1.3,2,0],["BlueSky",65,2,1.5,3,5]]
# Folder where fogs reside
 FOGS_FOLDER = "Parallaxes"
end
module Cache
 #--------------------------------------------------------------------------
 # * Get System Graphic
 # filename : Filename
 #--------------------------------------------------------------------------
 def self.fog(filename)
load_bitmap("Graphics/#{Mm12::FOGS_FOLDER}/", filename) rescue Bitmap.new(200,200)
 end
end
class Game_Map
 attr_accessor :fog, :fog_frozen, :fog_hidden, :fog_opacity, :fog_ox, :fog_oy,
 :fog_zoom, :fog_filename
 alias mm12_fog_gm_mp_setup setup
 alias mm12_fog_gm_mp_update update
 alias mm12_fog_gm_mp_init initialize
 def initialize
mm12_fog_gm_mp_init
@fogox = Array.new(9999,0)
@fogoy = Array.new(9999,0)
@fog_ox = []
@fog_oy = []
@fog = []
@filename = []
@fog_filename = []
@fog_zoom = []
@fog_hidden = []
@fog_frozen = Array.new(9999,false)
 end
 def setup(map_id)
mm12_fog_gm_mp_setup(map_id)
setup_fog
 end
 def setup_fog(fog_data=nil)
for i in 0..(@fog.size-1)
 if @fog_hidden[i]
@fog[i].opacity = @fog_opacity
@fog_hidden[i] = false
return
 end
 @fog[i].dispose unless @fog[i] == nil
 @fog[i] = nil
end
@fog = []
if fog_data == nil
 fog_data = Mm12::MAP_FOGS[@map_id]
 if fog_data.nil?
@fog_used = false
return
 end
 if !fog_data[0].is_a?(Array)
fog_data = [fog_data]
 end
 i = 0
 for data in fog_data
@fog[i] = Plane.new
@fog[i].ox=0
@fog[i].oy=0
@fog[i].ox = @fog_ox[i] unless @fog_ox[i].nil?
@fog[i].oy = @fog_oy[i] unless @fog_oy[i].nil?
@fog_ox[i] = nil
@fog_oy[i] = nil
@fog[i].bitmap = Cache.fog(data[0])
@fog[i].z = 30
@fog[i].opacity = data[1]
@fog[i].blend_type = data[2]
@fog[i].zoom_x = data[3]
@fog[i].zoom_y = data[3]
@fog_zoom[i] = data[3]
@fog[i].sx = data[4]#.to_f
@fog[i].sy = data[5]#.to_f
@filename[i] = data[0]
@fog_filename[i] = data[0]
i += 1
 end
else
 if !fog_data[0].is_a?(Array)
fog_data = [fog_data]
 end
 i = 0
 for data in fog_data
@fog_used = true
@fog[i] = Plane.new
@fog[i].bitmap = Cache.fog(data[0])
@fog[i].opacity = data[1]
@fog[i].blend_type = data[2]
@fog[i].zoom_x = data[3]
@fog[i].zoom_y = data[3]
@fog_zoom[i] = data[3]
@fog[i].sx = data[4]
@fog[i].sy = data[5]
@filename[i] = data[0]
@fog_filename[i] = data[0]
i += 1
 end
end
 end
 def update
mm12_fog_gm_mp_update
for i in 0..(@fog.size-1)
 return if @fog[i].nil?
 @fog[i].zoom_x = @fog[i].zoom_y = @fog_zoom[i] if @fog[i].zoom_x != @fog_zoom[i]
 if @fog_filename[i] != @filename[i]
@filename[i] = @fog_filename[i]
@fog[i].bitmap = Cache.fog(@filename)
 end
 if @fog_frozen[i]
@fog[i].ox = ($game_map.display_x/8.0)+@fogox[i] unless @fog[i].nil?# or @fog_frozen or @fog.ox == ($game_map.display_y/8.0)+(@fog.sx/8.0)
 else
@fogox[i] -= @fog[i].sx/8.0 unless @fogox[i].nil?
@fog[i].ox = ($game_map.display_x/8.0)+@fogox[i] unless @fog[i].nil?# or @fog_frozen or @fog.ox == ($game_map.display_y/8.0)+(@fog.sx/8.0)
 end
 if @fog_frozen[i]
@fog[i].oy = ($game_map.display_y/8.0)+@fogoy[i] unless @fog[i].nil?# or @fog_frozen or @fog.oy == ($game_map.display_y/8.0)+(@fog.sy/8.0)
 else
@fogoy[i] -= @fog[i].sy/8.0 unless @fogoy[i].nil?
@fog[i].oy = ($game_map.display_y/8.0)+@fogoy[i] unless @fog[i].nil?# or @fog_frozen or @fog.oy == ($game_map.display_y/8.0)+(@fog.sy/8.0)
 end
end
 end
end
class Scene_Map
 alias mm12_fog_scn_mp_terminate terminate
 alias mm12_fog_scn_mp_start start
 def start
mm12_fog_scn_mp_start
$game_map.setup_fog
 end
 def terminate
mm12_fog_scn_mp_terminate
for i in 0..9999
 next if $game_map.fog[i].nil?
 $game_map.fog_ox[i] = $game_map.fog[i].ox
 $game_map.fog_oy[i] = $game_map.fog[i].oy
 $game_map.fog[i].dispose unless $game_map.fog[i].nil?
 $game_map.fog[i] = nil
end
 end
end
class Plane
 attr_accessor :sx, :sy
end


Credit




Thanks


Support



I'm generally more active on RRR, but asking for support on here should be fine ^_^ Here's the RRR topic: http://www.rpgrevolution.com/forums/index.php?showtopic=33707

Known Compatibility Issues

None... Yet!

Demo


http://www.mediafire.com/download.php?mmzmykeymwu

Restrictions

If you want to use this for a commercial game, PM me on RRR(RPG RPG Revolution) Feel free to edit it, but please do not post this or an edited version elsewhere.

~Miget man12
Title: Re: Relatively Simple Fogs
Post by: Grafikal on August 02, 2009, 04:41:31 AM
thank you sir :)
Title: Re: Relatively Simple Fogs
Post by: miget man12 on August 02, 2009, 04:51:10 AM
Glad to help ;D

~Miget man12
Title: Re: Relatively Simple Fogs
Post by: modern algebra on August 03, 2009, 11:44:40 PM
Very nice - seems quite easy to use. Good work miget man12
Title: Re: Relatively Simple Fogs
Post by: miget man12 on August 07, 2009, 11:15:41 PM
Bug fix!
This will fix the error of having it so that if you open the menu and close it you get a no method error.
[spoiler=The Fixed Script]#==============================================================================
# Miget man12's Relatively Simple Fogs V 1.5
#
#  This script takes a different approach to fogs. Instead of having you enter
# a script call to make a fog appear, it will draw a different fog every time
# you transfer. In other words, each map has it's own fog that is automatically
# drawn. Version 1.5 allows you to have multiple fogs!
#-----------------------------------------------------------------------------
#Methods you can use::
# To pause a Fog, put a script command:
#  $game_map.fog_frozen[id] = true
#
# To change the Opacity of fog while in a map, put:
#  $game_map.fog[id].opacity = (0~255)
#
# To change the Blend of fog while in a map, put:
#  $game_map.fog[id].blend_type = 0, 1, or 2 (normal, additive, or subtractive)
#
# To change the X movement speed of fog while in a map, put:
#  $game_map.fog[id].sx = number (e.g.: 0.02, 348, 20.7 :P)
#
# To change the Y movement speed of fog while in a map, put:
#  $game_map.fog[id].sy = number (e.g.: 0.4, 4731, 48.29)
#
# To change the Zoom of fog while in a map, put:
#  $game_map.fog_zoom[id] = number (e.g.: 0.1, 674, 381.594)
#
# To change the Filename of a fog while in a map, put:
#  $game_map.fog_filename[id] = "filename" (in quotes!)
#
# To create a Fog in a map that does not have a preset fog or change the fog,
# put:
#  $game_map.setup_fog(See Fog Data Setup)
# Example::
#  $game_map.setup_fog(["BlueSky",95,2,1.5,4,2])
#==============================================================================
module Mm12
  #Customization::
  MAP_FOGS = {} # DO NOT DELETE OR CHANGE THIS! #
#Instructions::
# To set up, put
# MAP_FOGS[map ID]=["fog filename",fog opacity(0~255),
# blend type(0:norm,1:add,2:sub),zoom level(1 is normal),
# move speed on X Axis(1/8 pixel/frame),move speed on Y Axis(1/8 pixel / frame)]
# Example:
#  MAP_FOGS[1] = ["BlueSky",125,0,2,0,0]
#   Explanation:
# MAP001 will have a fog with the BlueSky parallax with 125 opacity that has
#   normal blend. It will be twice as big as the real file, and no movement.
#  MAP_FOGS[2] = ["BlueSky",95,2,1.5,4,2]
#   Explanation:
# MAP002 will have a fog with the BlueSky parallax with 95 opacity that has
#   Sub. blend. It will be 1 1/2 times as big as the real file. It will move 1/2
#   a pixel right every frame, and 1/4 a pixel down every frame.
#(V1.5)
# To have more than one fog per map, just put 2 fogs in brackets, seperated by
# commas:
#  MAP_FOGS[3] = [["CloudySky",45,0,1.3,2,0],["BlueSky",45,2,1.5,3,5]]
################
# Actual Setup::
  MAP_FOGS[1] = ["BlueSky",165,0,2,0,0]
  MAP_FOGS[2] = ["BlueSky",145,2,1.5,4,2]
  MAP_FOGS[3] = [["CloudySky",75,0,1.3,2,0],["BlueSky",65,2,1.5,3,5]]
# Folder where fogs reside
  FOGS_FOLDER = "Parallaxes"
end
module Cache
  #--------------------------------------------------------------------------
  # * Get System Graphic
  # filename : Filename
  #--------------------------------------------------------------------------
  def self.fog(filename)
load_bitmap("Graphics/#{Mm12::FOGS_FOLDER}/", filename) rescue Bitmap.new(200,200)
  end
end
class Game_Map
  attr_accessor :fog, :fog_frozen, :fog_hidden, :fog_opacity, :fog_ox, :fog_oy,
  :fog_zoom, :fog_filename
  alias mm12_fog_gm_mp_setup setup
  alias mm12_fog_gm_mp_update update
  alias mm12_fog_gm_mp_init initialize
  def initialize
mm12_fog_gm_mp_init
@fogox = Array.new(9999,0)
@fogoy = Array.new(9999,0)
@fog_ox = []
@fog_oy = []
@fog = []
@filename = []
@fog_filename = []
@fog_zoom = []
@fog_hidden = []
@fog_frozen = Array.new(9999,false)
  end
  def setup(map_id)
mm12_fog_gm_mp_setup(map_id)
setup_fog
  end
  def setup_fog(fog_data=nil)
for i in 0..(@fog.size-1)
  if @fog_hidden[i]
@fog[i].opacity = @fog_opacity
@fog_hidden[i] = false
return
  end
  @fog[i].dispose unless @fog[i] == nil
  @fog[i] = nil
end
@fog = []
if fog_data == nil
  fog_data = Mm12::MAP_FOGS[@map_id]
  if fog_data.nil?
@fog_used = false
return
  end
  if !fog_data[0].is_a?(Array)
fog_data = [fog_data]
  end
  i = 0
  for data in fog_data
@fog[i] = Plane.new
@fog[i].ox=0
@fog[i].oy=0
@fog[i].ox = @fog_ox[i] unless @fog_ox[i].nil?
@fog[i].oy = @fog_oy[i] unless @fog_oy[i].nil?
@fog_ox[i] = nil
@fog_oy[i] = nil
@fog[i].bitmap = Cache.fog(data[0])
@fog[i].z = 30
@fog[i].opacity = data[1]
@fog[i].blend_type = data[2]
@fog[i].zoom_x = data[3]
@fog[i].zoom_y = data[3]
@fog_zoom[i] = data[3]
@fog[i].sx = data[4]#.to_f
@fog[i].sy = data[5]#.to_f
@filename[i] = data[0]
@fog_filename[i] = data[0]
i += 1
  end
else
  if !fog_data[0].is_a?(Array)
fog_data = [fog_data]
  end
  i = 0
  for data in fog_data
@fog_used = true
@fog[i] = Plane.new
@fog[i].bitmap = Cache.fog(data[0])
@fog[i].opacity = data[1]
@fog[i].blend_type = data[2]
@fog[i].zoom_x = data[3]
@fog[i].zoom_y = data[3]
@fog_zoom[i] = data[3]
@fog[i].sx = data[4]
@fog[i].sy = data[5]
@filename[i] = data[0]
@fog_filename[i] = data[0]
i += 1
  end
end
  end
  def update
mm12_fog_gm_mp_update
for i in 0..(@fog.size-1)
  return if @fog[i].nil?
  @fog[i].zoom_x = @fog[i].zoom_y = @fog_zoom[i] if @fog[i].zoom_x != @fog_zoom[i]
  if @fog_filename[i] != @filename[i]
@filename[i] = @fog_filename[i]
@fog[i].bitmap = Cache.fog(@filename)
  end
  if @fog_frozen[i]
@fog[i].ox = ($game_map.display_x/8.0)+@fogox[i] unless @fog[i].nil?# or @fog_frozen or @fog.ox == ($game_map.display_y/8.0)+(@fog.sx/8.0)
  else
@fogox[i] -= @fog[i].sx/8.0 unless @fogox[i].nil?
@fog[i].ox = ($game_map.display_x/8.0)+@fogox[i] unless @fog[i].nil?# or @fog_frozen or @fog.ox == ($game_map.display_y/8.0)+(@fog.sx/8.0)
  end
  if @fog_frozen[i]
@fog[i].oy = ($game_map.display_y/8.0)+@fogoy[i] unless @fog[i].nil?# or @fog_frozen or @fog.oy == ($game_map.display_y/8.0)+(@fog.sy/8.0)
  else
@fogoy[i] -= @fog[i].sy/8.0 unless @fogoy[i].nil?
@fog[i].oy = ($game_map.display_y/8.0)+@fogoy[i] unless @fog[i].nil?# or @fog_frozen or @fog.oy == ($game_map.display_y/8.0)+(@fog.sy/8.0)
  end
end
  end
end
class Scene_Map
  alias mm12_fog_scn_mp_terminate terminate
  alias mm12_fog_scn_mp_start start
  def start
mm12_fog_scn_mp_start
$game_map.setup_fog
  end
  def terminate
mm12_fog_scn_mp_terminate
for i in 0..9999
  next if $game_map.fog[i].nil?
  $game_map.fog_ox[i] = $game_map.fog[i].ox
  $game_map.fog_oy[i] = $game_map.fog[i].oy
  $game_map.fog[i].dispose unless $game_map.fog[i].nil?
  $game_map.fog[i] = nil
end
  end
end
class Plane
  attr_accessor :sx, :sy
end
[/spoiler]
Fixed Demo: http://www.mediafire.com/download.php?mmzmykeymwu (http://"http://www.mediafire.com/download.php?mmzmykeymwu")

~Miget man12