RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Relatively Simple Fogs

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 84
Koalas are awesome
Relatively Simple Fogs
Version: 1.5b
Author: Miget man12
Date: August 1, 2009

Version History


  • Version 1.0 7.31.2009 First Version, Each map get's it's own fog.
  • Version 1.5 8.1.2009 Added Multiple Fogs Feature.
  • Version 1.5b 8.7.2009 Fixed bug when you enter and exit menu.

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

  • Each Map gets it's own fog
  • Ability to change fogs while in a map
  • Lots of customization for fogs
  • (V1.5)Maps can have up to 9999 fogs! (Having that many is a really bad idea though :D

Screenshots



Instructions

Refer to script instructions.

Script


Code: [Select]
#==============================================================================
# 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


  • Miget man12
  • Woratana - I never would have figured out the formula for getting the coordinates w/out his script.

Thanks

  • Twilight1300, for originally requesting me to make a fog script
  • Reijubv, for idea of multiple fogs per map

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
« Last Edit: August 07, 2009, 11:19:20 PM by miget man12 »
Spoiler for BIG:
A mini-biography-ish thing of meI am learning to script with Ruby/RGSS2, I think I'm getting pretty good at it :)
Oh yeah, and I know Latin, that count's for something, doesn't it?
This is amazing, can you raed it?
Quote
Olny 55% of plepoe can raed this.
I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it dseno't mtaetr in waht oerdr the ltteres in a wrod are, the olny iproamtnt tihng is taht the frsit and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it whotuit a pboerlm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Azanmig huh? yaeh and I awlyas tghuhot slpeling was ipmorantt! Spelling is important!! :D
fi yuo cna raed tihs, palce it in yuor siantugre.
The Best Ruby Guide I've Found: Why's (poignant) guide to ruby

********
Resource Artist
Rep:
Level 94
\\\\\
Project of the Month winner for June 2009
thank you sir :)

**
Rep:
Level 84
Koalas are awesome
Glad to help ;D

~Miget man12
Spoiler for BIG:
A mini-biography-ish thing of meI am learning to script with Ruby/RGSS2, I think I'm getting pretty good at it :)
Oh yeah, and I know Latin, that count's for something, doesn't it?
This is amazing, can you raed it?
Quote
Olny 55% of plepoe can raed this.
I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it dseno't mtaetr in waht oerdr the ltteres in a wrod are, the olny iproamtnt tihng is taht the frsit and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it whotuit a pboerlm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Azanmig huh? yaeh and I awlyas tghuhot slpeling was ipmorantt! Spelling is important!! :D
fi yuo cna raed tihs, palce it in yuor siantugre.
The Best Ruby Guide I've Found: Why's (poignant) guide to ruby

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Very nice - seems quite easy to use. Good work miget man12

**
Rep:
Level 84
Koalas are awesome
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 for The Fixed Script:
Code: [Select]
#==============================================================================
# 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
Fixed Demo: http://www.mediafire.com/download.php?mmzmykeymwu

~Miget man12
Spoiler for BIG:
A mini-biography-ish thing of meI am learning to script with Ruby/RGSS2, I think I'm getting pretty good at it :)
Oh yeah, and I know Latin, that count's for something, doesn't it?
This is amazing, can you raed it?
Quote
Olny 55% of plepoe can raed this.
I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it dseno't mtaetr in waht oerdr the ltteres in a wrod are, the olny iproamtnt tihng is taht the frsit and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it whotuit a pboerlm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Azanmig huh? yaeh and I awlyas tghuhot slpeling was ipmorantt! Spelling is important!! :D
fi yuo cna raed tihs, palce it in yuor siantugre.
The Best Ruby Guide I've Found: Why's (poignant) guide to ruby