Page 1 of 1

Custom sound in a square room not to spill out.

Posted: March 5th, 2012, 4:55 am
by Darfyddi
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..

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

Posted: March 5th, 2012, 1:13 pm
by Drofder2004
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).

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

Posted: March 5th, 2012, 1:18 pm
by Rezil

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.

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

Posted: March 6th, 2012, 1:21 am
by Darfyddi
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.