custom sounds

Have questions about CoD/UO mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

custom sounds

Post by Luke » September 30th, 2005, 1:25 am

I'd like to add custom sounds so that when u hit a trigger the sound starts..i tried the tut for sound effects, and that didnt work, but its not what i'm looking for anyway... leveller showed me a test map and if u fall down a pit or whatever u hear a sound, and thats the kind of thing i want. i looked at his scripts but its some what different to the tuts, and i cant figure it out without the .map....i cant get hold of him, so i thought i'd ask how it works here :P

this is his sound script(he put his transporter code here too for some reason)

Code: Select all

main()
{
	thread message1();
	thread message2();
	thread message3();
	thread message4();
	thread transporter();
}

message1()
{ 

messagetrig = getent ("die_human","targetname");

messagetrig waittill ("trigger");

alert = getent ("sound1", "targetname");

alert playsound("die");

wait (3);

thread message1();
}

message2()
{ 

messagetrig = getent ("die_human01","targetname");

messagetrig waittill ("trigger");

alert = getent ("sound01", "targetname");

alert playsound("die");

wait (3);

thread message2();

}

//message2()
//{ 

//messagetrig = getent ("duke_nukem_trigger","targetname");

//messagetrig waittill ("trigger");

//alert = getent ("duke_nukem", "targetname");

//alert playsound("duke_nukem_");

//wait (3);

//thread message2();

//}

message3()
{ 

play_intro = getent ("intro", "targetname");

play_intro playloopsound("intro_");

}

message4()
{ 

messagetrig = getent ("trigger03","targetname");

messagetrig waittill ("trigger");

alert = getent ("sl", "targetname");

alert playsound("slv");

wait (3);

thread message4();

}

transporter()
{
trig01 = getent ("transporter01","targetname");

trig01 waittill ("trigger");

transptr_plt01 = getent ("transporter_plate01", "targetname");
transptr_plt02 = getent ("transporter_plate02", "targetname");
wait 1;
transptr_plt01 movez (1424, 0.001);
transptr_plt01 waittill ("movedone");
transptr_plt02 movez (-1338, 0.001);
transptr_plt02 waittill ("movedone");
transptr_plt01 movey (72, 0.001);
transptr_plt01 waittill ("movedone");
transptr_plt02 movey (-72, 0.001);
transptr_plt02 waittill ("movedone");

transptr_plt01 movez (-88, 0.001);
transptr_plt01 waittill ("movedone");
transptr_plt02 movez (2, 0.001);
transptr_plt02 waittill ("movedone");


trig01 waittill ("trigger");

transptr_plt01 = getent ("transporter_plate01", "targetname");
transptr_plt02 = getent ("transporter_plate02", "targetname");
wait 1;
transptr_plt02 movez (1424, 0.001);
transptr_plt02 waittill ("movedone");
transptr_plt01 movez (-1338, 0.001);
transptr_plt01 waittill ("movedone");
transptr_plt02 movey (72, 0.001);
transptr_plt02 waittill ("movedone");
transptr_plt01 movey (-72, 0.001);
transptr_plt01 waittill ("movedone");

transptr_plt02 movez (-88, 0.001);
transptr_plt02 waittill ("movedone");
transptr_plt01 movez (2, 0.001);
transptr_plt01 waittill ("movedone");
thread transporter();
}

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 30th, 2005, 1:33 am

I removed everything except 1 functions as all you need is one. I cleaned up the script as well.
Ok, this is what your gonna have to do...
Make your hole, then make a trigger<multiple in the middle.
Use these figures
Key- Targetname
Value- die_human

Then make a Script<Model but give it no xmodel values (so its just a red block)
Then give it these values
Key-targetname
Value- alert

You will also need to build a csv file, if you dont know how, post again.

Code: Select all

main()
{
   thread message1();
}

message1()
{
messagetrig = getent ("die_human","targetname");
alert = getent ("sound1", "targetname");

while(1);
{
messagetrig waittill ("trigger");

alert playsound("die");

wait 3;
}
}
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » September 30th, 2005, 2:24 am

ok, i did what u said so far, and i've got the csv file, which goes in main/soundaliases right? i used the script u posted and named it sound, which is in maps/mp..and in mymapname.csg i reference that script with this line: maps\mp\sound::main();
i have the sound files in \Main\sound\misc..what i dont get is "alert = getent ("sound1", "targetname"); " where did the "sound1" come from? and where is the csv reference? :? sorry if these are dumb questions

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 30th, 2005, 5:16 am

Luke wrote:ok, i did what u said so far, and i've got the csv file, which goes in main/soundaliases right? i used the script u posted and named it sound, which is in maps/mp..and in mymapname.csg i reference that script with this line: maps\mp\sound::main();
i have the sound files in \Main\sound\misc..what i dont get is "alert = getent ("sound1", "targetname"); " where did the "sound1" come from? and where is the csv reference? :? sorry if these are dumb questions
Sorry made a slight error.
Instead of using alert as the targetname use sound1.

The csv is called by this function...

alert playsound("die");

die should be the name of the sound.

If you are still having trouble, post up your csv file, and also all the directories where each file is (and also, your current gsc).
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » September 30th, 2005, 9:44 am

ok heres the csv, same as leveller used but i removed the unused sounds that were below die. its directory is C:\Program Files\Call of Duty\Main\soundaliases i'm not sure if the file needs to be a certain name, so i just named it the same as my map.

Code: Select all

	name	name of the alias that is used to play this sound (required)
	sequence	used to uniquely identify alias entries when more than one sound goes to an alias, used only to catch unwanted duplicates (default = 0)
	file	the name of the file that contains the sound data (required)
	vol_min	0 is silent, 1 is full volume (default = 1)
	vol_max	0 is silent, 1 is full volume (default = same as vol_min)
	pitch_min	1 is normal playback, 2 is twice as fast, 0.5 is half as fast (default = 1)
	pitch_max	1 is normal playback, 2 is twice as fast, 0.5 is half as fast (default = same as pitch_min)
	dist_min	within this distance in inches, the sound is always full volume (default = 120)
	dist_max	outside this distance in inches, the sound is not started.  If left blank or set to 0, the sound will play from any distance.  This does not affect sound volume falloff.
	channel	auto, menu, weapon, voice, item, body, local, music, announcer (default = auto)
	type	streamed / loaded (default = loaded)
	probability	weight to use for the weighted probability of playing this sound instead of another sound (default = 1)
	loop	whether this sound is "looping" or "nonlooping" (default = "nonlooping")
	masterslave	if "master", this is a master sound.  If a number, then this sound won't exceed this volume whenever any master sound is playing.  If blank, then neither master nor slave.
	loadspec	space-separated list of which maps should use this alias; eg, "burnville dawnville".  If blank, the alias is used on all maps.
		
name	sequence	file	vol_min	vol_max	pitch_min	pitch_max	dist_min	dist_max	channel	type	probability	loop	masterslave	loadspec	subtitle
															
null	1	null.wav													
															
															
#Custom sound aliases															
die		misc/Die.wav	1	1			300	1500	auto			nonlooping			
and my gsc(this and sound.gsc are in C:\Program Files\Call of Duty\Main\maps\mp)

Code: Select all

main() 
{
 level._effect["fire"] = loadfx ("fx/fire/smallbon_1.efx");
maps\mp\_fx::loopfx("fire", (181, 1970, -1550), 0.6);
level._effect["fire"] = loadfx ("fx/fire/smallbon_1.efx");
maps\mp\_fx::loopfx("fire", (181, 2030, -1550), 0.6);
level._effect["fire"] = loadfx ("fx/fire/smallbon_1.efx");
maps\mp\_fx::loopfx("fire", (181, 2090, -1550), 0.6);
level._effect["fire"] = loadfx ("fx/fire/smallbon_1.efx");
maps\mp\_fx::loopfx("fire", (181, 2150, -1550), 0.6);
level._effect["fire"] = loadfx ("fx/fire/smallbon_1.efx");
maps\mp\_fx::loopfx("fire", (131, 1970, -1550), 0.6);
level._effect["fire"] = loadfx ("fx/fire/smallbon_1.efx");
maps\mp\_fx::loopfx("fire", (131, 2030, -1550), 0.6);
level._effect["fire"] = loadfx ("fx/fire/smallbon_1.efx");
maps\mp\_fx::loopfx("fire", (131, 2090, -1550), 0.6);
level._effect["fire"] = loadfx ("fx/fire/smallbon_1.efx");
maps\mp\_fx::loopfx("fire", (131, 2150, -1550), 0.6);

maps\mp\_load::main();
maps\mp\sound::main(); 

thread bob1(); 
thread bob2(); 
thread bob3();
thread bob4(); 
thread bob5();
} 

bob1() 
{ 
bob1 = getent("bob1","targetname"); 
wait (randomfloat (1.5)); 
org = (-64, 96, 72); 
timer = 3; 
while (1) 
{ 
bob1 moveto (org + (0,0,490), timer, timer*0.5, timer*0.5); 
wait (timer); 
bob1 moveto (org + (0,0,-500), timer, timer*0.5, timer*0.5); 
wait (timer); 
} 
} 

bob2() 
{ 
bob2 = getent("bob2","targetname"); 
wait (randomfloat (1.5)); 
org = (-64, 96, 72); 
timer = 3; 
while (1) 
{ 
bob2 moveto (org + (0,250,0), timer, timer*0.5, timer*0.5); 
wait (timer); 
bob2 moveto (org + (0,-250,0), timer, timer*0.5, timer*0.5); 
wait (timer); 
} 
} 

bob3() 
{ 
bob3 = getent("bob3","targetname"); 
wait (randomfloat (1.5));  
org = (-64, 96, 72); 
timer = 3; 
while (1) 
{ 
bob3 moveto (org + (0,250,0), timer, timer*0.5, timer*0.5); 
wait (timer); 
bob3 moveto (org + (0,-250,0), timer, timer*0.5, timer*0.5); 
wait (timer); 
} 
}

bob4() 
{ 
bob4 = getent("bob4","targetname"); 
wait (randomfloat (1.5));  
org = (-64, 96, 72); 
timer = 3; 
while (1) 
{ 
bob4 moveto (org + (0,250,0), timer, timer*0.5, timer*0.5); 
wait (timer); 
bob4 moveto (org + (0,-250,0), timer, timer*0.5, timer*0.5); 
wait (timer); 
} 
} 

bob5() 
{ 
bob5 = getent("bob5","targetname"); 
wait (randomfloat (1.5));  
org = (-64, 96, 72); 
timer = 3; 
while (1) 
{ 
bob5 moveto (org + (200,0,300), timer, timer*0.5, timer*0.5); 
wait (timer); 
bob5 moveto (org + (-200,0,-300), timer, timer*0.5, timer*0.5); 
wait (timer); 
} 
} 
the die.wav sound is in C:\Program Files\Call of Duty\Main\sound\misc

and i changed the script_model targetname from alert to sound1

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 30th, 2005, 4:21 pm

Ok, are you getting any errors loading the map?
If your not, then the Gsc's are fine.

If the sound is not playing, use a CoD builtin sound.
Instead of using "die" use "antitank_rifle_fire"

Also, remove everything not to do with the sound (using the block comment /* */ symbols) this way, you know nothing is conflicting.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » September 30th, 2005, 5:28 pm

woot! its working :) ..the damn problem was the script model target name some how changed back to alert..so i changed it once again to sound1 and double checked it, and it worked..so now i can have some fun :D thx a lot m8

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 30th, 2005, 5:29 pm

np, always happy to help :P
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » September 30th, 2005, 5:49 pm

does it only support .wav sounds? i tried an mp3 and it says 1 sound file missing or in a bad format

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 30th, 2005, 5:56 pm

I have never got mp3s to work, i think it has something to do with the bit rate.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Soviet
Core Staff
Core Staff
Posts: 7762
Joined: April 23rd, 2005, 9:12 pm

Post by Soviet » September 30th, 2005, 7:06 pm

the music is in mp3 format, but everything else is in wav, which i find kind of interesting

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » October 1st, 2005, 2:06 pm

omg, when i make the map into a pk3 i get script error everytime(bad syntax), but it WORKS before its pk3'd, using the same files, and same directories...

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » October 2nd, 2005, 12:13 am

Luke wrote:omg, when i make the map into a pk3 i get script error everytime(bad syntax), but it WORKS before its pk3'd, using the same files, and same directories...
Underneath "Syntax Error" you will get a line number and the syntax causing the error (most common is either a missing ; at the end of the line or a missing(or extra) { or })
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Luke
Past/Inactive Team Member
Past/Inactive Team Member
Posts: 1774
Joined: May 31st, 2005, 12:42 am
Location: Cornwall, UK

Post by Luke » October 2nd, 2005, 12:54 pm

this is what it says

******* script compile error *******
bad syntax
************************************
********************
ERROR: script compile error
(see console for details)
********************
----- Server Shutdown -----
Sending heartbeat to codmaster.activision.com
==== ShutdownGame ====

I really dont understand why it works using the same scripts before its made into a pk3, but maybe u can see whats wrong, i made a test map http://rapidshare.de/files/5782540/soundtest.zip.html

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » October 2nd, 2005, 5:13 pm

Edit: Obviously not what I posted :P

I will take a look now and post results.
Yep getting same error, will take a better look

Ok, the problem was 1 that can be a bastard to understand...

while(1) does not need a ; after it. I dont know the exact reason why...
Its the same thing as opening a thread e.g message1().

I just tested it, and it works.... lmfao at the sound :lol:
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests