Region Fog
This script allows you to control fog of war using region tiles. Each map can assign multiple different regions of fog. Different fog regions are separate from one another.
Script calls are used to show or hide region fog.
Download
Script – Demo
Required: Bit Switches
You will also need this image: region_fog_tileset
Installation
Place this script below Bit Switches and above Main.
Place the “region_fog_tileset” image into your Graphics/System folder
Usage
Creating your region fog
The basic note-tag is given as follows:
<region fog> region: x, switch: y </region fog>
Where x and y are both numbers. You can have as many region fogs as you want on a single map. You can assign the same switch to multiple regions, across different maps as well. The basic note-tag requires you to specify the region and its corresponding switch.
If you require more advanced options, or don’t want to use all of the options
available, use the extended note-tag as follows:
<region fog: 2> switch: 2 tile: 1 </region fog>
Which will designate region 2 as a region fog, whose visibility is based on
bit-switch 2, and uses fog tile 1.
Custom Fog Tiles
By default, the fog tile you get is black. If you look at the region_fog_tileset image, you will see a 32×32 black square near the top-left.
Each tile has an ID. The top-left tile is tile 0, which is no fog.
The one next to it is tile 1, which is the default black fog. You can add your
own fog tiles as well, and reference in the extended note-tag if you want
specific regions to use specific fog tiles.
Changing Fog Visibility
To show or hide the a region fog, you will need to change the value of the
switch. These are bit switches, so you won’t be able to use the “Control
Switches” event command to change them.
To hide the fog, make the script call
hide_region_fog(switch_id)
To show the fog, make the script call
show_region_fog(switch_id)
Example
Here’s a sample region fog setup:
<region fog> region: 1, switch: 1 region: 2, switch: 2 region: 3, switch: 1 </region fog>
This means that the fog for regions 1 and 3 use the same bitswitch.
If you called
hide_region_fog(1)
This would hide the fog for both region 1 and region 3.
An equivalent setup using the extended note-tag would be as follows:
<region fog: 1> switch: 1 </region fog> <region fog: 2> switch: 2 </region fog> <region fog: 3> switch: 1 </region fog>
It is more verbose, the extended note-tag provides more options and not every option is required.
Exist a method to show a character upper the fog?
No, when I wrote the script I assumed the fog would cover what’s under it.
Hey. Nice script but hard in use. Isnt be better to just automatically set all fogs on and just switching it off when player goes on specific area ? In way like this script is is just almost the same work as making this by game variables/switches and pictures without any outer ruby scripts.
Oh i just get idea i just change automatically switches by making common event for specific switches. Cool sctipt
Yes, but there are many different ways to use the fogs.
Hey Hime!
I was just thinking, for a little better aesthetics, would there be a way to create a slight fade on the fog's visibility?
Thank you!
Fade as in, making it somewhat transparent? Or an actual, fully animated fog effect? Cause transparency can be done, but if you want an actual fog with different opacities here and there, that would be out of the scope of my knowledge.
No, no sir! Haha, just the transparency thing, and it would be already awesome. This "fog of war" is exactly what I was looking for, but it should show up and disappear just a little bit more smoothly. The Nocturne Rebirth game (Echoes in the Moonlight) has something like it, and it shows how can nice things be done with it.
I looked at the way the script was written, but unfortunately it doesn't seem like there's an easy way to change it so that each region would fade-in or out with the current design.
A different approach would be required to provide the animations since the one I used doesn't support it.
Don't bother yourself with this request, it's ok. I mean, it's a detail and only. I confess didn't look at whole the script, I'm yet learning to program, but I can guess you replace the marked tiles with others, instead of covering the area with something else. If I'm right, to make a soft transition really wouldn't sound easy. Let me have another question, if you don't mind: to make an area covered with black, in that way, but enabling opacity managing in it would cause to much lag?
Thank you!
You basically have no control over tilemaps, so anything involving specific tile manipulations beyond telling it which tile you want to use is pretty much impossible.
Ideally the fogs themselves should just be sprites, which would then be easy to manipulate. You would also be able to perform custom fade animations such as out-to-in and so on. There would not be much lag there if it were implemented that way.
So I’m wondering if this idea I had would be a quick easy way to have a nice border to the fog. The idea is that you make the fog tiles larger than 32×32, say 40×40, but have them centre on the middle 32×32 section. The centre section would still be completely black but the “edges” that would overlap would be black with transperancy and the “corners” would have a higher transperancy so when they overlap with other corners it looks nice. Just an idea.
That can be done using a smarter fog generator that uses auto-tiles. The engine would use an auto-tile to generate the fog, and you would choose an auto-tile that has a border along the edge.
Each fog tile cannot be larger than 32×32 however, because I’m using the tilemap to generate it.
Could that be done by using vx aces built in tile reading capacities or does this script read the tiles straight from the .png meaning you’d have to put the auto-tiling into the script?
The script will have to do it, but there is code available to accomplish that already.
Script has been updated with a new extended note-tag that allows you to choose custom fog tile. Instructions on how to use the extended note-tag as well as creating your own fog tiles have been added.
Just an FYI. This script is causing a hard application crash on transition from battle to area map. The crash doesn’t happen when using the troop menu ‘Battle Test’ so whatever is happening it likely has to do with the process of re-loading of the area map.
I am using a lot of disparate scripts in my current build, with over a dozen of yours, Yanfly, Kread-EX, and a few others so I am not sure if it is due to any particular one, or just an overload of some sorts; but I can sometimes make out the black tiles starting to appear over the effected regions when the crash occurs, and removing this script (it took 2 hrs of removing/replacing stuff to isolate it) stopped it.
I do not expect you to fix it, just figured I would report on my attempt to use it. Hopefully my rambling leads you to a possible solution, if the desire strikes you. I will report if I find anything more specific.
Thanks again for sharing what you do.
Might be related to the fact that I did not dispose the graphics properly and there were too many of them left around. I’ve updated the script see if it continues to occur.
Works great now. Thanks!