Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /var/www/vhosts/own3mall/mohaaaa.co.uk/httpdocs/mohaa/tutorials/custom_sounds.php on line 3
Warning: include(http://map.planetmedalofhonor.gamespy.com/mohaa/poll/poll_cookie.php): failed to open stream: no suitable wrapper could be found in /var/www/vhosts/own3mall/mohaaaa.co.uk/httpdocs/mohaa/tutorials/custom_sounds.php on line 3
Warning: include(): Failed opening 'http://map.planetmedalofhonor.gamespy.com/mohaa/poll/poll_cookie.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/vhosts/own3mall/mohaaaa.co.uk/httpdocs/mohaa/tutorials/custom_sounds.php on line 3 .map :: Mapping for MoHAA
Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /var/www/vhosts/own3mall/mohaaaa.co.uk/httpdocs/mohaa/tutorials/custom_sounds.php on line 57
Warning: include(http://map.planetmedalofhonor.gamespy.com/mohaa/leftindex.php): failed to open stream: no suitable wrapper could be found in /var/www/vhosts/own3mall/mohaaaa.co.uk/httpdocs/mohaa/tutorials/custom_sounds.php on line 57
Warning: include(): Failed opening 'http://map.planetmedalofhonor.gamespy.com/mohaa/leftindex.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/vhosts/own3mall/mohaaaa.co.uk/httpdocs/mohaa/tutorials/custom_sounds.php on line 57
This tutorial describes how to add custom sounds to a map, such as positional
ambiences like radio, tree or river sounds. This can be done entirely through scripting but
in most cases you'll rather want to place some kind of sound entity in Radiant and refer to
this object in the script.
First I'll explain certain general concepts of sounds in mohaa. Any entity can make a sound
(even multiple sounds simultaneously if you want) provided it has a model. This means a
script_origin can't emit a sound nor can any of the speaker entities in the Radiant right-click
menu. It's common practice to use a script_model with model 'fx/dummy.tik' as invisible speaker
entity.
Now let's get started with the actual tutorial. I'll give a step-by-step description on how
to make the custom sound 'river.wav' in the 'main/sound/amb/' folder play in a demo map.
First of all add a script_model where you want the sound to play loudest. Press 'N' to bring
up the entity inspector and add key 'model' / value 'fx/dummy.tik'. Since you want to control the
entity from script it's necessary to add a targetname. For instance add key 'targetname' / value
'riverspeaker'. As the Quake 3 engine treats your new sound entity like any other entity it will
be hidden when it's not inside your 'pvs'. In short this means you may not hear the sound
when the sound entity is not in sight. Check the 'ALWAYS_DRAW' checkbox so this won't happen.
Well that was easy wasn't it? Now on to the scripting part which is slightly more complicated,
so you can easily compile your map in the meantime.
If you don't have a script for your map yet, just make a new file called 'mymapname.scr' in the
same folder as the bsp file of your map. You can edit a script in any text editor.
There are basically two things that need to be scripted for the sound to work. First, your
sound has to get an 'alias', which is a (shorter) name for the sound that is used in the script
instead of the filename. This alias also contains information about volume, pitch, audible radius
and possibly a subtitle for your sound. Once the alias is defined you can use it in your script.
This is also the second thing: getting your sound to play.
First we'll do the alias. The basic syntaxis for this is the following:
The values for all soundparms (basevolume, randvolume etc.) are discussed in the stock file
ubersound/ubersound.scr in pak0.pk3 (you can open this file with e.g. winzip). Within the scope
of this tutorial only [aliasname] and [soundfile] are interesting, and they're usage is very
straightforward. [aliasname] is the name of the alias which we will use in the script. For example
make it 'snd_river'. The [soundfile] is simply the real path to the sound and the filename, in this
example it should be sound/amb/river.wav. The final line could look like this:
Note: If you use this way to define aliases (instead of in ubersound.scr or uberdialog.scr)
you can only use 'aliascache', just 'alias' won't work. Also if you want a sound to play on the
local channel (no 3D localization) you'll have to write "local" (between quotes).
Now it's time to actually start the sound. In most cases you'll want a continuously
looping sound. Scripting is very easy and requires not more than one line:
$riverspeaker loopsound snd_river
'$riverspeaker' points to the entity you made in Radiant with this targetname.
If you want more advanced sound effects than the boring looping sound, you can use the
playsound, stoploopsound or stopaliaschannel commands. With some practice these commands
are fairly easy to understand.
At any time the aliases have to be defined above 'level waittill spawn' (except if the alias
refers to a pre-defined sound but with different soundparms) whereas the loopsound command has
to be placed below the 'level waittill spawn' line.
Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /var/www/vhosts/own3mall/mohaaaa.co.uk/httpdocs/mohaa/tutorials/custom_sounds.php on line 179
Warning: include(http://map.planetmedalofhonor.gamespy.com/mohaa/rightindex.php): failed to open stream: no suitable wrapper could be found in /var/www/vhosts/own3mall/mohaaaa.co.uk/httpdocs/mohaa/tutorials/custom_sounds.php on line 179
Warning: include(): Failed opening 'http://map.planetmedalofhonor.gamespy.com/mohaa/rightindex.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/vhosts/own3mall/mohaaaa.co.uk/httpdocs/mohaa/tutorials/custom_sounds.php on line 179
Warning: require(): open_basedir restriction in effect. File(/home/map/cgi-bin/mohaa/poll/include/config.inc.php) is not within the allowed path(s): (/var/www/vhosts/own3mall/mohaaaa.co.uk:/usr/share/php:/usr/share/pear) in /var/www/vhosts/own3mall/mohaaaa.co.uk/httpdocs/mohaa/tutorials/custom_sounds.php on line 190
Warning: require(/home/map/cgi-bin/mohaa/poll/include/config.inc.php): failed to open stream: Operation not permitted in /var/www/vhosts/own3mall/mohaaaa.co.uk/httpdocs/mohaa/tutorials/custom_sounds.php on line 190
Fatal error: require(): Failed opening required '/home/map/cgi-bin/mohaa/poll/include/config.inc.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/vhosts/own3mall/mohaaaa.co.uk/httpdocs/mohaa/tutorials/custom_sounds.php on line 190