Location Settings

From The DarkMod Wiki
Jump to navigationJump to search

written by demagogue

This describes a method of doing ambient sounds in which entering a "location" zone (the area inside a set of portals) turns on an omni ambient inside that area, then turns it off when you leave, possibly starting a new ambient for the new zone.

It uses three entities: a special speaker (speaker_zone_ambient), info_location's, and location dividers.

Note: Two alternative ways to get ambient sounds in your map are using speakers (Adding ambient Sounds to your Map), and using triggers (Ambient Sounds - Zone (using triggers)). Speakers are good if you only want your ambient to cover a definite radius and have a very simple setup. Triggers are basically obsoleted by the method in this tutorial. The only time you might still want to use a trigger-system is if you want a ambient sound to begin at a place where for some reason you can't create a portal to mark the zone boundary, but you can still have a trigger brush. There are some issues with a trigger system, too, that make the method in this tutorial superior.


The Speaker

Create a speaker_zone_ambient entity in your blueroom (i.e., a room off to the side the player will never enter). Right click -> Create entity -> Darkmod -> Sound -> atdm:speaker_zone_ambient.
In the speaker's spawnargs, put the names of all the ambient sounds you want to play in your map. (This pre-loads the sounds into the speaker so there isn't a pause when they start playing.) Put it in this property/value form (without the quote marks):
"snd_streets" "city_night01_loop"
"snd_mansion" "sound/ambient/ambience/mansion_tense01a.ogg"
The left hand spawnarg should have a "snd_" prefix, and any name, but most useful is probably the name of the area it is for. You'll use this name again when you place the location markers.
The right hand value points to the actual sound file that will play. You can enter either the soundshader name, or the address where the sound file is. You can see the soundshader names of ambient-ready sounds in the sub-folder "Darkmod/sound/tdm_ambient_ambience.sndshd". You can find the address of the sound files in "Darkmod/sound/ambient/ambience" (remember to start the address with "sound" in the spawnarg). You can also listen to the sounds at that location. They are are in .ogg format.
Note that it is very easy to add custom ambients with this system. Just create a folder in your .pk4 (a .zip file renamed to .pk4), "sound", with another folder inside it named after your FM or an abbreviation. Put your custom sound inside that second folder. (E.g., I have a custom ambient named Frozen.ogg, and my FM's name is Patently Dangerous. So in my .pk4 was "sound/patent/frozen.ogg". Note that ambients must be in either .ogg or .wav format. Now in your speaker_zone_ambient, just put the sound's address in the spawnarg. In my case, I have "snd_warehouse" "sound/patent/frozen.ogg".
Regarding properties, the speaker has by default the properties "omni", "global", and "looping" already turned on, so that all sounds played are heard everywhere, from no direction, and will loop. If you change these properties (e.g., for one ambient) the change will apply to all ambients on the speaker. So you probably don't want to turn these properties off. "Volume" is another potential property; but it has been left off as a default. You can change the volume of sounds played on the speaker with the property, but again it will apply to all the ambients on the speaker.
Your speaker will look like this:

It is worth noting that one special "sound" is already loaded by default.
"snd_silence" "silence"
You can see it if you check "Show Inhereted Properties". This is the sound you use to turn "off" the ambient sounds playing, so there is silence in the zone.
You are finished with the speaker now.

The Location Entities

Now you need to set up the location system so the game knows where the zones are, the boundaries of where it will turn an ambient on or off. A location is basically any area that's closed in by brushes and marked portals and contains an info_location entity.

As an aside, locations are also used for setting the EAX properties in the area (e.g., the echo-y-ness of a big hall or cave, or the dullness of a small carpeted room). So you have a good reason to have them even in addition to handling ambient sounds.


info_locationseparator.

As I suggested above, you have to mark all the portals leading in and out of a zone by hand. You do this with an entity called a info_locationseparator. Create one so it touches the portal you want as a boundary. Right click -> Create entity -> Darkmod -> Info -> info_locationseparator. If you don't touch a portal with this entity, than it will not register in the game as the boundary to a new zone, and the zone will continue into the area on the other side of the portal. This happens even if you have a second info_location (described below) on the other side (the game will just pick one and use that for the whole zone). This can be a good thing because, say you have a mansion with 30 portals inside. You can cover the whole area inside it by just marking the 2 or 3 portals leading into the mansion area through the doors and open windows, and everything inside that marked area will be counted as one location (just don't miss marking an exit, or have an un-portaled gap to the outside between brushes, or the location will leak outside. It has to be hermetically sealed).
I have read discussion that a door touching a portal marks it as a location boundary, but in my experiments the door did not create a new location and I still had to use a info_locationseparator over the portal to register it as a boundary.


info_location

Now, inside the zone you want to be covered with an ambient, create a info_location entity. Right click -> Create entity -> Darkmod -> Info -> info_location. Anywhere in the space of the zone is fine. Name it the name of the zone you want (to make it easy to find when you push "j").
Now create a spawnarg property of "ambient" with the value being the speaker-name of the sound you used in the speaker above (NOT the soundshader name or file name). For example,
"ambient" "snd_streets"
This will send a command to the speaker to play the ambient it has registered under "snd_streets" that you entered. When you enter a new zone, in turn, the new info_location sends a command to the speaker to turn off that ambient and start a new one.
If you wanted to have no ambient playing in the zone (and turn off any ambient started from another zone), you would use "snd_silence" as the value to command the speaker to turn off. Also, if you have an info_location with no "ambient" value at all, it will also turn off the ambient (in the present version of this system).
Here are two info_locations on two sides of a portal, with a info_locationseparator touching the portal, and with each info_location containing the name of the ambient that will play in its respective zone.

That's basically it. The ambients will now turn on when you enter a zone and turn off when you enter a new zone, turning on the new ambient in that new zone. If you open up the console, you should see a message saying that a new ambient is now playing in your current location, naming the ambient and location.

Fading

Finally, there are a few other spawnargs on the info_locations that you usually don't have to worry about, but you can use them if you like, so I will mention them. They concern the properties of the ambient fading. Check the "Show Inhereted Properties" to see their default values.

fiduration

"Fade in duration". This is the length of time in seconds it takes for the in-coming ambient (the one for this zone) to completely fade-in. The default value is 4 seconds. You can, e.g., make the fade last much longer with a larger value.
If you don't want your ambient to fade in at all, but start immediately at full volume, change this value to ".001" (NOT zero). That's what's being done in the image.

foduration

"Fade out duration". This is the length of time in seconds it takes for the out-going ambient (the one from the zone you're leaving) to completely fade-out. Again, if you want it to cut right off without fading, use a value of ".001". That's what's being done in the image.

fidelay

"Fade in Delay". You can delay the beginning of the in-coming ambient's fade-in after you enter the new area. You might want to do this, for example, if you want the out-going ambient to completely fade out before you begin fading in the new ambient. So you would set fidelay to the same time as the foduration. By default it is set to .001 so that there is no delay and the fade in starts immediately. If the out-going fade-out also starts immediately, then they blend together in a nice transition fade.

fodelay

"Fade out Delay". Similarly you can delay the beginning of the out-going ambient's fade out. You might want to do this if you wanted the in-coming ambient to completely fade in before you started the fade out of the old ambient. Then you would set it to fiduration. Like fidelay, it is set to .001 so there is no delay and the fade out starts immediately.

fovolume

"Fade out volume". This sets the volume to which the out-going ambient fades to. -60 turns it off, which is the default (0 means no decrease in volume at all). If you go any higher than -60, than it will leave the old ambient still playing at a lower volume under the new ambient (at least until you enter a 3rd new zone). Not sure why you'd ever want to do that, so you probably don't want to change it.

volume

Technically "Fade in volume". This sets the volume to which the in-coming ambient fades into. 60 is to its normal full volume, which is the default (0 would be no increase in volume). Any lower value than 60 fades it into a lower volume. Allegedly that means you can control the new ambients' volume with this, which is why I named it "volume" instead of "fivolume". In my testing however, I couldn't seem to actually change the volume with this property. So I don't know if it works, or how exactly it works. But it's here if you want to experiment with it yourself.


See also