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.
Fog of War

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 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 Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Best RPG Maker User (Scripting)2010 Best Use Of Avatar And Signature Space
Fog of War
Version: 1.0
Author: modern algebra
Date: July 6, 2010

Version History


  • <Version 1.0> 07.06.2010 - Original Release

Description


This script allows you to create "fog of war" on specified maps. This is a concept familiar to RTS games as it is used to hide the movement of enemy units when they are not in range of your own units. This script brings that concept to RMVX, and allows for two layers: a permanent one that is cleared forever once a unit explores the area, and a temporary one that is clear only for as long as it is within range of a unit. You can use either layer or both for any given map.

This script also allows for other events (not just the player) to have vision, and will hide other events not within direct vision of a unit unless you specify that event to show anyway.

Features

  • Allows you to give any map you want a fog of war, a great feature for dungeons
  • Has the ability to use two layers of fog of war, one that is cleared permanently once it comes in to sight, and one that is only cleared for as long as it is within sight
  • Uses separate autotiles for each layer, with the ability to change the opacity of each
  • You can use either or both layers for any given map
  • Events that are under the fog of war will not be shown, unless the current page of it is tagged with a special comment (for using events as a third map layer)
  • Sight is not limited to the player - you can also give an event sight by including a special comment on its page
  • Can use diamond shaped clear or circular clear for any unit with sight

Screenshots



Instructions

Please see the header of the script for instructions.

Script


Script is very long. Please retrieve it either from the text document or demo.

Bug Fixes

Spoiler for Exit Site Uncleared:
If you re-enter a fog of war map at a different place than you exited, the sight radius will still be cleared at the site you exited. This patch fixes that:

Code: [Select]
#==============================================================================
#  Clear Temporary Layer Patch
#    Bug fix for Fog of War 1.0
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    There was a bug in the previous version where if you re-entered a map with
#   fog of war at a different location than you exited, the sight radius from
#   when the player exited would still be there. This patch fixes that bug.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Paste this into its own slot below Fog of War but still above Main.
#==============================================================================

class Tilemap_FogofWar
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_hos_initz_fow_6yh2 initialize
  def initialize (*args)
    # Eliminate the top layer
    $game_system.paint_fog ($game_map.map_id, 0, 2816)
    $game_player.update_fow
    ma_hos_initz_fow_6yh2 (*args) # Run original method
  end
end

Credit


  • modern algebra

Thanks

  • Wachunga, for the RMXP script that inspired the creation of this one
  • Zeriab, for the Table Printout script
  • Heartofshadow, for a bug report

Support


Please post in this topic at RMRK if you require support, no matter when this topic was last posted in. Do not PM me.

Known Compatibility Issues

No currently known compatibility issues, but it may interact strangely with some fog scripts.

Demo


See attached

Graphics

I have attached a few fog of war autotiles as samples and free for use. "FogOfWar" and "FogOfWar2" I made myself, while "FogOfWar Wachunga" is a resized version of the sample autotile Wachunga used in his RMXP script. All FogOfWar autotiles must be saved in System.

Also, the script has "FogOfWar2" built into it, and it will use that autotile if you have no fog of war autotiles in the System folder.

Author's Notes


I remember using Wachunga's Fog of War script when I first started using RMXP. It's a nice idea, so I figured I'd write my own RMVX one.
« Last Edit: August 21, 2011, 08:32:33 PM by modern algebra »

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Holy cow... You even made your own default auto-tile through script...

I would never go so far for my scripts :P Great job. Could someone be working on an RTS Script?
« Last Edit: July 06, 2010, 08:32:43 PM by cozziekuns »

***
Rep:
Level 81
it's time to poke
It's also useful for TBS games in the vein of Fire Emblem, etc.

Awe-inspiring step forward yet again, Modern.


*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
It's also useful for TBS games in the vein of Fire Emblem, etc.

Awe-inspiring step forward yet again, Modern.

Speaking of which, do your forsee any compatability problems with any Tactical Battle System?

***
Rep:
Level 81
it's time to poke
Speaking of which, do your forsee any compatability problems with any Tactical Battle System?
Not with GTBS, but I'll have to take a look-see.


*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 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 Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Best RPG Maker User (Scripting)2010 Best Use Of Avatar And Signature Space
I've never used any TBS, so I couldn't say for sure. It would depend on if it uses or inherits from Spriteset_Map, and you could only set vision for player units if it uses events to denote them. Assuming those two factors are present, it would probably work.

And, definitely not working on an RTS script. That could only have terrible application to RM :P
« Last Edit: July 07, 2010, 01:19:10 AM by modern algebra »

***
Rep:
Level 81
it's time to poke
You are a genius if there ever was one. You could probably make a cleaner version than the GTBS (since GubiD used a large portion the XP version of his script, which made customisation kind of tedious in some ways).


I was wondering if you were interested in taking on a dynamic random dungeon generation script, if anything (there is one out already, but it has some problems). A Roguelike script, if you will ;)


**
Rep: +0/-0Level 84
Above Characters
Hmm i got an interesting idea. Don't know if something like this has already been made... (sorry if such thing already exists)
Is it hard to make two temporary 'fog of war' layers with possibility to set two independent sight radiuses? And i guess there must be a way to check if the player is in the 'darkness' or not.
I'm just still dreaming of realtime lighting&stealth system)
I've already seen a stealth script, but it felt incomplete without hiding-in-the-shadows routine)
I also tried to make stealth levels with parallax shadows. But the amount of eventing there was horrifying - to check all tiles on the map, if player is lit enough, whether or not the guards see him etc etc... And the main problem was that no matter how pretty hand-drawn shadows are, they were static.

So now its possible to make light sources, walking guards with torches and stuff like that)
« Last Edit: July 16, 2010, 01:10:51 AM by 104251 »

****
Rep:
Level 83
That does sound like a really neat idea and a great idea that could probably use this script to the fullest of its capabilities. This does sound like it would be very hard to do with out any scripts.

oh and modern this is a really cool script you never seize to amazing any one with your scripts, and im sure like me every one is always looking foreword to that next one.
Spoiler for:
METALFRESH is a paint contractor that specializes in refinishing metal and vinyl siding. We paint metal buildings as well as siding on homes.

We also

    Refinish decks
    Do custom interior painting
    Strip wallpaper
    Refinish cedar siding
    Metal front doors and sidelights
    Metal garage and service doors
    Grained fiberglass doors

    If your structure is *RUSTED *FADED *CHALKING *IN NEED OF COLOR CHANGE, we can fix it with a guarentee!

northern Illinois and southern Wisconsin.

http://metalfreshcoatings.com


**
Rep: +0/-0Level 84
Above Characters
So what do you say, MA?
How much of the script needs to be changed?  Two temporary layers, two radius, transparency and circular/diamond shape settings.


--edit--
like that)
Spoiler for:
« Last Edit: July 17, 2010, 02:03:07 PM by 104251 »

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 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 Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Best RPG Maker User (Scripting)2010 Best Use Of Avatar And Signature Space
It wouldn't be hard to do; if I get some time in the future I might do it, but I don't think it would look like that map - it looks like the parts with the fire are tinted. Are you actually wanting the fire layer to use a tinted autotile over the parts that it lights?
« Last Edit: July 18, 2010, 02:35:59 PM by modern algebra »

**
Rep: +0/-0Level 84
Above Characters
No-no, i just photoshop'd it like that) The glow effect around the light sources can be done separately with appropriate charsets or pictures, no need to do that with script.
Actually it can be enough with only one shadow layer, but with two layers shading will be smooth and not so blocky. Also i think that it can be used to determine the intensity of character lighting - is he fully, partially lit or in total darkness.

Gosh, if you'll manage to achieve that, it will be real masterpiece!

**
Rep: +0/-0Level 75
RMRK Junior
I really hope I don't get crunched into a little ball for necro-posting......

Anyway......I love this Fog of War system.  I just can't get it to work with GTBS v1.5.1.4 (The most current)

If there's anyway you can find it in you heart to make a patch, or at least point me in the right direction, I would be most grateful......Thank You!






*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 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 Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Best RPG Maker User (Scripting)2010 Best Use Of Avatar And Signature Space
I am in the middle of exams right now so cannot do anything, but remind me after April and I will see if I'm not busy then.

**
Rep: +0/-0Level 75
RMRK Junior
Roger that.....

I'm getting married in a couple of weeks, so I'll probably bug you sometime in late May.....


Thank You!

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 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 Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Best RPG Maker User (Scripting)2010 Best Use Of Avatar And Signature Space
Congratulations! Three cheers for marriage!

Just three though :P I'll cheer more for it when I'm not bitter and single.

**
Rep: +0/-0Level 75
RMRK Junior
HAHAHAHA.....My NOOB skills rock......

I copied the method used to make Wortona's Light effects, and multiple fogs Patches for GTBS.....


This patch will allow the Fog of War to work with GTBS......All I need now is a way to make the player view effect work......because GTBS is NOT run by events, but by sprite_sets....and it's really confusing... :(


At least this cuts down on future work.....and I'll try and find a way around this in the meantime.....

The power of NOOB runs strong within me!!!



Code: [Select]
#===============================================================================
# This Script is made specfically for usage with GTBS version 1.5.1.4 by GubiD.
#===============================================================================

#--------------------------------------------------------------
# Fog of War (modern_algebra) Patch
#--------------------------------------------------------------


if defined? (Tilemap_FogofWar)
class Spriteset_Battle_GTBS
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create Tilemap
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modrnb_fow_crttilmp_5tf2 create_tilemap
  def create_tilemap (*args)
    modrnb_fow_crttilmp_5tf2 (*args) # Run Original Method
    # Create viewport between tile and picture layers
    @fow_viewport = Viewport.new (0, 0, Graphics.width, Graphics.height)
    @fow_viewport.z = 40
    data = $game_system.fow_data
    $game_system.fow_reset_data ($game_map.map_id) if @tilemap.map_data.xsize != data.xsize || @tilemap.map_data.ysize != data.ysize
    @fow_tilemap = Tilemap_FogofWar.new(@fow_viewport)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Dispose of Tilemap
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malgbr_fow_dispmap_7yh2 dispose_tilemap
  def dispose_tilemap (*args)
    malgbr_fow_dispmap_7yh2 (*args) # Run Original Method
    for i in 0...9 do @fow_tilemap.bitmaps[i].dispose end
    @fow_tilemap.dispose
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Tilemap
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias monaba_fogwar_tilmup_2fu8 update_tilemap
  def update_tilemap (*args)
    monaba_fogwar_tilmup_2fu8 (*args) # Run Original Map
    @fow_tilemap.ox = @tilemap.ox
    @fow_tilemap.oy = @tilemap.oy
    @fow_viewport.visible = $game_map.fow_active
    @fow_tilemap.update
  end
end
end

**
Rep: +0/-0Level 84
Above Characters
Oh, its not dead? Nice!

**
Rep: +0/-0Level 75
RMRK Junior
I have come back from the awesomeness that is the Bahamas!!!!!!   8)

Anyway....back to reality.......

Ok....so I figured out how to show the Fog of War (FOW) on GTBS battles with the little scriplet I conjured up.  The problem now becomes integrating FOW with the players on the GTBS map.  Actors are spritesets instead of events......which makes the problem harder (at least for me it does).....

I don't think we have to worry about the enemies too much, because you probably don't want them to show if the players haven't found them.....I tried fiddling around with both your script and GTBS, and failed miserably....


I humbly ask for your help modern_algebra.....your status in the rpgmaker world is legendary.......any help would be most appreciated!





**
Rep: +0/-0Level 67
RMRK Junior
So, if the fog creates lag on the map, how do i fix this?

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 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 Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Best RPG Maker User (Scripting)2010 Best Use Of Avatar And Signature Space
Well, does the fog create lag on the map? You could grab an anti-lag script to help prevent lag from other sources, but to reduce lag from the FOW I would need to take a look; there probably are ways I could make it more efficient than it is. But why the hypothetical? Is it causing lag or not?

Sorry cippy, I forgot all about you. If you still want it, send the demo you have to me and I will take a look

**
Rep: +0/-0Level 67
RMRK Junior
EDIT:  If you experience lag using show_fow (0) change it to show_fow (1) and the script settings for opacity should be Permanant layer 255 temp layer 55 or whatever desired.
« Last Edit: August 02, 2011, 07:44:20 PM by twist3d nova »

**
Rep: +0/-0Level 75
RMRK Junior
No worries modern.....I figured out how to implement it a few weeks ago......

I actually have taught myself ruby(With GubiD's awesome tutorial series) and have been scripting for a little bit....I usually go by Nelderson, not sure why I chose cippy for this site.....

Anyway......here it is:

Crap it exceeds the maximum characters.......just download this demo, it has it in there......

 http://www.mediafire.com/?vqpas1a9uxruf2y

BTW: Your script does cause some lag, especially when dashing..... ::)
« Last Edit: August 11, 2011, 08:00:44 AM by cippy12486 »

*
Rep:
Level 98
2010 Best Veteran2014 Best Use of Avatar and Signature Space2014 King of RMRK2014 Favorite Staff Member2014 Best Counsel2014 Best Writer2014 Most Mature Member2014 Best IRC Chatterbox2013 Favorite Staff MemberSecret Santa 2013 ParticipantFor the great victory in the Breakfast War.Secret Santa 2012 Participant2011 Best Counsel2011 Best Writer2010 Best Writer2010 Funniest Member
Have you thought of a way to create complete encapsulating darkness until explored, and in the wake leaves the 'post-shadow' that is the current default?
you awoke in a burning paperhouse
from the infinite fields of dreamless sleep

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 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 Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Best RPG Maker User (Scripting)2010 Best Use Of Avatar And Signature Space
I'll look into ways of reducing the lag.

@Anski - I might be misunderstanding the question, but I think that's how it is now.