Fog of war - map visible only around my character

Hey!

I'm not sure if fog of war is the right term here but I'm trying to make only part of the map to be visible. The visibility would only be around the player character while the rest of it is darkened out.

In other words, when you move you can only see a certain part of the map around you while the rest of it is darkened out.

You can see the example on the picture below.

Is it possible to do something like this in RPG Maker MZ?

If yes, can you please guide me step by step how to implement this as I'm a beginner when it comes to this engine.


fow1.png


The above picture is taken from an indie game posted on reddit, link here for reference.
I believe fog of war is not the correct term here, as fog of war is a bit different, usually with fog of war, the map would remain visible, slightly darkened, while game objects( events ), would not be visible in this "fog" what your asking for is just more a simple loight source, there are several ways this can be acheieved.

The easiest would be to find a lighting plugin ^^ there are lots out there.

The next easiest way would be to event this. you can use a "show picture" command, to show a large black sprite with a transparent center ( the image itself needs to be MUCH larger than your games resolution I believe by 2X could need to be a little larger, then in a parallel event, you can assign the players screen position to a variable via script call... listed below.

This will set variable 1( change the 1 in the code to whatever variable you want ) to be the players screen X position.
JavaScript:
$gameVariables.setValue( 1, $gamePlayer.screenX() )

and this will set variable 2( change this to whatever variable ID you want ), to track the players screen Y position.
Code:
$gameVariables.setValue( 2, $gamePlayer.screenY() )

THEN after these two variables are set use the move picture command below these two script calls in said event.. in the position section use "Designate with Variables", set the X to variable 1( or whatever you used ), and set the Y to variable 2( or whatever you used to track screen Y ).

also set the duration to 1, and uncheck wait for completion. It should look like the screenshot below.

1705600254489.png


just an FYI I did not test this lol, but it should work( I think ), if you DO decide to do it this way( I recommend a plugin for simple lighting ), and run into any issues just let me know and I'll do my best to help resolve them ^^

EDIT: oops I forgot to mention, set the origin to center! this is important or things will not work correctly! lol
you can assign the players screen position to a variable via script call.
no need for a script call, screen X and Y are directly available to control variable via game data section
@Andar o_o; my apologies for complicating things further than necessary, I did not know you could access the players screen X and Y from within event commands without a script call, I learned something new haha. I guess i spend too much time in a text editor. T_T Thanks for pointing this out!~
@Andar o_o; my apologies for complicating things further than necessary, I did not know you could access the players screen X and Y from within event commands without a script call, I learned something new haha. I guess i spend too much time in a text editor. T_T Thanks for pointing this out!~

Thank you both for answers! Sorry but I'm a bit confused as I'm still fairly new to this engine.

How would I make such an event? Would you mind to give me an example - guide me through step by step?

Thanks in advance!

no need for a script call, screen X and Y are directly available to control variable via game data section

Andar can you help me out with setting such an event? Thanks!
I'm still fairly new to this engine.
Then I strongly suggest you work through the build-in tutorial under Help.
you'll need the basics of eventing before you can understand our instructions, and blindly copying commands without understanding them will cause more problems for you in the future.

After you have those basics, read the first answer above again, and tell us which part of it you still don't understand
I use MPP_Maplight
another one that can work nice (which I use for pitch dark level)
is Shora'sLightning plugin as it also have dynamic shadows and you
can turn it off anytime or do animations on them for the light to follow.

the one AquaEcho might work as well if you want it more simple for
caves only, but it's up to you what works and compatible with the rest
of your plugin uses.

Original thread: https://forums.rpgmakerweb.com/threads/fog-of-war-map-visible-only-around-my-character.164911/