Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds
Watch MODSonair

Members Online

»
2 Active | 51 Guests
Online:

LATEST FORUM THREADS

»
Mohaa maps on Cod2?
CoD2 MP Mapping

Tutorials

»
CoDUO Mapping
ratings:
Awful Rating
Poor Rating
Average Rating
Good Rating
Excellent Rating
Sounds in CoDUO
Versions: You must be logged in to view history.
Tutorial by Sir-Cowchip shows you how to add sounds to your UO map

 I finally figured out custom sounds in UO! It is really pretty simple.

The two built-in functions to manipulate sound are playsound and playloopsound. As you might expect, the first one simply plays the sound once, while the latter loops the sound continuously.

We will start with the easiest one: playloopsound
To get a continuously looping sound - follow these steps:
1. Place a script_model in the map. You do this by right clicking on the 2D view and select script and then select model.

ScriptModel.jpg

 Screenshot1
Here I am showing how to create a script_model by right clicking on the 2D screen (The white one with the grid that says XY TOP. I am positioning my script_model in the engine compartment so the sound will emanate from there.

 2. Associate a targetname with the script model. This is done by selecting the script_model (Hold shift and left click it in the 3D view) and then type n to bring up the entity dialog. Type in targetname in the Key field, and type in the name you want in the Value field. In this example I gave it the targetname of radio1.

ScriptModelTargetname.jpg

 Screenshot2
With the script model selected, I press the letter n on the keyboard to bring up the entity editor. You can also get there by going through the menu and selecting View – Toggle – Entity View. The origin will populate itself, don’t worry if it isn’t there when you first create the script_model. The key/pair for the targetname will not be there and this is the part that you will need to type in. Hit enter after completing the value and it should show up as part of the entity.

 3. Export the map and compile it - (See other tutorials for that)

4. Place the sound you want (.wav or .mp3 file) in a subdirectory below the uo/sound directory. In this example I created a subdirectory called misc for my custom sound. The file I copied into it is jeep_idle01.wav

5. Create a soundaliases .csv file for you map under the uo/soundaliases directory (You might have to create the subdirectory). This file can be called whatever you want, but for clarity, I always name mine the same as my map name. It is easiest to open .csv files in Excel. Always start with a copy of an existing soundalias file - the headings defined in it are essential to it working correctly. This is probably the trickiest part of the whole endeavor. There are three essential fields to get right. The name field should contain the alias for the sound - how you will refer to the sound in your scripts. The file field should be the subdirectory and name of the sound file that you placed in step 4. Finally the loop field is extremely important. It needs to say looping for any sound that will be played with the playloopsound function. If you don't make it looping, the sound will play as many copies of itself as possible as quickly as it can. If you hear a dull roar - you are looping a nonlooping sound.

6. Create a soundloadspecs .csv file for you map under the uo/soundloadspecs directory (You might have to create the subdirectory). Unlike step 5 where it was optional, this file must be named the same as your map name, except for the .gsc extension. All this file does is point to the soundaliases file! In this example I've got other references in the soundloadspecs file but they are not needed. Again, its easiest to edit .csv files in Excel. All this file needs is one line that is the filename of the soundaliases file we created in step 5. In this example, it should say UO_Trigger.csv, which coincidentally enough is the name of this file too. They just live in different subdirectories. You have to have both for sound to work! For this example we have a sound file named misc/jeep_idle01.wav which we will refer to with the alias CC_jeep_idle_low and we have specified that it is a looping sound

7. Now for the scripting. Create a function in your .gsc script file to play the sound. The .gsc file will be in the maps/mp directory and must have the same filename as your map.
For this example, I created a function called start_engine1. It will start the playing of a continuous engine idling sound. The function needs to be below the main function, making sure it is outside of any other functions you might define.

Here is the code from the UO_Trigger.gsc that is part of the example map.

 Code: 


start_engine1()

{

alert2 = getent ("radio1", "targetname");
alert2 playloopsound("CC_jeep_idle_low");

}
 

radio1 is the targetname we gave the script_model. We use the getent function to assign alert2 as a pointer to that entity so that we can manipulate it in the script. We then tell it to make a sound with the entity using the playloopsound function. Basically the script_model acts as an point in space origin definition for the sound - where to play it on your map.

8. Finally - all we have to do is start the function that starts the sound. Inside the main function of your .gsc file add a line like the following.

Code:


thread start_engine1(); 

Voila! If everything lined up correctly you should be able to playtest the map and approach the script_model and hear the engine idle sound. For this example, I've place a model of an automobile on top of the script_model to give the player a visual cue. It isn't necessary for the sound to work, and can make it a little difficult to select the script_model entity in the graydiant editor.



 The playsound function is only more difficult in that you have to set up something to trigger it. The rewards though are well worth it as this is the way to add really interesting sounds into your map. This is how you make sounds for events. They can be as mundane as a door creaking open to something like a bell tower taking damage from a rifle and ringing in response. Use your imagination!

As we move through this portion of the demo, many of the steps have been detailed above and I will rely on the reader’s ability to gain the concept from that discussion.

To get a one-time sound event follow these steps:
1. Place a script_model in the map.

playsoundscriptmodel.jpg

 Screenshot3
Here I have the script_model (soundsource) selected and not the trigger surrounding it. It is harder to see that it is selected since it was already red. It does highlight the edges white. Again, I am bringing up the entity editor with the n key and set the targetname key/value pair.

 2. Associate a targetname with the script model. In this example I gave it the targetname of soundsource.

3. Place a trigger in the map. You do this by right clicking on the 2D view and select trigger and then select multiple.

TriggerMulitple.jpg

 Screenshot4
This might be confusing because I’ve already created both the trigger and the script_model and both are visible. The trigger is the semi-transparent larger box, while the script_model is the smaller opaque box. The trigger is red because it is selected. The script_model is red since that is its default color – it is not selected. This shows that you can right-click on the 2D screen to create the trigger_multiple. It also shows the entity editor for the trigger where we enter in the targetname key/value pair. Remember to hit enter after you enter the value to get it to set.

 The other trigger methods are fair game – use them as appropriate. The trigger_multiple is the basic one that responds whenever the player touches or is inside the entity. I have textured it as common/trigger. In this example, I have made the trigger 512x512 so that completely covers a section of my terrain that I have textured as rock instead of grassy dirt. This is to provide a visual cue for where the trigger is but is completely unnecessary.

4. Associate a targetname with the trigger_multiple. Just like for a script_model. In this example I gave it the targetname of rock_trigger.

TriggerMulitple.jpg

 Now we have a trigger we can refer to as rock_trigger that will propagate the message “trigger” whenever the player steps onto the rocky terrain.

5. Export the map and compile it

6. Place the sound in the sound/misc subdirectory. The file I copied into it is runaway.wav

7. Create a soundaliases .csv file. This is exactly per the looping section of the tutorial except for one very important difference. It must not say looping under the loop field. If it does and you try to play it with playsound, not only will you get silence, but the thread that issued the playsound will hang there and not proceed forward. Bad stuff. Make sure it is nonlooping, and always double check the name and the file fields to ensure that it all lines up with the subsequent scripts and the actual location of the file. For this demo I’ve given the runaway sound the alias runaway for its name. The file field is populated with misc/runaway.wav

8. Create a soundloadspecs .csv file for you map. Just like the looping example (It must have the same name as your map) – Note that for sound to work you need both the soundaliases and the soundloadspecs .csv files. However, once you have the soundloadspecs file created, you can leave it alone. Additional sounds for a map only require a new alias for the sound, which is done with a new row in the soundaliases file.

9. Now for the scripting. Create a function in your .gsc script file to respond to the trigger and play the sound. The .gsc file will be in the maps/mp directory and must have the same filename as your map. Once these files are created you can simply add functions into them.

For this example, I created a function called message1. It will find the trigger and wait for it to signal that it has been touched. Once it receives the signal, it will print a message on the player’s screen and play a short sample of Yosemite Sam if he were to enter the game. After that it prints another message and idles for ten seconds. Finally, the script prints the message that it will re-enable the trigger again, and fires itself off again.

The function needs to be below the main function, making sure it is outside of any other functions you might define.

Here is the code from the UO_Trigger.gsc that is part of the example map.

Code:


message1() 

{
messagetrig = getent ("rock_trigger","targetname");
messagetrig waittill ("trigger");
iprintlnbold ("Player stepped within the Rock terrain");

alert = getent ("soundsource", "targetname");
alert playsound("runaway");

iprintlnbold ("Trigger is disabled for 10 seconds");
wait (10);

iprintlnbold ("Trigger is ready again");
thread message1();
}

rock_trigger is the targetname we gave the trigger_multiple. We use the getent function to assign messagetrig as a pointer to the trigger entity so that we can watch for it to send us the notification that it has been triggered. The waittill statement does the watching a waiting and execution will pause until the trigger value comes across – (which will happen when the player touches the trigger). soundsource is the targetname we gave the script_model. We use the getent function to assign alert as a pointer to that entity so that we can manipulate it in the script. We then tell it to make a sound with the entity using the playsound function. We always use the script_model to act as the point in space origin definition for the sound - where to play it on your map.

9. Finally - all we have to do is start the function that sets up the trigger . Inside the main function of your .gsc file add a line like the following.

Code:


 thread message1();

 Voila! If everything lined up correctly you should be able to playtest the map, touch the trigger_mulitiple and hear Sam give you sage advice. For this example, I've aligned the rocky terrain with the invisible trigger to give the player a visual cue. The scipt model is inside the trigger, but doesn’t have to be. Obviously, it should be close enough that the player can hear it. Otherwise you get into the academic question “If a tree falls in a forest when no one is around, does it really make a sound?”

There are better tutorials for triggers on Modsonline and hopefully this is a good enough example to get the mapper underway with the two types of sounds.

 Associated with this tutorial is the supplemental map Custom Sounds in United Offensive - UO_Trigger. It is a very simple map with no extras so that the concepts here can be clearly identified. Studying that map is probably the best way to learn the material.

That is it for today! I hope mappers find this a helpful step toward getting sounds to work correctly in United Offensive and I look forward to playing all the maps that incorporate a creative use of sound.

I’d like to thank and acknowledge the pioneers that came before me and blazed the trail. Thanks to Wyatt Earp, and StrYdeR for exceptional help in getting me started. Thanks to =ARC= T-Bag for his Arkov map and the scripts I stole from there to learn the basics of COD sound. Also a special thanks to the members of my clan – [LXG] the League of eXtraordinary Gamers for their continued efforts to keep the game interesting and fun.

For comments, suggestions, or questions – contact me at sir-cowchip@sunflower.com

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»