Custom sound in a square room not to spill out.

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

Moderator: Core Staff

Post Reply
Darfyddi
CJ Wannabe
CJ Wannabe
Posts: 2
Joined: March 5th, 2012, 4:01 am

Custom sound in a square room not to spill out.

Post by Darfyddi » March 5th, 2012, 4:55 am

Hello, I have a map with several rooms in and I would like to have sound to fill them but not spill out. I have got some sounds working elsewhere just as looping sounds based on a radius from x,y,z co-ordinates.

Now I am trying to get a sound to play in a room without spilling out the walls yet still reaching the corners - I can not do this with the radius method.

I have been trying for about 10 hours and just can't get anywhere - I was thinking that a Trgger_multiple that filled the room and some sort of object (script origin or model or a non-colliding caulk brush ) for the sound to be anchored to would work but no matter what I do it wont work.

I have one script that does nothing yet if I change the song name to one I haven't got then the game will say it can't find it when I am in the trigger. I guess from this that the script is calling the song but I can not hear it.

Code: Select all

main()
	{
		thread globalSoundFx();
		thread test_sound1();
	}
globalSoundFx()
	{
		maps\mp\_fx::loopSound("7th_dimension",(1024,1024,472),1);
		maps\mp\_fx::loopSound("coventry_carol",(1899,1553,364),1);	
//		maps\mp\_fx::loopSound("7th_dimension",("sound_origin"),1);	
	}
test_sound1()
	{
		orig = getent("sound_origin","targetname");
		trig = getent("sound_trigger","targetname");
		for (;;)
		{
			trig waittill("trigger",player);
			orig playsoundtoplayer("7th_dimension",player);
			wait(3);
		}
	}
//test_sound1()		
//	{ 
//		orig = getent ("sound_origin","targetname");
//		trig = getent ("sound_trigger","targetname");
//		while(1)
//		{
//			trig waittill ("trigger");
//			orig playsound("7th_dimension");
//			wait(5);
//		}
//	}
I have just commented out the bits I have tried with no luck but left them there just in case. In radiant Ihave tried both script_origin and scipt_model with the targetnames of 'SOUND_ORIGIN' and a trigger_multiple with the targetname of SOUND_TRIGGER my mp3 is 7th_dimension and it works fine when called like maps\mp\_fx::loopSound("7th_dimension",(1024,1024,472),1);

Any help would be great - it is now 04:00 and I am tearing my hair out due to lack of sleep so giving up on it for tonight but will check back here periodically to see if there is any advice.

Thank you for reading..

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

Re: Custom sound in a square room not to spill out.

Post by Drofder2004 » March 5th, 2012, 1:13 pm

Would it not make more sense to tell the soundalias to only play sounds up to a certain distance?

dist_min 500
dist_max 500

That will play a sound at a radius distance of 500 units at full volume (with no fade).
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
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Custom sound in a square room not to spill out.

Post by Rezil » March 5th, 2012, 1:18 pm

Code: Select all

playSoundInRoom()
{
	t = getent("trigger_room","targetname");
	
	while(1)
	{
		t waittill("trigger", user);
		user playSoundToPlayer("your_sound", user);
		while(user.istouching(t))
		{
			wait 0.05;
		}
		user playSoundToPlayer("null", user);
	}
}
I would imagine you're looking for something such as this. Make a trigger that covers the entire room and this (untested) method should work. The only downside to this is that the sound will abrupty cut off if the player leaves the room prematurely.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

Darfyddi
CJ Wannabe
CJ Wannabe
Posts: 2
Joined: March 5th, 2012, 4:01 am

Re: Custom sound in a square room not to spill out.

Post by Darfyddi » March 6th, 2012, 1:21 am

many thanks for the help - I am still struglging though. This is what I have -

Code: Select all

main()
	{
		thread globalSoundFx();
		thread test_sound1();
	}
globalSoundFx()
	{
		maps\mp\_fx::loopSound("7th_dimension",(1024,1024,472),1);
		maps\mp\_fx::loopSound("coventry_carol",(1899,1553,364),1);		
	}
test_sound1()	
	{
		t = getent("sound_trigger","targetname");
		while(1)
		{
			t waittill("trigger", user);
			user playSoundToPlayer("7th_dimension", user);
			while(user istouching(t))
			{
				wait 0.05;
			}
			user playSoundToPlayer("null", user);
		}
	}
and if I change the track name, like by adding the .mp3 on the end to make it user playSoundToPlayer("7th_dimension.mp3", user); then I get the message ERROR: Missing soundalias "7th_dimension.mp3". so I guess it works when I have the track name without the .extension on it but I just don't hear anything and no error message is shown.

I now think that as well as the trigger, I might need something 'solid' for the sound to be linked to but I have tried script_origin with no luck and if I try to use a script_model then I get the error about having a model without anything there.

I am going to have a rest now as my little baby had a bad day and spent most of it either screaming or puking on me and even managed to get poo squidged out of his nappy and all down me so I am just going to go into game now to see if I can take it out on some ice-cubes in freeze-tag :)

Many thanks if you can help me and thank you for the help so far.

Post Reply

Who is online

Users browsing this forum: No registered users and 33 guests