Multi Layer Fog

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,606
Reaction score
13,194
First Language
English
Primarily Uses
RMMV
Multi Layer Fog 1.0
Shaz
Introduction
This script allows you to add multiple fog layers to your map and control the appearance and behaviour of them individually.

Features
- Show fog between the parallax background and the map
- Show fog above the map
- Set different fog layers to scroll in different directions and at different speeds
- Change fog tone over time
- Change fog opacity over time
- Choose whether fog is cleared when going to a new map
- Choose whether fog on a map carries through to battle screens

How to Use
Installation
Paste into a new script slot below Materials.

Customization
BATTLE_FOGS - set to true to show fog on battle screens (default), or false to show fog only on the map
CLEAR_ON_TRANSFER - set to true to remove all fog when changing maps (default), or false to keep fog until removed manually (false will make fog behave like pictures)

Using Fog
The following commands are all made via Call Script event commands.



Code:
show_fog(id, "filename", hue, opacity, blend_type, zoom, speed_x, speed_y, z)
will add the fog to the map. id is an array index (like picture numbers), and is used to further control fog with other commands.
Only id and filename are mandatory.
z, if used, should be greater than -100 and less than 0 to display fog between the parallax background and the map. If not used, fog will be shown above characters; fogs with a higher id will be shown above those with a lower id.

Code:
tint_fog(id, red, green, blue, gray, duration)
will change the tint/tone of the fog over the duration (in frames)

Code:
fade_fog(id, opacity, duration)
will change the opacity of the fog over the duration (in frames)

Code:
erase_fog(id)
will remove the fog with that id


Script
Get it here
Version 2 here (to address the 'fog sticks to player' issue)

Credit and Thanks
- credit Shaz

Author's Notes
Free for use in commercial games. Give credit.
 
Last edited:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,094
Reaction score
11,435
First Language
English
Primarily Uses
RMVXA
I've been wanting a script like this, so seeing it I've plunged straight in - and got an error message because I'm useless at scripts.  The message is:

Script 'Shaz multi fog' line 414: NoMethodError occurred

undefined method 'each' for nil:NilClass

I have tried to use the script for 2 areas, and made sure that the folder Fogs exists and has the 2 images in it.  I think I must have made a mistake in at least one of the script calls.  This is what I have done:

show_fog(1, "alpha_fog", 0, 128, 1.5, -2, 1)

which represents: id, file name, hue, opacity, zoom, speed x, speed y

show_fog(1, "Nighttime fog", 0, 150, 1, 1.5, -2, -2)

which represents: id, file name, hue, opacity, blend type, zoom, speed x, speed y

Can you tell me what I have done wrong?

Thanks
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,606
Reaction score
13,194
First Language
English
Primarily Uses
RMMV
Zoom is a %, so if you want it twice the size, you'd use 200. But that's not the cause of the error. I'd almost bet you've loaded a saved game instead of starting a new one after adding the script.


As a one-off fix, add this before line 103:

Code:
@fogs = Game_Fogs.new if !@fogs
Hopefully that'll fix it, if that is indeed what you've done (loaded a save file). If it works, it won't hurt to leave that line in there, but I'd remove it when you're ready to start playing again from the beginning.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,094
Reaction score
11,435
First Language
English
Primarily Uses
RMVXA
You would have won your bet, I did indeed load a save file.  As I prefer to play test every area as I do it, and I'm past 9 hours of game play, I'd like to be able to continue with an existing save file, but I don't think I've understood properly your instruction to "add this before line 103".  I thought that meant adding it after line 102 and before line 103, effectively making a new line, but I get the same error message when I do that.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,606
Reaction score
13,194
First Language
English
Primarily Uses
RMMV
Yeah, I was a bit worried that might not work, since it's not in the same class that actually creates the fogs.

Can you try adding this, as a temporary NEW script? If it works, and you have multiple save files, open ALL your save files so this code runs, then save them again, and then you can get rid of the temp script.

Code:
class Game_Screen  def create_fog    @fogs = Game_Fogs.new  endendclass Spriteset_Map  alias save_fix_update_fogs update_fogs  def update_fogs    $game_map.screen.create_fog if !$game_map.screen.fogs    @fog_planes = [] if !@fog_planes    save_fix_update_fogs  endend
Let me know if that helps.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,094
Reaction score
11,435
First Language
English
Primarily Uses
RMVXA
Great, this seems to solved the problem.  I can't test it any further than just opening and re-saving everything as I now have to go out for the whole day, but that in itself is a huge step forward.

Thanks so much.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,094
Reaction score
11,435
First Language
English
Primarily Uses
RMVXA
I hope this doesn't count as a double post, but it is quite separate from the above.

In testing, I entered an area where I had set up the fog thus:

show_fog(1, "alpha_fog", 0, 128, 0, 150, -2, 1)

The fog shows beautifully.  However, when I go to enter a battle, I get this error message:

Script 'Shaz multi fog' line 95: NoMethodError occurred

undefine method 'each' for nil:NilClass

Just to check, I changed the default for showing the fog on the battle screen from 'true' to 'false', but still got the same message.

If I move on to the next map, where I have used copy/paste to set up the fog, I get this error message:

Script'Game_Interpretor' line 1411: NoMethodError occurred

undefined method 'set_up fog' for #<Game_Interpretor:0x98el1224>

You will not be surprised to learn that I have zero understanding of what that means, so have done nothing to test it further.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,606
Reaction score
13,194
First Language
English
Primarily Uses
RMMV
Can you try setting your starting position on that map, start a new game, and go into battle? See if the fog displays and you transition to battle with no errors.


That second error message sounds like the script isn't even in your game, or is all commented out.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,094
Reaction score
11,435
First Language
English
Primarily Uses
RMVXA
Starting a new game from that map solves the first problem.  It transitions into battle and the fog is showing.

However, moving on to the 2nd map still produces the same error message as before.  By definition the script is there and is not commented out because the fog shows up on the first map without a problem.  So the game can read the script on one map, but not the other.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,606
Reaction score
13,194
First Language
English
Primarily Uses
RMMV
Check the script call you use. Is it EXACTLY written as it needs to be? If it is exactly set_up fog as in your previous post, then it's wrong. The method call is show_fog.


If that doesn't help you, can you provide screenshots of your event (entire event window, including conditions, tabs, the lot) both from the map that works, and from the one that doesn't?
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,094
Reaction score
11,435
First Language
English
Primarily Uses
RMVXA
Here are the screen shots.  Map 1 shows the event that works, Map 2 comes from the map that is causing the problem.

">

">http://http://s1323.photobucket.com/user/ksjp17/media/Map2_zps27ca5009.png.html'>
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,606
Reaction score
13,194
First Language
English
Primarily Uses
RMMV
Can you give me a screenshot of the error message? The one you've written out CAN'T be produced by this script.


You don't have my old XP Style Fog script in there too, do you?
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,094
Reaction score
11,435
First Language
English
Primarily Uses
RMVXA
Here is the error message.  I have no other fog script installed.

">http://s1323.photobucket.com/user/ksjp17/media/Errormessage_zps5fb427b5.png.html'>
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,606
Reaction score
13,194
First Language
English
Primarily Uses
RMMV
Did you ever use the previous fog script I wrote? The setup_fog command was used in that script, but is not used in THIS script.


Somewhere, you have an event that's doing a Call Script command with setup_fog in it. It's giving you an error because this script has no setup_fog method.


It's either an event on the second map, or a common event.
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,094
Reaction score
11,435
First Language
English
Primarily Uses
RMVXA
Found it!  It was in a common event.  I never even thought of looking there until your suggestion.  Now everything is working perfectly. 

Thank you for taking the time to sort this one out.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,606
Reaction score
13,194
First Language
English
Primarily Uses
RMMV
I like it when it's a problem at your end, and not mine - still takes a while to track down and resolve, but it's comforting to know the script isn't faulty :)
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,094
Reaction score
11,435
First Language
English
Primarily Uses
RMVXA
Yeah, the script is fine, and looks really good in-game.  I feel such a dumbbat, though, at not thinking of the common event earlier.  Still, it's something I've learned and may well save me angst in the future.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,094
Reaction score
11,435
First Language
English
Primarily Uses
RMVXA
I'm sorry to come back with yet another stupid question, but I don't understand one of the instructions.

For tinting the fog, it says "To change fog tone, use the following in a Call Script event command:
#    tint_fog(number, red, green, blue, gray, duration)"

The duration I want is as long as the party is on the map, but I suspect that that is not what you are referring to.  Could you tell me what duration refers to in this context and how to set it.

Once again, apologies for such a basic question.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,606
Reaction score
13,194
First Language
English
Primarily Uses
RMMV
Duration, in both tint and fade, is how long you want it to take to apply the tint/fade (will it be gradual, over 5-10 seconds [300-600 frames]? Or will it be immediate?). Not how long you want it to last.


It's the same as tint/fade of fog in RMXP.
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,094
Reaction score
11,435
First Language
English
Primarily Uses
RMVXA
As I want it to be as soon as you enter the map, I tried putting 1 - either as one frame or 1 second, I don't know which the script uses - so that my script call reads

tint fog, -119, -81, -34, 85, 1

However, that gives me the error message

Script 'Game Interpreter' line 1411: NameError occurred

undefined local variable or method 'fog' for

#<Game Interpreter:0x9ad9b44>

I assume it's because just putting a 1 in the tint fog command is not how it's done, but I can't think of another way. 
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Don't mind me, just installing a fog machine. :LZSwink:


I can't stop looping this BGM while at work since I began to play PSO2. It just too good for mood booster.
How to post a picture there in the status feed?
So I was at the grocery store trying to reach for some small garbage bags on the top shelf way in the back. Instead of going all the way downstairs to find someone to help me I grabbed a broom and pulled it down. Putting the broom back I said, "Thank you for your service".
S.O.S.--10:16pm......two toddlers still awake....send help...

Forum statistics

Threads
100,423
Messages
975,701
Members
132,080
Latest member
Garycomehome
Top