Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → getting one of 4 sounds to play at 2 ghost positions...
getting one of 4 sounds to play at 2 ghost positions...
2002-12-14, 4:46 PM #1
I have this cog and it works fine except I want it to play the same sound at 2 ghost positions, I had "PlaySoundThing(sound0[Rand()*4], lightthing2, Rand()*0.8+0.2, 10.0, -1, 0x10080);" after the existing one, but they didn't play the same sounds (which I didn't think it would work, and I was right). But I can't figure out how to make the same sound play at the two ghosts. Any ideas?
Code:
symbols
thing		lightthing	desc=thing_to_light
thing		lightthing2	desc=thing_to_light2
sound		sound0		desc=lightning_sound
sound		sound1		desc=lightning_sound1
sound		sound2		desc=lightning_sound2
sound		sound3		desc=lightning_sound3
flex		lowlight=0.1	desc=off_light_val
flex		highlight=0.6	desc=on_light_val
flex		offmax=0.5     	desc=max_off_interval
flex		onmax=1.0	desc=max_on_interval
message		startup		
end

# COG Section
code
startup:
	while(1) {
		thinglight(lightthing, lowlight, 0.0);
		thinglight(lightthing2, lowlight, 0.0);
		sleep(rand()*offmax);
		thinglight(lightthing, highlight, 0.0);
		thinglight(lightthing2, highlight, 0.0);
		PlaySoundThing(sound0[Rand()*4], lightthing, Rand()*0.8+0.2, 10.0, -1, 0x10080);
		
		sleep(rand()*onmax);
	}
	stop;
end


------------------
Last week I cudn't evn spel grajuat, but now I is one.

*Takes out his blaster and fires shots at the wall, the blastmarks leave the words "STROOPER WUZ 'ERE!!!"

[This message has been edited by Stormtrooper (edited December 14, 2002).]
2002-12-14, 11:46 PM #2
Just store the randomized value in a variable and pass that to the verb. I'm not sure if arrays work with flex values, but you might try this:
Code:
symbols

thing		lightthing	desc=thing_to_light
thing		lightthing2	desc=thing_to_light2
sound		sound0		desc=lightning_sound
sound		sound1		desc=lightning_sound1
sound		sound2		desc=lightning_sound2
sound		sound3		desc=lightning_sound3
flex		lowlight=0.1	desc=off_light_val
flex		highlight=0.6	desc=on_light_val
flex		offmax=0.5     	desc=max_off_interval
flex		onmax=1.0	desc=max_on_interval
flex		randval		local
message		startup

end# COG Section

code

startup:
	while(1)
	{
		thinglight(lightthing, lowlight, 0.0);
		thinglight(lightthing2, lowlight, 0.0);
		sleep(rand()*offmax);
		thinglight(lightthing, highlight, 0.0);
		thinglight(lightthing2, highlight, 0.0);

		randval = Rand()*3;
		PlaySoundThing(sound0[randval], lightthing, Rand()*0.8+0.2, 10.0, -1, 0x10080);
		PlaySoundThing(sound0[randval], lightthing2, Rand()*0.8+0.2, 10.0, -1, 0x10080);
		sleep(rand()*onmax);
	}
	stop;

end

You could also store the volume, if you want them to have the same volume, too. If this does not work, then just have another int variable and assign randval to it, then use the int variable in the array.

------------------
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)

[This message has been edited by zagibu (edited December 15, 2002).]
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2002-12-15, 8:17 AM #3
Thanks, it worked.

------------------
Last week I cudn't evn spel grajuat, but now I is one.

*Takes out his blaster and fires shots at the wall, the blastmarks leave the words "STROOPER WUZ 'ERE!!!"

↑ Up to the top!