Simple Shadows
Version: 1.1b
Author: Marc of Fall From Eden
Date: April 12, 2012
Version History
- <Version 1.1b> 2012.04.12 - Minor bug fix. Events casting "sun" shadows would not have their shadows erased if the event graphic was changed to None.
- <Version 1.1> 2012.03.23 - Added an option in the Marc::Shadow module to enable or disable showing shadows only on floor tiles (for compatibility purposes).
- <Version 1.0> 2012.03.15 - Original Release
Description
This is a cosmetic script originally intended to work in tandem with Marc's Dynamic Lighting script in order to create shadows that are cast from the player and other events based on how close they are to a light source.
Features
- Generates shadows from defined light sources that may be cast on the player and other events.
- These light sources can be automatically generated if you are using Marc's Dynamic Lighting script.
- You may also create a "sun" effect that creates a constant shadow for exterior maps.
- Shadows are based on a picture rather than character or event graphics (making for smooth shadows).
- Shadows may only cast on "floor" tiles (tiles from TileA1, TileA2, and TileA5), not walls.
- For compatibility purposes, you can disable shadows being shown only on floor tiles.
- These effects may be enabled or disabled through a switch.
- It's eye-candy!
Screenshots Instructions
This script is relatively easy to use, particularly if you are already using Marc's Dynamic Lighting script (seeing as dynamic lights used in that system automatically generate shadows with this script). By default, however, no other events cast shadows, nor are they considered light sources that generate them.
In order to create a light source, add the comment SHADOW_SOURCE to the event you want to use as a light source. This will make the event generate shadows which will be displayed on shadow-casting events. To make an event cast shadows, add the comment SHADOW_CAST to the event.
For exterior scenes, you may also create a "sun" effect by adding the comment SHADOW_SUN to
any event on the map. This will create a persistent shadow that is generated by all shadow-casting events on the map with a pre-defined angle and opacity.
The script also makes use of the Marc::Shadow module, which allows you to change some of the default settings of the script. The first thing you will likely want to change is the SHADOW_SWITCH, which you should set to the switch ID that you want to enable or disable the shadow effects. SHADOW_ENABLED determines whether or not you wish to have the SHADOW_SWITCH turned "ON" automatically when a new game is started (this does not affect saved and loaded games). By default, the player also generates shadows; if you want this effect disabled, change PLAYER_SHADOW to "false" (without quotes). If you are using Marc's Dynamic Lighting script, you can have light effects automatically generate shadows by setting AUTO_SHADOW to "true" (without quotes); if this is not desired, set it to "false" (again, without quotes).
NOTE: If the SHADOW_SWITCH is turned "OFF" or "ON"
while the map is running, you will have to make the script call "$scene = Scene_Map.new" in order to clear or add the shadow effects!
To change the file used to create shadows, change the value of SHADOW_FILE to the name of the picture you would like to use as a shadow. Likewise, you may change the maximum opacity of shadows with SHADOW_OPACITY. The maximum range of shadows is represented as a number of tiles in SHADOW_RANGE (so a range of 4 will show shadows up to four tiles away from the light source).
You can also change the angle of "sun" effects with SUN_ANGLE, and the opacity of shadows generated by the "sun" effect with SUN_OPACITY.
The SHADOWS_ONLY_ON_FLOOR constant determines whether or not you want the shadows to be cast on floor tiles (TileA1, TileA2 and TileA5) or on
all tiles. Set it to true to only show shadows on floors, false to show them on all tiles. Setting this to true makes the shadows look a bit nicer overall, but may reduce compatibility; setting it to false, on the other hand, does not look
quite as good, but should be very compatible with other scripts.
Any of the values written in the Marc::Shadow module may be modified in-game by making a script call. For example, to change the maximum range of all shadows, make the script call "Marc::Shadow::SHADOW_RANGE = <new value>". Note that some of these changes
will require the script call "$scene = Scene_Map.new" to take effect immediately. (With some ingenuity, you could use this with a time script to change the angle of the "sun" shadows based on the current time, since changing the angle and opacity of the "sun" effect does not require renewing the scene.
)
Script
You may get the latest version of this script from my public Dropbox
here. You will also require
this image in your Graphics/Pictures directory, or
this image if you are using Mack-style characters. (
NOTE: You will need to rename the image for Mack-style characters to "sh.png"
or change the value of SHADOW_FILE to "sh_mack" in the script.)
Credit
- Marc of Fall From Eden
- rataime (for shadow-related formulas)
Support
You may receive support for this script in this topic or by sending us a personal message on these forums. Support in this topic is for the Simple Shadows script
only,
not the Dynamic Lighting script included in the demo!
Known Compatibility Issues
This script aliases quite a bit in Spriteset_Map, including overwriting how tilemaps are assigned to viewports. As such, there are likely to be compatibility problems with scripts which modify tileset viewports or make other extensive modifications to Spriteset_Map. If you encounter such compatibility problems, please let us know which script is conflicting with this one, and Marc will attempt to correct the issue.
Demo
Simple Shadows DemoIncludes the Simple Shadows script as well as Marc's Dynamic Lighting core script and module.
Author's Notes
This script was written entirely for our own purposes while creating an atmospheric adventure-style psychological horror game. This was the primary reason for such tight integration with Marc's Dynamic Lighting system. Honestly, he only added some other features to the script because he thought that they would be useful to anyone
not using his previous script.
As such, this script may seem light on features, but we've found the effect of it to be pleasing to the eye and easy enough to use that we thought we would share the outcome.
Restrictions
This script is licensed under a Creative Commons BY-SA 3.0 license. Essentially, you may use it for commercial games, but proper attribution is required; as well, you may modify the script any way you like as long as the modified version retains attribution to the original author and is released under an
identical license.