Lightning


For help, see the VDC Editing Help and Wikipedia cleanup process. Also, remember to check for any notes left by the tagger at this article's talk page.
Note: This article is under construction today. I'm just making a temp save and taking a breather.
This is a tutorial for adding a lightning storm to a map.
It will use custom made lightning sprites (lightning.vmt and lightningglow.vmt) which can be downloaded here (along with an example map). However, the following sprites already included in the SDK can simulate lightning suffciently too:
- bluelight1
- lgtning
- lgtning_noz
- physcannon_bluelight1b
It is assumed that the reader knows how to create a 3D skybox before reading this tutorial.
This setup will make the lightning automatically start on. You will have to do some random triggers if you want it to only be on at a certain part of the map.
Setting up the sprites
Unless lightning is intended to be close enough to strike within the playing area, create the 3D skybox that will house the lightning storm. Make sure that its fog is disabled.
- Place 2 env_sprites about 2-10 units away from each other. (Make sure ones in front of the other.)
- Select the one closest to the skycamera entity.
- In the Sprite Name box write the name of the glow sprite to use for the lightning glow. (The pictures will use the custom materials/sprites/lightningglow.vmt sprite.)
- Set its Scale to 7.
- Make sure Render Mode is additive.
- Make sure that the FX Amount is 50.
- Also change the Name to lightning1glow.
- After that click Apply and then Cancel.
Open the properties of the other sprite.
- Type a name (like lightning1) in its Name field.
- Change the Sprite Name to the name of the lightning sprite to use. (materials/sprites/lightning.vmt)
- Make sure the Render Mode is Additive
- Make sure that the FX Amount is 255.
- Change the Scale to .75.
Timing between strikes
Place a logic_timer in the map, preferably somewhere near your sprites. Open its properties and make the following alterations:
- Name it. (lightning1timer)
- Make sure Use Random Time is set to yes.
- Make sure Min Random Interval is set to 1.
- Make sure Max Random Interval is set to 10.
- Set Refire Interval to 0.35.
- Click on the Outputs tab and add some things to make it look like this:
http://img162.imageshack.us/img162/6269/step202af5.jpg
(Important Note: The example shows the number 2 but in this tutorial number 1 is used so just replace the 2 with 1. Also the Last line is an optional part of this tutorial!) Once you're done that click on the flags tab and make sure the only flag that showing is checked!
Done. Save it and test it out. The steps below are optional.
Adding thunder
To add some thunder sounds it is recommended to use a soundscape (which is not covered by thia tutorial), but a quicker way is to place an ambient_generic somewhere in the map - not in the 3D skybox - and change its name to Thunder.01, change its sound name to k_lab.teleport_post_thunder or another good thunder sound. Then go back to the logic_timer and add "OnTimerLow" "Thunder.02" "PlaySound" to the output tab. You can also set a delay that will reflect on how far away that the lighting is.
Randomized lightning
To prevent the lightning from hitting the same spot twice, you can make the sprites rotate around the skybox. (This doesn't actually show the lightning strikes moving.)
- Create a small brush textured with the invisible tool texture.
- Turn it into a func_rotating entity.
- Call it lightningrotator
- Change the max rotating speed to 3.
- Change the friction to 20.
- Click Apply and close its window.
- Go back to your two sprites and change their parent to lightningrotator.
- Add a logic_auto to the map (Not sure if this is needed or not...)
- In its Outputs tab add this:
"OnMapSpawn" "lightningrotator" "Start"
- Save and test the map.