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.


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:
"snd_streets" "city_night01_loop_z"
"snd_mansion" "mansion_tense01a_z"
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 should be the name of the sound (i.e., the soundshader name) that will play. You can see the names of ambient-ready sounds in the sub-folder "Darkmod/sound/tdm_ambient_ambience_zoned.sndshd". (The shader names add the "_z" at the end to the sound filenames to distinguish them for use with the zone approach.)
To listen to the sounds, they are located in the sub-folder "Darkmod\sound\ambient\ambience" and are in .ogg format.
(Note, need to check if adding "looping", "global", etc in the speaker will work, so you aren't restricted to only using soundshader-ready sounds. You can also technically enter the sound's address in the right hand side, such as "sounds/ambient/ambience/mansion_tense01a.ogg", but it doesn't help if it's not global and you can't hear it. For now, use the soundshader name until we get "global" working without it.)
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.
Unlike normal speakers, things like the volume, looping, global, etc, are handled by the speaker and soundshader by default. If you want to change the volume or stop the looping for a single ambient, you will need to do it in a soundshader for the sound (at the present time, this may change later). I'll explain how to do that at the end.

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 EAX settings 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 on the other side (the game will just pick one and use that for the whole zone).
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_locationseparator. 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.

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.

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