How To Simulate a Thunderstorm

The editor ships with some impressive abilities, such as a very simple way to simulate rain. By combining several of these basic abilities, you can create some more complex scenes such as a fierce storm with thunder and lightning.

Breaking down the effect
Before starting on the implementation, it's helpful to think carefully about what one visually perceives during a storm. This will probably include the following.
 * Pouring rain
 * A periodic lightning flash, which includes:
 * Several bright flickers of light. The light grows brighter very quickly, and fades a bit more slowly.
 * Each flicker sharply illuminates everything in sight
 * Some short time after the flash, you will hear a roll of thunder (with shorter delays indicating closer proximity to lightning)

We're going to look at each of three effects separately: rain, lightning, and thunder.

Rain
Rain is the simplest effect to produce as it only requires a simple Trigger.
 * 1) Create a new trigger
 * 2) Add the When Statement On Map Start
 * 3) Add the Do Statement Set Environmental Effect Amount
 * 4) Set the effect strength to 75

The trigger should look something like this:

WHEN:

DO:

Lighting
Storms are most dramatic in the evening, so your scene will probably have nighttime lighting to start. One scene might use an Ambient Lighting of (42, 37, 98, 225) and a Directional Color of (173, 214, 190, 255) in the direction (-.5, -1. -.75). That results in a dark, blueish black; your lightning will be more noticeable if you make your scene even darker, which may be appropriate depending on whether you want to be dramatic or subtle.

Lightning will result in a much brighter light for a fraction of a second. You can get strong contrast with your night sky by using pure white. I've found better results from using directional light over ambient, shining pure white light in the direction (0, -1, 0), which simulates a bright light from directly overhead that wipes out all shadows. As usual, you should experiment with the colors to find what works best for your map.

Lightning
A single flash doesn't look much like lightning: you'll want a set of fast flashes in rapid succession. You can do this by sending a delayed event for each flash, then having a trigger listen to each event and re-set the directional light, fading back to the original light afterwards.

Finally, lightning bolts tend to be unpredictable, so you'll want to use a random delay between each lightning incident. However, within a particular incident, the delays between flashes are so short that you can use fixed delays.


 * 1) Create three events and three matching triggers
 * 2) * PreFlash
 * 3) * Flash
 * 4) * Fade
 * 5) Check retain this trigger after triggering for all the triggers

At this point you'll have the On Start trigger, the events, and the event triggers.

On Map Start
The first thing we need to do is add an event to the On Map Start trigger that is currently making it rain.
 * 1) Add a Do Statement
 * 2) Select System -> Send Event After Delay
 * 3) Set the user event to the PreFlash event
 * 4) For the delay select Functions -> Random(float)
 * 5) Set the random value to be between 5 and 30

Your On Map Start should look something like this:

When:

Do:

PreFlash
PreFlash is the first event sent out by the On Map Start trigger. This is where we will loop back to later to keep the storm rolling.
 * 1) Add a new When Statement
 * 2) Right-Click the When Statement -> Select the PreFlash event
 * 3) Add a new Do Statement
 * 4) Select System -> Set Directional Light Color
 * 5) Set the Directional Light to face (0, -1, 0)
 * 6) Set the Directional Light color to (1, 1, 1, 1)
 * 7) Set the duration to be (0.5) seconds
 * 8) Set the camera region to your current camera region
 * 9) Add a new Do Statement
 * 10) Select System -> Send Event After Delay
 * 11) Set the User Event to Flash
 * 12) Set the delay to (0.2) seconds

When:

Do:

Flash
Setting up the Flash will be very similar to the PreFlash that triggered it
 * 1) Add a new When Statement
 * 2) Right-Click the When Statement -> Select the Flash event
 * 3) Add a new Do Statement
 * 4) Select System -> Set Directional Light Color
 * 5) Set the Directional Light to face (0, -1, 0)
 * 6) Set the Directional Light color to (1, 1, 1, 1)
 * 7) Set the duration to be (0.1) seconds
 * 8) Set the camera region to your current camera region
 * 9) Add a new Do Statement
 * 10) Select System -> Send Event After Delay
 * 11) Set the User Event to Fade
 * 12) Set the delay to (1) second

When:

Do:

Fade
Fade will be used to reset the scene to your standard lighting. It will also send out the PreFlash event to loop through the lightning again.
 * 1) Add a new When Statement
 * 2) Right-Click the When Statement -> Select the Fade event
 * 3) Add a new Do Statement
 * 4) Select System -> Set Directional Light Color
 * 5) Set the Directional Light to face (-.5, -1, -.75)
 * 6) Set the Directional Light color to (173, 214, 190, 255)
 * 7) Set the duration to be (0.5) seconds
 * 8) Set the camera region to your current camera region
 * 9) Add a new Do Statement
 * 10) Select System -> Send Event After Delay
 * 11) Set the User Event to PreFlash
 * 12) Set the delay to (.5) second

When:

Do:



Thunder
Good audio feedback is the key to making the incident believable. You might be tempted to use one of the Lightning sound effects, but it sounds too electrical and artificial. We want a more low, rumbling sound. None of the existing sounds are perfect, but there's a pretty good match with the spell sound FireboltExplosion (from the Spellcasting group). The first 75% or so of this clip is a really nice approximation of a thunderclap.

In this example, we'll start playing the sound of thunder shortly after the flash starts, and let it continue playing out after the light returns to normal. If you want to position the lightning directly above the player, it should be almost simultaneous; if the storm is far off, you may want a weaker light and a longer delay before the thunder.

To add thunder, we'll create a new event called Thunderclap and add it to the Flash trigger. Then we'll create a new trigger to match the event and play the sound.
 * 1) Create a new event called Thunderclap
 * 2) Select the trigger Flash and add a new Do Statement
 * 3) Right-Click the new Do Statement, select System -> Send Event After Delay
 * 4) Set the User Event to Thunderclap after a delay of 1.25 seconds
 * 5) Create a new trigger called Thunderclap
 * 6) Add a new When Statement
 * 7) Right-Click the When Statement -> Select the Thunderclap event
 * 8) Add a new Do Statement
 * 9) Right-Click the Do Statement, select Gameplay -> Play Sound
 * 10) Right-Click BloodBoltCast, under Existing Sounds select Spellcasting -> FireboltExplosion
 * 11) Set volume to 0.25 and set looping to false

Your Thunderclap trigger should look something like this:

When:

Do:

Fine Tuning
You might notice that there's a fairly long (and random) duration between lightning incidents. Stacking lightning too frequently can be annoying, and calls attention to the not-exactly-right sound effect. Spacing it out makes it more unexpected, which can be more impressive.

If you want to make your lightning more dynamic, you can make use of more random elements to help make the incidents more impressive and surprising. This could include things like:
 * Randomizing intensity, with a brighter flash and louder sound effect simulating a bigger bolt
 * Randomizing the number of flashes in an incident. You could do this by adding a randomized "if" clause, with DO scheduling an additional flash event and OTHERWISE just performing the current flash.

Example
The UGC Antumbra uses the lightning system described in this article in its first scene, simulating a moderate-intensity night thunderstorm.