scripting randomizer for wav file


(Doc_A) #1

Lets say I was building a map, and when a certain objective is
reached I want any 1 of 6 wavs to play to make things more fun.

The choice of wav file the server selects would be totally random based
off of some game variable but would be one of the 6 we use.

Can this easily be done with a small sound trigger script.

Thanks in advance. (hehe probably Sock)

Doc


(sock) #2

A classic example of this is the lightning crash in radar. Check the script and it selects a random sound and plays it. Keep the random section in the main script.


thunderstuff
{
	spawn
	{
		accum 0 set 0 //randomiser to play different lightnings and thunders
		trigger self random
	}

	trigger random
	{
		accum 0 random 5
		accum 0 trigger_if_equal 0 thunderstuff thunder01
		accum 0 trigger_if_equal 1 thunderstuff thunder02
		accum 0 trigger_if_equal 2 thunderstuff thunder03
		accum 0 trigger_if_equal 3 thunderstuff thunder04
		accum 0 trigger_if_equal 4 thunderstuff thunder05
		wait 25000
		trigger self random
	}

	trigger thunder01
	{
		alertentity lightning01
		togglespeaker thunderspeaker01
	}

	trigger thunder02
	{
		alertentity lightning02
		togglespeaker thunderspeaker02
	}

	trigger thunder03
	{
		alertentity lightning03
		togglespeaker thunderspeaker03
	}

	trigger thunder04
	{
		alertentity lightning04
		togglespeaker thunderspeaker04
	}

	trigger thunder05
	{
		alertentity lightning05
		togglespeaker thunderspeaker05
	}
}

Sock
:moo:


(Doc_A) #3

Thanks alot Sock…

Keep the random section in the main script.

So “Main Script” = game_manager section? Sorry noob question I know
but the terminology was unfamiliar.


(sock) #4

Yes the main map script in the one with the “game_manager” entity.

Sock
:moo:


(G0-Gerbil) #5

Bah what;s wrong with the old fashioned ‘alertentity -> target_relay w/ random flag’? :wink:

In other words, I didn’t know about the random thing until just now.

I live and learn :smiley: