content bg

Tutorials


Introduction, map for testing

All right, in this tutorial I'll do my best to explain how to make thunderstorm effects in Hammer editor.

Here's what we are going to make:
- Lightnings
- Thunders
- Rain
- Fog

So let's start. We are going to need some small map (DUH!), so let's make it. Let's create a large brush which will serve as a skybox. Then let's put some ground with walls around it. Inside we'll place some spawn points and a small building - one small room is enough. 




Once you are done with that, let's set our skybox. In the map's properties, set skybox tosky_day01_09. Now apply the changes, and close the properties window. Selectlight_environment entity, and place it somewhere in your map. Now set the values accordingly:

Ideal Sun Angle 0 12 0 
Ideal Sun Pitch -45 
Ideal Brightness 175 230 239 65 
Ideal Ambience 83 104 130 50 

(as you, undoubtedly, know, optimal values for different skyboxes are listed on the Valve Developer wiki: http://developer.valvesoftware.com/wiki/Sky_List )




Now we're all set, let's move on and make some lightnings and thunders.

Logic controllers

If you take a closer look on the list of different entities, you'll notice that there's a lot of different logic_ entities. They all serve a certain purpose, but right now we are interested in the following entities:

- logic_timer, 2 times
- logic_case

Go ahead, and place them somewhere in your map. Place the following entities somewhere nearby:

- ambient_generic, 4 entities
- light

By double-clicking on those entities you can change their properties. Before we do anything else, set names of those entities:
- name ambient_generic entities t1, t2, t3, t4
- name the first logic_timer as init, the second one as light_blinking
- name logic_case as case
- name light as light




Now that we have this stuff gathered in one place, let me explain how it works (in case you are new to this logic_ stuff).

logic_timer is just a timer. In the intervals that we define, this entity can send certain output to other entities, thus triggering certain actions, such as enabling/disabling light entity, making ambient_generic entity play sound and so on.

logic_case takes input from other entity (like for example logic_timer), and based on the input, decides, to which entity it will address it's output (with a value, that we define).

Lightning

How do we make lightning? Well, it's pretty simple.
The first timer (named init) is enabled all the time. And in the random intervals between 20 and 40 seconds it will activate another timer (named light_blinking), which is deactivated by default.
light_blinking timer will make our light (which has to be pretty bright) blink - simply by activating and disabling our light entity in the random intervals between 0.05 and 0.2 seconds.
I hope you get it.

So let's do it. First double-click the light entity. Set some blueish color and make it very very bright - 20,000 will do.
Now open the Flags tab, and set Initially dark, so that the light is disabled by default.




Now double click the light_blinking timer. We want it to activate/deactivate our light entity in the random, yet very small intervals (to make it blink - in case you didn't get it). So put "0.05" into the Minimum Random interval field and "0.2" into the Maximum Random Intervalfield. Set Use Random Time to "Yes", and Start Disabled to "Yes" (well, we don't want out lightning to flash all the time, right?).

Now switch to the Outputs field. Click Add button. Into the My output named field put "OnTimer" (which means that the action will be performed once the timer is triggered). The target is our light entity, so put "light" into the Targets entities named field. Into the Via this input field put "Toggle" - which will toggle the light. This is it, we are done with this entity.




So what do we got? Once we activate light_blinking timer, the light starts blinking. Once we disable it, the light stops blinking. Let's make it happen in a certain intervals.
For this you are gonna double-click the init timer. Make sure it is activated by default (Start disabled: No), uses random time (Use Random time: Yes). Set the minimum interval to 20 and the maximum to 40.




Now switch to the Outputs tab. This time we want the target named light_blinking to be activated for 3 seconds. How do we achieve it?
First of all, we activate it. Click Add button, put "OnTimer" to the My Output named field, name of our target entity (light_blinking) the the targets field. This time input is "Enable", so put "Enable" into the Via this inputi field. We don't need any delay, it's done.

So how do we turn off the light_blinking timer after 3 seconds? We do the same (so you just press Copy and then Paste), except we change the input to "Disable" and we put "3" into theAfter delay in seconds of field.




Done? Well guess what, our circuit is buggy. Say second timer (light_blinking) is activated. So it toggles the light entity on/off very often. Now the first timer (init) disables the second timer. Light goes down? Maybe. The point is, the first timer could disable the second timer when the light was on. In this case, the light won't go down before the second timer is activated again.

So we want to make sure the light is turned off. We create the new output. OnTimer, target named light will receive the TurnOff input with the delay of 4 seconds (4, not 3, because we want to perform this check once light_blinking timer has been turned off).

Congratulations, if you've done everything right, the lightning is fully functional now.

Rolls of thunder

Okay, we're almost done here. Let's configure our ambient_generic's first.

Once our mighty init timer goes on, we see the flash of light. Also we want to hear the roll of thunder. And we don't want to hear the same sound each time. This is why we have 4 ambient_generic entities.




So let's set them up. Double click the first one, named t1. We have to set the Sound namefield. Click "Browse...", and select ambient/atmosphere/thunder1.wav. The volume should probably be 10. Now switch to the Flags tab. Mark "Start silent", "Play everywhere" and "Is NOT looped" flags (I'm getting nervous over wasting my whole day with this tutorial, so this time you won't get any screenshot!).
Now do the same to the remaining ambient_generic's, except change thunder1.wav to thunder2.wav/thunder3.wav and thunder4.wav accordingly.

We wanna randomly pick which ambient_generic will be played once init is triggered, that's why we double click case (logic_case entity, remember?). 




There's nothing interesting in the Class Info tab, so let's switch to the Outputs tab. Now we are going to use 4 outputs: OnCase1,...,OnCase4. The will be picked randomly by init.
All you have to do is to select OnCase1 output, put t1 into the target field, select Play Soundinput, that's all. ambient_generic will stop playing automatically, since it's not looped. Do this for all 4 ambient_generics (changing numbers accordingly).
Once you are done, you should see this:




Now the last step is to make logic_case entity pick random value once init is triggered. So let's open Outputs flag in the properties of the init logic_timer, and add the following output:
output name: OnTimer
target: case
input: PickRandom

That's it. Click apply. As far as I remember, we've done everything to make it work. If you compile your map, and after 40 seconds you don't see lightning/hear thunder, put some insult into the comments.